]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Merge tag 'for-5.15/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Oct 2021 17:12:21 +0000 (10:12 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Oct 2021 17:12:21 +0000 (10:12 -0700)
Pull device mapper fixes from Mike Snitzer:

 - Fix DM verity target to skip redundant processing on I/O errors.

 - Fix request-based DM so that it doesn't queue request to blk-mq when
   DM device is suspended.

 - Fix DM core mempool NULL pointer race when completing IO.

 - Make DM clone target's 'descs' array static.

* tag 'for-5.15/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm: fix mempool NULL pointer race when completing IO
  dm rq: don't queue request to blk-mq during DM suspend
  dm clone: make array 'descs' static
  dm verity: skip redundant verity_handle_err() on I/O errors

207 files changed:
Documentation/admin-guide/cgroup-v2.rst
Documentation/devicetree/bindings/net/snps,dwmac.yaml
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
Documentation/filesystems/ntfs3.rst
MAINTAINERS
arch/arc/include/asm/pgtable.h
arch/arm/boot/dts/bcm2711-rpi-4-b.dts
arch/arm/boot/dts/bcm2711.dtsi
arch/arm/boot/dts/bcm2835-common.dtsi
arch/arm/boot/dts/bcm283x.dtsi
arch/arm/boot/dts/spear3xx.dtsi
arch/arm/mach-imx/src.c
arch/arm64/mm/hugetlbpage.c
arch/csky/Kconfig
arch/csky/include/asm/bitops.h
arch/csky/kernel/ptrace.c
arch/csky/kernel/signal.c
arch/s390/lib/string.c
drivers/acpi/arm64/gtdt.c
drivers/acpi/x86/s2idle.c
drivers/base/test/Makefile
drivers/firmware/arm_ffa/bus.c
drivers/gpio/gpio-74x164.c
drivers/gpio/gpio-mockup.c
drivers/gpio/gpio-pca953x.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/hyperv/hyperv_drm.h
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
drivers/gpu/drm/hyperv/hyperv_drm_proto.c
drivers/gpu/drm/i915/display/intel_acpi.c
drivers/gpu/drm/i915/gem/i915_gem_context.c
drivers/gpu/drm/i915/gt/intel_context.c
drivers/gpu/drm/mediatek/mtk_drm_crtc.c
drivers/gpu/drm/msm/adreno/a3xx_gpu.c
drivers/gpu/drm/msm/adreno/a4xx_gpu.c
drivers/gpu/drm/msm/adreno/a6xx_gmu.c
drivers/gpu/drm/msm/adreno/a6xx_gmu.h
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/adreno/a6xx_gpu.h
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
drivers/gpu/drm/msm/dp/dp_display.c
drivers/gpu/drm/msm/dsi/dsi.c
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c
drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
drivers/gpu/drm/msm/edp/edp_ctrl.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_gpu_devfreq.c
drivers/gpu/drm/msm/msm_submitqueue.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chang84.c
drivers/gpu/drm/panel/Kconfig
drivers/gpu/drm/r128/ati_pcigart.c
drivers/gpu/drm/rcar-du/rcar_du_encoder.c
drivers/gpu/drm/rcar-du/rcar_lvds.c
drivers/gpu/drm/rcar-du/rcar_lvds.h
drivers/iio/test/Makefile
drivers/iommu/Kconfig
drivers/isdn/capi/kcapi.c
drivers/isdn/hardware/mISDN/netjet.c
drivers/mtd/nand/raw/qcom_nandc.c
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/chip.h
drivers/net/dsa/mv88e6xxx/port.c
drivers/net/dsa/mv88e6xxx/port.h
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/ocelot/felix.h
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/dsa/sja1105/sja1105_ptp.c
drivers/net/dsa/sja1105/sja1105_ptp.h
drivers/net/ethernet/Kconfig
drivers/net/ethernet/arc/Kconfig
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/mellanox/mlx5/core/cq.c
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
drivers/net/ethernet/microchip/encx24j600-regmap.c
drivers/net/ethernet/microchip/encx24j600.c
drivers/net/ethernet/microchip/encx24j600_hw.h
drivers/net/ethernet/microsoft/mana/mana_en.c
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/mscc/ocelot_net.c
drivers/net/ethernet/neterion/s2io.c
drivers/net/ethernet/netronome/nfp/flower/main.c
drivers/net/ethernet/pensando/ionic/ionic_lif.c
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
drivers/net/ethernet/stmicro/stmmac/hwif.h
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
drivers/net/phy/phy_device.c
drivers/net/usb/Kconfig
drivers/net/virtio_net.c
drivers/pci/msi.c
drivers/platform/mellanox/mlxreg-io.c
drivers/platform/x86/amd-pmc.c
drivers/platform/x86/dell/Kconfig
drivers/platform/x86/gigabyte-wmi.c
drivers/platform/x86/intel/int1092/intel_sar.c
drivers/platform/x86/intel/int3472/intel_skl_int3472_discrete.c
drivers/platform/x86/intel_scu_ipc.c
drivers/spi/spi-atmel.c
drivers/spi/spi-bcm-qspi.c
drivers/spi/spi-mt65xx.c
drivers/spi/spi-mux.c
drivers/spi/spi-nxp-fspi.c
drivers/spi/spi-tegra20-slink.c
drivers/spi/spi.c
drivers/spi/spidev.c
drivers/tee/optee/core.c
drivers/tee/optee/device.c
drivers/tee/optee/optee_private.h
drivers/thunderbolt/Makefile
fs/btrfs/ctree.h
fs/btrfs/dir-item.c
fs/btrfs/extent-tree.c
fs/btrfs/file.c
fs/btrfs/tree-log.c
fs/ntfs3/attrib.c
fs/ntfs3/attrlist.c
fs/ntfs3/bitfunc.c
fs/ntfs3/bitmap.c
fs/ntfs3/debug.h
fs/ntfs3/dir.c
fs/ntfs3/file.c
fs/ntfs3/frecord.c
fs/ntfs3/fslog.c
fs/ntfs3/fsntfs.c
fs/ntfs3/index.c
fs/ntfs3/inode.c
fs/ntfs3/lib/decompress_common.h
fs/ntfs3/lib/lib.h
fs/ntfs3/lznt.c
fs/ntfs3/namei.c
fs/ntfs3/ntfs.h
fs/ntfs3/ntfs_fs.h
fs/ntfs3/record.c
fs/ntfs3/run.c
fs/ntfs3/super.c
fs/ntfs3/upcase.c
fs/ntfs3/xattr.c
include/kunit/test.h
include/linux/dsa/mv88e6xxx.h [new file with mode: 0644]
include/linux/dsa/ocelot.h
include/linux/dsa/sja1105.h
include/linux/mlx5/mlx5_ifc.h
include/linux/spi/spi.h
include/linux/workqueue.h
include/soc/mscc/ocelot.h
include/soc/mscc/ocelot_ptp.h
include/sound/hda_codec.h
kernel/cgroup/cpuset.c
kernel/module.c
kernel/workqueue.c
lib/Makefile
lib/kunit/executor_test.c
net/core/net-procfs.c
net/dsa/Kconfig
net/dsa/dsa2.c
net/dsa/switch.c
net/dsa/tag_dsa.c
net/dsa/tag_ocelot.c
net/dsa/tag_ocelot_8021q.c
net/dsa/tag_sja1105.c
net/ipv4/icmp.c
net/ipv6/ioam6.c
net/ipv6/ioam6_iptunnel.c
net/mptcp/protocol.c
net/nfc/af_nfc.c
net/nfc/digital_core.c
net/nfc/digital_technology.c
net/nfc/nci/rsp.c
net/sched/sch_mqprio.c
net/sctp/sm_make_chunk.c
net/smc/smc_cdc.c
net/smc/smc_core.c
net/smc/smc_llc.c
net/smc/smc_tx.c
net/smc/smc_wr.h
net/unix/af_unix.c
scripts/Makefile.gcc-plugins
sound/core/pcm_compat.c
sound/core/seq_device.c
sound/hda/hdac_controller.c
sound/pci/hda/hda_bind.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_controller.c
sound/pci/hda/hda_controller.h
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_intel.h
sound/pci/hda/patch_realtek.c
sound/usb/mixer_scarlett_gen2.c
sound/usb/quirks-table.h
sound/usb/quirks.c
tools/testing/kunit/kunit.py
tools/testing/kunit/kunit_tool_test.py
tools/testing/selftests/net/ioam6.sh
tools/testing/selftests/net/ioam6_parser.c

index babbe04c8d37d8a9c95c93a6916c47137672c816..4d8c27eca96be72ea0df121978ad04dd588e6ae3 100644 (file)
@@ -1226,7 +1226,7 @@ PAGE_SIZE multiple when read back.
 
        Note that all fields in this file are hierarchical and the
        file modified event can be generated due to an event down the
-       hierarchy. For for the local events at the cgroup level see
+       hierarchy. For the local events at the cgroup level see
        memory.events.local.
 
          low
@@ -2170,19 +2170,19 @@ existing device files.
 
 Cgroup v2 device controller has no interface files and is implemented
 on top of cgroup BPF. To control access to device files, a user may
-create bpf programs of the BPF_CGROUP_DEVICE type and attach them
-to cgroups. On an attempt to access a device file, corresponding
-BPF programs will be executed, and depending on the return value
-the attempt will succeed or fail with -EPERM.
-
-A BPF_CGROUP_DEVICE program takes a pointer to the bpf_cgroup_dev_ctx
-structure, which describes the device access attempt: access type
-(mknod/read/write) and device (type, major and minor numbers).
-If the program returns 0, the attempt fails with -EPERM, otherwise
-it succeeds.
-
-An example of BPF_CGROUP_DEVICE program may be found in the kernel
-source tree in the tools/testing/selftests/bpf/progs/dev_cgroup.c file.
+create bpf programs of type BPF_PROG_TYPE_CGROUP_DEVICE and attach
+them to cgroups with BPF_CGROUP_DEVICE flag. On an attempt to access a
+device file, corresponding BPF programs will be executed, and depending
+on the return value the attempt will succeed or fail with -EPERM.
+
+A BPF_PROG_TYPE_CGROUP_DEVICE program takes a pointer to the
+bpf_cgroup_dev_ctx structure, which describes the device access attempt:
+access type (mknod/read/write) and device (type, major and minor numbers).
+If the program returns 0, the attempt fails with -EPERM, otherwise it
+succeeds.
+
+An example of BPF_PROG_TYPE_CGROUP_DEVICE program may be found in
+tools/testing/selftests/bpf/progs/dev_cgroup.c in the kernel source tree.
 
 
 RDMA
index 42689b7d03a2ff84c35d08891fc060e06e6100a0..c115c95ee584e6aa382fc70173b1428089e6ab8b 100644 (file)
@@ -21,6 +21,7 @@ select:
       contains:
         enum:
           - snps,dwmac
+          - snps,dwmac-3.40a
           - snps,dwmac-3.50a
           - snps,dwmac-3.610
           - snps,dwmac-3.70a
@@ -76,6 +77,7 @@ properties:
         - rockchip,rk3399-gmac
         - rockchip,rv1108-gmac
         - snps,dwmac
+        - snps,dwmac-3.40a
         - snps,dwmac-3.50a
         - snps,dwmac-3.610
         - snps,dwmac-3.70a
index ca91201a99269750e80e497eb147979f42942fd3..d7e08b03e204f91dadb383b7ad5e7610c7f866a7 100644 (file)
@@ -171,7 +171,7 @@ examples:
       cs-gpios = <&gpio0 13 0>,
                  <&gpio0 14 0>;
       rx-sample-delay-ns = <3>;
-      spi-flash@1 {
+      flash@1 {
         compatible = "spi-nand";
         reg = <1>;
         rx-sample-delay-ns = <7>;
index ffe9ea0c1499896b23ee021ee881b805c6294726..d67ccd22c63b1eed83be1fa1f509247fdd9bdbb4 100644 (file)
 NTFS3
 =====
 
-
 Summary and Features
 ====================
 
-NTFS3 is fully functional NTFS Read-Write driver. The driver works with
-NTFS versions up to 3.1, normal/compressed/sparse files
-and journal replaying. File system type to use on mount is 'ntfs3'.
+NTFS3 is fully functional NTFS Read-Write driver. The driver works with NTFS
+versions up to 3.1. File system type to use on mount is *ntfs3*.
 
 - This driver implements NTFS read/write support for normal, sparse and
   compressed files.
-- Supports native journal replaying;
-- Supports extended attributes
-       Predefined extended attributes:
-       - 'system.ntfs_security' gets/sets security
-                       descriptor (SECURITY_DESCRIPTOR_RELATIVE)
-       - 'system.ntfs_attrib' gets/sets ntfs file/dir attributes.
-               Note: applied to empty files, this allows to switch type between
-               sparse(0x200), compressed(0x800) and normal;
+- Supports native journal replaying.
 - Supports NFS export of mounted NTFS volumes.
+- Supports extended attributes. Predefined extended attributes:
+
+       - *system.ntfs_security* gets/sets security
+
+               Descriptor: SECURITY_DESCRIPTOR_RELATIVE
+
+       - *system.ntfs_attrib* gets/sets ntfs file/dir attributes.
+
+         Note: Applied to empty files, this allows to switch type between
+         sparse(0x200), compressed(0x800) and normal.
 
 Mount Options
 =============
 
 The list below describes mount options supported by NTFS3 driver in addition to
-generic ones.
+generic ones. You can use every mount option with **no** option. If it is in
+this table marked with no it means default is without **no**.
 
-===============================================================================
+.. flat-table::
+   :widths: 1 5
+   :fill-cells:
 
-nls=name               This option informs the driver how to interpret path
-                       strings and translate them to Unicode and back. If
-                       this option is not set, the default codepage will be
-                       used (CONFIG_NLS_DEFAULT).
-                       Examples:
-                               'nls=utf8'
+   * - iocharset=name
+     - This option informs the driver how to interpret path strings and
+       translate them to Unicode and back. If this option is not set, the
+       default codepage will be used (CONFIG_NLS_DEFAULT).
 
-uid=
-gid=
-umask=                 Controls the default permissions for files/directories created
-                       after the NTFS volume is mounted.
+       Example: iocharset=utf8
 
-fmask=
-dmask=                 Instead of specifying umask which applies both to
-                       files and directories, fmask applies only to files and
-                       dmask only to directories.
+   * - uid=
+     - :rspan:`1`
+   * - gid=
 
-nohidden               Files with the Windows-specific HIDDEN (FILE_ATTRIBUTE_HIDDEN)
-                       attribute will not be shown under Linux.
+   * - umask=
+     - Controls the default permissions for files/directories created after
+       the NTFS volume is mounted.
 
-sys_immutable          Files with the Windows-specific SYSTEM
-                       (FILE_ATTRIBUTE_SYSTEM) attribute will be marked as system
-                       immutable files.
+   * - dmask=
+     - :rspan:`1` Instead of specifying umask which applies both to files and
+       directories, fmask applies only to files and dmask only to directories.
+   * - fmask=
 
-discard                        Enable support of the TRIM command for improved performance
-                       on delete operations, which is recommended for use with the
-                       solid-state drives (SSD).
+   * - noacsrules
+     - "No access rules" mount option sets access rights for files/folders to
+       777 and owner/group to root. This mount option absorbs all other
+       permissions.
 
-force                  Forces the driver to mount partitions even if 'dirty' flag
-                       (volume dirty) is set. Not recommended for use.
+       - Permissions change for files/folders will be reported as successful,
+        but they will remain 777.
 
-sparse                 Create new files as "sparse".
+       - Owner/group change will be reported as successful, butthey will stay
+        as root.
 
-showmeta               Use this parameter to show all meta-files (System Files) on
-                       a mounted NTFS partition.
-                       By default, all meta-files are hidden.
+   * - nohidden
+     - Files with the Windows-specific HIDDEN (FILE_ATTRIBUTE_HIDDEN) attribute
+       will not be shown under Linux.
 
-prealloc               Preallocate space for files excessively when file size is
-                       increasing on writes. Decreases fragmentation in case of
-                       parallel write operations to different files.
+   * - sys_immutable
+     - Files with the Windows-specific SYSTEM (FILE_ATTRIBUTE_SYSTEM) attribute
+       will be marked as system immutable files.
 
-no_acs_rules           "No access rules" mount option sets access rights for
-                       files/folders to 777 and owner/group to root. This mount
-                       option absorbs all other permissions:
-                       - permissions change for files/folders will be reported
-                               as successful, but they will remain 777;
-                       - owner/group change will be reported as successful, but
-                               they will stay as root
+   * - discard
+     - Enable support of the TRIM command for improved performance on delete
+       operations, which is recommended for use with the solid-state drives
+       (SSD).
 
-acl                    Support POSIX ACLs (Access Control Lists). Effective if
-                       supported by Kernel. Not to be confused with NTFS ACLs.
-                       The option specified as acl enables support for POSIX ACLs.
+   * - force
+     - Forces the driver to mount partitions even if volume is marked dirty.
+       Not recommended for use.
 
-noatime                        All files and directories will not update their last access
-                       time attribute if a partition is mounted with this parameter.
-                       This option can speed up file system operation.
+   * - sparse
+     - Create new files as sparse.
 
-===============================================================================
+   * - showmeta
+     - Use this parameter to show all meta-files (System Files) on a mounted
+       NTFS partition. By default, all meta-files are hidden.
 
-ToDo list
-=========
+   * - prealloc
+     - Preallocate space for files excessively when file size is increasing on
+       writes. Decreases fragmentation in case of parallel write operations to
+       different files.
 
-- Full journaling support (currently journal replaying is supported) over JBD.
+   * - acl
+     - Support POSIX ACLs (Access Control Lists). Effective if supported by
+       Kernel. Not to be confused with NTFS ACLs. The option specified as acl
+       enables support for POSIX ACLs.
 
+Todo list
+=========
+- Full journaling support over JBD. Currently journal replaying is supported
+  which is not necessarily as effectice as JBD would be.
 
 References
 ==========
-https://www.paragon-software.com/home/ntfs-linux-professional/
-       - Commercial version of the NTFS driver for Linux.
+- Commercial version of the NTFS driver for Linux.
+       https://www.paragon-software.com/home/ntfs-linux-professional/
 
-almaz.alexandrovich@paragon-software.com
-       - Direct e-mail address for feedback and requests on the NTFS3 implementation.
+- Direct e-mail address for feedback and requests on the NTFS3 implementation.
+       almaz.alexandrovich@paragon-software.com
index a4a0c2baaf2742a41cb6e6c562c57173dfaca529..c79388b7881819f40d57bc9ee607be024b49b019 100644 (file)
@@ -7440,7 +7440,7 @@ FREESCALE IMX / MXC FEC DRIVER
 M:     Joakim Zhang <qiangqing.zhang@nxp.com>
 L:     netdev@vger.kernel.org
 S:     Maintained
-F:     Documentation/devicetree/bindings/net/fsl-fec.txt
+F:     Documentation/devicetree/bindings/net/fsl,fec.yaml
 F:     drivers/net/ethernet/freescale/fec.h
 F:     drivers/net/ethernet/freescale/fec_main.c
 F:     drivers/net/ethernet/freescale/fec_ptp.c
@@ -9307,7 +9307,7 @@ S:        Maintained
 F:     drivers/platform/x86/intel/atomisp2/led.c
 
 INTEL BIOS SAR INT1092 DRIVER
-M:     Shravan S <s.shravan@intel.com>
+M:     Shravan Sudhakar <s.shravan@intel.com>
 M:     Intel Corporation <linuxwwan@intel.com>
 L:     platform-driver-x86@vger.kernel.org
 S:     Maintained
@@ -9629,7 +9629,7 @@ F:        include/uapi/linux/isst_if.h
 F:     tools/power/x86/intel-speed-select/
 
 INTEL STRATIX10 FIRMWARE DRIVERS
-M:     Richard Gong <richard.gong@linux.intel.com>
+M:     Dinh Nguyen <dinguyen@kernel.org>
 L:     linux-kernel@vger.kernel.org
 S:     Maintained
 F:     Documentation/ABI/testing/sysfs-devices-platform-stratix10-rsu
@@ -10279,7 +10279,6 @@ KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
 M:     Christian Borntraeger <borntraeger@de.ibm.com>
 M:     Janosch Frank <frankja@linux.ibm.com>
 R:     David Hildenbrand <david@redhat.com>
-R:     Cornelia Huck <cohuck@redhat.com>
 R:     Claudio Imbrenda <imbrenda@linux.ibm.com>
 L:     kvm@vger.kernel.org
 S:     Supported
@@ -11153,6 +11152,7 @@ S:      Maintained
 F:     Documentation/devicetree/bindings/net/dsa/marvell.txt
 F:     Documentation/networking/devlink/mv88e6xxx.rst
 F:     drivers/net/dsa/mv88e6xxx/
+F:     include/linux/dsa/mv88e6xxx.h
 F:     include/linux/platform_data/mv88e6xxx.h
 
 MARVELL ARMADA 3700 PHY DRIVERS
@@ -16301,6 +16301,7 @@ S390
 M:     Heiko Carstens <hca@linux.ibm.com>
 M:     Vasily Gorbik <gor@linux.ibm.com>
 M:     Christian Borntraeger <borntraeger@de.ibm.com>
+R:     Alexander Gordeev <agordeev@linux.ibm.com>
 L:     linux-s390@vger.kernel.org
 S:     Supported
 W:     http://www.ibm.com/developerworks/linux/linux390/
@@ -16379,7 +16380,6 @@ F:      drivers/s390/crypto/vfio_ap_ops.c
 F:     drivers/s390/crypto/vfio_ap_private.h
 
 S390 VFIO-CCW DRIVER
-M:     Cornelia Huck <cohuck@redhat.com>
 M:     Eric Farman <farman@linux.ibm.com>
 M:     Matthew Rosato <mjrosato@linux.ibm.com>
 R:     Halil Pasic <pasic@linux.ibm.com>
@@ -17986,7 +17986,7 @@ F:      net/switchdev/
 SY8106A REGULATOR DRIVER
 M:     Icenowy Zheng <icenowy@aosc.io>
 S:     Maintained
-F:     Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt
+F:     Documentation/devicetree/bindings/regulator/silergy,sy8106a.yaml
 F:     drivers/regulator/sy8106a-regulator.c
 
 SYNC FILE FRAMEWORK
index 9320b04c04bf55ba13ba85c3b14a48e0244531af..4cf45a99fd792a5e1b528c96a610cfdd9120f14e 100644 (file)
@@ -26,11 +26,6 @@ extern char empty_zero_page[PAGE_SIZE];
 
 extern pgd_t swapper_pg_dir[] __aligned(PAGE_SIZE);
 
-/* Macro to mark a page protection as uncacheable */
-#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) & ~_PAGE_CACHEABLE))
-
-extern pgd_t swapper_pg_dir[] __aligned(PAGE_SIZE);
-
 /* to cope with aliasing VIPT cache */
 #define HAVE_ARCH_UNMAPPED_AREA
 
index f24bdd0870a521bb0412805f8fa0d1a7e3aa474c..72ce80fbf26626f45729b257914f2baab2078217 100644 (file)
@@ -40,8 +40,8 @@
                regulator-always-on;
                regulator-settling-time-us = <5000>;
                gpios = <&expgpio 4 GPIO_ACTIVE_HIGH>;
-               states = <1800000 0x1
-                         3300000 0x0>;
+               states = <1800000 0x1>,
+                        <3300000 0x0>;
                status = "okay";
        };
 
 };
 
 &pcie0 {
-       pci@1,0 {
+       pci@0,0 {
+               device_type = "pci";
                #address-cells = <3>;
                #size-cells = <2>;
                ranges;
 
                reg = <0 0 0 0 0>;
 
-               usb@1,0 {
-                       reg = <0x10000 0 0 0 0>;
+               usb@0,0 {
+                       reg = <0 0 0 0 0>;
                        resets = <&reset RASPBERRYPI_FIRMWARE_RESET_ID_USB>;
                };
        };
index b8a4096192aa92fb801ea28308dcb89e9b75d141..3b60297af7f60b09f4c625e121f7e2d938eb9b58 100644 (file)
                        status = "disabled";
                };
 
+               vec: vec@7ec13000 {
+                       compatible = "brcm,bcm2711-vec";
+                       reg = <0x7ec13000 0x1000>;
+                       clocks = <&clocks BCM2835_CLOCK_VEC>;
+                       interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
+                       status = "disabled";
+               };
+
                dvp: clock@7ef00000 {
                        compatible = "brcm,brcm2711-dvp";
                        reg = <0x7ef00000 0x10>;
                                compatible = "brcm,genet-mdio-v5";
                                reg = <0xe14 0x8>;
                                reg-names = "mdio";
-                               #address-cells = <0x0>;
-                               #size-cells = <0x1>;
+                               #address-cells = <0x1>;
+                               #size-cells = <0x0>;
                        };
                };
        };
index 4119271c979d6f1b80e32e0ace0a4f76a3f4393d..c25e797b90600a26a5ed510084bef57e65ee80ae 100644 (file)
                        status = "okay";
                };
 
+               vec: vec@7e806000 {
+                       compatible = "brcm,bcm2835-vec";
+                       reg = <0x7e806000 0x1000>;
+                       clocks = <&clocks BCM2835_CLOCK_VEC>;
+                       interrupts = <2 27>;
+                       status = "disabled";
+               };
+
                pixelvalve@7e807000 {
                        compatible = "brcm,bcm2835-pixelvalve2";
                        reg = <0x7e807000 0x100>;
index 0f3be55201a5bea78b2d75b4455ec7a3e6c5ebfc..a3e06b6809476c3431e0a85ae9781d6bc37c600f 100644 (file)
                        status = "disabled";
                };
 
-               vec: vec@7e806000 {
-                       compatible = "brcm,bcm2835-vec";
-                       reg = <0x7e806000 0x1000>;
-                       clocks = <&clocks BCM2835_CLOCK_VEC>;
-                       interrupts = <2 27>;
-                       status = "disabled";
-               };
-
                usb: usb@7e980000 {
                        compatible = "brcm,bcm2835-usb";
                        reg = <0x7e980000 0x10000>;
index f266b7b034823a1063f4107fc6c0eda9e3e29767..cc88ebe7a60ced1725da1f3939f2fa0e462ef918 100644 (file)
@@ -47,7 +47,7 @@
                };
 
                gmac: eth@e0800000 {
-                       compatible = "st,spear600-gmac";
+                       compatible = "snps,dwmac-3.40a";
                        reg = <0xe0800000 0x8000>;
                        interrupts = <23 22>;
                        interrupt-names = "macirq", "eth_wake_irq";
index 95fd1fbb082607128aca4cf146d2e82a430150c2..59a8e8cc44693b0f4720f4945f1e1fd1d5183a7b 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/iopoll.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/platform_device.h>
 #include <linux/reset-controller.h>
 #include <linux/smp.h>
 #include <asm/smp_plat.h>
@@ -81,11 +82,6 @@ static const struct reset_control_ops imx_src_ops = {
        .reset = imx_src_reset_module,
 };
 
-static struct reset_controller_dev imx_reset_controller = {
-       .ops = &imx_src_ops,
-       .nr_resets = ARRAY_SIZE(sw_reset_bits),
-};
-
 static void imx_gpcv2_set_m_core_pgc(bool enable, u32 offset)
 {
        writel_relaxed(enable, gpc_base + offset);
@@ -177,10 +173,6 @@ void __init imx_src_init(void)
        src_base = of_iomap(np, 0);
        WARN_ON(!src_base);
 
-       imx_reset_controller.of_node = np;
-       if (IS_ENABLED(CONFIG_RESET_CONTROLLER))
-               reset_controller_register(&imx_reset_controller);
-
        /*
         * force warm reset sources to generate cold reset
         * for a more reliable restart
@@ -214,3 +206,33 @@ void __init imx7_src_init(void)
        if (!gpc_base)
                return;
 }
+
+static const struct of_device_id imx_src_dt_ids[] = {
+       { .compatible = "fsl,imx51-src" },
+       { /* sentinel */ }
+};
+
+static int imx_src_probe(struct platform_device *pdev)
+{
+       struct reset_controller_dev *rcdev;
+
+       rcdev = devm_kzalloc(&pdev->dev, sizeof(*rcdev), GFP_KERNEL);
+       if (!rcdev)
+               return -ENOMEM;
+
+       rcdev->ops = &imx_src_ops;
+       rcdev->dev = &pdev->dev;
+       rcdev->of_node = pdev->dev.of_node;
+       rcdev->nr_resets = ARRAY_SIZE(sw_reset_bits);
+
+       return devm_reset_controller_register(&pdev->dev, rcdev);
+}
+
+static struct platform_driver imx_src_driver = {
+       .driver = {
+               .name = "imx-src",
+               .of_match_table = imx_src_dt_ids,
+       },
+       .probe = imx_src_probe,
+};
+builtin_platform_driver(imx_src_driver);
index 23505fc353247019e952a2b760dda82677d5fdfe..a8158c9489666819b5d2a70034c3c645e512bc1f 100644 (file)
@@ -43,7 +43,7 @@ void __init arm64_hugetlb_cma_reserve(void)
 #ifdef CONFIG_ARM64_4K_PAGES
        order = PUD_SHIFT - PAGE_SHIFT;
 #else
-       order = CONT_PMD_SHIFT + PMD_SHIFT - PAGE_SHIFT;
+       order = CONT_PMD_SHIFT - PAGE_SHIFT;
 #endif
        /*
         * HugeTLB CMA reservation is required for gigantic
index 9d4d898df76ba717e7808afc4209e0cc20c4dafc..823d3d5a9e11487c3037fbbc01af0141456c9335 100644 (file)
@@ -8,7 +8,7 @@ config CSKY
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_USE_BUILTIN_BSWAP
        select ARCH_USE_QUEUED_RWLOCKS
-       select ARCH_WANT_FRAME_POINTERS if !CPU_CK610
+       select ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace)
        select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
        select COMMON_CLK
        select CLKSRC_MMIO
@@ -241,6 +241,7 @@ endchoice
 
 menuconfig HAVE_TCM
        bool "Tightly-Coupled/Sram Memory"
+       depends on !COMPILE_TEST
        help
          The implementation are not only used by TCM (Tightly-Coupled Meory)
          but also used by sram on SOC bus. It follow existed linux tcm
index 91818787d860925defd3fc71cb3cefe87fe02d17..02b72a0007671308878bae4de47eda256b442324 100644 (file)
@@ -74,7 +74,6 @@ static __always_inline unsigned long __fls(unsigned long x)
  * bug fix, why only could use atomic!!!!
  */
 #include <asm-generic/bitops/non-atomic.h>
-#define __clear_bit(nr, vaddr) clear_bit(nr, vaddr)
 
 #include <asm-generic/bitops/le.h>
 #include <asm-generic/bitops/ext2-atomic.h>
index 0105ac81b4328adc090342543cd4601c048aed7d..1a5f54e0d272631137179c848715a7ab8a5791ff 100644 (file)
@@ -99,7 +99,8 @@ static int gpr_set(struct task_struct *target,
        if (ret)
                return ret;
 
-       regs.sr = task_pt_regs(target)->sr;
+       /* BIT(0) of regs.sr is Condition Code/Carry bit */
+       regs.sr = (regs.sr & BIT(0)) | (task_pt_regs(target)->sr & ~BIT(0));
 #ifdef CONFIG_CPU_HAS_HILO
        regs.dcsr = task_pt_regs(target)->dcsr;
 #endif
index bc4238b9f709a8304d1766f1d7e2d3b06d9ac53c..c7b763d2f526e661f16b5ad98c5c56bd4c7c257e 100644 (file)
@@ -52,10 +52,14 @@ static long restore_sigcontext(struct pt_regs *regs,
        struct sigcontext __user *sc)
 {
        int err = 0;
+       unsigned long sr = regs->sr;
 
        /* sc_pt_regs is structured the same as the start of pt_regs */
        err |= __copy_from_user(regs, &sc->sc_pt_regs, sizeof(struct pt_regs));
 
+       /* BIT(0) of regs->sr is Condition Code/Carry bit */
+       regs->sr = (sr & ~1) | (regs->sr & 1);
+
        /* Restore the floating-point state. */
        err |= restore_fpu_state(sc);
 
index cfcdf76d6a9573be23b9482504c054d9f6816285..a95ca6df4e5e6902fef19f87da7e6a6754b80b62 100644 (file)
@@ -259,14 +259,13 @@ EXPORT_SYMBOL(strcmp);
 #ifdef __HAVE_ARCH_STRRCHR
 char *strrchr(const char *s, int c)
 {
-       size_t len = __strend(s) - s;
-
-       if (len)
-              do {
-                      if (s[len] == (char) c)
-                              return (char *) s + len;
-              } while (--len > 0);
-       return NULL;
+       ssize_t len = __strend(s) - s;
+
+       do {
+               if (s[len] == (char)c)
+                       return (char *)s + len;
+       } while (--len >= 0);
+       return NULL;
 }
 EXPORT_SYMBOL(strrchr);
 #endif
index 0a0a982f9c28d44e5cf48b170662c0df40852272..c0e77c1c8e09d6fa15094b2fff28d1c7bef0aed4 100644 (file)
@@ -36,7 +36,7 @@ struct acpi_gtdt_descriptor {
 
 static struct acpi_gtdt_descriptor acpi_gtdt_desc __initdata;
 
-static inline void *next_platform_timer(void *platform_timer)
+static inline __init void *next_platform_timer(void *platform_timer)
 {
        struct acpi_gtdt_header *gh = platform_timer;
 
index bd92b549fd5a4cae9f96f2cc84b9337ab976daa0..1c48358b43ba30306a84894bfadb4444e7896176 100644 (file)
@@ -371,7 +371,7 @@ static int lps0_device_attach(struct acpi_device *adev,
                return 0;
 
        if (acpi_s2idle_vendor_amd()) {
-               /* AMD0004, AMDI0005:
+               /* AMD0004, AMD0005, AMDI0005:
                 * - Should use rev_id 0x0
                 * - function mask > 0x3: Should use AMD method, but has off by one bug
                 * - function mask = 0x3: Should use Microsoft method
@@ -390,6 +390,7 @@ static int lps0_device_attach(struct acpi_device *adev,
                                        ACPI_LPS0_DSM_UUID_MICROSOFT, 0,
                                        &lps0_dsm_guid_microsoft);
                if (lps0_dsm_func_mask > 0x3 && (!strcmp(hid, "AMD0004") ||
+                                                !strcmp(hid, "AMD0005") ||
                                                 !strcmp(hid, "AMDI0005"))) {
                        lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1;
                        acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n",
index 64b2f3d744d51aa91d98d64012adb8fce6bae54b..7f76fee6f989d85d64bd29bb894003b0d5a2509b 100644 (file)
@@ -2,4 +2,4 @@
 obj-$(CONFIG_TEST_ASYNC_DRIVER_PROBE)  += test_async_driver_probe.o
 
 obj-$(CONFIG_DRIVER_PE_KUNIT_TEST) += property-entry-test.o
-CFLAGS_REMOVE_property-entry-test.o += -fplugin-arg-structleak_plugin-byref -fplugin-arg-structleak_plugin-byref-all
+CFLAGS_property-entry-test.o += $(DISABLE_STRUCTLEAK_PLUGIN)
index 00fe595a5bc8972ffc90363cda045b234d96dc01..641a91819088050759f995bbf346449a28f6a53b 100644 (file)
@@ -49,6 +49,13 @@ static int ffa_device_probe(struct device *dev)
        return ffa_drv->probe(ffa_dev);
 }
 
+static void ffa_device_remove(struct device *dev)
+{
+       struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
+
+       ffa_drv->remove(to_ffa_dev(dev));
+}
+
 static int ffa_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
        struct ffa_device *ffa_dev = to_ffa_dev(dev);
@@ -86,6 +93,7 @@ struct bus_type ffa_bus_type = {
        .name           = "arm_ffa",
        .match          = ffa_device_match,
        .probe          = ffa_device_probe,
+       .remove         = ffa_device_remove,
        .uevent         = ffa_device_uevent,
        .dev_groups     = ffa_device_attributes_groups,
 };
@@ -127,7 +135,7 @@ static void ffa_release_device(struct device *dev)
 
 static int __ffa_devices_unregister(struct device *dev, void *data)
 {
-       ffa_release_device(dev);
+       device_unregister(dev);
 
        return 0;
 }
index 05637d58515269b75c5a279291744ca2b6ad2481..4a55cdf089d62a33a793b4eb402ff08a19df720f 100644 (file)
@@ -174,6 +174,13 @@ static int gen_74x164_remove(struct spi_device *spi)
        return 0;
 }
 
+static const struct spi_device_id gen_74x164_spi_ids[] = {
+       { .name = "74hc595" },
+       { .name = "74lvc594" },
+       {},
+};
+MODULE_DEVICE_TABLE(spi, gen_74x164_spi_ids);
+
 static const struct of_device_id gen_74x164_dt_ids[] = {
        { .compatible = "fairchild,74hc595" },
        { .compatible = "nxp,74lvc594" },
@@ -188,6 +195,7 @@ static struct spi_driver gen_74x164_driver = {
        },
        .probe          = gen_74x164_probe,
        .remove         = gen_74x164_remove,
+       .id_table       = gen_74x164_spi_ids,
 };
 module_spi_driver(gen_74x164_driver);
 
index 0a9d746a0fe0a22fd654e3c90de1ce7e7532d9ac..d26bff29157b5d9b5004dbfc59457d99e2ca5dbc 100644 (file)
@@ -476,10 +476,19 @@ static struct platform_device *gpio_mockup_pdevs[GPIO_MOCKUP_MAX_GC];
 
 static void gpio_mockup_unregister_pdevs(void)
 {
+       struct platform_device *pdev;
+       struct fwnode_handle *fwnode;
        int i;
 
-       for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++)
-               platform_device_unregister(gpio_mockup_pdevs[i]);
+       for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) {
+               pdev = gpio_mockup_pdevs[i];
+               if (!pdev)
+                       continue;
+
+               fwnode = dev_fwnode(&pdev->dev);
+               platform_device_unregister(pdev);
+               fwnode_remove_software_node(fwnode);
+       }
 }
 
 static __init char **gpio_mockup_make_line_names(const char *label,
@@ -508,6 +517,7 @@ static int __init gpio_mockup_register_chip(int idx)
        struct property_entry properties[GPIO_MOCKUP_MAX_PROP];
        struct platform_device_info pdevinfo;
        struct platform_device *pdev;
+       struct fwnode_handle *fwnode;
        char **line_names = NULL;
        char chip_label[32];
        int prop = 0, base;
@@ -536,13 +546,18 @@ static int __init gpio_mockup_register_chip(int idx)
                                        "gpio-line-names", line_names, ngpio);
        }
 
+       fwnode = fwnode_create_software_node(properties, NULL);
+       if (IS_ERR(fwnode))
+               return PTR_ERR(fwnode);
+
        pdevinfo.name = "gpio-mockup";
        pdevinfo.id = idx;
-       pdevinfo.properties = properties;
+       pdevinfo.fwnode = fwnode;
 
        pdev = platform_device_register_full(&pdevinfo);
        kfree_strarray(line_names, ngpio);
        if (IS_ERR(pdev)) {
+               fwnode_remove_software_node(fwnode);
                pr_err("error registering device");
                return PTR_ERR(pdev);
        }
index 8ebf369b3ba0f49851fe2f5743741db2d0638f9a..d2fe76f3f34fd4930c62bc1b5213422bb04386b9 100644 (file)
@@ -559,21 +559,21 @@ static int pca953x_gpio_set_pull_up_down(struct pca953x_chip *chip,
 
        mutex_lock(&chip->i2c_lock);
 
-       /* Disable pull-up/pull-down */
-       ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0);
-       if (ret)
-               goto exit;
-
        /* Configure pull-up/pull-down */
        if (config == PIN_CONFIG_BIAS_PULL_UP)
                ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, bit);
        else if (config == PIN_CONFIG_BIAS_PULL_DOWN)
                ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, 0);
+       else
+               ret = 0;
        if (ret)
                goto exit;
 
-       /* Enable pull-up/pull-down */
-       ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit);
+       /* Disable/Enable pull-up/pull-down */
+       if (config == PIN_CONFIG_BIAS_DISABLE)
+               ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0);
+       else
+               ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit);
 
 exit:
        mutex_unlock(&chip->i2c_lock);
@@ -587,7 +587,9 @@ static int pca953x_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
 
        switch (pinconf_to_config_param(config)) {
        case PIN_CONFIG_BIAS_PULL_UP:
+       case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
        case PIN_CONFIG_BIAS_PULL_DOWN:
+       case PIN_CONFIG_BIAS_DISABLE:
                return pca953x_gpio_set_pull_up_down(chip, offset, config);
        default:
                return -ENOTSUPP;
index 6325877c5fd6e642169f350fa17d08593aaa95a0..ea9a79bc958391f6714249b438c96d65b94f080c 100644 (file)
@@ -1834,11 +1834,20 @@ static void connector_bad_edid(struct drm_connector *connector,
                               u8 *edid, int num_blocks)
 {
        int i;
-       u8 num_of_ext = edid[0x7e];
+       u8 last_block;
+
+       /*
+        * 0x7e in the EDID is the number of extension blocks. The EDID
+        * is 1 (base block) + num_ext_blocks big. That means we can think
+        * of 0x7e in the EDID of the _index_ of the last block in the
+        * combined chunk of memory.
+        */
+       last_block = edid[0x7e];
 
        /* Calculate real checksum for the last edid extension block data */
-       connector->real_edid_checksum =
-               drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH);
+       if (last_block < num_blocks)
+               connector->real_edid_checksum =
+                       drm_edid_block_checksum(edid + last_block * EDID_LENGTH);
 
        if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
                return;
index 3ab07832104587d97b774381b9110a570b7d714c..8e7a124d6c5a3ae27f18c268af7d02e4fa952b77 100644 (file)
@@ -1506,6 +1506,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
 {
        struct drm_client_dev *client = &fb_helper->client;
        struct drm_device *dev = fb_helper->dev;
+       struct drm_mode_config *config = &dev->mode_config;
        int ret = 0;
        int crtc_count = 0;
        struct drm_connector_list_iter conn_iter;
@@ -1663,6 +1664,11 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
        /* Handle our overallocation */
        sizes.surface_height *= drm_fbdev_overalloc;
        sizes.surface_height /= 100;
+       if (sizes.surface_height > config->max_height) {
+               drm_dbg_kms(dev, "Fbdev over-allocation too large; clamping height to %d\n",
+                           config->max_height);
+               sizes.surface_height = config->max_height;
+       }
 
        /* push down into drivers */
        ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
index 886add4f9cd0fde76b784d8c6e04903819fdd757..d2d8582b36df9aebac0ebbd6e4ac5f30ddf1bef8 100644 (file)
@@ -46,6 +46,7 @@ int hyperv_mode_config_init(struct hyperv_drm_device *hv);
 int hyperv_update_vram_location(struct hv_device *hdev, phys_addr_t vram_pp);
 int hyperv_update_situation(struct hv_device *hdev, u8 active, u32 bpp,
                            u32 w, u32 h, u32 pitch);
+int hyperv_hide_hw_ptr(struct hv_device *hdev);
 int hyperv_update_dirt(struct hv_device *hdev, struct drm_rect *rect);
 int hyperv_connect_vsp(struct hv_device *hdev);
 
index 6dd4717d3e1eacd74be7e66e574052a02388ee69..8c97a20dfe2310505110a4e125b3983490b41385 100644 (file)
@@ -101,6 +101,7 @@ static void hyperv_pipe_enable(struct drm_simple_display_pipe *pipe,
        struct hyperv_drm_device *hv = to_hv(pipe->crtc.dev);
        struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 
+       hyperv_hide_hw_ptr(hv->hdev);
        hyperv_update_situation(hv->hdev, 1,  hv->screen_depth,
                                crtc_state->mode.hdisplay,
                                crtc_state->mode.vdisplay,
index 6d4bdccfbd1adff363d04622d065187453173509..c0155c6271bf8935f9b1c967a9d2fd739fc4f074 100644 (file)
@@ -299,6 +299,55 @@ int hyperv_update_situation(struct hv_device *hdev, u8 active, u32 bpp,
        return 0;
 }
 
+/*
+ * Hyper-V supports a hardware cursor feature. It's not used by Linux VM,
+ * but the Hyper-V host still draws a point as an extra mouse pointer,
+ * which is unwanted, especially when Xorg is running.
+ *
+ * The hyperv_fb driver uses synthvid_send_ptr() to hide the unwanted
+ * pointer, by setting msg.ptr_pos.is_visible = 1 and setting the
+ * msg.ptr_shape.data. Note: setting msg.ptr_pos.is_visible to 0 doesn't
+ * work in tests.
+ *
+ * Copy synthvid_send_ptr() to hyperv_drm and rename it to
+ * hyperv_hide_hw_ptr(). Note: hyperv_hide_hw_ptr() is also called in the
+ * handler of the SYNTHVID_FEATURE_CHANGE event, otherwise the host still
+ * draws an extra unwanted mouse pointer after the VM Connection window is
+ * closed and reopened.
+ */
+int hyperv_hide_hw_ptr(struct hv_device *hdev)
+{
+       struct synthvid_msg msg;
+
+       memset(&msg, 0, sizeof(struct synthvid_msg));
+       msg.vid_hdr.type = SYNTHVID_POINTER_POSITION;
+       msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
+               sizeof(struct synthvid_pointer_position);
+       msg.ptr_pos.is_visible = 1;
+       msg.ptr_pos.video_output = 0;
+       msg.ptr_pos.image_x = 0;
+       msg.ptr_pos.image_y = 0;
+       hyperv_sendpacket(hdev, &msg);
+
+       memset(&msg, 0, sizeof(struct synthvid_msg));
+       msg.vid_hdr.type = SYNTHVID_POINTER_SHAPE;
+       msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
+               sizeof(struct synthvid_pointer_shape);
+       msg.ptr_shape.part_idx = SYNTHVID_CURSOR_COMPLETE;
+       msg.ptr_shape.is_argb = 1;
+       msg.ptr_shape.width = 1;
+       msg.ptr_shape.height = 1;
+       msg.ptr_shape.hot_x = 0;
+       msg.ptr_shape.hot_y = 0;
+       msg.ptr_shape.data[0] = 0;
+       msg.ptr_shape.data[1] = 1;
+       msg.ptr_shape.data[2] = 1;
+       msg.ptr_shape.data[3] = 1;
+       hyperv_sendpacket(hdev, &msg);
+
+       return 0;
+}
+
 int hyperv_update_dirt(struct hv_device *hdev, struct drm_rect *rect)
 {
        struct hyperv_drm_device *hv = hv_get_drvdata(hdev);
@@ -392,8 +441,11 @@ static void hyperv_receive_sub(struct hv_device *hdev)
                return;
        }
 
-       if (msg->vid_hdr.type == SYNTHVID_FEATURE_CHANGE)
+       if (msg->vid_hdr.type == SYNTHVID_FEATURE_CHANGE) {
                hv->dirt_needed = msg->feature_chg.is_dirt_needed;
+               if (hv->dirt_needed)
+                       hyperv_hide_hw_ptr(hv->hdev);
+       }
 }
 
 static void hyperv_receive(void *ctx)
index 7cfe91fc05f2470a21133cb2f7d7d3a1bc28e1c6..68abeaf2d7d4d818c3f6c5ddd3374838469b8bd5 100644 (file)
@@ -186,13 +186,16 @@ void intel_dsm_get_bios_data_funcs_supported(struct drm_i915_private *i915)
 {
        struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
        acpi_handle dhandle;
+       union acpi_object *obj;
 
        dhandle = ACPI_HANDLE(&pdev->dev);
        if (!dhandle)
                return;
 
-       acpi_evaluate_dsm(dhandle, &intel_dsm_guid2, INTEL_DSM_REVISION_ID,
-                         INTEL_DSM_FN_GET_BIOS_DATA_FUNCS_SUPPORTED, NULL);
+       obj = acpi_evaluate_dsm(dhandle, &intel_dsm_guid2, INTEL_DSM_REVISION_ID,
+                               INTEL_DSM_FN_GET_BIOS_DATA_FUNCS_SUPPORTED, NULL);
+       if (obj)
+               ACPI_FREE(obj);
 }
 
 /*
index 9ccf4b29b82e107dddec3019ac9243b88d105528..166bb46408a9bd655c044db8895e648cff79f765 100644 (file)
@@ -937,6 +937,10 @@ static struct i915_gem_engines *user_engines(struct i915_gem_context *ctx,
        unsigned int n;
 
        e = alloc_engines(num_engines);
+       if (!e)
+               return ERR_PTR(-ENOMEM);
+       e->num_engines = num_engines;
+
        for (n = 0; n < num_engines; n++) {
                struct intel_context *ce;
                int ret;
@@ -970,7 +974,6 @@ static struct i915_gem_engines *user_engines(struct i915_gem_context *ctx,
                        goto free_engines;
                }
        }
-       e->num_engines = num_engines;
 
        return e;
 
index e866105dd17462d6ac3a9792bcb76009254a40b9..17ca4dc4d0cb3a03169fc0efc3934a0851631a7e 100644 (file)
@@ -421,6 +421,7 @@ void intel_context_fini(struct intel_context *ce)
 
        mutex_destroy(&ce->pin_mutex);
        i915_active_fini(&ce->active);
+       i915_sw_fence_fini(&ce->guc_blocked);
 }
 
 void i915_context_module_exit(void)
index 5f81489fc60c7959a003d17094a22224d6f40360..a4e80e4996748d84bb1e8e170718491c696ad35e 100644 (file)
@@ -4,8 +4,6 @@
  */
 
 #include <linux/clk.h>
-#include <linux/dma-mapping.h>
-#include <linux/mailbox_controller.h>
 #include <linux/pm_runtime.h>
 #include <linux/soc/mediatek/mtk-cmdq.h>
 #include <linux/soc/mediatek/mtk-mmsys.h>
@@ -52,11 +50,8 @@ struct mtk_drm_crtc {
        bool                            pending_async_planes;
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-       struct mbox_client              cmdq_cl;
-       struct mbox_chan                *cmdq_chan;
-       struct cmdq_pkt                 cmdq_handle;
+       struct cmdq_client              *cmdq_client;
        u32                             cmdq_event;
-       u32                             cmdq_vblank_cnt;
 #endif
 
        struct device                   *mmsys_dev;
@@ -227,79 +222,9 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
 }
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-static int mtk_drm_cmdq_pkt_create(struct mbox_chan *chan, struct cmdq_pkt *pkt,
-                                   size_t size)
+static void ddp_cmdq_cb(struct cmdq_cb_data data)
 {
-       struct device *dev;
-       dma_addr_t dma_addr;
-
-       pkt->va_base = kzalloc(size, GFP_KERNEL);
-       if (!pkt->va_base) {
-               kfree(pkt);
-               return -ENOMEM;
-       }
-       pkt->buf_size = size;
-
-       dev = chan->mbox->dev;
-       dma_addr = dma_map_single(dev, pkt->va_base, pkt->buf_size,
-                                 DMA_TO_DEVICE);
-       if (dma_mapping_error(dev, dma_addr)) {
-               dev_err(dev, "dma map failed, size=%u\n", (u32)(u64)size);
-               kfree(pkt->va_base);
-               kfree(pkt);
-               return -ENOMEM;
-       }
-
-       pkt->pa_base = dma_addr;
-
-       return 0;
-}
-
-static void mtk_drm_cmdq_pkt_destroy(struct mbox_chan *chan, struct cmdq_pkt *pkt)
-{
-       dma_unmap_single(chan->mbox->dev, pkt->pa_base, pkt->buf_size,
-                        DMA_TO_DEVICE);
-       kfree(pkt->va_base);
-       kfree(pkt);
-}
-
-static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
-{
-       struct mtk_drm_crtc *mtk_crtc = container_of(cl, struct mtk_drm_crtc, cmdq_cl);
-       struct cmdq_cb_data *data = mssg;
-       struct mtk_crtc_state *state;
-       unsigned int i;
-
-       state = to_mtk_crtc_state(mtk_crtc->base.state);
-
-       state->pending_config = false;
-
-       if (mtk_crtc->pending_planes) {
-               for (i = 0; i < mtk_crtc->layer_nr; i++) {
-                       struct drm_plane *plane = &mtk_crtc->planes[i];
-                       struct mtk_plane_state *plane_state;
-
-                       plane_state = to_mtk_plane_state(plane->state);
-
-                       plane_state->pending.config = false;
-               }
-               mtk_crtc->pending_planes = false;
-       }
-
-       if (mtk_crtc->pending_async_planes) {
-               for (i = 0; i < mtk_crtc->layer_nr; i++) {
-                       struct drm_plane *plane = &mtk_crtc->planes[i];
-                       struct mtk_plane_state *plane_state;
-
-                       plane_state = to_mtk_plane_state(plane->state);
-
-                       plane_state->pending.async_config = false;
-               }
-               mtk_crtc->pending_async_planes = false;
-       }
-
-       mtk_crtc->cmdq_vblank_cnt = 0;
-       mtk_drm_cmdq_pkt_destroy(mtk_crtc->cmdq_chan, data->pkt);
+       cmdq_pkt_destroy(data.data);
 }
 #endif
 
@@ -453,8 +378,7 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
                                    state->pending_vrefresh, 0,
                                    cmdq_handle);
 
-               if (!cmdq_handle)
-                       state->pending_config = false;
+               state->pending_config = false;
        }
 
        if (mtk_crtc->pending_planes) {
@@ -474,12 +398,9 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
                                mtk_ddp_comp_layer_config(comp, local_layer,
                                                          plane_state,
                                                          cmdq_handle);
-                       if (!cmdq_handle)
-                               plane_state->pending.config = false;
+                       plane_state->pending.config = false;
                }
-
-               if (!cmdq_handle)
-                       mtk_crtc->pending_planes = false;
+               mtk_crtc->pending_planes = false;
        }
 
        if (mtk_crtc->pending_async_planes) {
@@ -499,12 +420,9 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
                                mtk_ddp_comp_layer_config(comp, local_layer,
                                                          plane_state,
                                                          cmdq_handle);
-                       if (!cmdq_handle)
-                               plane_state->pending.async_config = false;
+                       plane_state->pending.async_config = false;
                }
-
-               if (!cmdq_handle)
-                       mtk_crtc->pending_async_planes = false;
+               mtk_crtc->pending_async_planes = false;
        }
 }
 
@@ -512,7 +430,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
                                       bool needs_vblank)
 {
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-       struct cmdq_pkt *cmdq_handle = &mtk_crtc->cmdq_handle;
+       struct cmdq_pkt *cmdq_handle;
 #endif
        struct drm_crtc *crtc = &mtk_crtc->base;
        struct mtk_drm_private *priv = crtc->dev->dev_private;
@@ -550,24 +468,14 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
                mtk_mutex_release(mtk_crtc->mutex);
        }
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-       if (mtk_crtc->cmdq_chan) {
-               mbox_flush(mtk_crtc->cmdq_chan, 2000);
-               cmdq_handle->cmd_buf_size = 0;
+       if (mtk_crtc->cmdq_client) {
+               mbox_flush(mtk_crtc->cmdq_client->chan, 2000);
+               cmdq_handle = cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE);
                cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event);
                cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false);
                mtk_crtc_ddp_config(crtc, cmdq_handle);
                cmdq_pkt_finalize(cmdq_handle);
-               dma_sync_single_for_device(mtk_crtc->cmdq_chan->mbox->dev,
-                                           cmdq_handle->pa_base,
-                                           cmdq_handle->cmd_buf_size,
-                                           DMA_TO_DEVICE);
-               /*
-                * CMDQ command should execute in next vblank,
-                * If it fail to execute in next 2 vblank, timeout happen.
-                */
-               mtk_crtc->cmdq_vblank_cnt = 2;
-               mbox_send_message(mtk_crtc->cmdq_chan, cmdq_handle);
-               mbox_client_txdone(mtk_crtc->cmdq_chan, 0);
+               cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
        }
 #endif
        mtk_crtc->config_updating = false;
@@ -581,15 +489,12 @@ static void mtk_crtc_ddp_irq(void *data)
        struct mtk_drm_private *priv = crtc->dev->dev_private;
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-       if (!priv->data->shadow_register && !mtk_crtc->cmdq_chan)
-               mtk_crtc_ddp_config(crtc, NULL);
-       else if (mtk_crtc->cmdq_vblank_cnt > 0 && --mtk_crtc->cmdq_vblank_cnt == 0)
-               DRM_ERROR("mtk_crtc %d CMDQ execute command timeout!\n",
-                         drm_crtc_index(&mtk_crtc->base));
+       if (!priv->data->shadow_register && !mtk_crtc->cmdq_client)
 #else
        if (!priv->data->shadow_register)
-               mtk_crtc_ddp_config(crtc, NULL);
 #endif
+               mtk_crtc_ddp_config(crtc, NULL);
+
        mtk_drm_finish_page_flip(mtk_crtc);
 }
 
@@ -924,20 +829,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
        mutex_init(&mtk_crtc->hw_lock);
 
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
-       mtk_crtc->cmdq_cl.dev = mtk_crtc->mmsys_dev;
-       mtk_crtc->cmdq_cl.tx_block = false;
-       mtk_crtc->cmdq_cl.knows_txdone = true;
-       mtk_crtc->cmdq_cl.rx_callback = ddp_cmdq_cb;
-       mtk_crtc->cmdq_chan =
-                       mbox_request_channel(&mtk_crtc->cmdq_cl,
-                                             drm_crtc_index(&mtk_crtc->base));
-       if (IS_ERR(mtk_crtc->cmdq_chan)) {
+       mtk_crtc->cmdq_client =
+                       cmdq_mbox_create(mtk_crtc->mmsys_dev,
+                                        drm_crtc_index(&mtk_crtc->base));
+       if (IS_ERR(mtk_crtc->cmdq_client)) {
                dev_dbg(dev, "mtk_crtc %d failed to create mailbox client, writing register by CPU now\n",
                        drm_crtc_index(&mtk_crtc->base));
-               mtk_crtc->cmdq_chan = NULL;
+               mtk_crtc->cmdq_client = NULL;
        }
 
-       if (mtk_crtc->cmdq_chan) {
+       if (mtk_crtc->cmdq_client) {
                ret = of_property_read_u32_index(priv->mutex_node,
                                                 "mediatek,gce-events",
                                                 drm_crtc_index(&mtk_crtc->base),
@@ -945,18 +846,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
                if (ret) {
                        dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n",
                                drm_crtc_index(&mtk_crtc->base));
-                       mbox_free_channel(mtk_crtc->cmdq_chan);
-                       mtk_crtc->cmdq_chan = NULL;
-               } else {
-                       ret = mtk_drm_cmdq_pkt_create(mtk_crtc->cmdq_chan,
-                                                      &mtk_crtc->cmdq_handle,
-                                                      PAGE_SIZE);
-                       if (ret) {
-                               dev_dbg(dev, "mtk_crtc %d failed to create cmdq packet\n",
-                                       drm_crtc_index(&mtk_crtc->base));
-                               mbox_free_channel(mtk_crtc->cmdq_chan);
-                               mtk_crtc->cmdq_chan = NULL;
-                       }
+                       cmdq_mbox_destroy(mtk_crtc->cmdq_client);
+                       mtk_crtc->cmdq_client = NULL;
                }
        }
 #endif
index 4534633fe7cdb267718cbf58efef5ab5554203a4..8fb847c174ff840a26d778df02f1532221456304 100644 (file)
@@ -571,13 +571,14 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
        }
 
        icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
-       ret = IS_ERR(icc_path);
-       if (ret)
+       if (IS_ERR(icc_path)) {
+               ret = PTR_ERR(icc_path);
                goto fail;
+       }
 
        ocmem_icc_path = devm_of_icc_get(&pdev->dev, "ocmem");
-       ret = IS_ERR(ocmem_icc_path);
-       if (ret) {
+       if (IS_ERR(ocmem_icc_path)) {
+               ret = PTR_ERR(ocmem_icc_path);
                /* allow -ENODATA, ocmem icc is optional */
                if (ret != -ENODATA)
                        goto fail;
index 82bebb40234de14016e4e25768690706d8120283..a96ee79cc5e0886029b2ef94216562ace0d83c3e 100644 (file)
@@ -699,13 +699,14 @@ struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
        }
 
        icc_path = devm_of_icc_get(&pdev->dev, "gfx-mem");
-       ret = IS_ERR(icc_path);
-       if (ret)
+       if (IS_ERR(icc_path)) {
+               ret = PTR_ERR(icc_path);
                goto fail;
+       }
 
        ocmem_icc_path = devm_of_icc_get(&pdev->dev, "ocmem");
-       ret = IS_ERR(ocmem_icc_path);
-       if (ret) {
+       if (IS_ERR(ocmem_icc_path)) {
+               ret = PTR_ERR(ocmem_icc_path);
                /* allow -ENODATA, ocmem icc is optional */
                if (ret != -ENODATA)
                        goto fail;
index a7c58018959fbf28266e0f406a1e47a8b45e0be2..8b73f70766a4771771f2dd04cb98822554c3e6e8 100644 (file)
@@ -296,6 +296,8 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)
        u32 val;
        int request, ack;
 
+       WARN_ON_ONCE(!mutex_is_locked(&gmu->lock));
+
        if (state >= ARRAY_SIZE(a6xx_gmu_oob_bits))
                return -EINVAL;
 
@@ -337,6 +339,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)
 {
        int bit;
 
+       WARN_ON_ONCE(!mutex_is_locked(&gmu->lock));
+
        if (state >= ARRAY_SIZE(a6xx_gmu_oob_bits))
                return;
 
@@ -1482,6 +1486,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
        if (!pdev)
                return -ENODEV;
 
+       mutex_init(&gmu->lock);
+
        gmu->dev = &pdev->dev;
 
        of_dma_configure(gmu->dev, node, true);
index 3c74f64e31262cc9a13e4bd9b944542cbf8b1269..84bd516f01e895b27a54756463427779f54eaa43 100644 (file)
@@ -44,6 +44,9 @@ struct a6xx_gmu_bo {
 struct a6xx_gmu {
        struct device *dev;
 
+       /* For serializing communication with the GMU: */
+       struct mutex lock;
+
        struct msm_gem_address_space *aspace;
 
        void * __iomem mmio;
index 40c9fef457a49122b2bfa24570f1a477d13748a4..33da25b81615a7dcbd9b9ea17ce04e066109d35e 100644 (file)
@@ -106,7 +106,7 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,
        u32 asid;
        u64 memptr = rbmemptr(ring, ttbr0);
 
-       if (ctx == a6xx_gpu->cur_ctx)
+       if (ctx->seqno == a6xx_gpu->cur_ctx_seqno)
                return;
 
        if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid))
@@ -139,7 +139,7 @@ static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu,
        OUT_PKT7(ring, CP_EVENT_WRITE, 1);
        OUT_RING(ring, 0x31);
 
-       a6xx_gpu->cur_ctx = ctx;
+       a6xx_gpu->cur_ctx_seqno = ctx->seqno;
 }
 
 static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
@@ -881,7 +881,7 @@ static int a6xx_zap_shader_init(struct msm_gpu *gpu)
          A6XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS | \
          A6XX_RBBM_INT_0_MASK_UCHE_TRAP_INTR)
 
-static int a6xx_hw_init(struct msm_gpu *gpu)
+static int hw_init(struct msm_gpu *gpu)
 {
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
        struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
@@ -1081,7 +1081,7 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
        /* Always come up on rb 0 */
        a6xx_gpu->cur_ring = gpu->rb[0];
 
-       a6xx_gpu->cur_ctx = NULL;
+       a6xx_gpu->cur_ctx_seqno = 0;
 
        /* Enable the SQE_to start the CP engine */
        gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 1);
@@ -1135,6 +1135,19 @@ out:
        return ret;
 }
 
+static int a6xx_hw_init(struct msm_gpu *gpu)
+{
+       struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+       struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
+       int ret;
+
+       mutex_lock(&a6xx_gpu->gmu.lock);
+       ret = hw_init(gpu);
+       mutex_unlock(&a6xx_gpu->gmu.lock);
+
+       return ret;
+}
+
 static void a6xx_dump(struct msm_gpu *gpu)
 {
        DRM_DEV_INFO(&gpu->pdev->dev, "status:   %08x\n",
@@ -1509,7 +1522,9 @@ static int a6xx_pm_resume(struct msm_gpu *gpu)
 
        trace_msm_gpu_resume(0);
 
+       mutex_lock(&a6xx_gpu->gmu.lock);
        ret = a6xx_gmu_resume(a6xx_gpu);
+       mutex_unlock(&a6xx_gpu->gmu.lock);
        if (ret)
                return ret;
 
@@ -1532,7 +1547,9 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)
 
        msm_devfreq_suspend(gpu);
 
+       mutex_lock(&a6xx_gpu->gmu.lock);
        ret = a6xx_gmu_stop(a6xx_gpu);
+       mutex_unlock(&a6xx_gpu->gmu.lock);
        if (ret)
                return ret;
 
@@ -1547,18 +1564,19 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)
 {
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
        struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
-       static DEFINE_MUTEX(perfcounter_oob);
 
-       mutex_lock(&perfcounter_oob);
+       mutex_lock(&a6xx_gpu->gmu.lock);
 
        /* Force the GPU power on so we can read this register */
        a6xx_gmu_set_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
 
        *value = gpu_read64(gpu, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO,
-               REG_A6XX_CP_ALWAYS_ON_COUNTER_HI);
+                           REG_A6XX_CP_ALWAYS_ON_COUNTER_HI);
 
        a6xx_gmu_clear_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
-       mutex_unlock(&perfcounter_oob);
+
+       mutex_unlock(&a6xx_gpu->gmu.lock);
+
        return 0;
 }
 
@@ -1622,6 +1640,16 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)
        return (unsigned long)busy_time;
 }
 
+void a6xx_gpu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
+{
+       struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+       struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
+
+       mutex_lock(&a6xx_gpu->gmu.lock);
+       a6xx_gmu_set_freq(gpu, opp);
+       mutex_unlock(&a6xx_gpu->gmu.lock);
+}
+
 static struct msm_gem_address_space *
 a6xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev)
 {
@@ -1766,7 +1794,7 @@ static const struct adreno_gpu_funcs funcs = {
 #endif
                .gpu_busy = a6xx_gpu_busy,
                .gpu_get_freq = a6xx_gmu_get_freq,
-               .gpu_set_freq = a6xx_gmu_set_freq,
+               .gpu_set_freq = a6xx_gpu_set_freq,
 #if defined(CONFIG_DRM_MSM_GPU_STATE)
                .gpu_state_get = a6xx_gpu_state_get,
                .gpu_state_put = a6xx_gpu_state_put,
index 0bc2d062f54ab15a52e925a30ef0de130af92e83..8e5527c881b1e83e820b6919f6e4ea18916510b6 100644 (file)
@@ -19,7 +19,16 @@ struct a6xx_gpu {
        uint64_t sqe_iova;
 
        struct msm_ringbuffer *cur_ring;
-       struct msm_file_private *cur_ctx;
+
+       /**
+        * cur_ctx_seqno:
+        *
+        * The ctx->seqno value of the context with current pgtables
+        * installed.  Tracked by seqno rather than pointer value to
+        * avoid dangling pointers, and cases where a ctx can be freed
+        * and a new one created with the same address.
+        */
+       int cur_ctx_seqno;
 
        struct a6xx_gmu gmu;
 
index b131fd376192b6a9aede1cb4cdea0af7efe65910..700d65e39feb02471d7520b6ae9b2c1f82901a0e 100644 (file)
@@ -794,7 +794,7 @@ static const struct dpu_pingpong_cfg sm8150_pp[] = {
                        DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 30),
                        -1),
        PP_BLK("pingpong_5", PINGPONG_5, 0x72800, MERGE_3D_2, sdm845_pp_sblk,
-                       DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 30),
+                       DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 31),
                        -1),
 };
 
index f482e0911d039d3dce49b263e934a0ee201d2ce5..bb7d066618e6490bbffbb2cc16aedc0438be79fe 100644 (file)
@@ -1125,6 +1125,20 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc)
        __drm_atomic_helper_crtc_reset(crtc, &mdp5_cstate->base);
 }
 
+static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
+       .set_config = drm_atomic_helper_set_config,
+       .destroy = mdp5_crtc_destroy,
+       .page_flip = drm_atomic_helper_page_flip,
+       .reset = mdp5_crtc_reset,
+       .atomic_duplicate_state = mdp5_crtc_duplicate_state,
+       .atomic_destroy_state = mdp5_crtc_destroy_state,
+       .atomic_print_state = mdp5_crtc_atomic_print_state,
+       .get_vblank_counter = mdp5_crtc_get_vblank_counter,
+       .enable_vblank  = msm_crtc_enable_vblank,
+       .disable_vblank = msm_crtc_disable_vblank,
+       .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
+};
+
 static const struct drm_crtc_funcs mdp5_crtc_funcs = {
        .set_config = drm_atomic_helper_set_config,
        .destroy = mdp5_crtc_destroy,
@@ -1313,6 +1327,8 @@ struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
        mdp5_crtc->lm_cursor_enabled = cursor_plane ? false : true;
 
        drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane,
+                                 cursor_plane ?
+                                 &mdp5_crtc_no_lm_cursor_funcs :
                                  &mdp5_crtc_funcs, NULL);
 
        drm_flip_work_init(&mdp5_crtc->unref_cursor_work,
index fbe4c2cd52a3d9e2cc947801b206c05b1297268f..a0392e4d8134c3ad98f5b35aae65aec846236d16 100644 (file)
@@ -1309,14 +1309,14 @@ static int dp_pm_resume(struct device *dev)
         * can not declared display is connected unless
         * HDMI cable is plugged in and sink_count of
         * dongle become 1
+        * also only signal audio when disconnected
         */
-       if (dp->link->sink_count)
+       if (dp->link->sink_count) {
                dp->dp_display.is_connected = true;
-       else
+       } else {
                dp->dp_display.is_connected = false;
-
-       dp_display_handle_plugged_change(g_dp_display,
-                               dp->dp_display.is_connected);
+               dp_display_handle_plugged_change(g_dp_display, false);
+       }
 
        DRM_DEBUG_DP("After, sink_count=%d is_connected=%d core_inited=%d power_on=%d\n",
                        dp->link->sink_count, dp->dp_display.is_connected,
index 614dc7f26f2c8189e7510367fe9c4137da3823ab..75ae3008b68f4a2bb81f2cb4a439a42174c8d199 100644 (file)
@@ -215,8 +215,10 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
                goto fail;
        }
 
-       if (!msm_dsi_manager_validate_current_config(msm_dsi->id))
+       if (!msm_dsi_manager_validate_current_config(msm_dsi->id)) {
+               ret = -EINVAL;
                goto fail;
+       }
 
        msm_dsi->encoder = encoder;
 
index e269df285136c2c9d56fd0e171e336f0f46b209b..c86b5090fae60db7bc854496fffbdb368eacadaa 100644 (file)
@@ -451,7 +451,7 @@ static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host)
 
        return 0;
 err:
-       for (; i > 0; i--)
+       while (--i >= 0)
                clk_disable_unprepare(msm_host->bus_clks[i]);
 
        return ret;
index d13552b2213b695ae9e970a310f2f487134375ec..5b4e991f220d684f3bcc3abb23d9c1df210dbb24 100644 (file)
@@ -110,14 +110,13 @@ static struct dsi_pll_14nm *pll_14nm_list[DSI_MAX];
 static bool pll_14nm_poll_for_ready(struct dsi_pll_14nm *pll_14nm,
                                    u32 nb_tries, u32 timeout_us)
 {
-       bool pll_locked = false;
+       bool pll_locked = false, pll_ready = false;
        void __iomem *base = pll_14nm->phy->pll_base;
        u32 tries, val;
 
        tries = nb_tries;
        while (tries--) {
-               val = dsi_phy_read(base +
-                              REG_DSI_14nm_PHY_PLL_RESET_SM_READY_STATUS);
+               val = dsi_phy_read(base + REG_DSI_14nm_PHY_PLL_RESET_SM_READY_STATUS);
                pll_locked = !!(val & BIT(5));
 
                if (pll_locked)
@@ -126,23 +125,24 @@ static bool pll_14nm_poll_for_ready(struct dsi_pll_14nm *pll_14nm,
                udelay(timeout_us);
        }
 
-       if (!pll_locked) {
-               tries = nb_tries;
-               while (tries--) {
-                       val = dsi_phy_read(base +
-                               REG_DSI_14nm_PHY_PLL_RESET_SM_READY_STATUS);
-                       pll_locked = !!(val & BIT(0));
+       if (!pll_locked)
+               goto out;
 
-                       if (pll_locked)
-                               break;
+       tries = nb_tries;
+       while (tries--) {
+               val = dsi_phy_read(base + REG_DSI_14nm_PHY_PLL_RESET_SM_READY_STATUS);
+               pll_ready = !!(val & BIT(0));
 
-                       udelay(timeout_us);
-               }
+               if (pll_ready)
+                       break;
+
+               udelay(timeout_us);
        }
 
-       DBG("DSI PLL is %slocked", pll_locked ? "" : "*not* ");
+out:
+       DBG("DSI PLL is %slocked, %sready", pll_locked ? "" : "*not* ", pll_ready ? "" : "*not* ");
 
-       return pll_locked;
+       return pll_locked && pll_ready;
 }
 
 static void dsi_pll_14nm_config_init(struct dsi_pll_config *pconf)
index aaa37456f4ee3cf55831cac498823454b1e2f1aa..71ed4aa0dc67e6c7ce1707a3094f8be221166395 100644 (file)
@@ -428,7 +428,7 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw **prov
        bytediv->reg = pll_28nm->phy->pll_base + REG_DSI_28nm_8960_PHY_PLL_CTRL_9;
 
        snprintf(parent_name, 32, "dsi%dvco_clk", pll_28nm->phy->id);
-       snprintf(clk_name, 32, "dsi%dpllbyte", pll_28nm->phy->id);
+       snprintf(clk_name, 32, "dsi%dpllbyte", pll_28nm->phy->id + 1);
 
        bytediv_init.name = clk_name;
        bytediv_init.ops = &clk_bytediv_ops;
@@ -442,7 +442,7 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw **prov
                return ret;
        provided_clocks[DSI_BYTE_PLL_CLK] = &bytediv->hw;
 
-       snprintf(clk_name, 32, "dsi%dpll", pll_28nm->phy->id);
+       snprintf(clk_name, 32, "dsi%dpll", pll_28nm->phy->id + 1);
        /* DIV3 */
        hw = devm_clk_hw_register_divider(dev, clk_name,
                                parent_name, 0, pll_28nm->phy->pll_base +
index 4fb397ee7c8425c7809cc12e2f4d502faee4b5d1..fe1366b4c49f58083b554de380812b4dacbd762e 100644 (file)
@@ -1116,7 +1116,7 @@ void msm_edp_ctrl_power(struct edp_ctrl *ctrl, bool on)
 int msm_edp_ctrl_init(struct msm_edp *edp)
 {
        struct edp_ctrl *ctrl = NULL;
-       struct device *dev = &edp->pdev->dev;
+       struct device *dev;
        int ret;
 
        if (!edp) {
@@ -1124,6 +1124,7 @@ int msm_edp_ctrl_init(struct msm_edp *edp)
                return -EINVAL;
        }
 
+       dev = &edp->pdev->dev;
        ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
        if (!ctrl)
                return -ENOMEM;
index 2e6fc185e54da4b3e8a79a8cb5fcfd873bf76ce6..d4e09703a87dbb0db3333636eb0019f03016347f 100644 (file)
@@ -630,10 +630,11 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
        if (ret)
                goto err_msm_uninit;
 
-       ret = msm_disp_snapshot_init(ddev);
-       if (ret)
-               DRM_DEV_ERROR(dev, "msm_disp_snapshot_init failed ret = %d\n", ret);
-
+       if (kms) {
+               ret = msm_disp_snapshot_init(ddev);
+               if (ret)
+                       DRM_DEV_ERROR(dev, "msm_disp_snapshot_init failed ret = %d\n", ret);
+       }
        drm_mode_config_reset(ddev);
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
@@ -682,6 +683,7 @@ static void load_gpu(struct drm_device *dev)
 
 static int context_init(struct drm_device *dev, struct drm_file *file)
 {
+       static atomic_t ident = ATOMIC_INIT(0);
        struct msm_drm_private *priv = dev->dev_private;
        struct msm_file_private *ctx;
 
@@ -689,12 +691,17 @@ static int context_init(struct drm_device *dev, struct drm_file *file)
        if (!ctx)
                return -ENOMEM;
 
+       INIT_LIST_HEAD(&ctx->submitqueues);
+       rwlock_init(&ctx->queuelock);
+
        kref_init(&ctx->ref);
        msm_submitqueue_init(dev, ctx);
 
        ctx->aspace = msm_gpu_create_private_address_space(priv->gpu, current);
        file->driver_priv = ctx;
 
+       ctx->seqno = atomic_inc_return(&ident);
+
        return 0;
 }
 
index 8b005d1ac89974aa61b7ee960c68750af2d07b26..c552f0c3890c1c6107bbb9b70c2de50cbaeae3d9 100644 (file)
@@ -53,14 +53,6 @@ struct msm_disp_state;
 
 #define FRAC_16_16(mult, div)    (((mult) << 16) / (div))
 
-struct msm_file_private {
-       rwlock_t queuelock;
-       struct list_head submitqueues;
-       int queueid;
-       struct msm_gem_address_space *aspace;
-       struct kref ref;
-};
-
 enum msm_mdp_plane_property {
        PLANE_PROP_ZPOS,
        PLANE_PROP_ALPHA,
@@ -488,41 +480,6 @@ void msm_writel(u32 data, void __iomem *addr);
 u32 msm_readl(const void __iomem *addr);
 void msm_rmw(void __iomem *addr, u32 mask, u32 or);
 
-struct msm_gpu_submitqueue;
-int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx);
-struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx,
-               u32 id);
-int msm_submitqueue_create(struct drm_device *drm,
-               struct msm_file_private *ctx,
-               u32 prio, u32 flags, u32 *id);
-int msm_submitqueue_query(struct drm_device *drm, struct msm_file_private *ctx,
-               struct drm_msm_submitqueue_query *args);
-int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id);
-void msm_submitqueue_close(struct msm_file_private *ctx);
-
-void msm_submitqueue_destroy(struct kref *kref);
-
-static inline void __msm_file_private_destroy(struct kref *kref)
-{
-       struct msm_file_private *ctx = container_of(kref,
-               struct msm_file_private, ref);
-
-       msm_gem_address_space_put(ctx->aspace);
-       kfree(ctx);
-}
-
-static inline void msm_file_private_put(struct msm_file_private *ctx)
-{
-       kref_put(&ctx->ref, __msm_file_private_destroy);
-}
-
-static inline struct msm_file_private *msm_file_private_get(
-       struct msm_file_private *ctx)
-{
-       kref_get(&ctx->ref);
-       return ctx;
-}
-
 #define DBG(fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
 #define VERB(fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
 
@@ -547,7 +504,7 @@ static inline int align_pitch(int width, int bpp)
 static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
 {
        ktime_t now = ktime_get();
-       unsigned long remaining_jiffies;
+       s64 remaining_jiffies;
 
        if (ktime_compare(*timeout, now) < 0) {
                remaining_jiffies = 0;
@@ -556,7 +513,7 @@ static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
                remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ);
        }
 
-       return remaining_jiffies;
+       return clamp(remaining_jiffies, 0LL, (s64)INT_MAX);
 }
 
 #endif /* __MSM_DRV_H__ */
index fdc5367aecaa35190aa1d1afc0172b55ceb18368..151d19e4453cd477233d00cd4c102a26e3c33925 100644 (file)
@@ -46,7 +46,7 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
        if (!submit)
                return ERR_PTR(-ENOMEM);
 
-       ret = drm_sched_job_init(&submit->base, &queue->entity, queue);
+       ret = drm_sched_job_init(&submit->base, queue->entity, queue);
        if (ret) {
                kfree(submit);
                return ERR_PTR(ret);
@@ -171,7 +171,8 @@ out:
 static int submit_lookup_cmds(struct msm_gem_submit *submit,
                struct drm_msm_gem_submit *args, struct drm_file *file)
 {
-       unsigned i, sz;
+       unsigned i;
+       size_t sz;
        int ret = 0;
 
        for (i = 0; i < args->nr_cmds; i++) {
@@ -907,7 +908,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        /* The scheduler owns a ref now: */
        msm_gem_submit_get(submit);
 
-       drm_sched_entity_push_job(&submit->base, &queue->entity);
+       drm_sched_entity_push_job(&submit->base, queue->entity);
 
        args->fence = submit->fence_id;
 
index 0e4b45bff2e6e1b1d960e7cbbaed71c46ff4a8d9..030f82f149c2c7a4ad8b29b9c266a5b991d3e0be 100644 (file)
@@ -257,6 +257,39 @@ struct msm_gpu_perfcntr {
  */
 #define NR_SCHED_PRIORITIES (1 + DRM_SCHED_PRIORITY_HIGH - DRM_SCHED_PRIORITY_MIN)
 
+/**
+ * struct msm_file_private - per-drm_file context
+ *
+ * @queuelock:    synchronizes access to submitqueues list
+ * @submitqueues: list of &msm_gpu_submitqueue created by userspace
+ * @queueid:      counter incremented each time a submitqueue is created,
+ *                used to assign &msm_gpu_submitqueue.id
+ * @aspace:       the per-process GPU address-space
+ * @ref:          reference count
+ * @seqno:        unique per process seqno
+ */
+struct msm_file_private {
+       rwlock_t queuelock;
+       struct list_head submitqueues;
+       int queueid;
+       struct msm_gem_address_space *aspace;
+       struct kref ref;
+       int seqno;
+
+       /**
+        * entities:
+        *
+        * Table of per-priority-level sched entities used by submitqueues
+        * associated with this &drm_file.  Because some userspace apps
+        * make assumptions about rendering from multiple gl contexts
+        * (of the same priority) within the process happening in FIFO
+        * order without requiring any fencing beyond MakeCurrent(), we
+        * create at most one &drm_sched_entity per-process per-priority-
+        * level.
+        */
+       struct drm_sched_entity *entities[NR_SCHED_PRIORITIES * MSM_GPU_MAX_RINGS];
+};
+
 /**
  * msm_gpu_convert_priority - Map userspace priority to ring # and sched priority
  *
@@ -304,6 +337,8 @@ static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio,
 }
 
 /**
+ * struct msm_gpu_submitqueues - Userspace created context.
+ *
  * A submitqueue is associated with a gl context or vk queue (or equiv)
  * in userspace.
  *
@@ -321,7 +356,7 @@ static inline int msm_gpu_convert_priority(struct msm_gpu *gpu, int prio,
  *             seqno, protected by submitqueue lock
  * @lock:      submitqueue lock
  * @ref:       reference count
- * @entity: the submit job-queue
+ * @entity:    the submit job-queue
  */
 struct msm_gpu_submitqueue {
        int id;
@@ -333,7 +368,7 @@ struct msm_gpu_submitqueue {
        struct idr fence_idr;
        struct mutex lock;
        struct kref ref;
-       struct drm_sched_entity entity;
+       struct drm_sched_entity *entity;
 };
 
 struct msm_gpu_state_bo {
@@ -421,6 +456,33 @@ static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val)
 int msm_gpu_pm_suspend(struct msm_gpu *gpu);
 int msm_gpu_pm_resume(struct msm_gpu *gpu);
 
+int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx);
+struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx,
+               u32 id);
+int msm_submitqueue_create(struct drm_device *drm,
+               struct msm_file_private *ctx,
+               u32 prio, u32 flags, u32 *id);
+int msm_submitqueue_query(struct drm_device *drm, struct msm_file_private *ctx,
+               struct drm_msm_submitqueue_query *args);
+int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id);
+void msm_submitqueue_close(struct msm_file_private *ctx);
+
+void msm_submitqueue_destroy(struct kref *kref);
+
+void __msm_file_private_destroy(struct kref *kref);
+
+static inline void msm_file_private_put(struct msm_file_private *ctx)
+{
+       kref_put(&ctx->ref, __msm_file_private_destroy);
+}
+
+static inline struct msm_file_private *msm_file_private_get(
+       struct msm_file_private *ctx)
+{
+       kref_get(&ctx->ref);
+       return ctx;
+}
+
 void msm_devfreq_init(struct msm_gpu *gpu);
 void msm_devfreq_cleanup(struct msm_gpu *gpu);
 void msm_devfreq_resume(struct msm_gpu *gpu);
index 0a1ee20296a2cddc4b2d1c099d225d395a89ba3c..84e98c07c9001aed6e5ae299885c8a5a6dd047f2 100644 (file)
@@ -151,6 +151,9 @@ void msm_devfreq_active(struct msm_gpu *gpu)
        unsigned int idle_time;
        unsigned long target_freq = df->idle_freq;
 
+       if (!df->devfreq)
+               return;
+
        /*
         * Hold devfreq lock to synchronize with get_dev_status()/
         * target() callbacks
@@ -186,6 +189,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)
        struct msm_gpu_devfreq *df = &gpu->devfreq;
        unsigned long idle_freq, target_freq = 0;
 
+       if (!df->devfreq)
+               return;
+
        /*
         * Hold devfreq lock to synchronize with get_dev_status()/
         * target() callbacks
index 32a55d81b58b6d3d28e815a06256ad0931ca287b..b8621c6e055460caaf1bc2779945702670af9da1 100644 (file)
@@ -7,6 +7,24 @@
 
 #include "msm_gpu.h"
 
+void __msm_file_private_destroy(struct kref *kref)
+{
+       struct msm_file_private *ctx = container_of(kref,
+               struct msm_file_private, ref);
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(ctx->entities); i++) {
+               if (!ctx->entities[i])
+                       continue;
+
+               drm_sched_entity_destroy(ctx->entities[i]);
+               kfree(ctx->entities[i]);
+       }
+
+       msm_gem_address_space_put(ctx->aspace);
+       kfree(ctx);
+}
+
 void msm_submitqueue_destroy(struct kref *kref)
 {
        struct msm_gpu_submitqueue *queue = container_of(kref,
@@ -14,8 +32,6 @@ void msm_submitqueue_destroy(struct kref *kref)
 
        idr_destroy(&queue->fence_idr);
 
-       drm_sched_entity_destroy(&queue->entity);
-
        msm_file_private_put(queue->ctx);
 
        kfree(queue);
@@ -61,13 +77,47 @@ void msm_submitqueue_close(struct msm_file_private *ctx)
        }
 }
 
+static struct drm_sched_entity *
+get_sched_entity(struct msm_file_private *ctx, struct msm_ringbuffer *ring,
+                unsigned ring_nr, enum drm_sched_priority sched_prio)
+{
+       static DEFINE_MUTEX(entity_lock);
+       unsigned idx = (ring_nr * NR_SCHED_PRIORITIES) + sched_prio;
+
+       /* We should have already validated that the requested priority is
+        * valid by the time we get here.
+        */
+       if (WARN_ON(idx >= ARRAY_SIZE(ctx->entities)))
+               return ERR_PTR(-EINVAL);
+
+       mutex_lock(&entity_lock);
+
+       if (!ctx->entities[idx]) {
+               struct drm_sched_entity *entity;
+               struct drm_gpu_scheduler *sched = &ring->sched;
+               int ret;
+
+               entity = kzalloc(sizeof(*ctx->entities[idx]), GFP_KERNEL);
+
+               ret = drm_sched_entity_init(entity, sched_prio, &sched, 1, NULL);
+               if (ret) {
+                       kfree(entity);
+                       return ERR_PTR(ret);
+               }
+
+               ctx->entities[idx] = entity;
+       }
+
+       mutex_unlock(&entity_lock);
+
+       return ctx->entities[idx];
+}
+
 int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
                u32 prio, u32 flags, u32 *id)
 {
        struct msm_drm_private *priv = drm->dev_private;
        struct msm_gpu_submitqueue *queue;
-       struct msm_ringbuffer *ring;
-       struct drm_gpu_scheduler *sched;
        enum drm_sched_priority sched_prio;
        unsigned ring_nr;
        int ret;
@@ -91,12 +141,10 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
        queue->flags = flags;
        queue->ring_nr = ring_nr;
 
-       ring = priv->gpu->rb[ring_nr];
-       sched = &ring->sched;
-
-       ret = drm_sched_entity_init(&queue->entity,
-                       sched_prio, &sched, 1, NULL);
-       if (ret) {
+       queue->entity = get_sched_entity(ctx, priv->gpu->rb[ring_nr],
+                                        ring_nr, sched_prio);
+       if (IS_ERR(queue->entity)) {
+               ret = PTR_ERR(queue->entity);
                kfree(queue);
                return ret;
        }
@@ -140,10 +188,6 @@ int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx)
         */
        default_prio = DIV_ROUND_UP(max_priority, 2);
 
-       INIT_LIST_HEAD(&ctx->submitqueues);
-
-       rwlock_init(&ctx->queuelock);
-
        return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL);
 }
 
index 353b77d9b3dcffe35f12172e36e24b75cd454950..3492c561f2cfc858c4f776e1fd3d754d0136d544 100644 (file)
@@ -82,7 +82,7 @@ g84_fifo_chan_engine_fini(struct nvkm_fifo_chan *base,
        if (offset < 0)
                return 0;
 
-       engn = fifo->base.func->engine_id(&fifo->base, engine);
+       engn = fifo->base.func->engine_id(&fifo->base, engine) - 1;
        save = nvkm_mask(device, 0x002520, 0x0000003f, 1 << engn);
        nvkm_wr32(device, 0x0032fc, chan->base.inst->addr >> 12);
        done = nvkm_msec(device, 2000,
index beb581b96ecdc6f9dbdbc64676137de854428cd4..418638e6e3b0a06e1302ccdf682b7ea99232760d 100644 (file)
@@ -295,6 +295,7 @@ config DRM_PANEL_OLIMEX_LCD_OLINUXINO
        depends on OF
        depends on I2C
        depends on BACKLIGHT_CLASS_DEVICE
+       select CRC32
        help
          The panel is used with different sizes LCDs, from 480x272 to
          1280x800, and 24 bit per pixel.
index 0ecccf25a3c760337773d2d0e843ec865423df32..d2a0f5394fef69e4b5f4a103139620c04a1c5cf1 100644 (file)
@@ -214,7 +214,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
        }
        ret = 0;
 
-#if defined(__i386__) || defined(__x86_64__)
+#ifdef CONFIG_X86
        wbinvd();
 #else
        mb();
index 0daa8bba50f5a9097e861773ee725baf9bcb991d..4bf4e25d7f011fdacb1eabb1662f2e9fedf9d448 100644 (file)
@@ -86,12 +86,20 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
        }
 
        /*
-        * Create and initialize the encoder. On Gen3 skip the LVDS1 output if
+        * Create and initialize the encoder. On Gen3, skip the LVDS1 output if
         * the LVDS1 encoder is used as a companion for LVDS0 in dual-link
-        * mode.
+        * mode, or any LVDS output if it isn't connected. The latter may happen
+        * on D3 or E3 as the LVDS encoders are needed to provide the pixel
+        * clock to the DU, even when the LVDS outputs are not used.
         */
-       if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
-               if (rcar_lvds_dual_link(bridge))
+       if (rcdu->info->gen >= 3) {
+               if (output == RCAR_DU_OUTPUT_LVDS1 &&
+                   rcar_lvds_dual_link(bridge))
+                       return -ENOLINK;
+
+               if ((output == RCAR_DU_OUTPUT_LVDS0 ||
+                    output == RCAR_DU_OUTPUT_LVDS1) &&
+                   !rcar_lvds_is_connected(bridge))
                        return -ENOLINK;
        }
 
index d061b8de748fdd44fe71b3628ade5e8d1b8e1a13..b672c5bd72ee888764ba58177729b2b3b8ef2378 100644 (file)
@@ -576,6 +576,9 @@ static int rcar_lvds_attach(struct drm_bridge *bridge,
 {
        struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
 
+       if (!lvds->next_bridge)
+               return 0;
+
        return drm_bridge_attach(bridge->encoder, lvds->next_bridge, bridge,
                                 flags);
 }
@@ -598,6 +601,14 @@ bool rcar_lvds_dual_link(struct drm_bridge *bridge)
 }
 EXPORT_SYMBOL_GPL(rcar_lvds_dual_link);
 
+bool rcar_lvds_is_connected(struct drm_bridge *bridge)
+{
+       struct rcar_lvds *lvds = bridge_to_rcar_lvds(bridge);
+
+       return lvds->next_bridge != NULL;
+}
+EXPORT_SYMBOL_GPL(rcar_lvds_is_connected);
+
 /* -----------------------------------------------------------------------------
  * Probe & Remove
  */
index 222ec0e60785ca31901d0a14cf8ce9ca89860cb3..eb7c6ef03b00afa402f15b9aac6cb4db30624cb3 100644 (file)
@@ -16,6 +16,7 @@ struct drm_bridge;
 int rcar_lvds_clk_enable(struct drm_bridge *bridge, unsigned long freq);
 void rcar_lvds_clk_disable(struct drm_bridge *bridge);
 bool rcar_lvds_dual_link(struct drm_bridge *bridge);
+bool rcar_lvds_is_connected(struct drm_bridge *bridge);
 #else
 static inline int rcar_lvds_clk_enable(struct drm_bridge *bridge,
                                       unsigned long freq)
@@ -27,6 +28,10 @@ static inline bool rcar_lvds_dual_link(struct drm_bridge *bridge)
 {
        return false;
 }
+static inline bool rcar_lvds_is_connected(struct drm_bridge *bridge)
+{
+       return false;
+}
 #endif /* CONFIG_DRM_RCAR_LVDS */
 
 #endif /* __RCAR_LVDS_H__ */
index f1099b4953014c628002341426eb949f441fb332..467519a2027e5519ead92730ab91c95473254f9b 100644 (file)
@@ -5,3 +5,4 @@
 
 # Keep in alphabetical order
 obj-$(CONFIG_IIO_TEST_FORMAT) += iio-test-format.o
+CFLAGS_iio-test-format.o += $(DISABLE_STRUCTLEAK_PLUGIN)
index c5c71b7ab7e8358eaebde74bdd0cfc572cbe578d..3eb68fa1b8cc02949fc29468316df560ceaefc31 100644 (file)
@@ -355,6 +355,14 @@ config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT
          'arm-smmu.disable_bypass' will continue to override this
          config.
 
+config ARM_SMMU_QCOM
+       def_tristate y
+       depends on ARM_SMMU && ARCH_QCOM
+       select QCOM_SCM
+       help
+         When running on a Qualcomm platform that has the custom variant
+         of the ARM SMMU, this needs to be built into the SMMU driver.
+
 config ARM_SMMU_V3
        tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
        depends on ARM64
index cb0afe8971623668b232173e38dc7aad63d887c4..7313454e403a630d64196a07bfc805891753f00f 100644 (file)
@@ -480,6 +480,11 @@ int detach_capi_ctr(struct capi_ctr *ctr)
 
        ctr_down(ctr, CAPI_CTR_DETACHED);
 
+       if (ctr->cnr < 1 || ctr->cnr - 1 >= CAPI_MAXCONTR) {
+               err = -EINVAL;
+               goto unlock_out;
+       }
+
        if (capi_controller[ctr->cnr - 1] != ctr) {
                err = -EINVAL;
                goto unlock_out;
index 2a1ddd47a0968da8db09c9800b5219547ca5e43f..a52f275f826348475b0f49a241ee73b2c6553fca 100644 (file)
@@ -949,8 +949,8 @@ nj_release(struct tiger_hw *card)
                nj_disable_hwirq(card);
                mode_tiger(&card->bc[0], ISDN_P_NONE);
                mode_tiger(&card->bc[1], ISDN_P_NONE);
-               card->isac.release(&card->isac);
                spin_unlock_irqrestore(&card->lock, flags);
+               card->isac.release(&card->isac);
                release_region(card->base, card->base_s);
                card->base_s = 0;
        }
index ef0badea4f4158e9b136fa2274a87f7006ff20a1..04e6f7b26706482883fb3fe681200febc23fc92e 100644 (file)
@@ -1676,13 +1676,17 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
        struct nand_ecc_ctrl *ecc = &chip->ecc;
        int data_size1, data_size2, oob_size1, oob_size2;
        int ret, reg_off = FLASH_BUF_ACC, read_loc = 0;
+       int raw_cw = cw;
 
        nand_read_page_op(chip, page, 0, NULL, 0);
        host->use_ecc = false;
 
+       if (nandc->props->qpic_v2)
+               raw_cw = ecc->steps - 1;
+
        clear_bam_transaction(nandc);
        set_address(host, host->cw_size * cw, page);
-       update_rw_regs(host, 1, true, cw);
+       update_rw_regs(host, 1, true, raw_cw);
        config_nand_page_read(chip);
 
        data_size1 = mtd->writesize - host->cw_size * (ecc->steps - 1);
@@ -1711,7 +1715,7 @@ qcom_nandc_read_cw_raw(struct mtd_info *mtd, struct nand_chip *chip,
                nandc_set_read_loc(chip, cw, 3, read_loc, oob_size2, 1);
        }
 
-       config_nand_cw_read(chip, false, cw);
+       config_nand_cw_read(chip, false, raw_cw);
 
        read_data_dma(nandc, reg_off, data_buf, data_size1, 0);
        reg_off += data_size1;
index 1542bfb8b5e54a595ef822a679d6725c8f7eb85e..7c2968a639eba552e552bb418fc3cbeabe8a9dea 100644 (file)
@@ -449,8 +449,10 @@ EXPORT_SYMBOL(ksz_switch_register);
 void ksz_switch_remove(struct ksz_device *dev)
 {
        /* timer started */
-       if (dev->mib_read_interval)
+       if (dev->mib_read_interval) {
+               dev->mib_read_interval = 0;
                cancel_delayed_work_sync(&dev->mib_read);
+       }
 
        dev->dev_ops->exit(dev);
        dsa_unregister_switch(dev->ds);
index 03744d1c43fc2f885384fcc4231b81123ad7c3b5..8dadcae93c9b53ef8ad4f3440ff9d12630c8a13e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/bitfield.h>
 #include <linux/delay.h>
+#include <linux/dsa/mv88e6xxx.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/if_bridge.h>
@@ -749,7 +750,11 @@ static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
        ops = chip->info->ops;
 
        mv88e6xxx_reg_lock(chip);
-       if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
+       /* Internal PHYs propagate their configuration directly to the MAC.
+        * External PHYs depend on whether the PPU is enabled for this port.
+        */
+       if (((!mv88e6xxx_phy_is_internal(ds, port) &&
+             !mv88e6xxx_port_ppu_updates(chip, port)) ||
             mode == MLO_AN_FIXED) && ops->port_sync_link)
                err = ops->port_sync_link(chip, port, mode, false);
        mv88e6xxx_reg_unlock(chip);
@@ -772,7 +777,12 @@ static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
        ops = chip->info->ops;
 
        mv88e6xxx_reg_lock(chip);
-       if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
+       /* Internal PHYs propagate their configuration directly to the MAC.
+        * External PHYs depend on whether the PPU is enabled for this port.
+        */
+       if ((!mv88e6xxx_phy_is_internal(ds, port) &&
+            !mv88e6xxx_port_ppu_updates(chip, port)) ||
+           mode == MLO_AN_FIXED) {
                /* FIXME: for an automedia port, should we force the link
                 * down here - what if the link comes up due to "other" media
                 * while we're bringing the port up, how is the exclusivity
@@ -1677,6 +1687,30 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
        return 0;
 }
 
+static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
+{
+       struct dsa_port *dp = dsa_to_port(chip->ds, port);
+       struct mv88e6xxx_port *p = &chip->ports[port];
+       u16 pvid = MV88E6XXX_VID_STANDALONE;
+       bool drop_untagged = false;
+       int err;
+
+       if (dp->bridge_dev) {
+               if (br_vlan_enabled(dp->bridge_dev)) {
+                       pvid = p->bridge_pvid.vid;
+                       drop_untagged = !p->bridge_pvid.valid;
+               } else {
+                       pvid = MV88E6XXX_VID_BRIDGED;
+               }
+       }
+
+       err = mv88e6xxx_port_set_pvid(chip, port, pvid);
+       if (err)
+               return err;
+
+       return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged);
+}
+
 static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
                                         bool vlan_filtering,
                                         struct netlink_ext_ack *extack)
@@ -1690,7 +1724,16 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
                return -EOPNOTSUPP;
 
        mv88e6xxx_reg_lock(chip);
+
        err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
+       if (err)
+               goto unlock;
+
+       err = mv88e6xxx_port_commit_pvid(chip, port);
+       if (err)
+               goto unlock;
+
+unlock:
        mv88e6xxx_reg_unlock(chip);
 
        return err;
@@ -1725,11 +1768,15 @@ static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
        u16 fid;
        int err;
 
-       /* Null VLAN ID corresponds to the port private database */
+       /* Ports have two private address databases: one for when the port is
+        * standalone and one for when the port is under a bridge and the
+        * 802.1Q mode is disabled. When the port is standalone, DSA wants its
+        * address database to remain 100% empty, so we never load an ATU entry
+        * into a standalone port's database. Therefore, translate the null
+        * VLAN ID into the port's database used for VLAN-unaware bridging.
+        */
        if (vid == 0) {
-               err = mv88e6xxx_port_get_fid(chip, port, &fid);
-               if (err)
-                       return err;
+               fid = MV88E6XXX_FID_BRIDGED;
        } else {
                err = mv88e6xxx_vtu_get(chip, vid, &vlan);
                if (err)
@@ -2123,6 +2170,7 @@ static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
        struct mv88e6xxx_chip *chip = ds->priv;
        bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
        bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
+       struct mv88e6xxx_port *p = &chip->ports[port];
        bool warn;
        u8 member;
        int err;
@@ -2156,13 +2204,21 @@ static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
        }
 
        if (pvid) {
-               err = mv88e6xxx_port_set_pvid(chip, port, vlan->vid);
-               if (err) {
-                       dev_err(ds->dev, "p%d: failed to set PVID %d\n",
-                               port, vlan->vid);
+               p->bridge_pvid.vid = vlan->vid;
+               p->bridge_pvid.valid = true;
+
+               err = mv88e6xxx_port_commit_pvid(chip, port);
+               if (err)
+                       goto out;
+       } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) {
+               /* The old pvid was reinstalled as a non-pvid VLAN */
+               p->bridge_pvid.valid = false;
+
+               err = mv88e6xxx_port_commit_pvid(chip, port);
+               if (err)
                        goto out;
-               }
        }
+
 out:
        mv88e6xxx_reg_unlock(chip);
 
@@ -2212,6 +2268,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
                                   const struct switchdev_obj_port_vlan *vlan)
 {
        struct mv88e6xxx_chip *chip = ds->priv;
+       struct mv88e6xxx_port *p = &chip->ports[port];
        int err = 0;
        u16 pvid;
 
@@ -2229,7 +2286,9 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
                goto unlock;
 
        if (vlan->vid == pvid) {
-               err = mv88e6xxx_port_set_pvid(chip, port, 0);
+               p->bridge_pvid.valid = false;
+
+               err = mv88e6xxx_port_commit_pvid(chip, port);
                if (err)
                        goto unlock;
        }
@@ -2393,7 +2452,16 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
        int err;
 
        mv88e6xxx_reg_lock(chip);
+
        err = mv88e6xxx_bridge_map(chip, br);
+       if (err)
+               goto unlock;
+
+       err = mv88e6xxx_port_commit_pvid(chip, port);
+       if (err)
+               goto unlock;
+
+unlock:
        mv88e6xxx_reg_unlock(chip);
 
        return err;
@@ -2403,11 +2471,20 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
                                        struct net_device *br)
 {
        struct mv88e6xxx_chip *chip = ds->priv;
+       int err;
 
        mv88e6xxx_reg_lock(chip);
+
        if (mv88e6xxx_bridge_map(chip, br) ||
            mv88e6xxx_port_vlan_map(chip, port))
                dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
+
+       err = mv88e6xxx_port_commit_pvid(chip, port);
+       if (err)
+               dev_err(ds->dev,
+                       "port %d failed to restore standalone pvid: %pe\n",
+                       port, ERR_PTR(err));
+
        mv88e6xxx_reg_unlock(chip);
 }
 
@@ -2853,6 +2930,20 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
        if (err)
                return err;
 
+       /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the
+        * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as
+        * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used
+        * as the private PVID on ports under a VLAN-unaware bridge.
+        * Shared (DSA and CPU) ports must also be members of it, to translate
+        * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of
+        * relying on their port default FID.
+        */
+       err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED,
+                                      MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED,
+                                      false);
+       if (err)
+               return err;
+
        if (chip->info->ops->port_set_jumbo_size) {
                err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
                if (err)
@@ -2925,7 +3016,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
         * database, and allow bidirectional communication between the
         * CPU and DSA port(s), and the other ports.
         */
-       err = mv88e6xxx_port_set_fid(chip, port, 0);
+       err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE);
        if (err)
                return err;
 
@@ -3115,6 +3206,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
                }
        }
 
+       err = mv88e6xxx_vtu_setup(chip);
+       if (err)
+               goto unlock;
+
        /* Setup Switch Port Registers */
        for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
                if (dsa_is_unused_port(ds, i))
@@ -3144,10 +3239,6 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
        if (err)
                goto unlock;
 
-       err = mv88e6xxx_vtu_setup(chip);
-       if (err)
-               goto unlock;
-
        err = mv88e6xxx_pvt_setup(chip);
        if (err)
                goto unlock;
index 59f316cc8583ea17a0b7b14c09cacef321bb2ce3..8271b8aa7b71eafad4fbcf16c7f550fa1a872e56 100644 (file)
@@ -21,6 +21,9 @@
 #define EDSA_HLEN              8
 #define MV88E6XXX_N_FID                4096
 
+#define MV88E6XXX_FID_STANDALONE       0
+#define MV88E6XXX_FID_BRIDGED          1
+
 /* PVT limits for 4-bit port and 5-bit switch */
 #define MV88E6XXX_MAX_PVT_SWITCHES     32
 #define MV88E6XXX_MAX_PVT_PORTS                16
@@ -246,9 +249,15 @@ struct mv88e6xxx_policy {
        u16 vid;
 };
 
+struct mv88e6xxx_vlan {
+       u16     vid;
+       bool    valid;
+};
+
 struct mv88e6xxx_port {
        struct mv88e6xxx_chip *chip;
        int port;
+       struct mv88e6xxx_vlan bridge_pvid;
        u64 serdes_stats[2];
        u64 atu_member_violation;
        u64 atu_miss_violation;
index 451028c57af8affc42716b8f1aed6cc3bce0c508..d9817b20ea641f9b642435e693b5ee7e86398a7e 100644 (file)
@@ -1257,6 +1257,27 @@ int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port,
        return 0;
 }
 
+int mv88e6xxx_port_drop_untagged(struct mv88e6xxx_chip *chip, int port,
+                                bool drop_untagged)
+{
+       u16 old, new;
+       int err;
+
+       err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, &old);
+       if (err)
+               return err;
+
+       if (drop_untagged)
+               new = old | MV88E6XXX_PORT_CTL2_DISCARD_UNTAGGED;
+       else
+               new = old & ~MV88E6XXX_PORT_CTL2_DISCARD_UNTAGGED;
+
+       if (new == old)
+               return 0;
+
+       return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL2, new);
+}
+
 int mv88e6xxx_port_set_map_da(struct mv88e6xxx_chip *chip, int port)
 {
        u16 reg;
index b10e5aebacf6805916ddf6f28136e069e1947946..03382b66f80037dbf731178b3f6e1ee6c122db2a 100644 (file)
@@ -423,6 +423,8 @@ int mv88e6393x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
                              phy_interface_t mode);
 int mv88e6185_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode);
 int mv88e6352_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode);
+int mv88e6xxx_port_drop_untagged(struct mv88e6xxx_chip *chip, int port,
+                                bool drop_untagged);
 int mv88e6xxx_port_set_map_da(struct mv88e6xxx_chip *chip, int port);
 int mv88e6095_port_set_upstream_port(struct mv88e6xxx_chip *chip, int port,
                                     int upstream_port);
index a3a9636430d6c0f1782c52e5561bac6ecdfe709c..341236dcbdb472b6d8a2fd19b9a8e3aebed625d8 100644 (file)
@@ -266,12 +266,12 @@ static void felix_8021q_cpu_port_deinit(struct ocelot *ocelot, int port)
  */
 static int felix_setup_mmio_filtering(struct felix *felix)
 {
-       unsigned long user_ports = 0, cpu_ports = 0;
+       unsigned long user_ports = dsa_user_ports(felix->ds);
        struct ocelot_vcap_filter *redirect_rule;
        struct ocelot_vcap_filter *tagging_rule;
        struct ocelot *ocelot = &felix->ocelot;
        struct dsa_switch *ds = felix->ds;
-       int port, ret;
+       int cpu = -1, port, ret;
 
        tagging_rule = kzalloc(sizeof(struct ocelot_vcap_filter), GFP_KERNEL);
        if (!tagging_rule)
@@ -284,12 +284,15 @@ static int felix_setup_mmio_filtering(struct felix *felix)
        }
 
        for (port = 0; port < ocelot->num_phys_ports; port++) {
-               if (dsa_is_user_port(ds, port))
-                       user_ports |= BIT(port);
-               if (dsa_is_cpu_port(ds, port))
-                       cpu_ports |= BIT(port);
+               if (dsa_is_cpu_port(ds, port)) {
+                       cpu = port;
+                       break;
+               }
        }
 
+       if (cpu < 0)
+               return -EINVAL;
+
        tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE;
        *(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588);
        *(__be16 *)tagging_rule->key.etype.etype.mask = htons(0xffff);
@@ -325,7 +328,7 @@ static int felix_setup_mmio_filtering(struct felix *felix)
                 * the CPU port module
                 */
                redirect_rule->action.mask_mode = OCELOT_MASK_MODE_REDIRECT;
-               redirect_rule->action.port_mask = cpu_ports;
+               redirect_rule->action.port_mask = BIT(cpu);
        } else {
                /* Trap PTP packets only to the CPU port module (which is
                 * redirected to the NPI port)
@@ -1074,6 +1077,101 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
        return 0;
 }
 
+static void ocelot_port_purge_txtstamp_skb(struct ocelot *ocelot, int port,
+                                          struct sk_buff *skb)
+{
+       struct ocelot_port *ocelot_port = ocelot->ports[port];
+       struct sk_buff *clone = OCELOT_SKB_CB(skb)->clone;
+       struct sk_buff *skb_match = NULL, *skb_tmp;
+       unsigned long flags;
+
+       if (!clone)
+               return;
+
+       spin_lock_irqsave(&ocelot_port->tx_skbs.lock, flags);
+
+       skb_queue_walk_safe(&ocelot_port->tx_skbs, skb, skb_tmp) {
+               if (skb != clone)
+                       continue;
+               __skb_unlink(skb, &ocelot_port->tx_skbs);
+               skb_match = skb;
+               break;
+       }
+
+       spin_unlock_irqrestore(&ocelot_port->tx_skbs.lock, flags);
+
+       WARN_ONCE(!skb_match,
+                 "Could not find skb clone in TX timestamping list\n");
+}
+
+#define work_to_xmit_work(w) \
+               container_of((w), struct felix_deferred_xmit_work, work)
+
+static void felix_port_deferred_xmit(struct kthread_work *work)
+{
+       struct felix_deferred_xmit_work *xmit_work = work_to_xmit_work(work);
+       struct dsa_switch *ds = xmit_work->dp->ds;
+       struct sk_buff *skb = xmit_work->skb;
+       u32 rew_op = ocelot_ptp_rew_op(skb);
+       struct ocelot *ocelot = ds->priv;
+       int port = xmit_work->dp->index;
+       int retries = 10;
+
+       do {
+               if (ocelot_can_inject(ocelot, 0))
+                       break;
+
+               cpu_relax();
+       } while (--retries);
+
+       if (!retries) {
+               dev_err(ocelot->dev, "port %d failed to inject skb\n",
+                       port);
+               ocelot_port_purge_txtstamp_skb(ocelot, port, skb);
+               kfree_skb(skb);
+               return;
+       }
+
+       ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb);
+
+       consume_skb(skb);
+       kfree(xmit_work);
+}
+
+static int felix_port_setup_tagger_data(struct dsa_switch *ds, int port)
+{
+       struct dsa_port *dp = dsa_to_port(ds, port);
+       struct ocelot *ocelot = ds->priv;
+       struct felix *felix = ocelot_to_felix(ocelot);
+       struct felix_port *felix_port;
+
+       if (!dsa_port_is_user(dp))
+               return 0;
+
+       felix_port = kzalloc(sizeof(*felix_port), GFP_KERNEL);
+       if (!felix_port)
+               return -ENOMEM;
+
+       felix_port->xmit_worker = felix->xmit_worker;
+       felix_port->xmit_work_fn = felix_port_deferred_xmit;
+
+       dp->priv = felix_port;
+
+       return 0;
+}
+
+static void felix_port_teardown_tagger_data(struct dsa_switch *ds, int port)
+{
+       struct dsa_port *dp = dsa_to_port(ds, port);
+       struct felix_port *felix_port = dp->priv;
+
+       if (!felix_port)
+               return;
+
+       dp->priv = NULL;
+       kfree(felix_port);
+}
+
 /* Hardware initialization done here so that we can allocate structures with
  * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing
  * us to allocate structures twice (leak memory) and map PCI memory twice
@@ -1102,6 +1200,12 @@ static int felix_setup(struct dsa_switch *ds)
                }
        }
 
+       felix->xmit_worker = kthread_create_worker(0, "felix_xmit");
+       if (IS_ERR(felix->xmit_worker)) {
+               err = PTR_ERR(felix->xmit_worker);
+               goto out_deinit_timestamp;
+       }
+
        for (port = 0; port < ds->num_ports; port++) {
                if (dsa_is_unused_port(ds, port))
                        continue;
@@ -1112,6 +1216,14 @@ static int felix_setup(struct dsa_switch *ds)
                 * bits of vlan tag.
                 */
                felix_port_qos_map_init(ocelot, port);
+
+               err = felix_port_setup_tagger_data(ds, port);
+               if (err) {
+                       dev_err(ds->dev,
+                               "port %d failed to set up tagger data: %pe\n",
+                               port, ERR_PTR(err));
+                       goto out_deinit_ports;
+               }
        }
 
        err = ocelot_devlink_sb_register(ocelot);
@@ -1126,6 +1238,7 @@ static int felix_setup(struct dsa_switch *ds)
                 * there's no real point in checking for errors.
                 */
                felix_set_tag_protocol(ds, port, felix->tag_proto);
+               break;
        }
 
        ds->mtu_enforcement_ingress = true;
@@ -1138,9 +1251,13 @@ out_deinit_ports:
                if (dsa_is_unused_port(ds, port))
                        continue;
 
+               felix_port_teardown_tagger_data(ds, port);
                ocelot_deinit_port(ocelot, port);
        }
 
+       kthread_destroy_worker(felix->xmit_worker);
+
+out_deinit_timestamp:
        ocelot_deinit_timestamp(ocelot);
        ocelot_deinit(ocelot);
 
@@ -1162,19 +1279,23 @@ static void felix_teardown(struct dsa_switch *ds)
                        continue;
 
                felix_del_tag_protocol(ds, port, felix->tag_proto);
+               break;
        }
 
-       ocelot_devlink_sb_unregister(ocelot);
-       ocelot_deinit_timestamp(ocelot);
-       ocelot_deinit(ocelot);
-
        for (port = 0; port < ocelot->num_phys_ports; port++) {
                if (dsa_is_unused_port(ds, port))
                        continue;
 
+               felix_port_teardown_tagger_data(ds, port);
                ocelot_deinit_port(ocelot, port);
        }
 
+       kthread_destroy_worker(felix->xmit_worker);
+
+       ocelot_devlink_sb_unregister(ocelot);
+       ocelot_deinit_timestamp(ocelot);
+       ocelot_deinit(ocelot);
+
        if (felix->info->mdio_bus_free)
                felix->info->mdio_bus_free(ocelot);
 }
@@ -1291,8 +1412,12 @@ static void felix_txtstamp(struct dsa_switch *ds, int port,
        if (!ocelot->ptp)
                return;
 
-       if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone))
+       if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) {
+               dev_err_ratelimited(ds->dev,
+                                   "port %d delivering skb without TX timestamp\n",
+                                   port);
                return;
+       }
 
        if (clone)
                OCELOT_SKB_CB(skb)->clone = clone;
index 54024b6f9498f4c3bf2551252ce63f5779bbf25e..be3e42e135c008213a51ec6d51f6277f5238fb39 100644 (file)
@@ -62,6 +62,7 @@ struct felix {
        resource_size_t                 switch_base;
        resource_size_t                 imdio_base;
        enum dsa_tag_protocol           tag_proto;
+       struct kthread_worker           *xmit_worker;
 };
 
 struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
index 7c0db80eff008fb9c2aa5ee1a2f5ff83fda3d966..924c3f129992f27c134ed95873404ec9ae8695ed 100644 (file)
@@ -3117,7 +3117,7 @@ static void sja1105_teardown(struct dsa_switch *ds)
        sja1105_static_config_free(&priv->static_config);
 }
 
-const struct dsa_switch_ops sja1105_switch_ops = {
+static const struct dsa_switch_ops sja1105_switch_ops = {
        .get_tag_protocol       = sja1105_get_tag_protocol,
        .setup                  = sja1105_setup,
        .teardown               = sja1105_teardown,
@@ -3166,7 +3166,6 @@ const struct dsa_switch_ops sja1105_switch_ops = {
        .port_bridge_tx_fwd_offload = dsa_tag_8021q_bridge_tx_fwd_offload,
        .port_bridge_tx_fwd_unoffload = dsa_tag_8021q_bridge_tx_fwd_unoffload,
 };
-EXPORT_SYMBOL_GPL(sja1105_switch_ops);
 
 static const struct of_device_id sja1105_dt_ids[];
 
index 691f6dd7e669738e3316b0909ba578dfed78bcd4..54396992a9199c39b1abcabced620e5c6b4e9c58 100644 (file)
@@ -64,6 +64,7 @@ enum sja1105_ptp_clk_mode {
 static int sja1105_change_rxtstamping(struct sja1105_private *priv,
                                      bool on)
 {
+       struct sja1105_tagger_data *tagger_data = &priv->tagger_data;
        struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
        struct sja1105_general_params_entry *general_params;
        struct sja1105_table *table;
@@ -79,7 +80,7 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv,
                priv->tagger_data.stampable_skb = NULL;
        }
        ptp_cancel_worker_sync(ptp_data->clock);
-       skb_queue_purge(&ptp_data->skb_txtstamp_queue);
+       skb_queue_purge(&tagger_data->skb_txtstamp_queue);
        skb_queue_purge(&ptp_data->skb_rxtstamp_queue);
 
        return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING);
@@ -452,40 +453,6 @@ bool sja1105_port_rxtstamp(struct dsa_switch *ds, int port,
        return priv->info->rxtstamp(ds, port, skb);
 }
 
-void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, u8 ts_id,
-                                enum sja1110_meta_tstamp dir, u64 tstamp)
-{
-       struct sja1105_private *priv = ds->priv;
-       struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
-       struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
-       struct skb_shared_hwtstamps shwt = {0};
-
-       /* We don't care about RX timestamps on the CPU port */
-       if (dir == SJA1110_META_TSTAMP_RX)
-               return;
-
-       spin_lock(&ptp_data->skb_txtstamp_queue.lock);
-
-       skb_queue_walk_safe(&ptp_data->skb_txtstamp_queue, skb, skb_tmp) {
-               if (SJA1105_SKB_CB(skb)->ts_id != ts_id)
-                       continue;
-
-               __skb_unlink(skb, &ptp_data->skb_txtstamp_queue);
-               skb_match = skb;
-
-               break;
-       }
-
-       spin_unlock(&ptp_data->skb_txtstamp_queue.lock);
-
-       if (WARN_ON(!skb_match))
-               return;
-
-       shwt.hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(tstamp));
-       skb_complete_tx_timestamp(skb_match, &shwt);
-}
-EXPORT_SYMBOL_GPL(sja1110_process_meta_tstamp);
-
 /* In addition to cloning the skb which is done by the common
  * sja1105_port_txtstamp, we need to generate a timestamp ID and save the
  * packet to the TX timestamping queue.
@@ -494,7 +461,6 @@ void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
 {
        struct sk_buff *clone = SJA1105_SKB_CB(skb)->clone;
        struct sja1105_private *priv = ds->priv;
-       struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
        struct sja1105_port *sp = &priv->ports[port];
        u8 ts_id;
 
@@ -510,7 +476,7 @@ void sja1110_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
 
        spin_unlock(&sp->data->meta_lock);
 
-       skb_queue_tail(&ptp_data->skb_txtstamp_queue, clone);
+       skb_queue_tail(&sp->data->skb_txtstamp_queue, clone);
 }
 
 /* Called from dsa_skb_tx_timestamp. This callback is just to clone
@@ -953,7 +919,7 @@ int sja1105_ptp_clock_register(struct dsa_switch *ds)
        /* Only used on SJA1105 */
        skb_queue_head_init(&ptp_data->skb_rxtstamp_queue);
        /* Only used on SJA1110 */
-       skb_queue_head_init(&ptp_data->skb_txtstamp_queue);
+       skb_queue_head_init(&tagger_data->skb_txtstamp_queue);
        spin_lock_init(&tagger_data->meta_lock);
 
        ptp_data->clock = ptp_clock_register(&ptp_data->caps, ds->dev);
@@ -971,6 +937,7 @@ int sja1105_ptp_clock_register(struct dsa_switch *ds)
 void sja1105_ptp_clock_unregister(struct dsa_switch *ds)
 {
        struct sja1105_private *priv = ds->priv;
+       struct sja1105_tagger_data *tagger_data = &priv->tagger_data;
        struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
 
        if (IS_ERR_OR_NULL(ptp_data->clock))
@@ -978,7 +945,7 @@ void sja1105_ptp_clock_unregister(struct dsa_switch *ds)
 
        del_timer_sync(&ptp_data->extts_timer);
        ptp_cancel_worker_sync(ptp_data->clock);
-       skb_queue_purge(&ptp_data->skb_txtstamp_queue);
+       skb_queue_purge(&tagger_data->skb_txtstamp_queue);
        skb_queue_purge(&ptp_data->skb_rxtstamp_queue);
        ptp_clock_unregister(ptp_data->clock);
        ptp_data->clock = NULL;
index 3c874bb4c17b7385b727c436c3482b4ea8529231..3ae6b9fdd492b5eaadc6e96b233ce8536fbddfb5 100644 (file)
@@ -8,21 +8,6 @@
 
 #if IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP)
 
-/* Timestamps are in units of 8 ns clock ticks (equivalent to
- * a fixed 125 MHz clock).
- */
-#define SJA1105_TICK_NS                        8
-
-static inline s64 ns_to_sja1105_ticks(s64 ns)
-{
-       return ns / SJA1105_TICK_NS;
-}
-
-static inline s64 sja1105_ticks_to_ns(s64 ticks)
-{
-       return ticks * SJA1105_TICK_NS;
-}
-
 /* Calculate the first base_time in the future that satisfies this
  * relationship:
  *
@@ -77,10 +62,6 @@ struct sja1105_ptp_data {
        struct timer_list extts_timer;
        /* Used only on SJA1105 to reconstruct partial timestamps */
        struct sk_buff_head skb_rxtstamp_queue;
-       /* Used on SJA1110 where meta frames are generated only for
-        * 2-step TX timestamps
-        */
-       struct sk_buff_head skb_txtstamp_queue;
        struct ptp_clock_info caps;
        struct ptp_clock *clock;
        struct sja1105_ptp_cmd cmd;
index d796684ec9ca00523b774881fbbcbb3d9f06263b..412ae3e43ffb71782fc810c9541ccec749aa053e 100644 (file)
@@ -100,6 +100,7 @@ config JME
 config KORINA
        tristate "Korina (IDT RC32434) Ethernet support"
        depends on MIKROTIK_RB532 || COMPILE_TEST
+       select CRC32
        select MII
        help
          If you have a Mikrotik RouterBoard 500 or IDT RC32434
index 37a41773dd4350d96fded737601db7afef3ee521..92a79c4ffa2c7bc3313cf90cc2c8b8c513be47a2 100644 (file)
@@ -21,6 +21,7 @@ config ARC_EMAC_CORE
        depends on ARC || ARCH_ROCKCHIP || COMPILE_TEST
        select MII
        select PHYLIB
+       select CRC32
 
 config ARC_EMAC
        tristate "ARC EMAC support"
index 05cc5870e4efb52b01ef1cf649b4bf318d8e498d..80380aed8882d5681411cd04648a38679877fbd0 100644 (file)
@@ -1313,22 +1313,21 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
 {
        u8 idx;
 
-       spin_lock(&tx->lock);
-
        for (idx = 0; idx < tx->len; idx++) {
                u8 phy_idx = idx + tx->quad_offset;
 
-               /* Clear any potential residual timestamp in the PHY block */
-               if (!pf->hw.reset_ongoing)
-                       ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx);
-
+               spin_lock(&tx->lock);
                if (tx->tstamps[idx].skb) {
                        dev_kfree_skb_any(tx->tstamps[idx].skb);
                        tx->tstamps[idx].skb = NULL;
                }
-       }
+               clear_bit(idx, tx->in_use);
+               spin_unlock(&tx->lock);
 
-       spin_unlock(&tx->lock);
+               /* Clear any potential residual timestamp in the PHY block */
+               if (!pf->hw.reset_ongoing)
+                       ice_clear_phy_tstamp(&pf->hw, tx->quad, phy_idx);
+       }
 }
 
 /**
index cf97985628ab91d4bf2940adb24cd70b18a34e1f..02e77ffe5c3e4f68e3828482f07c2f2a12fdee68 100644 (file)
@@ -155,6 +155,8 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq)
        u32 in[MLX5_ST_SZ_DW(destroy_cq_in)] = {};
        int err;
 
+       mlx5_debug_cq_remove(dev, cq);
+
        mlx5_eq_del_cq(mlx5_get_async_eq(dev), cq);
        mlx5_eq_del_cq(&cq->eq->core, cq);
 
@@ -162,16 +164,13 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq)
        MLX5_SET(destroy_cq_in, in, cqn, cq->cqn);
        MLX5_SET(destroy_cq_in, in, uid, cq->uid);
        err = mlx5_cmd_exec_in(dev, destroy_cq, in);
-       if (err)
-               return err;
 
        synchronize_irq(cq->irqn);
 
-       mlx5_debug_cq_remove(dev, cq);
        mlx5_cq_put(cq);
        wait_for_completion(&cq->free);
 
-       return 0;
+       return err;
 }
 EXPORT_SYMBOL(mlx5_core_destroy_cq);
 
index b5ddaa82755f170eae6c6a17d70861f9013f23b7..c6d2f8c78db71ab2342cbb368de174831724e102 100644 (file)
@@ -475,9 +475,6 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv)
                esw_warn(mdev, "Failed to allocate bridge offloads workqueue\n");
                goto err_alloc_wq;
        }
-       INIT_DELAYED_WORK(&br_offloads->update_work, mlx5_esw_bridge_update_work);
-       queue_delayed_work(br_offloads->wq, &br_offloads->update_work,
-                          msecs_to_jiffies(MLX5_ESW_BRIDGE_UPDATE_INTERVAL));
 
        br_offloads->nb.notifier_call = mlx5_esw_bridge_switchdev_event;
        err = register_switchdev_notifier(&br_offloads->nb);
@@ -500,6 +497,9 @@ void mlx5e_rep_bridge_init(struct mlx5e_priv *priv)
                         err);
                goto err_register_netdev;
        }
+       INIT_DELAYED_WORK(&br_offloads->update_work, mlx5_esw_bridge_update_work);
+       queue_delayed_work(br_offloads->wq, &br_offloads->update_work,
+                          msecs_to_jiffies(MLX5_ESW_BRIDGE_UPDATE_INTERVAL));
        return;
 
 err_register_netdev:
@@ -523,10 +523,10 @@ void mlx5e_rep_bridge_cleanup(struct mlx5e_priv *priv)
        if (!br_offloads)
                return;
 
+       cancel_delayed_work_sync(&br_offloads->update_work);
        unregister_netdevice_notifier(&br_offloads->netdev_nb);
        unregister_switchdev_blocking_notifier(&br_offloads->nb_blk);
        unregister_switchdev_notifier(&br_offloads->nb);
-       cancel_delayed_work(&br_offloads->update_work);
        destroy_workqueue(br_offloads->wq);
        rtnl_lock();
        mlx5_esw_bridge_cleanup(esw);
index 0c5197f9cea395acc3c2141e06a3e793facf5404..09c8b71b186c72c7d6200c5b93762320a0bf16e8 100644 (file)
@@ -2981,8 +2981,8 @@ static int mlx5e_mqprio_channel_validate(struct mlx5e_priv *priv,
                agg_count += mqprio->qopt.count[i];
        }
 
-       if (priv->channels.params.num_channels < agg_count) {
-               netdev_err(netdev, "Num of queues (%d) exceeds available (%d)\n",
+       if (priv->channels.params.num_channels != agg_count) {
+               netdev_err(netdev, "Num of queues (%d) does not match available (%d)\n",
                           agg_count, priv->channels.params.num_channels);
                return -EINVAL;
        }
@@ -3325,20 +3325,67 @@ static int set_feature_rx_all(struct net_device *netdev, bool enable)
        return mlx5_set_port_fcs(mdev, !enable);
 }
 
+static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable)
+{
+       u32 in[MLX5_ST_SZ_DW(pcmr_reg)] = {};
+       bool supported, curr_state;
+       int err;
+
+       if (!MLX5_CAP_GEN(mdev, ports_check))
+               return 0;
+
+       err = mlx5_query_ports_check(mdev, in, sizeof(in));
+       if (err)
+               return err;
+
+       supported = MLX5_GET(pcmr_reg, in, rx_ts_over_crc_cap);
+       curr_state = MLX5_GET(pcmr_reg, in, rx_ts_over_crc);
+
+       if (!supported || enable == curr_state)
+               return 0;
+
+       MLX5_SET(pcmr_reg, in, local_port, 1);
+       MLX5_SET(pcmr_reg, in, rx_ts_over_crc, enable);
+
+       return mlx5_set_ports_check(mdev, in, sizeof(in));
+}
+
 static int set_feature_rx_fcs(struct net_device *netdev, bool enable)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
+       struct mlx5e_channels *chs = &priv->channels;
+       struct mlx5_core_dev *mdev = priv->mdev;
        int err;
 
        mutex_lock(&priv->state_lock);
 
-       priv->channels.params.scatter_fcs_en = enable;
-       err = mlx5e_modify_channels_scatter_fcs(&priv->channels, enable);
-       if (err)
-               priv->channels.params.scatter_fcs_en = !enable;
+       if (enable) {
+               err = mlx5e_set_rx_port_ts(mdev, false);
+               if (err)
+                       goto out;
 
-       mutex_unlock(&priv->state_lock);
+               chs->params.scatter_fcs_en = true;
+               err = mlx5e_modify_channels_scatter_fcs(chs, true);
+               if (err) {
+                       chs->params.scatter_fcs_en = false;
+                       mlx5e_set_rx_port_ts(mdev, true);
+               }
+       } else {
+               chs->params.scatter_fcs_en = false;
+               err = mlx5e_modify_channels_scatter_fcs(chs, false);
+               if (err) {
+                       chs->params.scatter_fcs_en = true;
+                       goto out;
+               }
+               err = mlx5e_set_rx_port_ts(mdev, true);
+               if (err) {
+                       mlx5_core_warn(mdev, "Failed to set RX port timestamp %d\n", err);
+                       err = 0;
+               }
+       }
 
+out:
+       mutex_unlock(&priv->state_lock);
        return err;
 }
 
index 3dd1101cc69355efd5b12501414b0bcbd957e6f8..0684ac6699b2de8f832e6a7f29df1f31d94227f5 100644 (file)
@@ -618,6 +618,11 @@ static void mlx5e_build_rep_params(struct net_device *netdev)
        params->mqprio.num_tc       = 1;
        params->tunneled_offload_en = false;
 
+       /* Set an initial non-zero value, so that mlx5e_select_queue won't
+        * divide by zero if called before first activating channels.
+        */
+       priv->num_tc_x_num_ch = params->num_channels * params->mqprio.num_tc;
+
        mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
 }
 
@@ -643,7 +648,6 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev,
        netdev->hw_features    |= NETIF_F_RXCSUM;
 
        netdev->features |= netdev->hw_features;
-       netdev->features |= NETIF_F_VLAN_CHALLENGED;
        netdev->features |= NETIF_F_NETNS_LOCAL;
 }
 
index 0998dcc9cac04688bbefc092973543a7fb7493e5..b29824448aa858d078878af2ebb366c26611e3dc 100644 (file)
 #define MLXSW_THERMAL_ZONE_MAX_NAME    16
 #define MLXSW_THERMAL_TEMP_SCORE_MAX   GENMASK(31, 0)
 #define MLXSW_THERMAL_MAX_STATE        10
+#define MLXSW_THERMAL_MIN_STATE        2
 #define MLXSW_THERMAL_MAX_DUTY 255
-/* Minimum and maximum fan allowed speed in percent: from 20% to 100%. Values
- * MLXSW_THERMAL_MAX_STATE + x, where x is between 2 and 10 are used for
- * setting fan speed dynamic minimum. For example, if value is set to 14 (40%)
- * cooling levels vector will be set to 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10 to
- * introduce PWM speed in percent: 40, 40, 40, 40, 40, 50, 60. 70, 80, 90, 100.
- */
-#define MLXSW_THERMAL_SPEED_MIN                (MLXSW_THERMAL_MAX_STATE + 2)
-#define MLXSW_THERMAL_SPEED_MAX                (MLXSW_THERMAL_MAX_STATE * 2)
-#define MLXSW_THERMAL_SPEED_MIN_LEVEL  2               /* 20% */
 
 /* External cooling devices, allowed for binding to mlxsw thermal zones. */
 static char * const mlxsw_thermal_external_allowed_cdev[] = {
@@ -646,49 +638,16 @@ static int mlxsw_thermal_set_cur_state(struct thermal_cooling_device *cdev,
        struct mlxsw_thermal *thermal = cdev->devdata;
        struct device *dev = thermal->bus_info->dev;
        char mfsc_pl[MLXSW_REG_MFSC_LEN];
-       unsigned long cur_state, i;
        int idx;
-       u8 duty;
        int err;
 
+       if (state > MLXSW_THERMAL_MAX_STATE)
+               return -EINVAL;
+
        idx = mlxsw_get_cooling_device_idx(thermal, cdev);
        if (idx < 0)
                return idx;
 
-       /* Verify if this request is for changing allowed fan dynamical
-        * minimum. If it is - update cooling levels accordingly and update
-        * state, if current state is below the newly requested minimum state.
-        * For example, if current state is 5, and minimal state is to be
-        * changed from 4 to 6, thermal->cooling_levels[0 to 5] will be changed
-        * all from 4 to 6. And state 5 (thermal->cooling_levels[4]) should be
-        * overwritten.
-        */
-       if (state >= MLXSW_THERMAL_SPEED_MIN &&
-           state <= MLXSW_THERMAL_SPEED_MAX) {
-               state -= MLXSW_THERMAL_MAX_STATE;
-               for (i = 0; i <= MLXSW_THERMAL_MAX_STATE; i++)
-                       thermal->cooling_levels[i] = max(state, i);
-
-               mlxsw_reg_mfsc_pack(mfsc_pl, idx, 0);
-               err = mlxsw_reg_query(thermal->core, MLXSW_REG(mfsc), mfsc_pl);
-               if (err)
-                       return err;
-
-               duty = mlxsw_reg_mfsc_pwm_duty_cycle_get(mfsc_pl);
-               cur_state = mlxsw_duty_to_state(duty);
-
-               /* If current fan state is lower than requested dynamical
-                * minimum, increase fan speed up to dynamical minimum.
-                */
-               if (state < cur_state)
-                       return 0;
-
-               state = cur_state;
-       }
-
-       if (state > MLXSW_THERMAL_MAX_STATE)
-               return -EINVAL;
-
        /* Normalize the state to the valid speed range. */
        state = thermal->cooling_levels[state];
        mlxsw_reg_mfsc_pack(mfsc_pl, idx, mlxsw_state_to_duty(state));
@@ -998,8 +957,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
 
        /* Initialize cooling levels per PWM state. */
        for (i = 0; i < MLXSW_THERMAL_MAX_STATE; i++)
-               thermal->cooling_levels[i] = max(MLXSW_THERMAL_SPEED_MIN_LEVEL,
-                                                i);
+               thermal->cooling_levels[i] = max(MLXSW_THERMAL_MIN_STATE, i);
 
        thermal->polling_delay = bus_info->low_frequency ?
                                 MLXSW_THERMAL_SLOW_POLL_INT :
index 796e46a5392699c932d1d9b94c09bd5749ad6b18..81a8ccca7e5e075de4e1c4d5dfc21cab6874a686 100644 (file)
@@ -497,13 +497,19 @@ static struct regmap_bus phymap_encx24j600 = {
        .reg_read = regmap_encx24j600_phy_reg_read,
 };
 
-void devm_regmap_init_encx24j600(struct device *dev,
-                                struct encx24j600_context *ctx)
+int devm_regmap_init_encx24j600(struct device *dev,
+                               struct encx24j600_context *ctx)
 {
        mutex_init(&ctx->mutex);
        regcfg.lock_arg = ctx;
        ctx->regmap = devm_regmap_init(dev, &regmap_encx24j600, ctx, &regcfg);
+       if (IS_ERR(ctx->regmap))
+               return PTR_ERR(ctx->regmap);
        ctx->phymap = devm_regmap_init(dev, &phymap_encx24j600, ctx, &phycfg);
+       if (IS_ERR(ctx->phymap))
+               return PTR_ERR(ctx->phymap);
+
+       return 0;
 }
 EXPORT_SYMBOL_GPL(devm_regmap_init_encx24j600);
 
index ee921a99e439a23f42b27f34cca6a01a64b99957..0bc6b3176fbf0a5c4703c6a4b4b36e78f48be4b2 100644 (file)
@@ -1023,10 +1023,13 @@ static int encx24j600_spi_probe(struct spi_device *spi)
        priv->speed = SPEED_100;
 
        priv->ctx.spi = spi;
-       devm_regmap_init_encx24j600(&spi->dev, &priv->ctx);
        ndev->irq = spi->irq;
        ndev->netdev_ops = &encx24j600_netdev_ops;
 
+       ret = devm_regmap_init_encx24j600(&spi->dev, &priv->ctx);
+       if (ret)
+               goto out_free;
+
        mutex_init(&priv->lock);
 
        /* Reset device and check if it is connected */
index fac61a8fbd0205feef4e1ed3608b733fcad12722..34c5a289898c925c4cb477afb1d1a773796e2131 100644 (file)
@@ -15,8 +15,8 @@ struct encx24j600_context {
        int bank;
 };
 
-void devm_regmap_init_encx24j600(struct device *dev,
-                                struct encx24j600_context *ctx);
+int devm_regmap_init_encx24j600(struct device *dev,
+                               struct encx24j600_context *ctx);
 
 /* Single-byte instructions */
 #define BANK_SELECT(bank) (0xC0 | ((bank & (BANK_MASK >> BANK_SHIFT)) << 1))
index 1b21030308e57c6004c299eb6e76de5a822fd8d6..030ae89f3a337abb52568185b494c15945e309f5 100644 (file)
@@ -1477,8 +1477,10 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
        if (err)
                goto out;
 
-       if (cq->gdma_id >= gc->max_num_cqs)
+       if (WARN_ON(cq->gdma_id >= gc->max_num_cqs)) {
+               err = -EINVAL;
                goto out;
+       }
 
        gc->cq_table[cq->gdma_id] = cq->gdma_cq;
 
index 559177e6ded40754b138d0bc1e5fe425972a737c..a08e4f530c1c1186a55d8a1392a3786792c11396 100644 (file)
@@ -472,9 +472,9 @@ void ocelot_phylink_mac_link_down(struct ocelot *ocelot, int port,
            !(quirks & OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP))
                ocelot_port_rmwl(ocelot_port,
                                 DEV_CLOCK_CFG_MAC_TX_RST |
-                                DEV_CLOCK_CFG_MAC_TX_RST,
+                                DEV_CLOCK_CFG_MAC_RX_RST,
                                 DEV_CLOCK_CFG_MAC_TX_RST |
-                                DEV_CLOCK_CFG_MAC_TX_RST,
+                                DEV_CLOCK_CFG_MAC_RX_RST,
                                 DEV_CLOCK_CFG);
 }
 EXPORT_SYMBOL_GPL(ocelot_phylink_mac_link_down);
@@ -569,49 +569,44 @@ void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
 }
 EXPORT_SYMBOL_GPL(ocelot_phylink_mac_link_up);
 
-static void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
-                                        struct sk_buff *clone)
+static int ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port,
+                                       struct sk_buff *clone)
 {
        struct ocelot_port *ocelot_port = ocelot->ports[port];
+       unsigned long flags;
+
+       spin_lock_irqsave(&ocelot->ts_id_lock, flags);
 
-       spin_lock(&ocelot_port->ts_id_lock);
+       if (ocelot_port->ptp_skbs_in_flight == OCELOT_MAX_PTP_ID ||
+           ocelot->ptp_skbs_in_flight == OCELOT_PTP_FIFO_SIZE) {
+               spin_unlock_irqrestore(&ocelot->ts_id_lock, flags);
+               return -EBUSY;
+       }
 
        skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS;
        /* Store timestamp ID in OCELOT_SKB_CB(clone)->ts_id */
        OCELOT_SKB_CB(clone)->ts_id = ocelot_port->ts_id;
-       ocelot_port->ts_id = (ocelot_port->ts_id + 1) % 4;
-       skb_queue_tail(&ocelot_port->tx_skbs, clone);
 
-       spin_unlock(&ocelot_port->ts_id_lock);
-}
+       ocelot_port->ts_id++;
+       if (ocelot_port->ts_id == OCELOT_MAX_PTP_ID)
+               ocelot_port->ts_id = 0;
 
-u32 ocelot_ptp_rew_op(struct sk_buff *skb)
-{
-       struct sk_buff *clone = OCELOT_SKB_CB(skb)->clone;
-       u8 ptp_cmd = OCELOT_SKB_CB(skb)->ptp_cmd;
-       u32 rew_op = 0;
+       ocelot_port->ptp_skbs_in_flight++;
+       ocelot->ptp_skbs_in_flight++;
 
-       if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP && clone) {
-               rew_op = ptp_cmd;
-               rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3;
-       } else if (ptp_cmd == IFH_REW_OP_ORIGIN_PTP) {
-               rew_op = ptp_cmd;
-       }
+       skb_queue_tail(&ocelot_port->tx_skbs, clone);
 
-       return rew_op;
+       spin_unlock_irqrestore(&ocelot->ts_id_lock, flags);
+
+       return 0;
 }
-EXPORT_SYMBOL(ocelot_ptp_rew_op);
 
-static bool ocelot_ptp_is_onestep_sync(struct sk_buff *skb)
+static bool ocelot_ptp_is_onestep_sync(struct sk_buff *skb,
+                                      unsigned int ptp_class)
 {
        struct ptp_header *hdr;
-       unsigned int ptp_class;
        u8 msgtype, twostep;
 
-       ptp_class = ptp_classify_raw(skb);
-       if (ptp_class == PTP_CLASS_NONE)
-               return false;
-
        hdr = ptp_parse_header(skb, ptp_class);
        if (!hdr)
                return false;
@@ -631,10 +626,20 @@ int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
 {
        struct ocelot_port *ocelot_port = ocelot->ports[port];
        u8 ptp_cmd = ocelot_port->ptp_cmd;
+       unsigned int ptp_class;
+       int err;
+
+       /* Don't do anything if PTP timestamping not enabled */
+       if (!ptp_cmd)
+               return 0;
+
+       ptp_class = ptp_classify_raw(skb);
+       if (ptp_class == PTP_CLASS_NONE)
+               return -EINVAL;
 
        /* Store ptp_cmd in OCELOT_SKB_CB(skb)->ptp_cmd */
        if (ptp_cmd == IFH_REW_OP_ORIGIN_PTP) {
-               if (ocelot_ptp_is_onestep_sync(skb)) {
+               if (ocelot_ptp_is_onestep_sync(skb, ptp_class)) {
                        OCELOT_SKB_CB(skb)->ptp_cmd = ptp_cmd;
                        return 0;
                }
@@ -648,8 +653,12 @@ int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
                if (!(*clone))
                        return -ENOMEM;
 
-               ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
+               err = ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
+               if (err)
+                       return err;
+
                OCELOT_SKB_CB(skb)->ptp_cmd = ptp_cmd;
+               OCELOT_SKB_CB(*clone)->ptp_class = ptp_class;
        }
 
        return 0;
@@ -683,6 +692,17 @@ static void ocelot_get_hwtimestamp(struct ocelot *ocelot,
        spin_unlock_irqrestore(&ocelot->ptp_clock_lock, flags);
 }
 
+static bool ocelot_validate_ptp_skb(struct sk_buff *clone, u16 seqid)
+{
+       struct ptp_header *hdr;
+
+       hdr = ptp_parse_header(clone, OCELOT_SKB_CB(clone)->ptp_class);
+       if (WARN_ON(!hdr))
+               return false;
+
+       return seqid == ntohs(hdr->sequence_id);
+}
+
 void ocelot_get_txtstamp(struct ocelot *ocelot)
 {
        int budget = OCELOT_PTP_QUEUE_SZ;
@@ -690,10 +710,10 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
        while (budget--) {
                struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
                struct skb_shared_hwtstamps shhwtstamps;
+               u32 val, id, seqid, txport;
                struct ocelot_port *port;
                struct timespec64 ts;
                unsigned long flags;
-               u32 val, id, txport;
 
                val = ocelot_read(ocelot, SYS_PTP_STATUS);
 
@@ -706,10 +726,17 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
                /* Retrieve the ts ID and Tx port */
                id = SYS_PTP_STATUS_PTP_MESS_ID_X(val);
                txport = SYS_PTP_STATUS_PTP_MESS_TXPORT_X(val);
+               seqid = SYS_PTP_STATUS_PTP_MESS_SEQ_ID(val);
 
-               /* Retrieve its associated skb */
                port = ocelot->ports[txport];
 
+               spin_lock(&ocelot->ts_id_lock);
+               port->ptp_skbs_in_flight--;
+               ocelot->ptp_skbs_in_flight--;
+               spin_unlock(&ocelot->ts_id_lock);
+
+               /* Retrieve its associated skb */
+try_again:
                spin_lock_irqsave(&port->tx_skbs.lock, flags);
 
                skb_queue_walk_safe(&port->tx_skbs, skb, skb_tmp) {
@@ -722,12 +749,20 @@ void ocelot_get_txtstamp(struct ocelot *ocelot)
 
                spin_unlock_irqrestore(&port->tx_skbs.lock, flags);
 
+               if (WARN_ON(!skb_match))
+                       continue;
+
+               if (!ocelot_validate_ptp_skb(skb_match, seqid)) {
+                       dev_err_ratelimited(ocelot->dev,
+                                           "port %d received stale TX timestamp for seqid %d, discarding\n",
+                                           txport, seqid);
+                       dev_kfree_skb_any(skb);
+                       goto try_again;
+               }
+
                /* Get the h/w timestamp */
                ocelot_get_hwtimestamp(ocelot, &ts);
 
-               if (unlikely(!skb_match))
-                       continue;
-
                /* Set the timestamp into the skb */
                memset(&shhwtstamps, 0, sizeof(shhwtstamps));
                shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
@@ -1948,7 +1983,6 @@ void ocelot_init_port(struct ocelot *ocelot, int port)
        struct ocelot_port *ocelot_port = ocelot->ports[port];
 
        skb_queue_head_init(&ocelot_port->tx_skbs);
-       spin_lock_init(&ocelot_port->ts_id_lock);
 
        /* Basic L2 initialization */
 
@@ -2081,6 +2115,7 @@ int ocelot_init(struct ocelot *ocelot)
        mutex_init(&ocelot->stats_lock);
        mutex_init(&ocelot->ptp_lock);
        spin_lock_init(&ocelot->ptp_clock_lock);
+       spin_lock_init(&ocelot->ts_id_lock);
        snprintf(queue_name, sizeof(queue_name), "%s-stats",
                 dev_name(ocelot->dev));
        ocelot->stats_queue = create_singlethread_workqueue(queue_name);
index e54b9fb2a97a60f0653a5a1c425e58780913462f..2545727fd5b2f31288683a8648629f4fb7cb9e3f 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright 2020-2021 NXP
  */
 
+#include <linux/dsa/ocelot.h>
 #include <linux/if_bridge.h>
 #include <linux/of_net.h>
 #include <linux/phy/phy.h>
@@ -1625,7 +1626,7 @@ static int ocelot_port_phylink_create(struct ocelot *ocelot, int port,
        if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
                ocelot_port_rmwl(ocelot_port, 0,
                                 DEV_CLOCK_CFG_MAC_TX_RST |
-                                DEV_CLOCK_CFG_MAC_TX_RST,
+                                DEV_CLOCK_CFG_MAC_RX_RST,
                                 DEV_CLOCK_CFG);
 
        ocelot_port->phy_mode = phy_mode;
index 09c0e839cca5822a4a9ea88774da5abb69672f6d..3b6b2e61139e65df9a719b49768c9d3bb8e36ccb 100644 (file)
@@ -8566,7 +8566,7 @@ static void s2io_io_resume(struct pci_dev *pdev)
                        return;
                }
 
-               if (s2io_set_mac_addr(netdev, netdev->dev_addr) == FAILURE) {
+               if (do_s2io_prog_unicast(netdev, netdev->dev_addr) == FAILURE) {
                        s2io_card_down(sp);
                        pr_err("Can't restore mac addr after reset.\n");
                        return;
index c029950a81e202230ea8b8b4e427bf018643c258..ac1dcfa1d17908fae345db8555de8919fb40db14 100644 (file)
@@ -830,10 +830,6 @@ static int nfp_flower_init(struct nfp_app *app)
        if (err)
                goto err_cleanup;
 
-       err = flow_indr_dev_register(nfp_flower_indr_setup_tc_cb, app);
-       if (err)
-               goto err_cleanup;
-
        if (app_priv->flower_ext_feats & NFP_FL_FEATS_VF_RLIM)
                nfp_flower_qos_init(app);
 
@@ -942,7 +938,20 @@ static int nfp_flower_start(struct nfp_app *app)
                        return err;
        }
 
-       return nfp_tunnel_config_start(app);
+       err = flow_indr_dev_register(nfp_flower_indr_setup_tc_cb, app);
+       if (err)
+               return err;
+
+       err = nfp_tunnel_config_start(app);
+       if (err)
+               goto err_tunnel_config;
+
+       return 0;
+
+err_tunnel_config:
+       flow_indr_dev_unregister(nfp_flower_indr_setup_tc_cb, app,
+                                nfp_flower_setup_indr_tc_release);
+       return err;
 }
 
 static void nfp_flower_stop(struct nfp_app *app)
index ccf3ffcd3939ec975c6a879abf40f276f8674b0f..7f3322ce044c7c5d91cffd6e2002daf1a9c26e5b 100644 (file)
@@ -1379,6 +1379,10 @@ static int ionic_addr_add(struct net_device *netdev, const u8 *addr)
 
 static int ionic_addr_del(struct net_device *netdev, const u8 *addr)
 {
+       /* Don't delete our own address from the uc list */
+       if (ether_addr_equal(addr, netdev->dev_addr))
+               return 0;
+
        return ionic_lif_list_addr(netdev_priv(netdev), addr, DEL_ADDR);
 }
 
index 15ef59aa34ff56fbec1f31cbb21db3e44bd408a7..d10e1cd6d2ba96b1a75575f468c3a21ad1625d73 100644 (file)
@@ -1299,6 +1299,7 @@ static int qed_slowpath_start(struct qed_dev *cdev,
                        } else {
                                DP_NOTICE(cdev,
                                          "Failed to acquire PTT for aRFS\n");
+                               rc = -EINVAL;
                                goto err;
                        }
                }
index fbfda55b4c5263112070323a97f7baf39c516855..5e731a72cce81a4c2d50dbece319465588e3df70 100644 (file)
@@ -71,6 +71,7 @@ err_remove_config_dt:
 
 static const struct of_device_id dwmac_generic_match[] = {
        { .compatible = "st,spear600-gmac"},
+       { .compatible = "snps,dwmac-3.40a"},
        { .compatible = "snps,dwmac-3.50a"},
        { .compatible = "snps,dwmac-3.610"},
        { .compatible = "snps,dwmac-3.70a"},
index 90383abafa66acbba638c95e076b6a7fc7598b3e..f5581db0ba9bacb040d5328866ab2bc47b2029e0 100644 (file)
@@ -218,11 +218,18 @@ static void dwmac1000_dump_dma_regs(void __iomem *ioaddr, u32 *reg_space)
                                readl(ioaddr + DMA_BUS_MODE + i * 4);
 }
 
-static void dwmac1000_get_hw_feature(void __iomem *ioaddr,
-                                    struct dma_features *dma_cap)
+static int dwmac1000_get_hw_feature(void __iomem *ioaddr,
+                                   struct dma_features *dma_cap)
 {
        u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
 
+       if (!hw_cap) {
+               /* 0x00000000 is the value read on old hardware that does not
+                * implement this register
+                */
+               return -EOPNOTSUPP;
+       }
+
        dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
        dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
        dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
@@ -252,6 +259,8 @@ static void dwmac1000_get_hw_feature(void __iomem *ioaddr,
        dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
        /* Alternate (enhanced) DESC mode */
        dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
+
+       return 0;
 }
 
 static void dwmac1000_rx_watchdog(void __iomem *ioaddr, u32 riwt,
index 5be8e6a631d9b9ccdda9a25217ac6cc72efbea6a..d99fa028c6468ef988482c80dc5a941283e530f9 100644 (file)
@@ -347,8 +347,8 @@ static void dwmac4_dma_tx_chan_op_mode(void __iomem *ioaddr, int mode,
        writel(mtl_tx_op, ioaddr +  MTL_CHAN_TX_OP_MODE(channel));
 }
 
-static void dwmac4_get_hw_feature(void __iomem *ioaddr,
-                                 struct dma_features *dma_cap)
+static int dwmac4_get_hw_feature(void __iomem *ioaddr,
+                                struct dma_features *dma_cap)
 {
        u32 hw_cap = readl(ioaddr + GMAC_HW_FEATURE0);
 
@@ -437,6 +437,8 @@ static void dwmac4_get_hw_feature(void __iomem *ioaddr,
        dma_cap->frpbs = (hw_cap & GMAC_HW_FEAT_FRPBS) >> 11;
        dma_cap->frpsel = (hw_cap & GMAC_HW_FEAT_FRPSEL) >> 10;
        dma_cap->dvlan = (hw_cap & GMAC_HW_FEAT_DVLAN) >> 5;
+
+       return 0;
 }
 
 /* Enable/disable TSO feature and set MSS */
index 906e985441a93b17c11bb89bd8554ad4961fa917..5e98355f422b39e22110bded362de1939f85ce3f 100644 (file)
@@ -371,8 +371,8 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr,
        return ret;
 }
 
-static void dwxgmac2_get_hw_feature(void __iomem *ioaddr,
-                                   struct dma_features *dma_cap)
+static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
+                                  struct dma_features *dma_cap)
 {
        u32 hw_cap;
 
@@ -445,6 +445,8 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr,
        dma_cap->frpes = (hw_cap & XGMAC_HWFEAT_FRPES) >> 11;
        dma_cap->frpbs = (hw_cap & XGMAC_HWFEAT_FRPPB) >> 9;
        dma_cap->frpsel = (hw_cap & XGMAC_HWFEAT_FRPSEL) >> 3;
+
+       return 0;
 }
 
 static void dwxgmac2_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 queue)
index 6dc1c98ebec82aba543d80ee9489e62c5d724613..fe2660d5694d7994db088195c5126afd4a61a335 100644 (file)
@@ -203,8 +203,8 @@ struct stmmac_dma_ops {
        int (*dma_interrupt) (void __iomem *ioaddr,
                              struct stmmac_extra_stats *x, u32 chan, u32 dir);
        /* If supported then get the optional core features */
-       void (*get_hw_feature)(void __iomem *ioaddr,
-                              struct dma_features *dma_cap);
+       int (*get_hw_feature)(void __iomem *ioaddr,
+                             struct dma_features *dma_cap);
        /* Program the HW RX Watchdog */
        void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 queue);
        void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
@@ -255,7 +255,7 @@ struct stmmac_dma_ops {
 #define stmmac_dma_interrupt_status(__priv, __args...) \
        stmmac_do_callback(__priv, dma, dma_interrupt, __args)
 #define stmmac_get_hw_feature(__priv, __args...) \
-       stmmac_do_void_callback(__priv, dma, get_hw_feature, __args)
+       stmmac_do_callback(__priv, dma, get_hw_feature, __args)
 #define stmmac_rx_watchdog(__priv, __args...) \
        stmmac_do_void_callback(__priv, dma, rx_watchdog, __args)
 #define stmmac_set_tx_ring_len(__priv, __args...) \
index 62cec9bfcd33722d6b124695fcd327ca6d238248..232ac98943cd08a66a4bd65b53c2d100843d29f1 100644 (file)
@@ -508,6 +508,14 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
                plat->pmt = 1;
        }
 
+       if (of_device_is_compatible(np, "snps,dwmac-3.40a")) {
+               plat->has_gmac = 1;
+               plat->enh_desc = 1;
+               plat->tx_coe = 1;
+               plat->bugged_jumbo = 1;
+               plat->pmt = 1;
+       }
+
        if (of_device_is_compatible(np, "snps,dwmac-4.00") ||
            of_device_is_compatible(np, "snps,dwmac-4.10a") ||
            of_device_is_compatible(np, "snps,dwmac-4.20a") ||
index ba5ad86ec8261256af4523e6ddb1f00b98bc5cf1..4f9990b47a377de462454378ce3888f6274d1a79 100644 (file)
@@ -3125,6 +3125,9 @@ static void phy_shutdown(struct device *dev)
 {
        struct phy_device *phydev = to_phy_device(dev);
 
+       if (phydev->state == PHY_READY || !phydev->attached_dev)
+               return;
+
        phy_disable_interrupts(phydev);
 }
 
index 4c5d69732a7e125528fdc6f519d873f9c8181503..f87f175033731a38b87fe9183b023185519c6a9d 100644 (file)
@@ -99,6 +99,10 @@ config USB_RTL8150
 config USB_RTL8152
        tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters"
        select MII
+       select CRC32
+       select CRYPTO
+       select CRYPTO_HASH
+       select CRYPTO_SHA256
        help
          This option adds support for Realtek RTL8152 based USB 2.0
          10/100 Ethernet adapters and RTL8153 based USB 3.0 10/100/1000
index 79bd2585ec6b2d16d76280d189d775313ccfd530..4ad25a8b0870c67f40c2cc8a6a0f6eddaded09dd 100644 (file)
@@ -406,7 +406,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
         * add_recvbuf_mergeable() + get_mergeable_buf_len()
         */
        truesize = headroom ? PAGE_SIZE : truesize;
-       tailroom = truesize - len - headroom;
+       tailroom = truesize - len - headroom - (hdr_padded_len - hdr_len);
        buf = p - headroom;
 
        len -= hdr_len;
index 0099a00af361ba657e04bb00cf8d9091f4154e3a..4b4792940e8691062affc2dd4868745c55b41fb8 100644 (file)
@@ -535,6 +535,7 @@ static int msi_verify_entries(struct pci_dev *dev)
 static int msi_capability_init(struct pci_dev *dev, int nvec,
                               struct irq_affinity *affd)
 {
+       const struct attribute_group **groups;
        struct msi_desc *entry;
        int ret;
 
@@ -558,12 +559,14 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
        if (ret)
                goto err;
 
-       dev->msi_irq_groups = msi_populate_sysfs(&dev->dev);
-       if (IS_ERR(dev->msi_irq_groups)) {
-               ret = PTR_ERR(dev->msi_irq_groups);
+       groups = msi_populate_sysfs(&dev->dev);
+       if (IS_ERR(groups)) {
+               ret = PTR_ERR(groups);
                goto err;
        }
 
+       dev->msi_irq_groups = groups;
+
        /* Set MSI enabled bits */
        pci_intx_for_msi(dev, 0);
        pci_msi_set_enable(dev, 1);
@@ -691,6 +694,7 @@ static void msix_mask_all(void __iomem *base, int tsize)
 static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
                                int nvec, struct irq_affinity *affd)
 {
+       const struct attribute_group **groups;
        void __iomem *base;
        int ret, tsize;
        u16 control;
@@ -730,12 +734,14 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
 
        msix_update_entries(dev, entries);
 
-       dev->msi_irq_groups = msi_populate_sysfs(&dev->dev);
-       if (IS_ERR(dev->msi_irq_groups)) {
-               ret = PTR_ERR(dev->msi_irq_groups);
+       groups = msi_populate_sysfs(&dev->dev);
+       if (IS_ERR(groups)) {
+               ret = PTR_ERR(groups);
                goto out_free;
        }
 
+       dev->msi_irq_groups = groups;
+
        /* Set MSI-X enabled bits and unmask the function */
        pci_intx_for_msi(dev, 0);
        dev->msix_enabled = 1;
index 7646708d57e42bdc0ae57d2f0cdbf41bcc1a2fc2..a916cd89cbbeddf99272f26012a790d43ce08f7b 100644 (file)
@@ -98,7 +98,7 @@ mlxreg_io_get_reg(void *regmap, struct mlxreg_core_data *data, u32 in_val,
                        if (ret)
                                goto access_error;
 
-                       *regval |= rol32(val, regsize * i);
+                       *regval |= rol32(val, regsize * i * 8);
                }
        }
 
@@ -141,7 +141,7 @@ mlxreg_io_attr_store(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
 
        /* Convert buffer to input value. */
-       ret = kstrtou32(buf, len, &input_val);
+       ret = kstrtou32(buf, 0, &input_val);
        if (ret)
                return ret;
 
index d6a7c896ac8661c166368a7326c0e410dbc04f5d..fc95620101e85bf21b1201fb897c5098b3066ffd 100644 (file)
@@ -476,6 +476,7 @@ static const struct acpi_device_id amd_pmc_acpi_ids[] = {
        {"AMDI0006", 0},
        {"AMDI0007", 0},
        {"AMD0004", 0},
+       {"AMD0005", 0},
        { }
 };
 MODULE_DEVICE_TABLE(acpi, amd_pmc_acpi_ids);
index 42513eab1d064c7038d21b3105cdba67ae7d1a39..2fffa57e596e4191c68301e5244518bd2474b759 100644 (file)
@@ -167,6 +167,7 @@ config DELL_WMI
 config DELL_WMI_PRIVACY
        bool "Dell WMI Hardware Privacy Support"
        depends on LEDS_TRIGGER_AUDIO = y || DELL_WMI = LEDS_TRIGGER_AUDIO
+       depends on DELL_WMI
        help
          This option adds integration with the "Dell Hardware Privacy"
          feature of Dell laptops to the dell-wmi driver.
index d53634c8a6e09952bb70ddc0fdb99be5b71fcda5..658bab4b79648b7cdbcb9455c6053e2c322b0c8f 100644 (file)
@@ -141,6 +141,7 @@ static u8 gigabyte_wmi_detect_sensor_usability(struct wmi_device *wdev)
 
 static const struct dmi_system_id gigabyte_wmi_known_working_platforms[] = {
        DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B450M S2H V2"),
+       DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE AX V2"),
        DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE"),
        DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 AORUS ELITE V2"),
        DMI_EXACT_MATCH_GIGABYTE_BOARD_NAME("B550 GAMING X V2"),
index 379560fe5df96db2fad30d809e2d94db6730e75d..e03943e6380a6dfec2438c379d27674f0d69293b 100644 (file)
@@ -42,12 +42,20 @@ static void update_sar_data(struct wwan_sar_context *context)
 
        if (config->device_mode_info &&
            context->sar_data.device_mode < config->total_dev_mode) {
-               struct wwan_device_mode_info *dev_mode =
-                       &config->device_mode_info[context->sar_data.device_mode];
-
-               context->sar_data.antennatable_index = dev_mode->antennatable_index;
-               context->sar_data.bandtable_index = dev_mode->bandtable_index;
-               context->sar_data.sartable_index = dev_mode->sartable_index;
+               int itr = 0;
+
+               for (itr = 0; itr < config->total_dev_mode; itr++) {
+                       if (context->sar_data.device_mode ==
+                               config->device_mode_info[itr].device_mode) {
+                               struct wwan_device_mode_info *dev_mode =
+                               &config->device_mode_info[itr];
+
+                               context->sar_data.antennatable_index = dev_mode->antennatable_index;
+                               context->sar_data.bandtable_index = dev_mode->bandtable_index;
+                               context->sar_data.sartable_index = dev_mode->sartable_index;
+                               break;
+                       }
+               }
        }
 }
 
@@ -305,7 +313,6 @@ static struct platform_driver sar_driver = {
        .remove = sar_remove,
        .driver = {
                .name = DRVNAME,
-               .owner = THIS_MODULE,
                .acpi_match_table = ACPI_PTR(sar_device_ids)
        }
 };
@@ -313,4 +320,4 @@ module_platform_driver(sar_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Platform device driver for INTEL MODEM BIOS SAR");
-MODULE_AUTHOR("Shravan S <s.shravan@intel.com>");
+MODULE_AUTHOR("Shravan Sudhakar <s.shravan@intel.com>");
index 9fe0a2527e1cd2c5d449d7f2468c9c7b81177b61..e59d79c7e82f866f665bdcd6932f48a01ee7a878 100644 (file)
@@ -401,7 +401,7 @@ int skl_int3472_discrete_remove(struct platform_device *pdev)
 
        gpiod_remove_lookup_table(&int3472->gpios);
 
-       if (int3472->clock.ena_gpio)
+       if (int3472->clock.cl)
                skl_int3472_unregister_clock(int3472);
 
        gpiod_put(int3472->clock.ena_gpio);
index bfa0cc20750d3621996142917f62c6cf7dee48f2..7cc9089d1e14f4c16e332321ecf24327aaeb9268 100644 (file)
@@ -75,7 +75,7 @@ struct intel_scu_ipc_dev {
 #define IPC_READ_BUFFER                0x90
 
 /* Timeout in jiffies */
-#define IPC_TIMEOUT            (5 * HZ)
+#define IPC_TIMEOUT            (10 * HZ)
 
 static struct intel_scu_ipc_dev *ipcdev; /* Only one for now */
 static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */
@@ -232,7 +232,7 @@ static inline u32 ipc_data_readl(struct intel_scu_ipc_dev *scu, u32 offset)
 /* Wait till scu status is busy */
 static inline int busy_loop(struct intel_scu_ipc_dev *scu)
 {
-       unsigned long end = jiffies + msecs_to_jiffies(IPC_TIMEOUT);
+       unsigned long end = jiffies + IPC_TIMEOUT;
 
        do {
                u32 status;
@@ -247,7 +247,7 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu)
        return -ETIMEDOUT;
 }
 
-/* Wait till ipc ioc interrupt is received or timeout in 3 HZ */
+/* Wait till ipc ioc interrupt is received or timeout in 10 HZ */
 static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu)
 {
        int status;
index 788dcdf25f003019cd76757b6435e97a94a434ff..f872cf196c2f324d20a4e27e61c48575b401b3dc 100644 (file)
@@ -1301,7 +1301,7 @@ static int atmel_spi_one_transfer(struct spi_master *master,
         * DMA map early, for performance (empties dcache ASAP) and
         * better fault reporting.
         */
-       if ((!master->cur_msg_mapped)
+       if ((!master->cur_msg->is_dma_mapped)
                && as->use_pdc) {
                if (atmel_spi_dma_map_xfer(as, xfer) < 0)
                        return -ENOMEM;
@@ -1381,7 +1381,7 @@ static int atmel_spi_one_transfer(struct spi_master *master,
                }
        }
 
-       if (!master->cur_msg_mapped
+       if (!master->cur_msg->is_dma_mapped
                && as->use_pdc)
                atmel_spi_dma_unmap_xfer(master, xfer);
 
index a78e56f566dd8933169fa6615bc3d6cb61a33305..3043677ba22268bd0f95d178c05e5b0c7a3b530c 100644 (file)
@@ -1250,10 +1250,14 @@ static void bcm_qspi_hw_init(struct bcm_qspi *qspi)
 
 static void bcm_qspi_hw_uninit(struct bcm_qspi *qspi)
 {
+       u32 status = bcm_qspi_read(qspi, MSPI, MSPI_MSPI_STATUS);
+
        bcm_qspi_write(qspi, MSPI, MSPI_SPCR2, 0);
        if (has_bspi(qspi))
                bcm_qspi_write(qspi, MSPI, MSPI_WRITE_LOCK, 0);
 
+       /* clear interrupt */
+       bcm_qspi_write(qspi, MSPI, MSPI_MSPI_STATUS, status & ~1);
 }
 
 static const struct spi_controller_mem_ops bcm_qspi_mem_ops = {
@@ -1397,6 +1401,47 @@ int bcm_qspi_probe(struct platform_device *pdev,
        if (!qspi->dev_ids)
                return -ENOMEM;
 
+       /*
+        * Some SoCs integrate spi controller (e.g., its interrupt bits)
+        * in specific ways
+        */
+       if (soc_intc) {
+               qspi->soc_intc = soc_intc;
+               soc_intc->bcm_qspi_int_set(soc_intc, MSPI_DONE, true);
+       } else {
+               qspi->soc_intc = NULL;
+       }
+
+       if (qspi->clk) {
+               ret = clk_prepare_enable(qspi->clk);
+               if (ret) {
+                       dev_err(dev, "failed to prepare clock\n");
+                       goto qspi_probe_err;
+               }
+               qspi->base_clk = clk_get_rate(qspi->clk);
+       } else {
+               qspi->base_clk = MSPI_BASE_FREQ;
+       }
+
+       if (data->has_mspi_rev) {
+               rev = bcm_qspi_read(qspi, MSPI, MSPI_REV);
+               /* some older revs do not have a MSPI_REV register */
+               if ((rev & 0xff) == 0xff)
+                       rev = 0;
+       }
+
+       qspi->mspi_maj_rev = (rev >> 4) & 0xf;
+       qspi->mspi_min_rev = rev & 0xf;
+       qspi->mspi_spcr3_sysclk = data->has_spcr3_sysclk;
+
+       qspi->max_speed_hz = qspi->base_clk / (bcm_qspi_spbr_min(qspi) * 2);
+
+       /*
+        * On SW resets it is possible to have the mask still enabled
+        * Need to disable the mask and clear the status while we init
+        */
+       bcm_qspi_hw_uninit(qspi);
+
        for (val = 0; val < num_irqs; val++) {
                irq = -1;
                name = qspi_irq_tab[val].irq_name;
@@ -1433,38 +1478,6 @@ int bcm_qspi_probe(struct platform_device *pdev,
                goto qspi_probe_err;
        }
 
-       /*
-        * Some SoCs integrate spi controller (e.g., its interrupt bits)
-        * in specific ways
-        */
-       if (soc_intc) {
-               qspi->soc_intc = soc_intc;
-               soc_intc->bcm_qspi_int_set(soc_intc, MSPI_DONE, true);
-       } else {
-               qspi->soc_intc = NULL;
-       }
-
-       ret = clk_prepare_enable(qspi->clk);
-       if (ret) {
-               dev_err(dev, "failed to prepare clock\n");
-               goto qspi_probe_err;
-       }
-
-       qspi->base_clk = clk_get_rate(qspi->clk);
-
-       if (data->has_mspi_rev) {
-               rev = bcm_qspi_read(qspi, MSPI, MSPI_REV);
-               /* some older revs do not have a MSPI_REV register */
-               if ((rev & 0xff) == 0xff)
-                       rev = 0;
-       }
-
-       qspi->mspi_maj_rev = (rev >> 4) & 0xf;
-       qspi->mspi_min_rev = rev & 0xf;
-       qspi->mspi_spcr3_sysclk = data->has_spcr3_sysclk;
-
-       qspi->max_speed_hz = qspi->base_clk / (bcm_qspi_spbr_min(qspi) * 2);
-
        bcm_qspi_hw_init(qspi);
        init_completion(&qspi->mspi_done);
        init_completion(&qspi->bspi_done);
index 386e8c84be0af24c951526554b37e24cfbc4ae79..a15de10ee286a9e4f7760295fc2420fd8b51c68c 100644 (file)
@@ -233,36 +233,44 @@ static int mtk_spi_set_hw_cs_timing(struct spi_device *spi)
                return delay;
        inactive = (delay * DIV_ROUND_UP(mdata->spi_clk_hz, 1000000)) / 1000;
 
-       setup    = setup ? setup : 1;
-       hold     = hold ? hold : 1;
-       inactive = inactive ? inactive : 1;
-
-       reg_val = readl(mdata->base + SPI_CFG0_REG);
-       if (mdata->dev_comp->enhance_timing) {
-               hold = min_t(u32, hold, 0x10000);
-               setup = min_t(u32, setup, 0x10000);
-               reg_val &= ~(0xffff << SPI_ADJUST_CFG0_CS_HOLD_OFFSET);
-               reg_val |= (((hold - 1) & 0xffff)
-                          << SPI_ADJUST_CFG0_CS_HOLD_OFFSET);
-               reg_val &= ~(0xffff << SPI_ADJUST_CFG0_CS_SETUP_OFFSET);
-               reg_val |= (((setup - 1) & 0xffff)
-                          << SPI_ADJUST_CFG0_CS_SETUP_OFFSET);
-       } else {
-               hold = min_t(u32, hold, 0x100);
-               setup = min_t(u32, setup, 0x100);
-               reg_val &= ~(0xff << SPI_CFG0_CS_HOLD_OFFSET);
-               reg_val |= (((hold - 1) & 0xff) << SPI_CFG0_CS_HOLD_OFFSET);
-               reg_val &= ~(0xff << SPI_CFG0_CS_SETUP_OFFSET);
-               reg_val |= (((setup - 1) & 0xff)
-                           << SPI_CFG0_CS_SETUP_OFFSET);
+       if (hold || setup) {
+               reg_val = readl(mdata->base + SPI_CFG0_REG);
+               if (mdata->dev_comp->enhance_timing) {
+                       if (hold) {
+                               hold = min_t(u32, hold, 0x10000);
+                               reg_val &= ~(0xffff << SPI_ADJUST_CFG0_CS_HOLD_OFFSET);
+                               reg_val |= (((hold - 1) & 0xffff)
+                                       << SPI_ADJUST_CFG0_CS_HOLD_OFFSET);
+                       }
+                       if (setup) {
+                               setup = min_t(u32, setup, 0x10000);
+                               reg_val &= ~(0xffff << SPI_ADJUST_CFG0_CS_SETUP_OFFSET);
+                               reg_val |= (((setup - 1) & 0xffff)
+                                       << SPI_ADJUST_CFG0_CS_SETUP_OFFSET);
+                       }
+               } else {
+                       if (hold) {
+                               hold = min_t(u32, hold, 0x100);
+                               reg_val &= ~(0xff << SPI_CFG0_CS_HOLD_OFFSET);
+                               reg_val |= (((hold - 1) & 0xff) << SPI_CFG0_CS_HOLD_OFFSET);
+                       }
+                       if (setup) {
+                               setup = min_t(u32, setup, 0x100);
+                               reg_val &= ~(0xff << SPI_CFG0_CS_SETUP_OFFSET);
+                               reg_val |= (((setup - 1) & 0xff)
+                                       << SPI_CFG0_CS_SETUP_OFFSET);
+                       }
+               }
+               writel(reg_val, mdata->base + SPI_CFG0_REG);
        }
-       writel(reg_val, mdata->base + SPI_CFG0_REG);
 
-       inactive = min_t(u32, inactive, 0x100);
-       reg_val = readl(mdata->base + SPI_CFG1_REG);
-       reg_val &= ~SPI_CFG1_CS_IDLE_MASK;
-       reg_val |= (((inactive - 1) & 0xff) << SPI_CFG1_CS_IDLE_OFFSET);
-       writel(reg_val, mdata->base + SPI_CFG1_REG);
+       if (inactive) {
+               inactive = min_t(u32, inactive, 0x100);
+               reg_val = readl(mdata->base + SPI_CFG1_REG);
+               reg_val &= ~SPI_CFG1_CS_IDLE_MASK;
+               reg_val |= (((inactive - 1) & 0xff) << SPI_CFG1_CS_IDLE_OFFSET);
+               writel(reg_val, mdata->base + SPI_CFG1_REG);
+       }
 
        return 0;
 }
index 9708b7827ff7068ab484b4132675131247cc6232..f5d32ec4634e341d51b20446e041886b07dbb871 100644 (file)
@@ -137,6 +137,13 @@ static int spi_mux_probe(struct spi_device *spi)
        priv = spi_controller_get_devdata(ctlr);
        priv->spi = spi;
 
+       /*
+        * Increase lockdep class as these lock are taken while the parent bus
+        * already holds their instance's lock.
+        */
+       lockdep_set_subclass(&ctlr->io_mutex, 1);
+       lockdep_set_subclass(&ctlr->add_lock, 1);
+
        priv->mux = devm_mux_control_get(&spi->dev, NULL);
        if (IS_ERR(priv->mux)) {
                ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
index a66fa97046ee1d8f17f0d11ed5e3fb688e37a87b..2b0301fc971c6cb98d4140f2cca1d44955a695e8 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/acpi.h>
 #include <linux/bitops.h>
+#include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/completion.h>
 #include <linux/delay.h>
 #define NXP_FSPI_MIN_IOMAP     SZ_4M
 
 #define DCFG_RCWSR1            0x100
+#define SYS_PLL_RAT            GENMASK(6, 2)
 
 /* Access flash memory using IP bus only */
 #define FSPI_QUIRK_USE_IP_ONLY BIT(0)
@@ -926,9 +928,8 @@ static void erratum_err050568(struct nxp_fspi *f)
                { .family = "QorIQ LS1028A" },
                { /* sentinel */ }
        };
-       struct device_node *np;
        struct regmap *map;
-       u32 val = 0, sysclk = 0;
+       u32 val, sys_pll_ratio;
        int ret;
 
        /* Check for LS1028A family */
@@ -937,7 +938,6 @@ static void erratum_err050568(struct nxp_fspi *f)
                return;
        }
 
-       /* Compute system clock frequency multiplier ratio */
        map = syscon_regmap_lookup_by_compatible("fsl,ls1028a-dcfg");
        if (IS_ERR(map)) {
                dev_err(f->dev, "No syscon regmap\n");
@@ -948,23 +948,11 @@ static void erratum_err050568(struct nxp_fspi *f)
        if (ret < 0)
                goto err;
 
-       /* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */
-       val = (val >> 2) & 0x1F;
-       WARN(val == 0, "Strapping is zero: Cannot determine ratio");
+       sys_pll_ratio = FIELD_GET(SYS_PLL_RAT, val);
+       dev_dbg(f->dev, "val: 0x%08x, sys_pll_ratio: %d\n", val, sys_pll_ratio);
 
-       /* Compute system clock frequency */
-       np = of_find_node_by_name(NULL, "clock-sysclk");
-       if (!np)
-               goto err;
-
-       if (of_property_read_u32(np, "clock-frequency", &sysclk))
-               goto err;
-
-       sysclk = (sysclk * val) / 1000000; /* Convert sysclk to Mhz */
-       dev_dbg(f->dev, "val: 0x%08x, sysclk: %dMhz\n", val, sysclk);
-
-       /* Use IP bus only if PLL is 300MHz */
-       if (sysclk == 300)
+       /* Use IP bus only if platform clock is 300MHz */
+       if (sys_pll_ratio == 3)
                f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY;
 
        return;
index 8ce840c7ecc82c7be7bb88fd2d7198f7bee200cb..713292b0c71ea74889882375e7eff373dffb353b 100644 (file)
@@ -1182,8 +1182,7 @@ static int tegra_slink_resume(struct device *dev)
 }
 #endif
 
-#ifdef CONFIG_PM
-static int tegra_slink_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra_slink_runtime_suspend(struct device *dev)
 {
        struct spi_master *master = dev_get_drvdata(dev);
        struct tegra_slink_data *tspi = spi_master_get_devdata(master);
@@ -1208,7 +1207,6 @@ static int tegra_slink_runtime_resume(struct device *dev)
        }
        return 0;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops slink_pm_ops = {
        SET_RUNTIME_PM_OPS(tegra_slink_runtime_suspend,
index aea037c65985e950a580eb0004adf3bad8559248..926b68aa45d3ed2053bbc128a16d5935d8108be8 100644 (file)
@@ -478,12 +478,6 @@ static LIST_HEAD(spi_controller_list);
  */
 static DEFINE_MUTEX(board_lock);
 
-/*
- * Prevents addition of devices with same chip select and
- * addition of devices below an unregistering controller.
- */
-static DEFINE_MUTEX(spi_add_lock);
-
 /**
  * spi_alloc_device - Allocate a new SPI device
  * @ctlr: Controller to which device is connected
@@ -636,9 +630,9 @@ int spi_add_device(struct spi_device *spi)
         * chipselect **BEFORE** we call setup(), else we'll trash
         * its configuration.  Lock against concurrent add() calls.
         */
-       mutex_lock(&spi_add_lock);
+       mutex_lock(&ctlr->add_lock);
        status = __spi_add_device(spi);
-       mutex_unlock(&spi_add_lock);
+       mutex_unlock(&ctlr->add_lock);
        return status;
 }
 EXPORT_SYMBOL_GPL(spi_add_device);
@@ -658,7 +652,7 @@ static int spi_add_device_locked(struct spi_device *spi)
        /* Set the bus ID string */
        spi_dev_set_name(spi);
 
-       WARN_ON(!mutex_is_locked(&spi_add_lock));
+       WARN_ON(!mutex_is_locked(&ctlr->add_lock));
        return __spi_add_device(spi);
 }
 
@@ -2553,6 +2547,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
                return NULL;
 
        device_initialize(&ctlr->dev);
+       INIT_LIST_HEAD(&ctlr->queue);
+       spin_lock_init(&ctlr->queue_lock);
+       spin_lock_init(&ctlr->bus_lock_spinlock);
+       mutex_init(&ctlr->bus_lock_mutex);
+       mutex_init(&ctlr->io_mutex);
+       mutex_init(&ctlr->add_lock);
        ctlr->bus_num = -1;
        ctlr->num_chipselect = 1;
        ctlr->slave = slave;
@@ -2825,11 +2825,6 @@ int spi_register_controller(struct spi_controller *ctlr)
                        return id;
                ctlr->bus_num = id;
        }
-       INIT_LIST_HEAD(&ctlr->queue);
-       spin_lock_init(&ctlr->queue_lock);
-       spin_lock_init(&ctlr->bus_lock_spinlock);
-       mutex_init(&ctlr->bus_lock_mutex);
-       mutex_init(&ctlr->io_mutex);
        ctlr->bus_lock_flag = 0;
        init_completion(&ctlr->xfer_completion);
        if (!ctlr->max_dma_len)
@@ -2966,7 +2961,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
 
        /* Prevent addition of new devices, unregister existing ones */
        if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
-               mutex_lock(&spi_add_lock);
+               mutex_lock(&ctlr->add_lock);
 
        device_for_each_child(&ctlr->dev, NULL, __unregister);
 
@@ -2997,7 +2992,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        mutex_unlock(&board_lock);
 
        if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
-               mutex_unlock(&spi_add_lock);
+               mutex_unlock(&ctlr->add_lock);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_controller);
 
index 6dc29ce3b4bf8664e788fc73f195ad2b41029794..1bd73e322b7bbdcd2874d97668592791e639c4b4 100644 (file)
@@ -673,6 +673,19 @@ static const struct file_operations spidev_fops = {
 
 static struct class *spidev_class;
 
+static const struct spi_device_id spidev_spi_ids[] = {
+       { .name = "dh2228fv" },
+       { .name = "ltc2488" },
+       { .name = "sx1301" },
+       { .name = "bk4" },
+       { .name = "dhcom-board" },
+       { .name = "m53cpld" },
+       { .name = "spi-petra" },
+       { .name = "spi-authenta" },
+       {},
+};
+MODULE_DEVICE_TABLE(spi, spidev_spi_ids);
+
 #ifdef CONFIG_OF
 static const struct of_device_id spidev_dt_ids[] = {
        { .compatible = "rohm,dh2228fv" },
@@ -818,6 +831,7 @@ static struct spi_driver spidev_spi_driver = {
        },
        .probe =        spidev_probe,
        .remove =       spidev_remove,
+       .id_table =     spidev_spi_ids,
 
        /* NOTE:  suspend/resume methods are not necessary here.
         * We don't do anything except pass the requests to/from
index 5ce13b099d7dc8fb7f665ff869f0c3f7cf023359..5363ebebfc357f480515a019e769091f095b69bd 100644 (file)
@@ -585,6 +585,9 @@ static int optee_remove(struct platform_device *pdev)
 {
        struct optee *optee = platform_get_drvdata(pdev);
 
+       /* Unregister OP-TEE specific client devices on TEE bus */
+       optee_unregister_devices();
+
        /*
         * Ask OP-TEE to free all cached shared memory objects to decrease
         * reference counters and also avoid wild pointers in secure world
index ec1d24693ebaae10d89874fc67ead117e961daa8..128a2d2a50a16c540d42bdc5dc1c5fdb84bd328a 100644 (file)
@@ -53,6 +53,13 @@ static int get_devices(struct tee_context *ctx, u32 session,
        return 0;
 }
 
+static void optee_release_device(struct device *dev)
+{
+       struct tee_client_device *optee_device = to_tee_client_device(dev);
+
+       kfree(optee_device);
+}
+
 static int optee_register_device(const uuid_t *device_uuid)
 {
        struct tee_client_device *optee_device = NULL;
@@ -63,6 +70,7 @@ static int optee_register_device(const uuid_t *device_uuid)
                return -ENOMEM;
 
        optee_device->dev.bus = &tee_bus_type;
+       optee_device->dev.release = optee_release_device;
        if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
                kfree(optee_device);
                return -ENOMEM;
@@ -154,3 +162,17 @@ int optee_enumerate_devices(u32 func)
 {
        return  __optee_enumerate_devices(func);
 }
+
+static int __optee_unregister_device(struct device *dev, void *data)
+{
+       if (!strncmp(dev_name(dev), "optee-ta", strlen("optee-ta")))
+               device_unregister(dev);
+
+       return 0;
+}
+
+void optee_unregister_devices(void)
+{
+       bus_for_each_dev(&tee_bus_type, NULL, NULL,
+                        __optee_unregister_device);
+}
index dbdd367be1568330aa5481f9924932196282d5d4..f6bb4a763ba94e80f0463cc42957702ef47f1b93 100644 (file)
@@ -184,6 +184,7 @@ void optee_fill_pages_list(u64 *dst, struct page **pages, int num_pages,
 #define PTA_CMD_GET_DEVICES            0x0
 #define PTA_CMD_GET_DEVICES_SUPP       0x1
 int optee_enumerate_devices(u32 func);
+void optee_unregister_devices(void);
 
 /*
  * Small helpers
index da19d7987d0057a83e7137c2eebaf317316a1108..78fd365893c13f284a7de60b399edb0da0a40aec 100644 (file)
@@ -7,6 +7,7 @@ thunderbolt-objs += usb4_port.o nvm.o retimer.o quirks.o
 thunderbolt-${CONFIG_ACPI} += acpi.o
 thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
 thunderbolt-${CONFIG_USB4_KUNIT_TEST} += test.o
+CFLAGS_test.o += $(DISABLE_STRUCTLEAK_PLUGIN)
 
 thunderbolt_dma_test-${CONFIG_USB4_DMA_TEST} += dma_test.o
 obj-$(CONFIG_USB4_DMA_TEST) += thunderbolt_dma_test.o
index dff2c8a3e059f92379b50da3909f831eef20a51a..c0cebcf745cefdbe94ac83f3605acc380ef18a5c 100644 (file)
@@ -3030,7 +3030,7 @@ struct btrfs_dir_item *
 btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
                            struct btrfs_root *root,
                            struct btrfs_path *path, u64 dir,
-                           u64 objectid, const char *name, int name_len,
+                           u64 index, const char *name, int name_len,
                            int mod);
 struct btrfs_dir_item *
 btrfs_search_dir_index_item(struct btrfs_root *root,
index f1274d5c3805eb6a8871ad2c51980977132c5b1e..7721ce0c060483256d1d529449753d152b7ffe1d 100644 (file)
@@ -190,9 +190,20 @@ static struct btrfs_dir_item *btrfs_lookup_match_dir(
 }
 
 /*
- * lookup a directory item based on name.  'dir' is the objectid
- * we're searching in, and 'mod' tells us if you plan on deleting the
- * item (use mod < 0) or changing the options (use mod > 0)
+ * Lookup for a directory item by name.
+ *
+ * @trans:     The transaction handle to use. Can be NULL if @mod is 0.
+ * @root:      The root of the target tree.
+ * @path:      Path to use for the search.
+ * @dir:       The inode number (objectid) of the directory.
+ * @name:      The name associated to the directory entry we are looking for.
+ * @name_len:  The length of the name.
+ * @mod:       Used to indicate if the tree search is meant for a read only
+ *             lookup, for a modification lookup or for a deletion lookup, so
+ *             its value should be 0, 1 or -1, respectively.
+ *
+ * Returns: NULL if the dir item does not exists, an error pointer if an error
+ * happened, or a pointer to a dir item if a dir item exists for the given name.
  */
 struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
                                             struct btrfs_root *root,
@@ -273,27 +284,42 @@ out:
 }
 
 /*
- * lookup a directory item based on index.  'dir' is the objectid
- * we're searching in, and 'mod' tells us if you plan on deleting the
- * item (use mod < 0) or changing the options (use mod > 0)
+ * Lookup for a directory index item by name and index number.
  *
- * The name is used to make sure the index really points to the name you were
- * looking for.
+ * @trans:     The transaction handle to use. Can be NULL if @mod is 0.
+ * @root:      The root of the target tree.
+ * @path:      Path to use for the search.
+ * @dir:       The inode number (objectid) of the directory.
+ * @index:     The index number.
+ * @name:      The name associated to the directory entry we are looking for.
+ * @name_len:  The length of the name.
+ * @mod:       Used to indicate if the tree search is meant for a read only
+ *             lookup, for a modification lookup or for a deletion lookup, so
+ *             its value should be 0, 1 or -1, respectively.
+ *
+ * Returns: NULL if the dir index item does not exists, an error pointer if an
+ * error happened, or a pointer to a dir item if the dir index item exists and
+ * matches the criteria (name and index number).
  */
 struct btrfs_dir_item *
 btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
                            struct btrfs_root *root,
                            struct btrfs_path *path, u64 dir,
-                           u64 objectid, const char *name, int name_len,
+                           u64 index, const char *name, int name_len,
                            int mod)
 {
+       struct btrfs_dir_item *di;
        struct btrfs_key key;
 
        key.objectid = dir;
        key.type = BTRFS_DIR_INDEX_KEY;
-       key.offset = objectid;
+       key.offset = index;
 
-       return btrfs_lookup_match_dir(trans, root, path, &key, name, name_len, mod);
+       di = btrfs_lookup_match_dir(trans, root, path, &key, name, name_len, mod);
+       if (di == ERR_PTR(-ENOENT))
+               return NULL;
+
+       return di;
 }
 
 struct btrfs_dir_item *
index fc3da7585fb786be71f0308541a4d21b4b96305f..0ab456cb4bf801fc9f6f89623100ea182964b8f4 100644 (file)
@@ -4859,6 +4859,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
 out_free_delayed:
        btrfs_free_delayed_extent_op(extent_op);
 out_free_buf:
+       btrfs_tree_unlock(buf);
        free_extent_buffer(buf);
 out_free_reserved:
        btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 0);
index 7ff577005d0febbf6be14c21a2d1c81f3e600c50..a1762363f61faff8248c9fc4e7cda9503c775da5 100644 (file)
@@ -734,8 +734,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
        if (args->start >= inode->disk_i_size && !args->replace_extent)
                modify_tree = 0;
 
-       update_refs = (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
-                      root == fs_info->tree_root);
+       update_refs = (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID);
        while (1) {
                recow = 0;
                ret = btrfs_lookup_file_extent(trans, root, path, ino,
@@ -2704,14 +2703,16 @@ int btrfs_replace_file_extents(struct btrfs_inode *inode,
                                                 drop_args.bytes_found);
                if (ret != -ENOSPC) {
                        /*
-                        * When cloning we want to avoid transaction aborts when
-                        * nothing was done and we are attempting to clone parts
-                        * of inline extents, in such cases -EOPNOTSUPP is
-                        * returned by __btrfs_drop_extents() without having
-                        * changed anything in the file.
+                        * The only time we don't want to abort is if we are
+                        * attempting to clone a partial inline extent, in which
+                        * case we'll get EOPNOTSUPP.  However if we aren't
+                        * clone we need to abort no matter what, because if we
+                        * got EOPNOTSUPP via prealloc then we messed up and
+                        * need to abort.
                         */
-                       if (extent_info && !extent_info->is_new_extent &&
-                           ret && ret != -EOPNOTSUPP)
+                       if (ret &&
+                           (ret != -EOPNOTSUPP ||
+                            (extent_info && extent_info->is_new_extent)))
                                btrfs_abort_transaction(trans, ret);
                        break;
                }
index f7efc26aa82a114e13e1816e40f881e840790108..b415c5ec03ea0642c4053c07fe857a2540f10a09 100644 (file)
@@ -939,9 +939,11 @@ out:
 }
 
 /*
- * helper function to see if a given name and sequence number found
- * in an inode back reference are already in a directory and correctly
- * point to this inode
+ * See if a given name and sequence number found in an inode back reference are
+ * already in a directory and correctly point to this inode.
+ *
+ * Returns: < 0 on error, 0 if the directory entry does not exists and 1 if it
+ * exists.
  */
 static noinline int inode_in_dir(struct btrfs_root *root,
                                 struct btrfs_path *path,
@@ -950,29 +952,34 @@ static noinline int inode_in_dir(struct btrfs_root *root,
 {
        struct btrfs_dir_item *di;
        struct btrfs_key location;
-       int match = 0;
+       int ret = 0;
 
        di = btrfs_lookup_dir_index_item(NULL, root, path, dirid,
                                         index, name, name_len, 0);
-       if (di && !IS_ERR(di)) {
+       if (IS_ERR(di)) {
+               ret = PTR_ERR(di);
+               goto out;
+       } else if (di) {
                btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location);
                if (location.objectid != objectid)
                        goto out;
-       } else
+       } else {
                goto out;
-       btrfs_release_path(path);
+       }
 
+       btrfs_release_path(path);
        di = btrfs_lookup_dir_item(NULL, root, path, dirid, name, name_len, 0);
-       if (di && !IS_ERR(di)) {
-               btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location);
-               if (location.objectid != objectid)
-                       goto out;
-       } else
+       if (IS_ERR(di)) {
+               ret = PTR_ERR(di);
                goto out;
-       match = 1;
+       } else if (di) {
+               btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location);
+               if (location.objectid == objectid)
+                       ret = 1;
+       }
 out:
        btrfs_release_path(path);
-       return match;
+       return ret;
 }
 
 /*
@@ -1182,7 +1189,9 @@ next:
        /* look for a conflicting sequence number */
        di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir),
                                         ref_index, name, namelen, 0);
-       if (di && !IS_ERR(di)) {
+       if (IS_ERR(di)) {
+               return PTR_ERR(di);
+       } else if (di) {
                ret = drop_one_dir_item(trans, root, path, dir, di);
                if (ret)
                        return ret;
@@ -1192,7 +1201,9 @@ next:
        /* look for a conflicting name */
        di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir),
                                   name, namelen, 0);
-       if (di && !IS_ERR(di)) {
+       if (IS_ERR(di)) {
+               return PTR_ERR(di);
+       } else if (di) {
                ret = drop_one_dir_item(trans, root, path, dir, di);
                if (ret)
                        return ret;
@@ -1517,10 +1528,12 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
                if (ret)
                        goto out;
 
-               /* if we already have a perfect match, we're done */
-               if (!inode_in_dir(root, path, btrfs_ino(BTRFS_I(dir)),
-                                       btrfs_ino(BTRFS_I(inode)), ref_index,
-                                       name, namelen)) {
+               ret = inode_in_dir(root, path, btrfs_ino(BTRFS_I(dir)),
+                                  btrfs_ino(BTRFS_I(inode)), ref_index,
+                                  name, namelen);
+               if (ret < 0) {
+                       goto out;
+               } else if (ret == 0) {
                        /*
                         * look for a conflicting back reference in the
                         * metadata. if we find one we have to unlink that name
@@ -1580,6 +1593,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
                        if (ret)
                                goto out;
                }
+               /* Else, ret == 1, we already have a perfect match, we're done. */
 
                ref_ptr = (unsigned long)(ref_ptr + ref_struct_size) + namelen;
                kfree(name);
@@ -1936,8 +1950,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
        struct btrfs_key log_key;
        struct inode *dir;
        u8 log_type;
-       int exists;
-       int ret = 0;
+       bool exists;
+       int ret;
        bool update_size = (key->type == BTRFS_DIR_INDEX_KEY);
        bool name_added = false;
 
@@ -1957,12 +1971,12 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
                   name_len);
 
        btrfs_dir_item_key_to_cpu(eb, di, &log_key);
-       exists = btrfs_lookup_inode(trans, root, path, &log_key, 0);
-       if (exists == 0)
-               exists = 1;
-       else
-               exists = 0;
+       ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
        btrfs_release_path(path);
+       if (ret < 0)
+               goto out;
+       exists = (ret == 0);
+       ret = 0;
 
        if (key->type == BTRFS_DIR_ITEM_KEY) {
                dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
@@ -1977,7 +1991,11 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
                ret = -EINVAL;
                goto out;
        }
-       if (IS_ERR_OR_NULL(dst_di)) {
+
+       if (IS_ERR(dst_di)) {
+               ret = PTR_ERR(dst_di);
+               goto out;
+       } else if (!dst_di) {
                /* we need a sequence number to insert, so we only
                 * do inserts for the BTRFS_DIR_INDEX_KEY types
                 */
@@ -2281,7 +2299,7 @@ again:
                                                     dir_key->offset,
                                                     name, name_len, 0);
                }
-               if (!log_di || log_di == ERR_PTR(-ENOENT)) {
+               if (!log_di) {
                        btrfs_dir_item_key_to_cpu(eb, di, &location);
                        btrfs_release_path(path);
                        btrfs_release_path(log_path);
@@ -3540,8 +3558,7 @@ out_unlock:
        if (err == -ENOSPC) {
                btrfs_set_log_full_commit(trans);
                err = 0;
-       } else if (err < 0 && err != -ENOENT) {
-               /* ENOENT can be returned if the entry hasn't been fsynced yet */
+       } else if (err < 0) {
                btrfs_abort_transaction(trans, err);
        }
 
index 34c4cbf7e29bc49bdb3fa060fd2c235c3fb68536..e8c00dda42adbbff372908fdcb3d7d6814567cdf 100644 (file)
@@ -6,13 +6,9 @@
  * TODO: Merge attr_set_size/attr_data_get_block/attr_allocate_frame?
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/hash.h>
-#include <linux/nls.h>
-#include <linux/ratelimit.h>
 #include <linux/slab.h>
+#include <linux/kernel.h>
 
 #include "debug.h"
 #include "ntfs.h"
@@ -291,7 +287,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
                if (!rsize) {
                        /* Empty resident -> Non empty nonresident. */
                } else if (!is_data) {
-                       err = ntfs_sb_write_run(sbi, run, 0, data, rsize);
+                       err = ntfs_sb_write_run(sbi, run, 0, data, rsize, 0);
                        if (err)
                                goto out2;
                } else if (!page) {
@@ -451,11 +447,8 @@ again:
 again_1:
        align = sbi->cluster_size;
 
-       if (is_ext) {
+       if (is_ext)
                align <<= attr_b->nres.c_unit;
-               if (is_attr_sparsed(attr_b))
-                       keep_prealloc = false;
-       }
 
        old_valid = le64_to_cpu(attr_b->nres.valid_size);
        old_size = le64_to_cpu(attr_b->nres.data_size);
@@ -465,9 +458,6 @@ again_1:
        new_alloc = (new_size + align - 1) & ~(u64)(align - 1);
        new_alen = new_alloc >> cluster_bits;
 
-       if (keep_prealloc && is_ext)
-               keep_prealloc = false;
-
        if (keep_prealloc && new_size < old_size) {
                attr_b->nres.data_size = cpu_to_le64(new_size);
                mi_b->dirty = true;
@@ -529,7 +519,7 @@ add_alloc_in_same_attr_seg:
                } else if (pre_alloc == -1) {
                        pre_alloc = 0;
                        if (type == ATTR_DATA && !name_len &&
-                           sbi->options.prealloc) {
+                           sbi->options->prealloc) {
                                CLST new_alen2 = bytes_to_cluster(
                                        sbi, get_pre_allocated(new_size));
                                pre_alloc = new_alen2 - new_alen;
@@ -1966,7 +1956,7 @@ int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size)
                        return 0;
 
                from = vbo;
-               to = (vbo + bytes) < data_size ? (vbo + bytes) : data_size;
+               to = min_t(u64, vbo + bytes, data_size);
                memset(Add2Ptr(resident_data(attr_b), from), 0, to - from);
                return 0;
        }
index fa32399eb5171ce25f037fbd1bd8e483a37b839c..bad6d8a849a24b3a4a9fc2c4c372496d6ac1b54a 100644 (file)
@@ -5,10 +5,7 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
 
 #include "debug.h"
 #include "ntfs.h"
@@ -336,7 +333,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
 
        if (attr && attr->non_res) {
                err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-                                       al->size);
+                                       al->size, 0);
                if (err)
                        return err;
                al->dirty = false;
@@ -423,7 +420,7 @@ next:
        return true;
 }
 
-int al_update(struct ntfs_inode *ni)
+int al_update(struct ntfs_inode *ni, int sync)
 {
        int err;
        struct ATTRIB *attr;
@@ -445,7 +442,7 @@ int al_update(struct ntfs_inode *ni)
                memcpy(resident_data(attr), al->le, al->size);
        } else {
                err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-                                       al->size);
+                                       al->size, sync);
                if (err)
                        goto out;
 
index ce304d40b5e1642cc84d48143e2aa961ac3ea735..50d838093790a1f07474ea201510dde42d2431f3 100644 (file)
@@ -5,13 +5,8 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
-#include <linux/fs.h>
-#include <linux/nls.h>
+#include <linux/types.h>
 
-#include "debug.h"
-#include "ntfs.h"
 #include "ntfs_fs.h"
 
 #define BITS_IN_SIZE_T (sizeof(size_t) * 8)
@@ -124,8 +119,7 @@ bool are_bits_set(const ulong *lmap, size_t bit, size_t nbits)
 
        pos = nbits & 7;
        if (pos) {
-               u8 mask = fill_mask[pos];
-
+               mask = fill_mask[pos];
                if ((*map & mask) != mask)
                        return false;
        }
index 831501555009533d8b3eac04b6258e7072bd6304..aa184407520f0263844839e03d2f1edde3c6628f 100644 (file)
  *
  */
 
-#include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
+#include <linux/kernel.h>
 
-#include "debug.h"
 #include "ntfs.h"
 #include "ntfs_fs.h"
 
@@ -435,7 +433,7 @@ static void wnd_remove_free_ext(struct wnd_bitmap *wnd, size_t bit, size_t len)
                ;
        } else {
                n3 = rb_next(&e->count.node);
-               max_new_len = len > new_len ? len : new_len;
+               max_new_len = max(len, new_len);
                if (!n3) {
                        wnd->extent_max = max_new_len;
                } else {
@@ -731,7 +729,7 @@ int wnd_set_free(struct wnd_bitmap *wnd, size_t bit, size_t bits)
                        wbits = wnd->bits_last;
 
                tail = wbits - wbit;
-               op = tail < bits ? tail : bits;
+               op = min_t(u32, tail, bits);
 
                bh = wnd_map(wnd, iw);
                if (IS_ERR(bh)) {
@@ -784,7 +782,7 @@ int wnd_set_used(struct wnd_bitmap *wnd, size_t bit, size_t bits)
                        wbits = wnd->bits_last;
 
                tail = wbits - wbit;
-               op = tail < bits ? tail : bits;
+               op = min_t(u32, tail, bits);
 
                bh = wnd_map(wnd, iw);
                if (IS_ERR(bh)) {
@@ -834,7 +832,7 @@ static bool wnd_is_free_hlp(struct wnd_bitmap *wnd, size_t bit, size_t bits)
                        wbits = wnd->bits_last;
 
                tail = wbits - wbit;
-               op = tail < bits ? tail : bits;
+               op = min_t(u32, tail, bits);
 
                if (wbits != wnd->free_bits[iw]) {
                        bool ret;
@@ -926,7 +924,7 @@ use_wnd:
                        wbits = wnd->bits_last;
 
                tail = wbits - wbit;
-               op = tail < bits ? tail : bits;
+               op = min_t(u32, tail, bits);
 
                if (wnd->free_bits[iw]) {
                        bool ret;
index 31120569a87b9b07cf91f8e0b8c7291db059f4f3..53ef7489c75fd70f239d4e50af9a5e2f097c6bde 100644 (file)
@@ -11,6 +11,9 @@
 #ifndef _LINUX_NTFS3_DEBUG_H
 #define _LINUX_NTFS3_DEBUG_H
 
+struct super_block;
+struct inode;
+
 #ifndef Add2Ptr
 #define Add2Ptr(P, I)          ((void *)((u8 *)(P) + (I)))
 #define PtrOffset(B, O)                ((size_t)((size_t)(O) - (size_t)(B)))
index 93f6d485564e0103e56ad417f184f1ace0926eea..fb438d6040409838389ba7454645034ab2fa7a08 100644 (file)
@@ -7,10 +7,7 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/iversion.h>
 #include <linux/nls.h>
 
 #include "debug.h"
 #include "ntfs_fs.h"
 
 /* Convert little endian UTF-16 to NLS string. */
-int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
+int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
                      u8 *buf, int buf_len)
 {
-       int ret, uni_len, warn;
-       const __le16 *ip;
+       int ret, warn;
        u8 *op;
-       struct nls_table *nls = sbi->options.nls;
+       struct nls_table *nls = sbi->options->nls;
 
        static_assert(sizeof(wchar_t) == sizeof(__le16));
 
        if (!nls) {
                /* UTF-16 -> UTF-8 */
-               ret = utf16s_to_utf8s((wchar_t *)uni->name, uni->len,
-                                     UTF16_LITTLE_ENDIAN, buf, buf_len);
+               ret = utf16s_to_utf8s(name, len, UTF16_LITTLE_ENDIAN, buf,
+                                     buf_len);
                buf[ret] = '\0';
                return ret;
        }
 
-       ip = uni->name;
        op = buf;
-       uni_len = uni->len;
        warn = 0;
 
-       while (uni_len--) {
+       while (len--) {
                u16 ec;
                int charlen;
                char dump[5];
@@ -52,7 +46,7 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
                        break;
                }
 
-               ec = le16_to_cpu(*ip++);
+               ec = le16_to_cpu(*name++);
                charlen = nls->uni2char(ec, op, buf_len);
 
                if (charlen > 0) {
@@ -186,7 +180,7 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
 {
        int ret, slen;
        const u8 *end;
-       struct nls_table *nls = sbi->options.nls;
+       struct nls_table *nls = sbi->options->nls;
        u16 *uname = uni->name;
 
        static_assert(sizeof(wchar_t) == sizeof(u16));
@@ -301,14 +295,14 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni,
                return 0;
 
        /* Skip meta files. Unless option to show metafiles is set. */
-       if (!sbi->options.showmeta && ntfs_is_meta_file(sbi, ino))
+       if (!sbi->options->showmeta && ntfs_is_meta_file(sbi, ino))
                return 0;
 
-       if (sbi->options.nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
+       if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN))
                return 0;
 
-       name_len = ntfs_utf16_to_nls(sbi, (struct le_str *)&fname->name_len,
-                                    name, PATH_MAX);
+       name_len = ntfs_utf16_to_nls(sbi, fname->name, fname->name_len, name,
+                                    PATH_MAX);
        if (name_len <= 0) {
                ntfs_warn(sbi->sb, "failed to convert name for inode %lx.",
                          ino);
index 424450e77ad52ae550e8de444dc393411d97cde6..43b1451bff539576cd03c0f624708bf65b959270 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/compat.h>
 #include <linux/falloc.h>
 #include <linux/fiemap.h>
-#include <linux/nls.h>
 
 #include "debug.h"
 #include "ntfs.h"
@@ -588,8 +587,11 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
                truncate_pagecache(inode, vbo_down);
 
                if (!is_sparsed(ni) && !is_compressed(ni)) {
-                       /* Normal file. */
-                       err = ntfs_zero_range(inode, vbo, end);
+                       /*
+                        * Normal file, can't make hole.
+                        * TODO: Try to find way to save info about hole.
+                        */
+                       err = -EOPNOTSUPP;
                        goto out;
                }
 
@@ -737,7 +739,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
        umode_t mode = inode->i_mode;
        int err;
 
-       if (sbi->options.no_acs_rules) {
+       if (sbi->options->noacsrules) {
                /* "No access rules" - Force any changes of time etc. */
                attr->ia_valid |= ATTR_FORCE;
                /* and disable for editing some attributes. */
@@ -1185,7 +1187,7 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
        int err = 0;
 
        /* If we are last writer on the inode, drop the block reservation. */
-       if (sbi->options.prealloc && ((file->f_mode & FMODE_WRITE) &&
+       if (sbi->options->prealloc && ((file->f_mode & FMODE_WRITE) &&
                                      atomic_read(&inode->i_writecount) == 1)) {
                ni_lock(ni);
                down_write(&ni->file.run_lock);
index 938b12d56ca676308d2af82666a4f6f19cc8f122..6f47a9c17f896c62e355db7a6948075a88247378 100644 (file)
@@ -5,11 +5,8 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fiemap.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
 #include <linux/vmalloc.h>
 
 #include "debug.h"
@@ -708,18 +705,35 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
                        continue;
 
                mi = ni_find_mi(ni, ino_get(&le->ref));
+               if (!mi) {
+                       /* Should never happened, 'cause already checked. */
+                       goto bad;
+               }
 
                attr = mi_find_attr(mi, NULL, le->type, le_name(le),
                                    le->name_len, &le->id);
+               if (!attr) {
+                       /* Should never happened, 'cause already checked. */
+                       goto bad;
+               }
                asize = le32_to_cpu(attr->size);
 
                /* Insert into primary record. */
                attr_ins = mi_insert_attr(&ni->mi, le->type, le_name(le),
                                          le->name_len, asize,
                                          le16_to_cpu(attr->name_off));
-               id = attr_ins->id;
+               if (!attr_ins) {
+                       /*
+                        * Internal error.
+                        * Either no space in primary record (already checked).
+                        * Either tried to insert another
+                        * non indexed attribute (logic error).
+                        */
+                       goto bad;
+               }
 
                /* Copy all except id. */
+               id = attr_ins->id;
                memcpy(attr_ins, attr, asize);
                attr_ins->id = id;
 
@@ -735,6 +749,10 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
        ni->attr_list.dirty = false;
 
        return 0;
+bad:
+       ntfs_inode_err(&ni->vfs_inode, "Internal error");
+       make_bad_inode(&ni->vfs_inode);
+       return -EINVAL;
 }
 
 /*
@@ -956,6 +974,13 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
                        continue;
                }
 
+               /*
+                * Do not try to insert this attribute
+                * if there is no room in record.
+                */
+               if (le32_to_cpu(mi->mrec->used) + asize > sbi->record_size)
+                       continue;
+
                /* Try to insert attribute into this subrecord. */
                attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
                                       name_off, svcn, ins_le);
@@ -1451,7 +1476,7 @@ int ni_insert_resident(struct ntfs_inode *ni, u32 data_size,
                attr->res.flags = RESIDENT_FLAG_INDEXED;
 
                /* is_attr_indexed(attr)) == true */
-               le16_add_cpu(&ni->mi.mrec->hard_links, +1);
+               le16_add_cpu(&ni->mi.mrec->hard_links, 1);
                ni->mi.dirty = true;
        }
        attr->res.res = 0;
@@ -1606,7 +1631,7 @@ struct ATTR_FILE_NAME *ni_fname_type(struct ntfs_inode *ni, u8 name_type,
 
        *le = NULL;
 
-       if (FILE_NAME_POSIX == name_type)
+       if (name_type == FILE_NAME_POSIX)
                return NULL;
 
        /* Enumerate all names. */
@@ -1706,18 +1731,16 @@ out:
 /*
  * ni_parse_reparse
  *
- * Buffer is at least 24 bytes.
+ * buffer - memory for reparse buffer header
  */
 enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
-                                  void *buffer)
+                                  struct REPARSE_DATA_BUFFER *buffer)
 {
        const struct REPARSE_DATA_BUFFER *rp = NULL;
        u8 bits;
        u16 len;
        typeof(rp->CompressReparseBuffer) *cmpr;
 
-       static_assert(sizeof(struct REPARSE_DATA_BUFFER) <= 24);
-
        /* Try to estimate reparse point. */
        if (!attr->non_res) {
                rp = resident_data_ex(attr, sizeof(struct REPARSE_DATA_BUFFER));
@@ -1803,6 +1826,9 @@ enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
                return REPARSE_NONE;
        }
 
+       if (buffer != rp)
+               memcpy(buffer, rp, sizeof(struct REPARSE_DATA_BUFFER));
+
        /* Looks like normal symlink. */
        return REPARSE_LINK;
 }
@@ -2906,9 +2932,8 @@ bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
                memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de + 1, de_key_size);
                mi_get_ref(&ni->mi, &de->ref);
 
-               if (indx_insert_entry(&dir_ni->dir, dir_ni, de, sbi, NULL, 1)) {
+               if (indx_insert_entry(&dir_ni->dir, dir_ni, de, sbi, NULL, 1))
                        return false;
-               }
        }
 
        return true;
@@ -3077,7 +3102,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
                        const struct EA_INFO *info;
 
                        info = resident_data_ex(attr, sizeof(struct EA_INFO));
-                       dup->ea_size = info->size_pack;
+                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
+                       if (info)
+                               dup->ea_size = info->size_pack;
                }
        }
 
@@ -3205,7 +3232,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
                                        goto out;
                        }
 
-                       err = al_update(ni);
+                       err = al_update(ni, sync);
                        if (err)
                                goto out;
                }
index b5853aed0e25bc6d93b3f6f667ae36feda3d980b..06492f088d6020592bd4fdb8b1a6ecd22b823324 100644 (file)
@@ -6,12 +6,8 @@
  */
 
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/hash.h>
-#include <linux/nls.h>
 #include <linux/random.h>
-#include <linux/ratelimit.h>
 #include <linux/slab.h>
 
 #include "debug.h"
@@ -2219,7 +2215,7 @@ file_is_valid:
 
                        err = ntfs_sb_write_run(log->ni->mi.sbi,
                                                &log->ni->file.run, off, page,
-                                               log->page_size);
+                                               log->page_size, 0);
 
                        if (err)
                                goto out;
@@ -3710,7 +3706,7 @@ move_data:
 
        if (a_dirty) {
                attr = oa->attr;
-               err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes);
+               err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes, 0);
                if (err)
                        goto out;
        }
@@ -5152,10 +5148,10 @@ end_reply:
 
        ntfs_fix_pre_write(&rh->rhdr, log->page_size);
 
-       err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size);
+       err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size, 0);
        if (!err)
                err = ntfs_sb_write_run(sbi, &log->ni->file.run, log->page_size,
-                                       rh, log->page_size);
+                                       rh, log->page_size, 0);
 
        kfree(rh);
        if (err)
index 91e3743e1442f10cfc727eba0587a9ef0b20c039..4de9acb1696898057fe3a096984ab3c6c1119810 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
+#include <linux/kernel.h>
 
 #include "debug.h"
 #include "ntfs.h"
@@ -358,7 +358,7 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
                             enum ALLOCATE_OPT opt)
 {
        int err;
-       CLST alen = 0;
+       CLST alen;
        struct super_block *sb = sbi->sb;
        size_t alcn, zlen, zeroes, zlcn, zlen2, ztrim, new_zlen;
        struct wnd_bitmap *wnd = &sbi->used.bitmap;
@@ -370,27 +370,28 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
                if (!zlen) {
                        err = ntfs_refresh_zone(sbi);
                        if (err)
-                               goto out;
+                               goto up_write;
+
                        zlen = wnd_zone_len(wnd);
                }
 
                if (!zlen) {
                        ntfs_err(sbi->sb, "no free space to extend mft");
-                       goto out;
+                       err = -ENOSPC;
+                       goto up_write;
                }
 
                lcn = wnd_zone_bit(wnd);
-               alen = zlen > len ? len : zlen;
+               alen = min_t(CLST, len, zlen);
 
                wnd_zone_set(wnd, lcn + alen, zlen - alen);
 
                err = wnd_set_used(wnd, lcn, alen);
-               if (err) {
-                       up_write(&wnd->rw_lock);
-                       return err;
-               }
+               if (err)
+                       goto up_write;
+
                alcn = lcn;
-               goto out;
+               goto space_found;
        }
        /*
         * 'Cause cluster 0 is always used this value means that we should use
@@ -404,49 +405,45 @@ int ntfs_look_for_free_space(struct ntfs_sb_info *sbi, CLST lcn, CLST len,
 
        alen = wnd_find(wnd, len, lcn, BITMAP_FIND_MARK_AS_USED, &alcn);
        if (alen)
-               goto out;
+               goto space_found;
 
        /* Try to use clusters from MftZone. */
        zlen = wnd_zone_len(wnd);
        zeroes = wnd_zeroes(wnd);
 
        /* Check too big request */
-       if (len > zeroes + zlen || zlen <= NTFS_MIN_MFT_ZONE)
-               goto out;
+       if (len > zeroes + zlen || zlen <= NTFS_MIN_MFT_ZONE) {
+               err = -ENOSPC;
+               goto up_write;
+       }
 
        /* How many clusters to cat from zone. */
        zlcn = wnd_zone_bit(wnd);
        zlen2 = zlen >> 1;
-       ztrim = len > zlen ? zlen : (len > zlen2 ? len : zlen2);
-       new_zlen = zlen - ztrim;
-
-       if (new_zlen < NTFS_MIN_MFT_ZONE) {
-               new_zlen = NTFS_MIN_MFT_ZONE;
-               if (new_zlen > zlen)
-                       new_zlen = zlen;
-       }
+       ztrim = clamp_val(len, zlen2, zlen);
+       new_zlen = max_t(size_t, zlen - ztrim, NTFS_MIN_MFT_ZONE);
 
        wnd_zone_set(wnd, zlcn, new_zlen);
 
        /* Allocate continues clusters. */
        alen = wnd_find(wnd, len, 0,
                        BITMAP_FIND_MARK_AS_USED | BITMAP_FIND_FULL, &alcn);
-
-out:
-       if (alen) {
-               err = 0;
-               *new_len = alen;
-               *new_lcn = alcn;
-
-               ntfs_unmap_meta(sb, alcn, alen);
-
-               /* Set hint for next requests. */
-               if (!(opt & ALLOCATE_MFT))
-                       sbi->used.next_free_lcn = alcn + alen;
-       } else {
+       if (!alen) {
                err = -ENOSPC;
+               goto up_write;
        }
 
+space_found:
+       err = 0;
+       *new_len = alen;
+       *new_lcn = alcn;
+
+       ntfs_unmap_meta(sb, alcn, alen);
+
+       /* Set hint for next requests. */
+       if (!(opt & ALLOCATE_MFT))
+               sbi->used.next_free_lcn = alcn + alen;
+up_write:
        up_write(&wnd->rw_lock);
        return err;
 }
@@ -1080,7 +1077,7 @@ int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 }
 
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-                     u64 vbo, const void *buf, size_t bytes)
+                     u64 vbo, const void *buf, size_t bytes, int sync)
 {
        struct super_block *sb = sbi->sb;
        u8 cluster_bits = sbi->cluster_bits;
@@ -1099,8 +1096,8 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
        len = ((u64)clen << cluster_bits) - off;
 
        for (;;) {
-               u32 op = len < bytes ? len : bytes;
-               int err = ntfs_sb_write(sb, lbo, op, buf, 0);
+               u32 op = min_t(u64, len, bytes);
+               int err = ntfs_sb_write(sb, lbo, op, buf, sync);
 
                if (err)
                        return err;
@@ -1300,7 +1297,7 @@ int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo,
        nb->off = off = lbo & (blocksize - 1);
 
        for (;;) {
-               u32 len32 = len < bytes ? len : bytes;
+               u32 len32 = min_t(u64, len, bytes);
                sector_t block = lbo >> sb->s_blocksize_bits;
 
                do {
@@ -2175,7 +2172,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
        /* Write main SDS bucket. */
        err = ntfs_sb_write_run(sbi, &ni->file.run, sbi->security.next_off,
-                               d_security, aligned_sec_size);
+                               d_security, aligned_sec_size, 0);
 
        if (err)
                goto out;
@@ -2193,7 +2190,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
        /* Write copy SDS bucket. */
        err = ntfs_sb_write_run(sbi, &ni->file.run, mirr_off, d_security,
-                               aligned_sec_size);
+                               aligned_sec_size, 0);
        if (err)
                goto out;
 
index 0daca9adc54c79084743efc2487b49a0ac0d3227..6f81e3a49abfb30f7aa570e26cf595b3e8599032 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
+#include <linux/kernel.h>
 
 #include "debug.h"
 #include "ntfs.h"
@@ -671,138 +671,74 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
                                  const struct INDEX_HDR *hdr, const void *key,
                                  size_t key_len, const void *ctx, int *diff)
 {
-       struct NTFS_DE *e;
+       struct NTFS_DE *e, *found = NULL;
        NTFS_CMP_FUNC cmp = indx->cmp;
+       int min_idx = 0, mid_idx, max_idx = 0;
+       int diff2;
+       int table_size = 8;
        u32 e_size, e_key_len;
        u32 end = le32_to_cpu(hdr->used);
        u32 off = le32_to_cpu(hdr->de_off);
+       u16 offs[128];
 
-#ifdef NTFS3_INDEX_BINARY_SEARCH
-       int max_idx = 0, fnd, min_idx;
-       int nslots = 64;
-       u16 *offs;
-
-       if (end > 0x10000)
-               goto next;
-
-       offs = kmalloc(sizeof(u16) * nslots, GFP_NOFS);
-       if (!offs)
-               goto next;
+fill_table:
+       if (off + sizeof(struct NTFS_DE) > end)
+               return NULL;
 
-       /* Use binary search algorithm. */
-next1:
-       if (off + sizeof(struct NTFS_DE) > end) {
-               e = NULL;
-               goto out1;
-       }
        e = Add2Ptr(hdr, off);
        e_size = le16_to_cpu(e->size);
 
-       if (e_size < sizeof(struct NTFS_DE) || off + e_size > end) {
-               e = NULL;
-               goto out1;
-       }
-
-       if (max_idx >= nslots) {
-               u16 *ptr;
-               int new_slots = ALIGN(2 * nslots, 8);
-
-               ptr = kmalloc(sizeof(u16) * new_slots, GFP_NOFS);
-               if (ptr)
-                       memcpy(ptr, offs, sizeof(u16) * max_idx);
-               kfree(offs);
-               offs = ptr;
-               nslots = new_slots;
-               if (!ptr)
-                       goto next;
-       }
-
-       /* Store entry table. */
-       offs[max_idx] = off;
+       if (e_size < sizeof(struct NTFS_DE) || off + e_size > end)
+               return NULL;
 
        if (!de_is_last(e)) {
+               offs[max_idx] = off;
                off += e_size;
-               max_idx += 1;
-               goto next1;
-       }
 
-       /*
-        * Table of pointers is created.
-        * Use binary search to find entry that is <= to the search value.
-        */
-       fnd = -1;
-       min_idx = 0;
+               max_idx++;
+               if (max_idx < table_size)
+                       goto fill_table;
 
-       while (min_idx <= max_idx) {
-               int mid_idx = min_idx + ((max_idx - min_idx) >> 1);
-               int diff2;
-
-               e = Add2Ptr(hdr, offs[mid_idx]);
+               max_idx--;
+       }
 
-               e_key_len = le16_to_cpu(e->key_size);
+binary_search:
+       e_key_len = le16_to_cpu(e->key_size);
 
-               diff2 = (*cmp)(key, key_len, e + 1, e_key_len, ctx);
+       diff2 = (*cmp)(key, key_len, e + 1, e_key_len, ctx);
+       if (diff2 > 0) {
+               if (found) {
+                       min_idx = mid_idx + 1;
+               } else {
+                       if (de_is_last(e))
+                               return NULL;
 
-               if (!diff2) {
-                       *diff = 0;
-                       goto out1;
+                       max_idx = 0;
+                       table_size = min(table_size * 2,
+                                        (int)ARRAY_SIZE(offs));
+                       goto fill_table;
                }
-
-               if (diff2 < 0) {
+       } else if (diff2 < 0) {
+               if (found)
                        max_idx = mid_idx - 1;
-                       fnd = mid_idx;
-                       if (!fnd)
-                               break;
-               } else {
-                       min_idx = mid_idx + 1;
-               }
-       }
+               else
+                       max_idx--;
 
-       if (fnd == -1) {
-               e = NULL;
-               goto out1;
+               found = e;
+       } else {
+               *diff = 0;
+               return e;
        }
 
-       *diff = -1;
-       e = Add2Ptr(hdr, offs[fnd]);
-
-out1:
-       kfree(offs);
-
-       return e;
-#endif
-
-next:
-       /*
-        * Entries index are sorted.
-        * Enumerate all entries until we find entry
-        * that is <= to the search value.
-        */
-       if (off + sizeof(struct NTFS_DE) > end)
-               return NULL;
-
-       e = Add2Ptr(hdr, off);
-       e_size = le16_to_cpu(e->size);
-
-       if (e_size < sizeof(struct NTFS_DE) || off + e_size > end)
-               return NULL;
-
-       off += e_size;
-
-       e_key_len = le16_to_cpu(e->key_size);
-
-       *diff = (*cmp)(key, key_len, e + 1, e_key_len, ctx);
-       if (!*diff)
-               return e;
+       if (min_idx > max_idx) {
+               *diff = -1;
+               return found;
+       }
 
-       if (*diff <= 0)
-               return e;
+       mid_idx = (min_idx + max_idx) >> 1;
+       e = Add2Ptr(hdr, offs[mid_idx]);
 
-       if (de_is_last(e)) {
-               *diff = 1;
-               return e;
-       }
-       goto next;
+       goto binary_search;
 }
 
 /*
@@ -1136,9 +1072,7 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
        if (!e)
                return -EINVAL;
 
-       if (fnd)
-               fnd->root_de = e;
-
+       fnd->root_de = e;
        err = 0;
 
        for (;;) {
@@ -1401,7 +1335,7 @@ ok:
 static int indx_create_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
                                CLST *vbn)
 {
-       int err = -ENOMEM;
+       int err;
        struct ntfs_sb_info *sbi = ni->mi.sbi;
        struct ATTRIB *bitmap;
        struct ATTRIB *alloc;
index db2a5a4c38e4d62abfb2c7ca16947cd766982b13..859951d785cb2f4380c85b1d799f66f008da7d45 100644 (file)
@@ -5,10 +5,8 @@
  *
  */
 
-#include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/iversion.h>
 #include <linux/mpage.h>
 #include <linux/namei.h>
 #include <linux/nls.h>
@@ -49,8 +47,8 @@ static struct inode *ntfs_read_mft(struct inode *inode,
 
        inode->i_op = NULL;
        /* Setup 'uid' and 'gid' */
-       inode->i_uid = sbi->options.fs_uid;
-       inode->i_gid = sbi->options.fs_gid;
+       inode->i_uid = sbi->options->fs_uid;
+       inode->i_gid = sbi->options->fs_gid;
 
        err = mi_init(&ni->mi, sbi, ino);
        if (err)
@@ -224,12 +222,9 @@ next_attr:
                if (!attr->non_res) {
                        ni->i_valid = inode->i_size = rsize;
                        inode_set_bytes(inode, rsize);
-                       t32 = asize;
-               } else {
-                       t32 = le16_to_cpu(attr->nres.run_off);
                }
 
-               mode = S_IFREG | (0777 & sbi->options.fs_fmask_inv);
+               mode = S_IFREG | (0777 & sbi->options->fs_fmask_inv);
 
                if (!attr->non_res) {
                        ni->ni_flags |= NI_FLAG_RESIDENT;
@@ -272,7 +267,7 @@ next_attr:
                        goto out;
 
                mode = sb->s_root
-                              ? (S_IFDIR | (0777 & sbi->options.fs_dmask_inv))
+                              ? (S_IFDIR | (0777 & sbi->options->fs_dmask_inv))
                               : (S_IFDIR | 0777);
                goto next_attr;
 
@@ -315,17 +310,14 @@ next_attr:
                rp_fa = ni_parse_reparse(ni, attr, &rp);
                switch (rp_fa) {
                case REPARSE_LINK:
-                       if (!attr->non_res) {
-                               inode->i_size = rsize;
-                               inode_set_bytes(inode, rsize);
-                               t32 = asize;
-                       } else {
-                               inode->i_size =
-                                       le64_to_cpu(attr->nres.data_size);
-                               t32 = le16_to_cpu(attr->nres.run_off);
-                       }
+                       /*
+                        * Normal symlink.
+                        * Assume one unicode symbol == one utf8.
+                        */
+                       inode->i_size = le16_to_cpu(rp.SymbolicLinkReparseBuffer
+                                                           .PrintNameLength) /
+                                       sizeof(u16);
 
-                       /* Looks like normal symlink. */
                        ni->i_valid = inode->i_size;
 
                        /* Clear directory bit. */
@@ -422,7 +414,7 @@ end_enum:
                ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY;
                inode->i_op = &ntfs_link_inode_operations;
                inode->i_fop = NULL;
-               inode_nohighmem(inode); // ??
+               inode_nohighmem(inode);
        } else if (S_ISREG(mode)) {
                ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY;
                inode->i_op = &ntfs_file_inode_operations;
@@ -443,7 +435,7 @@ end_enum:
                goto out;
        }
 
-       if ((sbi->options.sys_immutable &&
+       if ((sbi->options->sys_immutable &&
             (std5->fa & FILE_ATTRIBUTE_SYSTEM)) &&
            !S_ISFIFO(mode) && !S_ISSOCK(mode) && !S_ISLNK(mode)) {
                inode->i_flags |= S_IMMUTABLE;
@@ -1200,9 +1192,13 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
        struct REPARSE_DATA_BUFFER *rp = NULL;
        bool rp_inserted = false;
 
+       ni_lock_dir(dir_ni);
+
        dir_root = indx_get_root(&dir_ni->dir, dir_ni, NULL, NULL);
-       if (!dir_root)
-               return ERR_PTR(-EINVAL);
+       if (!dir_root) {
+               err = -EINVAL;
+               goto out1;
+       }
 
        if (S_ISDIR(mode)) {
                /* Use parent's directory attributes. */
@@ -1244,7 +1240,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
                 *      }
                 */
        } else if (S_ISREG(mode)) {
-               if (sbi->options.sparse) {
+               if (sbi->options->sparse) {
                        /* Sparsed regular file, cause option 'sparse'. */
                        fa = FILE_ATTRIBUTE_SPARSE_FILE |
                             FILE_ATTRIBUTE_ARCHIVE;
@@ -1486,7 +1482,10 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
                asize = ALIGN(SIZEOF_RESIDENT + nsize, 8);
                t16 = PtrOffset(rec, attr);
 
-               /* 0x78 - the size of EA + EAINFO to store WSL */
+               /*
+                * Below function 'ntfs_save_wsl_perm' requires 0x78 bytes.
+                * It is good idea to keep extened attributes resident.
+                */
                if (asize + t16 + 0x78 + 8 > sbi->record_size) {
                        CLST alen;
                        CLST clst = bytes_to_cluster(sbi, nsize);
@@ -1521,14 +1520,14 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
                        }
 
                        asize = SIZEOF_NONRESIDENT + ALIGN(err, 8);
-                       inode->i_size = nsize;
                } else {
                        attr->res.data_off = SIZEOF_RESIDENT_LE;
                        attr->res.data_size = cpu_to_le32(nsize);
                        memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), rp, nsize);
-                       inode->i_size = nsize;
                        nsize = 0;
                }
+               /* Size of symlink equals the length of input string. */
+               inode->i_size = size;
 
                attr->size = cpu_to_le32(asize);
 
@@ -1551,6 +1550,9 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
        if (err)
                goto out6;
 
+       /* Unlock parent directory before ntfs_init_acl. */
+       ni_unlock(dir_ni);
+
        inode->i_generation = le16_to_cpu(rec->seq);
 
        dir->i_mtime = dir->i_ctime = inode->i_atime;
@@ -1562,6 +1564,8 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
                inode->i_op = &ntfs_link_inode_operations;
                inode->i_fop = NULL;
                inode->i_mapping->a_ops = &ntfs_aops;
+               inode->i_size = size;
+               inode_nohighmem(inode);
        } else if (S_ISREG(mode)) {
                inode->i_op = &ntfs_file_inode_operations;
                inode->i_fop = &ntfs_file_operations;
@@ -1577,7 +1581,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
        if (!S_ISLNK(mode) && (sb->s_flags & SB_POSIXACL)) {
                err = ntfs_init_acl(mnt_userns, inode, dir);
                if (err)
-                       goto out6;
+                       goto out7;
        } else
 #endif
        {
@@ -1586,7 +1590,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
 
        /* Write non resident data. */
        if (nsize) {
-               err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize);
+               err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize, 0);
                if (err)
                        goto out7;
        }
@@ -1607,8 +1611,10 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
 out7:
 
        /* Undo 'indx_insert_entry'. */
+       ni_lock_dir(dir_ni);
        indx_delete_entry(&dir_ni->dir, dir_ni, new_de + 1,
                          le16_to_cpu(new_de->key_size), sbi);
+       /* ni_unlock(dir_ni); will be called later. */
 out6:
        if (rp_inserted)
                ntfs_remove_reparse(sbi, IO_REPARSE_TAG_SYMLINK, &new_de->ref);
@@ -1632,8 +1638,10 @@ out2:
        kfree(rp);
 
 out1:
-       if (err)
+       if (err) {
+               ni_unlock(dir_ni);
                return ERR_PTR(err);
+       }
 
        unlock_new_inode(inode);
 
@@ -1754,15 +1762,15 @@ void ntfs_evict_inode(struct inode *inode)
 static noinline int ntfs_readlink_hlp(struct inode *inode, char *buffer,
                                      int buflen)
 {
-       int i, err = 0;
+       int i, err = -EINVAL;
        struct ntfs_inode *ni = ntfs_i(inode);
        struct super_block *sb = inode->i_sb;
        struct ntfs_sb_info *sbi = sb->s_fs_info;
-       u64 i_size = inode->i_size;
-       u16 nlen = 0;
+       u64 size;
+       u16 ulen = 0;
        void *to_free = NULL;
        struct REPARSE_DATA_BUFFER *rp;
-       struct le_str *uni;
+       const __le16 *uname;
        struct ATTRIB *attr;
 
        /* Reparse data present. Try to parse it. */
@@ -1771,68 +1779,64 @@ static noinline int ntfs_readlink_hlp(struct inode *inode, char *buffer,
 
        *buffer = 0;
 
-       /* Read into temporal buffer. */
-       if (i_size > sbi->reparse.max_size || i_size <= sizeof(u32)) {
-               err = -EINVAL;
-               goto out;
-       }
-
        attr = ni_find_attr(ni, NULL, NULL, ATTR_REPARSE, NULL, 0, NULL, NULL);
-       if (!attr) {
-               err = -EINVAL;
+       if (!attr)
                goto out;
-       }
 
        if (!attr->non_res) {
-               rp = resident_data_ex(attr, i_size);
-               if (!rp) {
-                       err = -EINVAL;
+               rp = resident_data_ex(attr, sizeof(struct REPARSE_DATA_BUFFER));
+               if (!rp)
                        goto out;
-               }
+               size = le32_to_cpu(attr->res.data_size);
        } else {
-               rp = kmalloc(i_size, GFP_NOFS);
+               size = le64_to_cpu(attr->nres.data_size);
+               rp = NULL;
+       }
+
+       if (size > sbi->reparse.max_size || size <= sizeof(u32))
+               goto out;
+
+       if (!rp) {
+               rp = kmalloc(size, GFP_NOFS);
                if (!rp) {
                        err = -ENOMEM;
                        goto out;
                }
                to_free = rp;
-               err = ntfs_read_run_nb(sbi, &ni->file.run, 0, rp, i_size, NULL);
+               /* Read into temporal buffer. */
+               err = ntfs_read_run_nb(sbi, &ni->file.run, 0, rp, size, NULL);
                if (err)
                        goto out;
        }
 
-       err = -EINVAL;
-
        /* Microsoft Tag. */
        switch (rp->ReparseTag) {
        case IO_REPARSE_TAG_MOUNT_POINT:
                /* Mount points and junctions. */
                /* Can we use 'Rp->MountPointReparseBuffer.PrintNameLength'? */
-               if (i_size <= offsetof(struct REPARSE_DATA_BUFFER,
-                                      MountPointReparseBuffer.PathBuffer))
+               if (size <= offsetof(struct REPARSE_DATA_BUFFER,
+                                    MountPointReparseBuffer.PathBuffer))
                        goto out;
-               uni = Add2Ptr(rp,
-                             offsetof(struct REPARSE_DATA_BUFFER,
-                                      MountPointReparseBuffer.PathBuffer) +
-                                     le16_to_cpu(rp->MountPointReparseBuffer
-                                                         .PrintNameOffset) -
-                                     2);
-               nlen = le16_to_cpu(rp->MountPointReparseBuffer.PrintNameLength);
+               uname = Add2Ptr(rp,
+                               offsetof(struct REPARSE_DATA_BUFFER,
+                                        MountPointReparseBuffer.PathBuffer) +
+                                       le16_to_cpu(rp->MountPointReparseBuffer
+                                                           .PrintNameOffset));
+               ulen = le16_to_cpu(rp->MountPointReparseBuffer.PrintNameLength);
                break;
 
        case IO_REPARSE_TAG_SYMLINK:
                /* FolderSymbolicLink */
                /* Can we use 'Rp->SymbolicLinkReparseBuffer.PrintNameLength'? */
-               if (i_size <= offsetof(struct REPARSE_DATA_BUFFER,
-                                      SymbolicLinkReparseBuffer.PathBuffer))
+               if (size <= offsetof(struct REPARSE_DATA_BUFFER,
+                                    SymbolicLinkReparseBuffer.PathBuffer))
                        goto out;
-               uni = Add2Ptr(rp,
-                             offsetof(struct REPARSE_DATA_BUFFER,
-                                      SymbolicLinkReparseBuffer.PathBuffer) +
-                                     le16_to_cpu(rp->SymbolicLinkReparseBuffer
-                                                         .PrintNameOffset) -
-                                     2);
-               nlen = le16_to_cpu(
+               uname = Add2Ptr(
+                       rp, offsetof(struct REPARSE_DATA_BUFFER,
+                                    SymbolicLinkReparseBuffer.PathBuffer) +
+                                   le16_to_cpu(rp->SymbolicLinkReparseBuffer
+                                                       .PrintNameOffset));
+               ulen = le16_to_cpu(
                        rp->SymbolicLinkReparseBuffer.PrintNameLength);
                break;
 
@@ -1864,29 +1868,28 @@ static noinline int ntfs_readlink_hlp(struct inode *inode, char *buffer,
                        goto out;
                }
                if (!IsReparseTagNameSurrogate(rp->ReparseTag) ||
-                   i_size <= sizeof(struct REPARSE_POINT)) {
+                   size <= sizeof(struct REPARSE_POINT)) {
                        goto out;
                }
 
                /* Users tag. */
-               uni = Add2Ptr(rp, sizeof(struct REPARSE_POINT) - 2);
-               nlen = le16_to_cpu(rp->ReparseDataLength) -
+               uname = Add2Ptr(rp, sizeof(struct REPARSE_POINT));
+               ulen = le16_to_cpu(rp->ReparseDataLength) -
                       sizeof(struct REPARSE_POINT);
        }
 
        /* Convert nlen from bytes to UNICODE chars. */
-       nlen >>= 1;
+       ulen >>= 1;
 
        /* Check that name is available. */
-       if (!nlen || &uni->name[nlen] > (__le16 *)Add2Ptr(rp, i_size))
+       if (!ulen || uname + ulen > (__le16 *)Add2Ptr(rp, size))
                goto out;
 
        /* If name is already zero terminated then truncate it now. */
-       if (!uni->name[nlen - 1])
-               nlen -= 1;
-       uni->len = nlen;
+       if (!uname[ulen - 1])
+               ulen -= 1;
 
-       err = ntfs_utf16_to_nls(sbi, uni, buffer, buflen);
+       err = ntfs_utf16_to_nls(sbi, uname, ulen, buffer, buflen);
 
        if (err < 0)
                goto out;
index 2d70ae42f1b511f3b43af7a9b886ac1ffd21822b..dd7ced000d0e755ca1b337273dab7577c194a7c4 100644 (file)
@@ -5,6 +5,9 @@
  * Copyright (C) 2015 Eric Biggers
  */
 
+#ifndef _LINUX_NTFS3_LIB_DECOMPRESS_COMMON_H
+#define _LINUX_NTFS3_LIB_DECOMPRESS_COMMON_H
+
 #include <linux/string.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
@@ -336,3 +339,5 @@ static forceinline u8 *lz_copy(u8 *dst, u32 length, u32 offset, const u8 *bufend
 
        return dst;
 }
+
+#endif /* _LINUX_NTFS3_LIB_DECOMPRESS_COMMON_H */
index f508fbad2e712d946274b13f0ec7b244dc264a4d..90309a5ae59c7a98f3f0b61f5883fe390790eb50 100644 (file)
@@ -7,6 +7,10 @@
  * - linux kernel code style
  */
 
+#ifndef _LINUX_NTFS3_LIB_LIB_H
+#define _LINUX_NTFS3_LIB_LIB_H
+
+#include <linux/types.h>
 
 /* globals from xpress_decompress.c */
 struct xpress_decompressor *xpress_allocate_decompressor(void);
@@ -24,3 +28,5 @@ int lzx_decompress(struct lzx_decompressor *__restrict d,
                   const void *__restrict compressed_data,
                   size_t compressed_size, void *__restrict uncompressed_data,
                   size_t uncompressed_size);
+
+#endif /* _LINUX_NTFS3_LIB_LIB_H */
index f1f691a67cc490254957f062cfc38ec12ac7e834..28f654561f279a5d09ddd4a1352930b0fefb5416 100644 (file)
@@ -5,13 +5,13 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
-#include <linux/fs.h>
-#include <linux/nls.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/types.h>
 
 #include "debug.h"
-#include "ntfs.h"
 #include "ntfs_fs.h"
 
 // clang-format off
@@ -292,7 +292,7 @@ next:
 /*
  * get_lznt_ctx
  * @level: 0 - Standard compression.
- *        !0 - Best compression, requires a lot of cpu.
+ *        !0 - Best compression, requires a lot of cpu.
  */
 struct lznt *get_lznt_ctx(int level)
 {
index e58415d0713280297df1b7bac30eb17642431fa0..bc741213ad84833b7fd434c32d4b784c6e7cb2f7 100644 (file)
@@ -5,11 +5,7 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/iversion.h>
-#include <linux/namei.h>
 #include <linux/nls.h>
 
 #include "debug.h"
@@ -99,16 +95,11 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
 static int ntfs_create(struct user_namespace *mnt_userns, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
-       struct ntfs_inode *ni = ntfs_i(dir);
        struct inode *inode;
 
-       ni_lock_dir(ni);
-
        inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFREG | mode,
                                  0, NULL, 0, NULL);
 
-       ni_unlock(ni);
-
        return IS_ERR(inode) ? PTR_ERR(inode) : 0;
 }
 
@@ -120,16 +111,11 @@ static int ntfs_create(struct user_namespace *mnt_userns, struct inode *dir,
 static int ntfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
                      struct dentry *dentry, umode_t mode, dev_t rdev)
 {
-       struct ntfs_inode *ni = ntfs_i(dir);
        struct inode *inode;
 
-       ni_lock_dir(ni);
-
        inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, mode, rdev,
                                  NULL, 0, NULL);
 
-       ni_unlock(ni);
-
        return IS_ERR(inode) ? PTR_ERR(inode) : 0;
 }
 
@@ -200,15 +186,10 @@ static int ntfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 {
        u32 size = strlen(symname);
        struct inode *inode;
-       struct ntfs_inode *ni = ntfs_i(dir);
-
-       ni_lock_dir(ni);
 
        inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFLNK | 0777,
                                  0, symname, size, NULL);
 
-       ni_unlock(ni);
-
        return IS_ERR(inode) ? PTR_ERR(inode) : 0;
 }
 
@@ -219,15 +200,10 @@ static int ntfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
                      struct dentry *dentry, umode_t mode)
 {
        struct inode *inode;
-       struct ntfs_inode *ni = ntfs_i(dir);
-
-       ni_lock_dir(ni);
 
        inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFDIR | mode,
                                  0, NULL, 0, NULL);
 
-       ni_unlock(ni);
-
        return IS_ERR(inode) ? PTR_ERR(inode) : 0;
 }
 
index 6bb3e595263b67c7cc66a0fecc5dfa68310826d4..9cc396b117bfd9b02531ad6c6de89ded53bba7f3 100644 (file)
 #ifndef _LINUX_NTFS3_NTFS_H
 #define _LINUX_NTFS3_NTFS_H
 
-/* TODO: Check 4K MFT record and 512 bytes cluster. */
+#include <linux/blkdev.h>
+#include <linux/build_bug.h>
+#include <linux/kernel.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
+#include "debug.h"
 
-/* Activate this define to use binary search in indexes. */
-#define NTFS3_INDEX_BINARY_SEARCH
+/* TODO: Check 4K MFT record and 512 bytes cluster. */
 
 /* Check each run for marked clusters. */
 #define NTFS3_CHECK_FREE_CLST
 
 #define NTFS_NAME_LEN 255
 
-/* ntfs.sys used 500 maximum links on-disk struct allows up to 0xffff. */
-#define NTFS_LINK_MAX 0x400
-//#define NTFS_LINK_MAX 0xffff
+/*
+ * ntfs.sys used 500 maximum links on-disk struct allows up to 0xffff.
+ * xfstest generic/041 creates 3003 hardlinks.
+ */
+#define NTFS_LINK_MAX 4000
 
 /*
  * Activate to use 64 bit clusters instead of 32 bits in ntfs.sys.
index dc71c59fd44545118b6ab3023492aa8e4e75b017..8aaec7e0804efaa4b66727bf0d7360f68abba8c0 100644 (file)
@@ -9,6 +9,37 @@
 #ifndef _LINUX_NTFS3_NTFS_FS_H
 #define _LINUX_NTFS3_NTFS_FS_H
 
+#include <linux/blkdev.h>
+#include <linux/buffer_head.h>
+#include <linux/cleancache.h>
+#include <linux/fs.h>
+#include <linux/highmem.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/page-flags.h>
+#include <linux/pagemap.h>
+#include <linux/rbtree.h>
+#include <linux/rwsem.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/time64.h>
+#include <linux/types.h>
+#include <linux/uidgid.h>
+#include <asm/div64.h>
+#include <asm/page.h>
+
+#include "debug.h"
+#include "ntfs.h"
+
+struct dentry;
+struct fiemap_extent_info;
+struct user_namespace;
+struct page;
+struct writeback_control;
+enum utf16_endian;
+
+
 #define MINUS_ONE_T                    ((size_t)(-1))
 /* Biggest MFT / smallest cluster */
 #define MAXIMUM_BYTES_PER_MFT          4096
@@ -52,6 +83,7 @@
 // clang-format on
 
 struct ntfs_mount_options {
+       char *nls_name;
        struct nls_table *nls;
 
        kuid_t fs_uid;
@@ -59,19 +91,16 @@ struct ntfs_mount_options {
        u16 fs_fmask_inv;
        u16 fs_dmask_inv;
 
-       unsigned uid : 1, /* uid was set. */
-               gid : 1, /* gid was set. */
-               fmask : 1, /* fmask was set. */
-               dmask : 1, /* dmask was set. */
-               sys_immutable : 1, /* Immutable system files. */
-               discard : 1, /* Issue discard requests on deletions. */
-               sparse : 1, /* Create sparse files. */
-               showmeta : 1, /* Show meta files. */
-               nohidden : 1, /* Do not show hidden files. */
-               force : 1, /* Rw mount dirty volume. */
-               no_acs_rules : 1, /*Exclude acs rules. */
-               prealloc : 1 /* Preallocate space when file is growing. */
-               ;
+       unsigned fmask : 1; /* fmask was set. */
+       unsigned dmask : 1; /*dmask was set. */
+       unsigned sys_immutable : 1; /* Immutable system files. */
+       unsigned discard : 1; /* Issue discard requests on deletions. */
+       unsigned sparse : 1; /* Create sparse files. */
+       unsigned showmeta : 1; /* Show meta files. */
+       unsigned nohidden : 1; /* Do not show hidden files. */
+       unsigned force : 1; /* RW mount dirty volume. */
+       unsigned noacsrules : 1; /* Exclude acs rules. */
+       unsigned prealloc : 1; /* Preallocate space when file is growing. */
 };
 
 /* Special value to unpack and deallocate. */
@@ -182,10 +211,8 @@ struct ntfs_sb_info {
        u32 blocks_per_cluster; // cluster_size / sb->s_blocksize
 
        u32 record_size;
-       u32 sector_size;
        u32 index_size;
 
-       u8 sector_bits;
        u8 cluster_bits;
        u8 record_bits;
 
@@ -279,7 +306,7 @@ struct ntfs_sb_info {
 #endif
        } compress;
 
-       struct ntfs_mount_options options;
+       struct ntfs_mount_options *options;
        struct ratelimit_state msg_ratelimit;
 };
 
@@ -436,7 +463,7 @@ bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le);
 bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
                  const __le16 *name, size_t name_len,
                  const struct MFT_REF *ref);
-int al_update(struct ntfs_inode *ni);
+int al_update(struct ntfs_inode *ni, int sync);
 static inline size_t al_aligned(size_t size)
 {
        return (size + 1023) & ~(size_t)1023;
@@ -448,7 +475,7 @@ bool are_bits_set(const ulong *map, size_t bit, size_t nbits);
 size_t get_set_bits_ex(const ulong *map, size_t bit, size_t nbits);
 
 /* Globals from dir.c */
-int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni,
+int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const __le16 *name, u32 len,
                      u8 *buf, int buf_len);
 int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len,
                      struct cpu_str *uni, u32 max_ulen,
@@ -520,7 +547,7 @@ struct ATTR_FILE_NAME *ni_fname_type(struct ntfs_inode *ni, u8 name_type,
                                     struct ATTR_LIST_ENTRY **entry);
 int ni_new_attr_flags(struct ntfs_inode *ni, enum FILE_ATTRIBUTE new_fa);
 enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr,
-                                  void *buffer);
+                                  struct REPARSE_DATA_BUFFER *buffer);
 int ni_write_inode(struct inode *inode, int sync, const char *hint);
 #define _ni_write_inode(i, w) ni_write_inode(i, w, __func__)
 int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
@@ -577,7 +604,7 @@ int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
 int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
                  const void *buffer, int wait);
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-                     u64 vbo, const void *buf, size_t bytes);
+                     u64 vbo, const void *buf, size_t bytes, int sync);
 struct buffer_head *ntfs_bread_run(struct ntfs_sb_info *sbi,
                                   const struct runs_tree *run, u64 vbo);
 int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run,
index 103705c86772f45a90227e6434449e99c4d7d94b..861e35791506e801dc446414d935d5463e64a1fb 100644 (file)
@@ -5,10 +5,7 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
 
 #include "debug.h"
 #include "ntfs.h"
index 26ed2b64345e665a39c6b37d88b29c5b81592ecd..a8fec651f9732878ad871cc476d8a6fcf28f9312 100644 (file)
@@ -7,10 +7,8 @@
  */
 
 #include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include <linux/log2.h>
-#include <linux/nls.h>
 
 #include "debug.h"
 #include "ntfs.h"
index 55bbc9200a10ebdf3011e0a517eb44afd8a35f3f..d41d76979e121fd9e836ef0072b122ab6de3735b 100644 (file)
  *
  */
 
-#include <linux/backing-dev.h>
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/exportfs.h>
 #include <linux/fs.h>
-#include <linux/iversion.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 #include <linux/log2.h>
 #include <linux/module.h>
 #include <linux/nls.h>
-#include <linux/parser.h>
 #include <linux/seq_file.h>
 #include <linux/statfs.h>
 
@@ -205,9 +204,11 @@ void *ntfs_put_shared(void *ptr)
        return ret;
 }
 
-static inline void clear_mount_options(struct ntfs_mount_options *options)
+static inline void put_mount_options(struct ntfs_mount_options *options)
 {
+       kfree(options->nls_name);
        unload_nls(options->nls);
+       kfree(options);
 }
 
 enum Opt {
@@ -223,218 +224,175 @@ enum Opt {
        Opt_nohidden,
        Opt_showmeta,
        Opt_acl,
-       Opt_noatime,
-       Opt_nls,
+       Opt_iocharset,
        Opt_prealloc,
-       Opt_no_acs_rules,
+       Opt_noacsrules,
        Opt_err,
 };
 
-static const match_table_t ntfs_tokens = {
-       { Opt_uid, "uid=%u" },
-       { Opt_gid, "gid=%u" },
-       { Opt_umask, "umask=%o" },
-       { Opt_dmask, "dmask=%o" },
-       { Opt_fmask, "fmask=%o" },
-       { Opt_immutable, "sys_immutable" },
-       { Opt_discard, "discard" },
-       { Opt_force, "force" },
-       { Opt_sparse, "sparse" },
-       { Opt_nohidden, "nohidden" },
-       { Opt_acl, "acl" },
-       { Opt_noatime, "noatime" },
-       { Opt_showmeta, "showmeta" },
-       { Opt_nls, "nls=%s" },
-       { Opt_prealloc, "prealloc" },
-       { Opt_no_acs_rules, "no_acs_rules" },
-       { Opt_err, NULL },
+static const struct fs_parameter_spec ntfs_fs_parameters[] = {
+       fsparam_u32("uid",                      Opt_uid),
+       fsparam_u32("gid",                      Opt_gid),
+       fsparam_u32oct("umask",                 Opt_umask),
+       fsparam_u32oct("dmask",                 Opt_dmask),
+       fsparam_u32oct("fmask",                 Opt_fmask),
+       fsparam_flag_no("sys_immutable",        Opt_immutable),
+       fsparam_flag_no("discard",              Opt_discard),
+       fsparam_flag_no("force",                Opt_force),
+       fsparam_flag_no("sparse",               Opt_sparse),
+       fsparam_flag_no("hidden",               Opt_nohidden),
+       fsparam_flag_no("acl",                  Opt_acl),
+       fsparam_flag_no("showmeta",             Opt_showmeta),
+       fsparam_flag_no("prealloc",             Opt_prealloc),
+       fsparam_flag_no("acsrules",             Opt_noacsrules),
+       fsparam_string("iocharset",             Opt_iocharset),
+       {}
 };
 
-static noinline int ntfs_parse_options(struct super_block *sb, char *options,
-                                      int silent,
-                                      struct ntfs_mount_options *opts)
+/*
+ * Load nls table or if @nls is utf8 then return NULL.
+ */
+static struct nls_table *ntfs_load_nls(char *nls)
 {
-       char *p;
-       substring_t args[MAX_OPT_ARGS];
-       int option;
-       char nls_name[30];
-       struct nls_table *nls;
+       struct nls_table *ret;
 
-       opts->fs_uid = current_uid();
-       opts->fs_gid = current_gid();
-       opts->fs_fmask_inv = opts->fs_dmask_inv = ~current_umask();
-       nls_name[0] = 0;
+       if (!nls)
+               nls = CONFIG_NLS_DEFAULT;
 
-       if (!options)
-               goto out;
+       if (strcmp(nls, "utf8") == 0)
+               return NULL;
 
-       while ((p = strsep(&options, ","))) {
-               int token;
+       if (strcmp(nls, CONFIG_NLS_DEFAULT) == 0)
+               return load_nls_default();
 
-               if (!*p)
-                       continue;
+       ret = load_nls(nls);
+       if (ret)
+               return ret;
 
-               token = match_token(p, ntfs_tokens, args);
-               switch (token) {
-               case Opt_immutable:
-                       opts->sys_immutable = 1;
-                       break;
-               case Opt_uid:
-                       if (match_int(&args[0], &option))
-                               return -EINVAL;
-                       opts->fs_uid = make_kuid(current_user_ns(), option);
-                       if (!uid_valid(opts->fs_uid))
-                               return -EINVAL;
-                       opts->uid = 1;
-                       break;
-               case Opt_gid:
-                       if (match_int(&args[0], &option))
-                               return -EINVAL;
-                       opts->fs_gid = make_kgid(current_user_ns(), option);
-                       if (!gid_valid(opts->fs_gid))
-                               return -EINVAL;
-                       opts->gid = 1;
-                       break;
-               case Opt_umask:
-                       if (match_octal(&args[0], &option))
-                               return -EINVAL;
-                       opts->fs_fmask_inv = opts->fs_dmask_inv = ~option;
-                       opts->fmask = opts->dmask = 1;
-                       break;
-               case Opt_dmask:
-                       if (match_octal(&args[0], &option))
-                               return -EINVAL;
-                       opts->fs_dmask_inv = ~option;
-                       opts->dmask = 1;
-                       break;
-               case Opt_fmask:
-                       if (match_octal(&args[0], &option))
-                               return -EINVAL;
-                       opts->fs_fmask_inv = ~option;
-                       opts->fmask = 1;
-                       break;
-               case Opt_discard:
-                       opts->discard = 1;
-                       break;
-               case Opt_force:
-                       opts->force = 1;
-                       break;
-               case Opt_sparse:
-                       opts->sparse = 1;
-                       break;
-               case Opt_nohidden:
-                       opts->nohidden = 1;
-                       break;
-               case Opt_acl:
+       return ERR_PTR(-EINVAL);
+}
+
+static int ntfs_fs_parse_param(struct fs_context *fc,
+                              struct fs_parameter *param)
+{
+       struct ntfs_mount_options *opts = fc->fs_private;
+       struct fs_parse_result result;
+       int opt;
+
+       opt = fs_parse(fc, ntfs_fs_parameters, param, &result);
+       if (opt < 0)
+               return opt;
+
+       switch (opt) {
+       case Opt_uid:
+               opts->fs_uid = make_kuid(current_user_ns(), result.uint_32);
+               if (!uid_valid(opts->fs_uid))
+                       return invalf(fc, "ntfs3: Invalid value for uid.");
+               break;
+       case Opt_gid:
+               opts->fs_gid = make_kgid(current_user_ns(), result.uint_32);
+               if (!gid_valid(opts->fs_gid))
+                       return invalf(fc, "ntfs3: Invalid value for gid.");
+               break;
+       case Opt_umask:
+               if (result.uint_32 & ~07777)
+                       return invalf(fc, "ntfs3: Invalid value for umask.");
+               opts->fs_fmask_inv = ~result.uint_32;
+               opts->fs_dmask_inv = ~result.uint_32;
+               opts->fmask = 1;
+               opts->dmask = 1;
+               break;
+       case Opt_dmask:
+               if (result.uint_32 & ~07777)
+                       return invalf(fc, "ntfs3: Invalid value for dmask.");
+               opts->fs_dmask_inv = ~result.uint_32;
+               opts->dmask = 1;
+               break;
+       case Opt_fmask:
+               if (result.uint_32 & ~07777)
+                       return invalf(fc, "ntfs3: Invalid value for fmask.");
+               opts->fs_fmask_inv = ~result.uint_32;
+               opts->fmask = 1;
+               break;
+       case Opt_immutable:
+               opts->sys_immutable = result.negated ? 0 : 1;
+               break;
+       case Opt_discard:
+               opts->discard = result.negated ? 0 : 1;
+               break;
+       case Opt_force:
+               opts->force = result.negated ? 0 : 1;
+               break;
+       case Opt_sparse:
+               opts->sparse = result.negated ? 0 : 1;
+               break;
+       case Opt_nohidden:
+               opts->nohidden = result.negated ? 1 : 0;
+               break;
+       case Opt_acl:
+               if (!result.negated)
 #ifdef CONFIG_NTFS3_FS_POSIX_ACL
-                       sb->s_flags |= SB_POSIXACL;
-                       break;
+                       fc->sb_flags |= SB_POSIXACL;
 #else
-                       ntfs_err(sb, "support for ACL not compiled in!");
-                       return -EINVAL;
+                       return invalf(fc, "ntfs3: Support for ACL not compiled in!");
 #endif
-               case Opt_noatime:
-                       sb->s_flags |= SB_NOATIME;
-                       break;
-               case Opt_showmeta:
-                       opts->showmeta = 1;
-                       break;
-               case Opt_nls:
-                       match_strlcpy(nls_name, &args[0], sizeof(nls_name));
-                       break;
-               case Opt_prealloc:
-                       opts->prealloc = 1;
-                       break;
-               case Opt_no_acs_rules:
-                       opts->no_acs_rules = 1;
-                       break;
-               default:
-                       if (!silent)
-                               ntfs_err(
-                                       sb,
-                                       "Unrecognized mount option \"%s\" or missing value",
-                                       p);
-                       //return -EINVAL;
-               }
-       }
-
-out:
-       if (!strcmp(nls_name[0] ? nls_name : CONFIG_NLS_DEFAULT, "utf8")) {
-               /*
-                * For UTF-8 use utf16s_to_utf8s()/utf8s_to_utf16s()
-                * instead of NLS.
-                */
-               nls = NULL;
-       } else if (nls_name[0]) {
-               nls = load_nls(nls_name);
-               if (!nls) {
-                       ntfs_err(sb, "failed to load \"%s\"", nls_name);
-                       return -EINVAL;
-               }
-       } else {
-               nls = load_nls_default();
-               if (!nls) {
-                       ntfs_err(sb, "failed to load default nls");
-                       return -EINVAL;
-               }
+               else
+                       fc->sb_flags &= ~SB_POSIXACL;
+               break;
+       case Opt_showmeta:
+               opts->showmeta = result.negated ? 0 : 1;
+               break;
+       case Opt_iocharset:
+               kfree(opts->nls_name);
+               opts->nls_name = param->string;
+               param->string = NULL;
+               break;
+       case Opt_prealloc:
+               opts->prealloc = result.negated ? 0 : 1;
+               break;
+       case Opt_noacsrules:
+               opts->noacsrules = result.negated ? 1 : 0;
+               break;
+       default:
+               /* Should not be here unless we forget add case. */
+               return -EINVAL;
        }
-       opts->nls = nls;
-
        return 0;
 }
 
-static int ntfs_remount(struct super_block *sb, int *flags, char *data)
+static int ntfs_fs_reconfigure(struct fs_context *fc)
 {
-       int err, ro_rw;
+       struct super_block *sb = fc->root->d_sb;
        struct ntfs_sb_info *sbi = sb->s_fs_info;
-       struct ntfs_mount_options old_opts;
-       char *orig_data = kstrdup(data, GFP_KERNEL);
-
-       if (data && !orig_data)
-               return -ENOMEM;
+       struct ntfs_mount_options *new_opts = fc->fs_private;
+       int ro_rw;
 
-       /* Store  original options. */
-       memcpy(&old_opts, &sbi->options, sizeof(old_opts));
-       clear_mount_options(&sbi->options);
-       memset(&sbi->options, 0, sizeof(sbi->options));
-
-       err = ntfs_parse_options(sb, data, 0, &sbi->options);
-       if (err)
-               goto restore_opts;
-
-       ro_rw = sb_rdonly(sb) && !(*flags & SB_RDONLY);
+       ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY);
        if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY)) {
-               ntfs_warn(
-                       sb,
-                       "Couldn't remount rw because journal is not replayed. Please umount/remount instead\n");
-               err = -EINVAL;
-               goto restore_opts;
+               errorf(fc, "ntfs3: Couldn't remount rw because journal is not replayed. Please umount/remount instead\n");
+               return -EINVAL;
        }
 
+       new_opts->nls = ntfs_load_nls(new_opts->nls_name);
+       if (IS_ERR(new_opts->nls)) {
+               new_opts->nls = NULL;
+               errorf(fc, "ntfs3: Cannot load iocharset %s", new_opts->nls_name);
+               return -EINVAL;
+       }
+       if (new_opts->nls != sbi->options->nls)
+               return invalf(fc, "ntfs3: Cannot use different iocharset when remounting!");
+
        sync_filesystem(sb);
 
        if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) &&
-           !sbi->options.force) {
-               ntfs_warn(sb, "volume is dirty and \"force\" flag is not set!");
-               err = -EINVAL;
-               goto restore_opts;
+           !new_opts->force) {
+               errorf(fc, "ntfs3: Volume is dirty and \"force\" flag is not set!");
+               return -EINVAL;
        }
 
-       clear_mount_options(&old_opts);
-
-       *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME) |
-                SB_NODIRATIME | SB_NOATIME;
-       ntfs_info(sb, "re-mounted. Opts: %s", orig_data);
-       err = 0;
-       goto out;
+       memcpy(sbi->options, new_opts, sizeof(*new_opts));
 
-restore_opts:
-       clear_mount_options(&sbi->options);
-       memcpy(&sbi->options, &old_opts, sizeof(old_opts));
-
-out:
-       kfree(orig_data);
-       return err;
+       return 0;
 }
 
 static struct kmem_cache *ntfs_inode_cachep;
@@ -513,8 +471,6 @@ static noinline void put_ntfs(struct ntfs_sb_info *sbi)
        xpress_free_decompressor(sbi->compress.xpress);
        lzx_free_decompressor(sbi->compress.lzx);
 #endif
-       clear_mount_options(&sbi->options);
-
        kfree(sbi);
 }
 
@@ -525,7 +481,9 @@ static void ntfs_put_super(struct super_block *sb)
        /* Mark rw ntfs as clear, if possible. */
        ntfs_set_state(sbi, NTFS_DIRTY_CLEAR);
 
+       put_mount_options(sbi->options);
        put_ntfs(sbi);
+       sb->s_fs_info = NULL;
 
        sync_blockdev(sb->s_bdev);
 }
@@ -552,23 +510,21 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
 {
        struct super_block *sb = root->d_sb;
        struct ntfs_sb_info *sbi = sb->s_fs_info;
-       struct ntfs_mount_options *opts = &sbi->options;
+       struct ntfs_mount_options *opts = sbi->options;
        struct user_namespace *user_ns = seq_user_ns(m);
 
-       if (opts->uid)
-               seq_printf(m, ",uid=%u",
-                          from_kuid_munged(user_ns, opts->fs_uid));
-       if (opts->gid)
-               seq_printf(m, ",gid=%u",
-                          from_kgid_munged(user_ns, opts->fs_gid));
+       seq_printf(m, ",uid=%u",
+                 from_kuid_munged(user_ns, opts->fs_uid));
+       seq_printf(m, ",gid=%u",
+                 from_kgid_munged(user_ns, opts->fs_gid));
        if (opts->fmask)
                seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv);
        if (opts->dmask)
                seq_printf(m, ",dmask=%04o", ~opts->fs_dmask_inv);
        if (opts->nls)
-               seq_printf(m, ",nls=%s", opts->nls->charset);
+               seq_printf(m, ",iocharset=%s", opts->nls->charset);
        else
-               seq_puts(m, ",nls=utf8");
+               seq_puts(m, ",iocharset=utf8");
        if (opts->sys_immutable)
                seq_puts(m, ",sys_immutable");
        if (opts->discard)
@@ -581,14 +537,12 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root)
                seq_puts(m, ",nohidden");
        if (opts->force)
                seq_puts(m, ",force");
-       if (opts->no_acs_rules)
-               seq_puts(m, ",no_acs_rules");
+       if (opts->noacsrules)
+               seq_puts(m, ",noacsrules");
        if (opts->prealloc)
                seq_puts(m, ",prealloc");
        if (sb->s_flags & SB_POSIXACL)
                seq_puts(m, ",acl");
-       if (sb->s_flags & SB_NOATIME)
-               seq_puts(m, ",noatime");
 
        return 0;
 }
@@ -643,7 +597,6 @@ static const struct super_operations ntfs_sops = {
        .statfs = ntfs_statfs,
        .show_options = ntfs_show_options,
        .sync_fs = ntfs_sync_fs,
-       .remount_fs = ntfs_remount,
        .write_inode = ntfs3_write_inode,
 };
 
@@ -729,7 +682,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
        struct ntfs_sb_info *sbi = sb->s_fs_info;
        int err;
        u32 mb, gb, boot_sector_size, sct_per_clst, record_size;
-       u64 sectors, clusters, fs_size, mlcn, mlcn2;
+       u64 sectors, clusters, mlcn, mlcn2;
        struct NTFS_BOOT *boot;
        struct buffer_head *bh;
        struct MFT_REC *rec;
@@ -787,20 +740,20 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
                goto out;
        }
 
-       sbi->sector_size = boot_sector_size;
-       sbi->sector_bits = blksize_bits(boot_sector_size);
-       fs_size = (sectors + 1) << sbi->sector_bits;
+       sbi->volume.size = sectors * boot_sector_size;
 
-       gb = format_size_gb(fs_size, &mb);
+       gb = format_size_gb(sbi->volume.size + boot_sector_size, &mb);
 
        /*
         * - Volume formatted and mounted with the same sector size.
         * - Volume formatted 4K and mounted as 512.
         * - Volume formatted 512 and mounted as 4K.
         */
-       if (sbi->sector_size != sector_size) {
-               ntfs_warn(sb,
-                         "Different NTFS' sector size and media sector size");
+       if (boot_sector_size != sector_size) {
+               ntfs_warn(
+                       sb,
+                       "Different NTFS' sector size (%u) and media sector size (%u)",
+                       boot_sector_size, sector_size);
                dev_size += sector_size - 1;
        }
 
@@ -810,8 +763,19 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
        sbi->mft.lbo = mlcn << sbi->cluster_bits;
        sbi->mft.lbo2 = mlcn2 << sbi->cluster_bits;
 
-       if (sbi->cluster_size < sbi->sector_size)
+       /* Compare boot's cluster and sector. */
+       if (sbi->cluster_size < boot_sector_size)
+               goto out;
+
+       /* Compare boot's cluster and media sector. */
+       if (sbi->cluster_size < sector_size) {
+               /* No way to use ntfs_get_block in this case. */
+               ntfs_err(
+                       sb,
+                       "Failed to mount 'cause NTFS's cluster size (%u) is less than media sector size (%u)",
+                       sbi->cluster_size, sector_size);
                goto out;
+       }
 
        sbi->cluster_mask = sbi->cluster_size - 1;
        sbi->cluster_mask_inv = ~(u64)sbi->cluster_mask;
@@ -836,10 +800,9 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
                                  : (u32)boot->index_size << sbi->cluster_bits;
 
        sbi->volume.ser_num = le64_to_cpu(boot->serial_num);
-       sbi->volume.size = sectors << sbi->sector_bits;
 
        /* Warning if RAW volume. */
-       if (dev_size < fs_size) {
+       if (dev_size < sbi->volume.size + boot_sector_size) {
                u32 mb0, gb0;
 
                gb0 = format_size_gb(dev_size, &mb0);
@@ -883,8 +846,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
        rec->total = cpu_to_le32(sbi->record_size);
        ((struct ATTRIB *)Add2Ptr(rec, ao))->type = ATTR_END;
 
-       if (sbi->cluster_size < PAGE_SIZE)
-               sb_set_blocksize(sb, sbi->cluster_size);
+       sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE));
 
        sbi->block_mask = sb->s_blocksize - 1;
        sbi->blocks_per_cluster = sbi->cluster_size >> sb->s_blocksize_bits;
@@ -897,9 +859,11 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
        if (clusters >= (1ull << (64 - sbi->cluster_bits)))
                sbi->maxbytes = -1;
        sbi->maxbytes_sparse = -1;
+       sb->s_maxbytes = MAX_LFS_FILESIZE;
 #else
        /* Maximum size for sparse file. */
        sbi->maxbytes_sparse = (1ull << (sbi->cluster_bits + 32)) - 1;
+       sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
 #endif
 
        err = 0;
@@ -913,14 +877,13 @@ out:
 /*
  * ntfs_fill_super - Try to mount.
  */
-static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
+static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
        int err;
-       struct ntfs_sb_info *sbi;
+       struct ntfs_sb_info *sbi = sb->s_fs_info;
        struct block_device *bdev = sb->s_bdev;
-       struct inode *bd_inode = bdev->bd_inode;
-       struct request_queue *rq = bdev_get_queue(bdev);
-       struct inode *inode = NULL;
+       struct request_queue *rq;
+       struct inode *inode;
        struct ntfs_inode *ni;
        size_t i, tt;
        CLST vcn, lcn, len;
@@ -928,18 +891,11 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        const struct VOLUME_INFO *info;
        u32 idx, done, bytes;
        struct ATTR_DEF_ENTRY *t;
-       u16 *upcase = NULL;
        u16 *shared;
-       bool is_ro;
        struct MFT_REF ref;
 
        ref.high = 0;
 
-       sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
-       if (!sbi)
-               return -ENOMEM;
-
-       sb->s_fs_info = sbi;
        sbi->sb = sb;
        sb->s_flags |= SB_NODIRATIME;
        sb->s_magic = 0x7366746e; // "ntfs"
@@ -948,41 +904,27 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
        sb->s_xattr = ntfs_xattr_handlers;
 
-       ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
-                            DEFAULT_RATELIMIT_BURST);
-
-       err = ntfs_parse_options(sb, data, silent, &sbi->options);
-       if (err)
+       sbi->options->nls = ntfs_load_nls(sbi->options->nls_name);
+       if (IS_ERR(sbi->options->nls)) {
+               sbi->options->nls = NULL;
+               errorf(fc, "Cannot load nls %s", sbi->options->nls_name);
+               err = -EINVAL;
                goto out;
+       }
 
-       if (!rq || !blk_queue_discard(rq) || !rq->limits.discard_granularity) {
-               ;
-       } else {
+       rq = bdev_get_queue(bdev);
+       if (blk_queue_discard(rq) && rq->limits.discard_granularity) {
                sbi->discard_granularity = rq->limits.discard_granularity;
                sbi->discard_granularity_mask_inv =
                        ~(u64)(sbi->discard_granularity - 1);
        }
 
-       sb_set_blocksize(sb, PAGE_SIZE);
-
        /* Parse boot. */
        err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512,
-                                 bd_inode->i_size);
+                                 bdev->bd_inode->i_size);
        if (err)
                goto out;
 
-#ifdef CONFIG_NTFS3_64BIT_CLUSTER
-       sb->s_maxbytes = MAX_LFS_FILESIZE;
-#else
-       sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
-#endif
-
-       mutex_init(&sbi->compress.mtx_lznt);
-#ifdef CONFIG_NTFS3_LZX_XPRESS
-       mutex_init(&sbi->compress.mtx_xpress);
-       mutex_init(&sbi->compress.mtx_lzx);
-#endif
-
        /*
         * Load $Volume. This should be done before $LogFile
         * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'.
@@ -991,9 +933,8 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        ref.seq = cpu_to_le16(MFT_REC_VOL);
        inode = ntfs_iget5(sb, &ref, &NAME_VOLUME);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $Volume.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
@@ -1015,36 +956,33 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        } else {
                /* Should we break mounting here? */
                //err = -EINVAL;
-               //goto out;
+               //goto put_inode_out;
        }
 
        attr = ni_find_attr(ni, attr, NULL, ATTR_VOL_INFO, NULL, 0, NULL, NULL);
        if (!attr || is_attr_ext(attr)) {
                err = -EINVAL;
-               goto out;
+               goto put_inode_out;
        }
 
        info = resident_data_ex(attr, SIZEOF_ATTRIBUTE_VOLUME_INFO);
        if (!info) {
                err = -EINVAL;
-               goto out;
+               goto put_inode_out;
        }
 
        sbi->volume.major_ver = info->major_ver;
        sbi->volume.minor_ver = info->minor_ver;
        sbi->volume.flags = info->flags;
-
        sbi->volume.ni = ni;
-       inode = NULL;
 
        /* Load $MFTMirr to estimate recs_mirr. */
        ref.low = cpu_to_le32(MFT_REC_MIRR);
        ref.seq = cpu_to_le16(MFT_REC_MIRR);
        inode = ntfs_iget5(sb, &ref, &NAME_MIRROR);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $MFTMirr.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
@@ -1058,9 +996,8 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        ref.seq = cpu_to_le16(MFT_REC_LOG);
        inode = ntfs_iget5(sb, &ref, &NAME_LOGFILE);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load \x24LogFile.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
@@ -1068,22 +1005,19 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
        err = ntfs_loadlog_and_replay(ni, sbi);
        if (err)
-               goto out;
+               goto put_inode_out;
 
        iput(inode);
-       inode = NULL;
-
-       is_ro = sb_rdonly(sbi->sb);
 
        if (sbi->flags & NTFS_FLAGS_NEED_REPLAY) {
-               if (!is_ro) {
+               if (!sb_rdonly(sb)) {
                        ntfs_warn(sb,
                                  "failed to replay log file. Can't mount rw!");
                        err = -EINVAL;
                        goto out;
                }
        } else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) {
-               if (!is_ro && !sbi->options.force) {
+               if (!sb_rdonly(sb) && !sbi->options->force) {
                        ntfs_warn(
                                sb,
                                "volume is dirty and \"force\" flag is not set!");
@@ -1098,9 +1032,8 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
        inode = ntfs_iget5(sb, &ref, &NAME_MFT);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $MFT.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
@@ -1112,11 +1045,11 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
        err = wnd_init(&sbi->mft.bitmap, sb, tt);
        if (err)
-               goto out;
+               goto put_inode_out;
 
        err = ni_load_all_mi(ni);
        if (err)
-               goto out;
+               goto put_inode_out;
 
        sbi->mft.ni = ni;
 
@@ -1125,9 +1058,8 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        ref.seq = cpu_to_le16(MFT_REC_BADCLUST);
        inode = ntfs_iget5(sb, &ref, &NAME_BADCLUS);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $BadClus.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
@@ -1150,18 +1082,15 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        ref.seq = cpu_to_le16(MFT_REC_BITMAP);
        inode = ntfs_iget5(sb, &ref, &NAME_BITMAP);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $Bitmap.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
-       ni = ntfs_i(inode);
-
 #ifndef CONFIG_NTFS3_64BIT_CLUSTER
        if (inode->i_size >> 32) {
                err = -EINVAL;
-               goto out;
+               goto put_inode_out;
        }
 #endif
 
@@ -1169,14 +1098,14 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        tt = sbi->used.bitmap.nbits;
        if (inode->i_size < bitmap_size(tt)) {
                err = -EINVAL;
-               goto out;
+               goto put_inode_out;
        }
 
        /* Not necessary. */
        sbi->used.bitmap.set_tail = true;
-       err = wnd_init(&sbi->used.bitmap, sbi->sb, tt);
+       err = wnd_init(&sbi->used.bitmap, sb, tt);
        if (err)
-               goto out;
+               goto put_inode_out;
 
        iput(inode);
 
@@ -1188,23 +1117,22 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        /* Load $AttrDef. */
        ref.low = cpu_to_le32(MFT_REC_ATTR);
        ref.seq = cpu_to_le16(MFT_REC_ATTR);
-       inode = ntfs_iget5(sbi->sb, &ref, &NAME_ATTRDEF);
+       inode = ntfs_iget5(sb, &ref, &NAME_ATTRDEF);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load $AttrDef -> %d", err);
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
        if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
                err = -EINVAL;
-               goto out;
+               goto put_inode_out;
        }
        bytes = inode->i_size;
        sbi->def_table = t = kmalloc(bytes, GFP_NOFS);
        if (!t) {
                err = -ENOMEM;
-               goto out;
+               goto put_inode_out;
        }
 
        for (done = idx = 0; done < bytes; done += PAGE_SIZE, idx++) {
@@ -1213,7 +1141,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
-                       goto out;
+                       goto put_inode_out;
                }
                memcpy(Add2Ptr(t, done), page_address(page),
                       min(PAGE_SIZE, tail));
@@ -1221,7 +1149,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
                if (!idx && ATTR_STD != t->type) {
                        err = -EINVAL;
-                       goto out;
+                       goto put_inode_out;
                }
        }
 
@@ -1254,33 +1182,24 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
        ref.seq = cpu_to_le16(MFT_REC_UPCASE);
        inode = ntfs_iget5(sb, &ref, &NAME_UPCASE);
        if (IS_ERR(inode)) {
+               ntfs_err(sb, "Failed to load $UpCase.");
                err = PTR_ERR(inode);
-               ntfs_err(sb, "Failed to load \x24LogFile.");
-               inode = NULL;
                goto out;
        }
 
-       ni = ntfs_i(inode);
-
        if (inode->i_size != 0x10000 * sizeof(short)) {
                err = -EINVAL;
-               goto out;
-       }
-
-       sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
-       if (!upcase) {
-               err = -ENOMEM;
-               goto out;
+               goto put_inode_out;
        }
 
        for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) {
                const __le16 *src;
-               u16 *dst = Add2Ptr(upcase, idx << PAGE_SHIFT);
+               u16 *dst = Add2Ptr(sbi->upcase, idx << PAGE_SHIFT);
                struct page *page = ntfs_map_page(inode->i_mapping, idx);
 
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
-                       goto out;
+                       goto put_inode_out;
                }
 
                src = page_address(page);
@@ -1294,14 +1213,13 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
                ntfs_unmap_page(page);
        }
 
-       shared = ntfs_set_shared(upcase, 0x10000 * sizeof(short));
-       if (shared && upcase != shared) {
+       shared = ntfs_set_shared(sbi->upcase, 0x10000 * sizeof(short));
+       if (shared && sbi->upcase != shared) {
+               kvfree(sbi->upcase);
                sbi->upcase = shared;
-               kvfree(upcase);
        }
 
        iput(inode);
-       inode = NULL;
 
        if (is_ntfs3(sbi)) {
                /* Load $Secure. */
@@ -1331,34 +1249,31 @@ load_root:
        ref.seq = cpu_to_le16(MFT_REC_ROOT);
        inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
        if (IS_ERR(inode)) {
-               err = PTR_ERR(inode);
                ntfs_err(sb, "Failed to load root.");
-               inode = NULL;
+               err = PTR_ERR(inode);
                goto out;
        }
 
-       ni = ntfs_i(inode);
-
        sb->s_root = d_make_root(inode);
-
        if (!sb->s_root) {
-               err = -EINVAL;
-               goto out;
+               err = -ENOMEM;
+               goto put_inode_out;
        }
 
+       fc->fs_private = NULL;
+
        return 0;
 
-out:
+put_inode_out:
        iput(inode);
-
-       if (sb->s_root) {
-               d_drop(sb->s_root);
-               sb->s_root = NULL;
-       }
-
+out:
+       /*
+        * Free resources here.
+        * ntfs_fs_free will be called with fc->s_fs_info = NULL
+        */
        put_ntfs(sbi);
-
        sb->s_fs_info = NULL;
+
        return err;
 }
 
@@ -1403,7 +1318,7 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len)
        if (sbi->flags & NTFS_FLAGS_NODISCARD)
                return -EOPNOTSUPP;
 
-       if (!sbi->options.discard)
+       if (!sbi->options->discard)
                return -EOPNOTSUPP;
 
        lbo = (u64)lcn << sbi->cluster_bits;
@@ -1428,19 +1343,99 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len)
        return err;
 }
 
-static struct dentry *ntfs_mount(struct file_system_type *fs_type, int flags,
-                                const char *dev_name, void *data)
+static int ntfs_fs_get_tree(struct fs_context *fc)
+{
+       return get_tree_bdev(fc, ntfs_fill_super);
+}
+
+/*
+ * ntfs_fs_free - Free fs_context.
+ *
+ * Note that this will be called after fill_super and reconfigure
+ * even when they pass. So they have to take pointers if they pass.
+ */
+static void ntfs_fs_free(struct fs_context *fc)
 {
-       return mount_bdev(fs_type, flags, dev_name, data, ntfs_fill_super);
+       struct ntfs_mount_options *opts = fc->fs_private;
+       struct ntfs_sb_info *sbi = fc->s_fs_info;
+
+       if (sbi)
+               put_ntfs(sbi);
+
+       if (opts)
+               put_mount_options(opts);
+}
+
+static const struct fs_context_operations ntfs_context_ops = {
+       .parse_param    = ntfs_fs_parse_param,
+       .get_tree       = ntfs_fs_get_tree,
+       .reconfigure    = ntfs_fs_reconfigure,
+       .free           = ntfs_fs_free,
+};
+
+/*
+ * ntfs_init_fs_context - Initialize spi and opts
+ *
+ * This will called when mount/remount. We will first initiliaze
+ * options so that if remount we can use just that.
+ */
+static int ntfs_init_fs_context(struct fs_context *fc)
+{
+       struct ntfs_mount_options *opts;
+       struct ntfs_sb_info *sbi;
+
+       opts = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS);
+       if (!opts)
+               return -ENOMEM;
+
+       /* Default options. */
+       opts->fs_uid = current_uid();
+       opts->fs_gid = current_gid();
+       opts->fs_fmask_inv = ~current_umask();
+       opts->fs_dmask_inv = ~current_umask();
+
+       if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE)
+               goto ok;
+
+       sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
+       if (!sbi)
+               goto free_opts;
+
+       sbi->upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
+       if (!sbi->upcase)
+               goto free_sbi;
+
+       ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL,
+                            DEFAULT_RATELIMIT_BURST);
+
+       mutex_init(&sbi->compress.mtx_lznt);
+#ifdef CONFIG_NTFS3_LZX_XPRESS
+       mutex_init(&sbi->compress.mtx_xpress);
+       mutex_init(&sbi->compress.mtx_lzx);
+#endif
+
+       sbi->options = opts;
+       fc->s_fs_info = sbi;
+ok:
+       fc->fs_private = opts;
+       fc->ops = &ntfs_context_ops;
+
+       return 0;
+free_sbi:
+       kfree(sbi);
+free_opts:
+       kfree(opts);
+       return -ENOMEM;
 }
 
 // clang-format off
 static struct file_system_type ntfs_fs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "ntfs3",
-       .mount          = ntfs_mount,
-       .kill_sb        = kill_block_super,
-       .fs_flags       = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
+       .owner                  = THIS_MODULE,
+       .name                   = "ntfs3",
+       .init_fs_context        = ntfs_init_fs_context,
+       .parameters             = ntfs_fs_parameters,
+       .kill_sb                = kill_block_super,
+       .fs_flags               = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
 };
 // clang-format on
 
index bbeba778237eefc318b00e04b05ad0ac1592e1ec..b5e8256fd710d5263b2be07b92df14cb8eea3c35 100644 (file)
@@ -5,13 +5,9 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
-#include <linux/module.h>
-#include <linux/nls.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
 
-#include "debug.h"
-#include "ntfs.h"
 #include "ntfs_fs.h"
 
 static inline u16 upcase_unicode_char(const u16 *upcase, u16 chr)
index 7282d85c4ece447c42118b81ae82d9924003a0ce..afd0ddad826ff49f661ce758bcbecec46921fd1c 100644 (file)
@@ -5,10 +5,7 @@
  *
  */
 
-#include <linux/blkdev.h>
-#include <linux/buffer_head.h>
 #include <linux/fs.h>
-#include <linux/nls.h>
 #include <linux/posix_acl.h>
 #include <linux/posix_acl_xattr.h>
 #include <linux/xattr.h>
@@ -78,6 +75,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
                        size_t add_bytes, const struct EA_INFO **info)
 {
        int err;
+       struct ntfs_sb_info *sbi = ni->mi.sbi;
        struct ATTR_LIST_ENTRY *le = NULL;
        struct ATTRIB *attr_info, *attr_ea;
        void *ea_p;
@@ -102,10 +100,10 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
 
        /* Check Ea limit. */
        size = le32_to_cpu((*info)->size);
-       if (size > ni->mi.sbi->ea_max_size)
+       if (size > sbi->ea_max_size)
                return -EFBIG;
 
-       if (attr_size(attr_ea) > ni->mi.sbi->ea_max_size)
+       if (attr_size(attr_ea) > sbi->ea_max_size)
                return -EFBIG;
 
        /* Allocate memory for packed Ea. */
@@ -113,15 +111,16 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
        if (!ea_p)
                return -ENOMEM;
 
-       if (attr_ea->non_res) {
+       if (!size) {
+               ;
+       } else if (attr_ea->non_res) {
                struct runs_tree run;
 
                run_init(&run);
 
                err = attr_load_runs(attr_ea, ni, &run, NULL);
                if (!err)
-                       err = ntfs_read_run_nb(ni->mi.sbi, &run, 0, ea_p, size,
-                                              NULL);
+                       err = ntfs_read_run_nb(sbi, &run, 0, ea_p, size, NULL);
                run_close(&run);
 
                if (err)
@@ -260,7 +259,7 @@ out:
 
 static noinline int ntfs_set_ea(struct inode *inode, const char *name,
                                size_t name_len, const void *value,
-                               size_t val_size, int flags, int locked)
+                               size_t val_size, int flags)
 {
        struct ntfs_inode *ni = ntfs_i(inode);
        struct ntfs_sb_info *sbi = ni->mi.sbi;
@@ -279,8 +278,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
        u64 new_sz;
        void *p;
 
-       if (!locked)
-               ni_lock(ni);
+       ni_lock(ni);
 
        run_init(&ea_run);
 
@@ -370,21 +368,22 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
        new_ea->name[name_len] = 0;
        memcpy(new_ea->name + name_len + 1, value, val_size);
        new_pack = le16_to_cpu(ea_info.size_pack) + packed_ea_size(new_ea);
-
-       /* Should fit into 16 bits. */
-       if (new_pack > 0xffff) {
-               err = -EFBIG; // -EINVAL?
-               goto out;
-       }
        ea_info.size_pack = cpu_to_le16(new_pack);
-
        /* New size of ATTR_EA. */
        size += add;
-       if (size > sbi->ea_max_size) {
+       ea_info.size = cpu_to_le32(size);
+
+       /*
+        * 1. Check ea_info.size_pack for overflow.
+        * 2. New attibute size must fit value from $AttrDef
+        */
+       if (new_pack > 0xffff || size > sbi->ea_max_size) {
+               ntfs_inode_warn(
+                       inode,
+                       "The size of extended attributes must not exceed 64KiB");
                err = -EFBIG; // -EINVAL?
                goto out;
        }
-       ea_info.size = cpu_to_le32(size);
 
 update_ea:
 
@@ -444,7 +443,7 @@ update_ea:
                /* Delete xattr, ATTR_EA */
                ni_remove_attr_le(ni, attr, mi, le);
        } else if (attr->non_res) {
-               err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size);
+               err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
                if (err)
                        goto out;
        } else {
@@ -468,8 +467,7 @@ update_ea:
        mark_inode_dirty(&ni->vfs_inode);
 
 out:
-       if (!locked)
-               ni_unlock(ni);
+       ni_unlock(ni);
 
        run_close(&ea_run);
        kfree(ea_all);
@@ -478,12 +476,6 @@ out:
 }
 
 #ifdef CONFIG_NTFS3_FS_POSIX_ACL
-static inline void ntfs_posix_acl_release(struct posix_acl *acl)
-{
-       if (acl && refcount_dec_and_test(&acl->a_refcount))
-               kfree(acl);
-}
-
 static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
                                         struct inode *inode, int type,
                                         int locked)
@@ -521,12 +513,15 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
        /* Translate extended attribute to acl. */
        if (err >= 0) {
                acl = posix_acl_from_xattr(mnt_userns, buf, err);
-               if (!IS_ERR(acl))
-                       set_cached_acl(inode, type, acl);
+       } else if (err == -ENODATA) {
+               acl = NULL;
        } else {
-               acl = err == -ENODATA ? NULL : ERR_PTR(err);
+               acl = ERR_PTR(err);
        }
 
+       if (!IS_ERR(acl))
+               set_cached_acl(inode, type, acl);
+
        __putname(buf);
 
        return acl;
@@ -546,12 +541,13 @@ struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu)
 
 static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
                                    struct inode *inode, struct posix_acl *acl,
-                                   int type, int locked)
+                                   int type)
 {
        const char *name;
        size_t size, name_len;
        void *value = NULL;
        int err = 0;
+       int flags;
 
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
@@ -561,22 +557,15 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
                if (acl) {
                        umode_t mode = inode->i_mode;
 
-                       err = posix_acl_equiv_mode(acl, &mode);
-                       if (err < 0)
-                               return err;
+                       err = posix_acl_update_mode(mnt_userns, inode, &mode,
+                                                   &acl);
+                       if (err)
+                               goto out;
 
                        if (inode->i_mode != mode) {
                                inode->i_mode = mode;
                                mark_inode_dirty(inode);
                        }
-
-                       if (!err) {
-                               /*
-                                * ACL can be exactly represented in the
-                                * traditional file mode permission bits.
-                                */
-                               acl = NULL;
-                       }
                }
                name = XATTR_NAME_POSIX_ACL_ACCESS;
                name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
@@ -594,20 +583,24 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
        }
 
        if (!acl) {
+               /* Remove xattr if it can be presented via mode. */
                size = 0;
                value = NULL;
+               flags = XATTR_REPLACE;
        } else {
                size = posix_acl_xattr_size(acl->a_count);
                value = kmalloc(size, GFP_NOFS);
                if (!value)
                        return -ENOMEM;
-
                err = posix_acl_to_xattr(mnt_userns, acl, value, size);
                if (err < 0)
                        goto out;
+               flags = 0;
        }
 
-       err = ntfs_set_ea(inode, name, name_len, value, size, 0, locked);
+       err = ntfs_set_ea(inode, name, name_len, value, size, flags);
+       if (err == -ENODATA && !size)
+               err = 0; /* Removing non existed xattr. */
        if (!err)
                set_cached_acl(inode, type, acl);
 
@@ -623,68 +616,7 @@ out:
 int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
                 struct posix_acl *acl, int type)
 {
-       return ntfs_set_acl_ex(mnt_userns, inode, acl, type, 0);
-}
-
-static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
-                             struct inode *inode, int type, void *buffer,
-                             size_t size)
-{
-       struct posix_acl *acl;
-       int err;
-
-       if (!(inode->i_sb->s_flags & SB_POSIXACL)) {
-               ntfs_inode_warn(inode, "add mount option \"acl\" to use acl");
-               return -EOPNOTSUPP;
-       }
-
-       acl = ntfs_get_acl(inode, type, false);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-
-       if (!acl)
-               return -ENODATA;
-
-       err = posix_acl_to_xattr(mnt_userns, acl, buffer, size);
-       ntfs_posix_acl_release(acl);
-
-       return err;
-}
-
-static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
-                             struct inode *inode, int type, const void *value,
-                             size_t size)
-{
-       struct posix_acl *acl;
-       int err;
-
-       if (!(inode->i_sb->s_flags & SB_POSIXACL)) {
-               ntfs_inode_warn(inode, "add mount option \"acl\" to use acl");
-               return -EOPNOTSUPP;
-       }
-
-       if (!inode_owner_or_capable(mnt_userns, inode))
-               return -EPERM;
-
-       if (!value) {
-               acl = NULL;
-       } else {
-               acl = posix_acl_from_xattr(mnt_userns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-
-               if (acl) {
-                       err = posix_acl_valid(mnt_userns, acl);
-                       if (err)
-                               goto release_and_out;
-               }
-       }
-
-       err = ntfs_set_acl(mnt_userns, inode, acl, type);
-
-release_and_out:
-       ntfs_posix_acl_release(acl);
-       return err;
+       return ntfs_set_acl_ex(mnt_userns, inode, acl, type);
 }
 
 /*
@@ -698,54 +630,27 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
        struct posix_acl *default_acl, *acl;
        int err;
 
-       /*
-        * TODO: Refactoring lock.
-        * ni_lock(dir) ... -> posix_acl_create(dir,...) -> ntfs_get_acl -> ni_lock(dir)
-        */
-       inode->i_default_acl = NULL;
-
-       default_acl = ntfs_get_acl_ex(mnt_userns, dir, ACL_TYPE_DEFAULT, 1);
-
-       if (!default_acl || default_acl == ERR_PTR(-EOPNOTSUPP)) {
-               inode->i_mode &= ~current_umask();
-               err = 0;
-               goto out;
-       }
-
-       if (IS_ERR(default_acl)) {
-               err = PTR_ERR(default_acl);
-               goto out;
-       }
-
-       acl = default_acl;
-       err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
-       if (err < 0)
-               goto out1;
-       if (!err) {
-               posix_acl_release(acl);
-               acl = NULL;
-       }
+       err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (err)
+               return err;
 
-       if (!S_ISDIR(inode->i_mode)) {
+       if (default_acl) {
+               err = ntfs_set_acl_ex(mnt_userns, inode, default_acl,
+                                     ACL_TYPE_DEFAULT);
                posix_acl_release(default_acl);
-               default_acl = NULL;
+       } else {
+               inode->i_default_acl = NULL;
        }
 
-       if (default_acl)
-               err = ntfs_set_acl_ex(mnt_userns, inode, default_acl,
-                                     ACL_TYPE_DEFAULT, 1);
-
        if (!acl)
                inode->i_acl = NULL;
-       else if (!err)
-               err = ntfs_set_acl_ex(mnt_userns, inode, acl, ACL_TYPE_ACCESS,
-                                     1);
-
-       posix_acl_release(acl);
-out1:
-       posix_acl_release(default_acl);
+       else {
+               if (!err)
+                       err = ntfs_set_acl_ex(mnt_userns, inode, acl,
+                                             ACL_TYPE_ACCESS);
+               posix_acl_release(acl);
+       }
 
-out:
        return err;
 }
 #endif
@@ -772,7 +677,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
                    int mask)
 {
-       if (ntfs_sb(inode->i_sb)->options.no_acs_rules) {
+       if (ntfs_sb(inode->i_sb)->options->noacsrules) {
                /* "No access rules" mode - Allow all changes. */
                return 0;
        }
@@ -880,23 +785,6 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
                goto out;
        }
 
-#ifdef CONFIG_NTFS3_FS_POSIX_ACL
-       if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 &&
-            !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
-                    sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) ||
-           (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 &&
-            !memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
-                    sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
-               /* TODO: init_user_ns? */
-               err = ntfs_xattr_get_acl(
-                       &init_user_ns, inode,
-                       name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
-                               ? ACL_TYPE_ACCESS
-                               : ACL_TYPE_DEFAULT,
-                       buffer, size);
-               goto out;
-       }
-#endif
        /* Deal with NTFS extended attribute. */
        err = ntfs_get_ea(inode, name, name_len, buffer, size, NULL);
 
@@ -1009,24 +897,8 @@ set_new_fa:
                goto out;
        }
 
-#ifdef CONFIG_NTFS3_FS_POSIX_ACL
-       if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 &&
-            !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS,
-                    sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) ||
-           (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 &&
-            !memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
-                    sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
-               err = ntfs_xattr_set_acl(
-                       mnt_userns, inode,
-                       name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
-                               ? ACL_TYPE_ACCESS
-                               : ACL_TYPE_DEFAULT,
-                       value, size);
-               goto out;
-       }
-#endif
        /* Deal with NTFS extended attribute. */
-       err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
+       err = ntfs_set_ea(inode, name, name_len, value, size, flags);
 
 out:
        return err;
@@ -1042,28 +914,29 @@ int ntfs_save_wsl_perm(struct inode *inode)
        int err;
        __le32 value;
 
+       /* TODO: refactor this, so we don't lock 4 times in ntfs_set_ea */
        value = cpu_to_le32(i_uid_read(inode));
        err = ntfs_set_ea(inode, "$LXUID", sizeof("$LXUID") - 1, &value,
-                         sizeof(value), 0, 0);
+                         sizeof(value), 0);
        if (err)
                goto out;
 
        value = cpu_to_le32(i_gid_read(inode));
        err = ntfs_set_ea(inode, "$LXGID", sizeof("$LXGID") - 1, &value,
-                         sizeof(value), 0, 0);
+                         sizeof(value), 0);
        if (err)
                goto out;
 
        value = cpu_to_le32(inode->i_mode);
        err = ntfs_set_ea(inode, "$LXMOD", sizeof("$LXMOD") - 1, &value,
-                         sizeof(value), 0, 0);
+                         sizeof(value), 0);
        if (err)
                goto out;
 
        if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
                value = cpu_to_le32(inode->i_rdev);
                err = ntfs_set_ea(inode, "$LXDEV", sizeof("$LXDEV") - 1, &value,
-                                 sizeof(value), 0, 0);
+                                 sizeof(value), 0);
                if (err)
                        goto out;
        }
index 24b40e5c160b2b43bdbe58bfedfc58ba2855aeff..018e776a34b9a90c06a0b2540b5aa0b0ef7fa36b 100644 (file)
@@ -613,7 +613,7 @@ void kunit_remove_resource(struct kunit *test, struct kunit_resource *res);
  * and is automatically cleaned up after the test case concludes. See &struct
  * kunit_resource for more information.
  */
-void *kunit_kmalloc_array(struct kunit *test, size_t n, size_t size, gfp_t flags);
+void *kunit_kmalloc_array(struct kunit *test, size_t n, size_t size, gfp_t gfp);
 
 /**
  * kunit_kmalloc() - Like kmalloc() except the allocation is *test managed*.
@@ -657,9 +657,9 @@ static inline void *kunit_kzalloc(struct kunit *test, size_t size, gfp_t gfp)
  *
  * See kcalloc() and kunit_kmalloc_array() for more information.
  */
-static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp_t flags)
+static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp_t gfp)
 {
-       return kunit_kmalloc_array(test, n, size, flags | __GFP_ZERO);
+       return kunit_kmalloc_array(test, n, size, gfp | __GFP_ZERO);
 }
 
 void kunit_cleanup(struct kunit *test);
diff --git a/include/linux/dsa/mv88e6xxx.h b/include/linux/dsa/mv88e6xxx.h
new file mode 100644 (file)
index 0000000..8c3d45e
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0
+ * Copyright 2021 NXP
+ */
+
+#ifndef _NET_DSA_TAG_MV88E6XXX_H
+#define _NET_DSA_TAG_MV88E6XXX_H
+
+#include <linux/if_vlan.h>
+
+#define MV88E6XXX_VID_STANDALONE       0
+#define MV88E6XXX_VID_BRIDGED          (VLAN_N_VID - 1)
+
+#endif
index 435777a0073c76d3f760b0b43b1b5aaf7ea7cdbd..8ae999f587c48eb74b7c018a479a4d6eb836b2fe 100644 (file)
@@ -5,7 +5,28 @@
 #ifndef _NET_DSA_TAG_OCELOT_H
 #define _NET_DSA_TAG_OCELOT_H
 
+#include <linux/kthread.h>
 #include <linux/packing.h>
+#include <linux/skbuff.h>
+
+struct ocelot_skb_cb {
+       struct sk_buff *clone;
+       unsigned int ptp_class; /* valid only for clones */
+       u8 ptp_cmd;
+       u8 ts_id;
+};
+
+#define OCELOT_SKB_CB(skb) \
+       ((struct ocelot_skb_cb *)((skb)->cb))
+
+#define IFH_TAG_TYPE_C                 0
+#define IFH_TAG_TYPE_S                 1
+
+#define IFH_REW_OP_NOOP                        0x0
+#define IFH_REW_OP_DSCP                        0x1
+#define IFH_REW_OP_ONE_STEP_PTP                0x2
+#define IFH_REW_OP_TWO_STEP_PTP                0x3
+#define IFH_REW_OP_ORIGIN_PTP          0x5
 
 #define OCELOT_TAG_LEN                 16
 #define OCELOT_SHORT_PREFIX_LEN                4
  *         +------+------+------+------+------+------+------+------+
  */
 
+struct felix_deferred_xmit_work {
+       struct dsa_port *dp;
+       struct sk_buff *skb;
+       struct kthread_work work;
+};
+
+struct felix_port {
+       void (*xmit_work_fn)(struct kthread_work *work);
+       struct kthread_worker *xmit_worker;
+};
+
 static inline void ocelot_xfh_get_rew_val(void *extraction, u64 *rew_val)
 {
        packing(extraction, rew_val, 116, 85, OCELOT_TAG_LEN, UNPACK, 0);
@@ -215,4 +247,21 @@ static inline void ocelot_ifh_set_vid(void *injection, u64 vid)
        packing(injection, &vid, 11, 0, OCELOT_TAG_LEN, PACK, 0);
 }
 
+/* Determine the PTP REW_OP to use for injecting the given skb */
+static inline u32 ocelot_ptp_rew_op(struct sk_buff *skb)
+{
+       struct sk_buff *clone = OCELOT_SKB_CB(skb)->clone;
+       u8 ptp_cmd = OCELOT_SKB_CB(skb)->ptp_cmd;
+       u32 rew_op = 0;
+
+       if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP && clone) {
+               rew_op = ptp_cmd;
+               rew_op |= OCELOT_SKB_CB(clone)->ts_id << 3;
+       } else if (ptp_cmd == IFH_REW_OP_ORIGIN_PTP) {
+               rew_op = ptp_cmd;
+       }
+
+       return rew_op;
+}
+
 #endif
index 171106202fe5bef538778f5bd681223e6c430421..9e07079528a53fe39e3e4974998785cefcecd47d 100644 (file)
@@ -48,6 +48,10 @@ struct sja1105_tagger_data {
        spinlock_t meta_lock;
        unsigned long state;
        u8 ts_id;
+       /* Used on SJA1110 where meta frames are generated only for
+        * 2-step TX timestamps
+        */
+       struct sk_buff_head skb_txtstamp_queue;
 };
 
 struct sja1105_skb_cb {
@@ -69,42 +73,24 @@ struct sja1105_port {
        bool hwts_tx_en;
 };
 
-enum sja1110_meta_tstamp {
-       SJA1110_META_TSTAMP_TX = 0,
-       SJA1110_META_TSTAMP_RX = 1,
-};
-
-#if IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP)
-
-void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port, u8 ts_id,
-                                enum sja1110_meta_tstamp dir, u64 tstamp);
-
-#else
+/* Timestamps are in units of 8 ns clock ticks (equivalent to
+ * a fixed 125 MHz clock).
+ */
+#define SJA1105_TICK_NS                        8
 
-static inline void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port,
-                                              u8 ts_id, enum sja1110_meta_tstamp dir,
-                                              u64 tstamp)
+static inline s64 ns_to_sja1105_ticks(s64 ns)
 {
+       return ns / SJA1105_TICK_NS;
 }
 
-#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_PTP) */
-
-#if IS_ENABLED(CONFIG_NET_DSA_SJA1105)
-
-extern const struct dsa_switch_ops sja1105_switch_ops;
-
-static inline bool dsa_port_is_sja1105(struct dsa_port *dp)
+static inline s64 sja1105_ticks_to_ns(s64 ticks)
 {
-       return dp->ds->ops == &sja1105_switch_ops;
+       return ticks * SJA1105_TICK_NS;
 }
 
-#else
-
 static inline bool dsa_port_is_sja1105(struct dsa_port *dp)
 {
-       return false;
+       return true;
 }
 
-#endif
-
 #endif /* _NET_DSA_SJA1105_H */
index f3638d09ba776468ec0f84439d0116e791993d18..993204a6c1a1376e47490ab0f72e0254921f85d3 100644 (file)
@@ -9475,16 +9475,22 @@ struct mlx5_ifc_pcmr_reg_bits {
        u8         reserved_at_0[0x8];
        u8         local_port[0x8];
        u8         reserved_at_10[0x10];
+
        u8         entropy_force_cap[0x1];
        u8         entropy_calc_cap[0x1];
        u8         entropy_gre_calc_cap[0x1];
-       u8         reserved_at_23[0x1b];
+       u8         reserved_at_23[0xf];
+       u8         rx_ts_over_crc_cap[0x1];
+       u8         reserved_at_33[0xb];
        u8         fcs_cap[0x1];
        u8         reserved_at_3f[0x1];
+
        u8         entropy_force[0x1];
        u8         entropy_calc[0x1];
        u8         entropy_gre_calc[0x1];
-       u8         reserved_at_43[0x1b];
+       u8         reserved_at_43[0xf];
+       u8         rx_ts_over_crc[0x1];
+       u8         reserved_at_53[0xb];
        u8         fcs_chk[0x1];
        u8         reserved_at_5f[0x1];
 };
index 8371bca13729b9f9541730fdcf52b1c664ffd619..6b0b686f6f9042ec732ca3b2476656a07a1adc6a 100644 (file)
@@ -531,6 +531,9 @@ struct spi_controller {
        /* I/O mutex */
        struct mutex            io_mutex;
 
+       /* Used to avoid adding the same CS twice */
+       struct mutex            add_lock;
+
        /* lock and mutex for SPI bus locking */
        spinlock_t              bus_lock_spinlock;
        struct mutex            bus_lock_mutex;
index 2ebef6b1a3d6cd8f429be752b14c110acff63f90..74d3c1efd9bb5c8d8d6507f5f9a0ff607d893789 100644 (file)
@@ -399,9 +399,8 @@ extern struct workqueue_struct *system_freezable_power_efficient_wq;
  * RETURNS:
  * Pointer to the allocated workqueue on success, %NULL on failure.
  */
-struct workqueue_struct *alloc_workqueue(const char *fmt,
-                                        unsigned int flags,
-                                        int max_active, ...);
+__printf(1, 4) struct workqueue_struct *
+alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
 
 /**
  * alloc_ordered_workqueue - allocate an ordered workqueue
index 06706a9fd5b1c2d1a1e5dc4ad03ff5a5e32983ef..d7055b41982dfaa7f99189728c14b1cd0316dbc9 100644 (file)
 /* Source PGIDs, one per physical port */
 #define PGID_SRC                       80
 
-#define IFH_TAG_TYPE_C                 0
-#define IFH_TAG_TYPE_S                 1
-
-#define IFH_REW_OP_NOOP                        0x0
-#define IFH_REW_OP_DSCP                        0x1
-#define IFH_REW_OP_ONE_STEP_PTP                0x2
-#define IFH_REW_OP_TWO_STEP_PTP                0x3
-#define IFH_REW_OP_ORIGIN_PTP          0x5
-
 #define OCELOT_NUM_TC                  8
 
 #define OCELOT_SPEED_2500              0
@@ -603,10 +594,10 @@ struct ocelot_port {
        /* The VLAN ID that will be transmitted as untagged, on egress */
        struct ocelot_vlan              native_vlan;
 
+       unsigned int                    ptp_skbs_in_flight;
        u8                              ptp_cmd;
        struct sk_buff_head             tx_skbs;
        u8                              ts_id;
-       spinlock_t                      ts_id_lock;
 
        phy_interface_t                 phy_mode;
 
@@ -680,6 +671,9 @@ struct ocelot {
        struct ptp_clock                *ptp_clock;
        struct ptp_clock_info           ptp_info;
        struct hwtstamp_config          hwtstamp_config;
+       unsigned int                    ptp_skbs_in_flight;
+       /* Protects the 2-step TX timestamp ID logic */
+       spinlock_t                      ts_id_lock;
        /* Protects the PTP interface state */
        struct mutex                    ptp_lock;
        /* Protects the PTP clock */
@@ -692,15 +686,6 @@ struct ocelot_policer {
        u32 burst; /* bytes */
 };
 
-struct ocelot_skb_cb {
-       struct sk_buff *clone;
-       u8 ptp_cmd;
-       u8 ts_id;
-};
-
-#define OCELOT_SKB_CB(skb) \
-       ((struct ocelot_skb_cb *)((skb)->cb))
-
 #define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
 #define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
 #define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
@@ -752,8 +737,6 @@ u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target,
 void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target,
                              u32 val, u32 reg, u32 offset);
 
-#if IS_ENABLED(CONFIG_MSCC_OCELOT_SWITCH_LIB)
-
 /* Packet I/O */
 bool ocelot_can_inject(struct ocelot *ocelot, int grp);
 void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
@@ -761,36 +744,6 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
 int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **skb);
 void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp);
 
-u32 ocelot_ptp_rew_op(struct sk_buff *skb);
-#else
-
-static inline bool ocelot_can_inject(struct ocelot *ocelot, int grp)
-{
-       return false;
-}
-
-static inline void ocelot_port_inject_frame(struct ocelot *ocelot, int port,
-                                           int grp, u32 rew_op,
-                                           struct sk_buff *skb)
-{
-}
-
-static inline int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp,
-                                       struct sk_buff **skb)
-{
-       return -EIO;
-}
-
-static inline void ocelot_drain_cpu_queue(struct ocelot *ocelot, int grp)
-{
-}
-
-static inline u32 ocelot_ptp_rew_op(struct sk_buff *skb)
-{
-       return 0;
-}
-#endif
-
 /* Hardware initialization */
 int ocelot_regfields_init(struct ocelot *ocelot,
                          const struct reg_field *const regfields);
index ded497d72bdbbcad572be9636416b04bf24c8546..f085884b1fa27ffc14293deb5a3a7bb8083b5662 100644 (file)
@@ -13,6 +13,9 @@
 #include <linux/ptp_clock_kernel.h>
 #include <soc/mscc/ocelot.h>
 
+#define OCELOT_MAX_PTP_ID              63
+#define OCELOT_PTP_FIFO_SIZE           128
+
 #define PTP_PIN_CFG_RSZ                        0x20
 #define PTP_PIN_TOD_SEC_MSB_RSZ                PTP_PIN_CFG_RSZ
 #define PTP_PIN_TOD_SEC_LSB_RSZ                PTP_PIN_CFG_RSZ
index 01570dbda503850a0a7eb5fb2da4cc3d806401e1..0e45963bb767f767f85eeb59e8bc6dc8603959a2 100644 (file)
@@ -224,6 +224,7 @@ struct hda_codec {
 #endif
 
        /* misc flags */
+       unsigned int configured:1; /* codec was configured */
        unsigned int in_freeing:1; /* being released */
        unsigned int registered:1; /* codec was registered */
        unsigned int display_power_control:1; /* needs display power */
index df1ccf4558f8242904aad112bdf86f68ed3fa76b..2a9695ccb65f539c713fdce1cc9bb2fd15c4779f 100644 (file)
@@ -311,17 +311,19 @@ static struct cpuset top_cpuset = {
                if (is_cpuset_online(((des_cs) = css_cs((pos_css)))))
 
 /*
- * There are two global locks guarding cpuset structures - cpuset_mutex and
+ * There are two global locks guarding cpuset structures - cpuset_rwsem and
  * callback_lock. We also require taking task_lock() when dereferencing a
  * task's cpuset pointer. See "The task_lock() exception", at the end of this
- * comment.
+ * comment.  The cpuset code uses only cpuset_rwsem write lock.  Other
+ * kernel subsystems can use cpuset_read_lock()/cpuset_read_unlock() to
+ * prevent change to cpuset structures.
  *
  * A task must hold both locks to modify cpusets.  If a task holds
- * cpuset_mutex, then it blocks others wanting that mutex, ensuring that it
+ * cpuset_rwsem, it blocks others wanting that rwsem, ensuring that it
  * is the only task able to also acquire callback_lock and be able to
  * modify cpusets.  It can perform various checks on the cpuset structure
  * first, knowing nothing will change.  It can also allocate memory while
- * just holding cpuset_mutex.  While it is performing these checks, various
+ * just holding cpuset_rwsem.  While it is performing these checks, various
  * callback routines can briefly acquire callback_lock to query cpusets.
  * Once it is ready to make the changes, it takes callback_lock, blocking
  * everyone else.
@@ -393,7 +395,7 @@ static inline bool is_in_v2_mode(void)
  * One way or another, we guarantee to return some non-empty subset
  * of cpu_online_mask.
  *
- * Call with callback_lock or cpuset_mutex held.
+ * Call with callback_lock or cpuset_rwsem held.
  */
 static void guarantee_online_cpus(struct task_struct *tsk,
                                  struct cpumask *pmask)
@@ -435,7 +437,7 @@ out_unlock:
  * One way or another, we guarantee to return some non-empty subset
  * of node_states[N_MEMORY].
  *
- * Call with callback_lock or cpuset_mutex held.
+ * Call with callback_lock or cpuset_rwsem held.
  */
 static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask)
 {
@@ -447,7 +449,7 @@ static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask)
 /*
  * update task's spread flag if cpuset's page/slab spread flag is set
  *
- * Call with callback_lock or cpuset_mutex held.
+ * Call with callback_lock or cpuset_rwsem held.
  */
 static void cpuset_update_task_spread_flag(struct cpuset *cs,
                                        struct task_struct *tsk)
@@ -468,7 +470,7 @@ static void cpuset_update_task_spread_flag(struct cpuset *cs,
  *
  * One cpuset is a subset of another if all its allowed CPUs and
  * Memory Nodes are a subset of the other, and its exclusive flags
- * are only set if the other's are set.  Call holding cpuset_mutex.
+ * are only set if the other's are set.  Call holding cpuset_rwsem.
  */
 
 static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
@@ -577,7 +579,7 @@ static inline void free_cpuset(struct cpuset *cs)
  * If we replaced the flag and mask values of the current cpuset
  * (cur) with those values in the trial cpuset (trial), would
  * our various subset and exclusive rules still be valid?  Presumes
- * cpuset_mutex held.
+ * cpuset_rwsem held.
  *
  * 'cur' is the address of an actual, in-use cpuset.  Operations
  * such as list traversal that depend on the actual address of the
@@ -700,7 +702,7 @@ static void update_domain_attr_tree(struct sched_domain_attr *dattr,
        rcu_read_unlock();
 }
 
-/* Must be called with cpuset_mutex held.  */
+/* Must be called with cpuset_rwsem held.  */
 static inline int nr_cpusets(void)
 {
        /* jump label reference count + the top-level cpuset */
@@ -726,7 +728,7 @@ static inline int nr_cpusets(void)
  * domains when operating in the severe memory shortage situations
  * that could cause allocation failures below.
  *
- * Must be called with cpuset_mutex held.
+ * Must be called with cpuset_rwsem held.
  *
  * The three key local variables below are:
  *    cp - cpuset pointer, used (together with pos_css) to perform a
@@ -1005,7 +1007,7 @@ partition_and_rebuild_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
  * 'cpus' is removed, then call this routine to rebuild the
  * scheduler's dynamic sched domains.
  *
- * Call with cpuset_mutex held.  Takes cpus_read_lock().
+ * Call with cpuset_rwsem held.  Takes cpus_read_lock().
  */
 static void rebuild_sched_domains_locked(void)
 {
@@ -1078,7 +1080,7 @@ void rebuild_sched_domains(void)
  * @cs: the cpuset in which each task's cpus_allowed mask needs to be changed
  *
  * Iterate through each task of @cs updating its cpus_allowed to the
- * effective cpuset's.  As this function is called with cpuset_mutex held,
+ * effective cpuset's.  As this function is called with cpuset_rwsem held,
  * cpuset membership stays stable.
  */
 static void update_tasks_cpumask(struct cpuset *cs)
@@ -1347,7 +1349,7 @@ static int update_parent_subparts_cpumask(struct cpuset *cpuset, int cmd,
  *
  * On legacy hierarchy, effective_cpus will be the same with cpu_allowed.
  *
- * Called with cpuset_mutex held
+ * Called with cpuset_rwsem held
  */
 static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp)
 {
@@ -1704,12 +1706,12 @@ static void *cpuset_being_rebound;
  * @cs: the cpuset in which each task's mems_allowed mask needs to be changed
  *
  * Iterate through each task of @cs updating its mems_allowed to the
- * effective cpuset's.  As this function is called with cpuset_mutex held,
+ * effective cpuset's.  As this function is called with cpuset_rwsem held,
  * cpuset membership stays stable.
  */
 static void update_tasks_nodemask(struct cpuset *cs)
 {
-       static nodemask_t newmems;      /* protected by cpuset_mutex */
+       static nodemask_t newmems;      /* protected by cpuset_rwsem */
        struct css_task_iter it;
        struct task_struct *task;
 
@@ -1722,7 +1724,7 @@ static void update_tasks_nodemask(struct cpuset *cs)
         * take while holding tasklist_lock.  Forks can happen - the
         * mpol_dup() cpuset_being_rebound check will catch such forks,
         * and rebind their vma mempolicies too.  Because we still hold
-        * the global cpuset_mutex, we know that no other rebind effort
+        * the global cpuset_rwsem, we know that no other rebind effort
         * will be contending for the global variable cpuset_being_rebound.
         * It's ok if we rebind the same mm twice; mpol_rebind_mm()
         * is idempotent.  Also migrate pages in each mm to new nodes.
@@ -1768,7 +1770,7 @@ static void update_tasks_nodemask(struct cpuset *cs)
  *
  * On legacy hierarchy, effective_mems will be the same with mems_allowed.
  *
- * Called with cpuset_mutex held
+ * Called with cpuset_rwsem held
  */
 static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
 {
@@ -1821,7 +1823,7 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)
  * mempolicies and if the cpuset is marked 'memory_migrate',
  * migrate the tasks pages to the new memory.
  *
- * Call with cpuset_mutex held. May take callback_lock during call.
+ * Call with cpuset_rwsem held. May take callback_lock during call.
  * Will take tasklist_lock, scan tasklist for tasks in cpuset cs,
  * lock each such tasks mm->mmap_lock, scan its vma's and rebind
  * their mempolicies to the cpusets new mems_allowed.
@@ -1911,7 +1913,7 @@ static int update_relax_domain_level(struct cpuset *cs, s64 val)
  * @cs: the cpuset in which each task's spread flags needs to be changed
  *
  * Iterate through each task of @cs updating its spread flags.  As this
- * function is called with cpuset_mutex held, cpuset membership stays
+ * function is called with cpuset_rwsem held, cpuset membership stays
  * stable.
  */
 static void update_tasks_flags(struct cpuset *cs)
@@ -1931,7 +1933,7 @@ static void update_tasks_flags(struct cpuset *cs)
  * cs:         the cpuset to update
  * turning_on:         whether the flag is being set or cleared
  *
- * Call with cpuset_mutex held.
+ * Call with cpuset_rwsem held.
  */
 
 static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs,
@@ -1980,7 +1982,7 @@ out:
  * cs: the cpuset to update
  * new_prs: new partition root state
  *
- * Call with cpuset_mutex held.
+ * Call with cpuset_rwsem held.
  */
 static int update_prstate(struct cpuset *cs, int new_prs)
 {
@@ -2167,7 +2169,7 @@ static int fmeter_getrate(struct fmeter *fmp)
 
 static struct cpuset *cpuset_attach_old_cs;
 
-/* Called by cgroups to determine if a cpuset is usable; cpuset_mutex held */
+/* Called by cgroups to determine if a cpuset is usable; cpuset_rwsem held */
 static int cpuset_can_attach(struct cgroup_taskset *tset)
 {
        struct cgroup_subsys_state *css;
@@ -2219,7 +2221,7 @@ static void cpuset_cancel_attach(struct cgroup_taskset *tset)
 }
 
 /*
- * Protected by cpuset_mutex.  cpus_attach is used only by cpuset_attach()
+ * Protected by cpuset_rwsem.  cpus_attach is used only by cpuset_attach()
  * but we can't allocate it dynamically there.  Define it global and
  * allocate from cpuset_init().
  */
@@ -2227,7 +2229,7 @@ static cpumask_var_t cpus_attach;
 
 static void cpuset_attach(struct cgroup_taskset *tset)
 {
-       /* static buf protected by cpuset_mutex */
+       /* static buf protected by cpuset_rwsem */
        static nodemask_t cpuset_attach_nodemask_to;
        struct task_struct *task;
        struct task_struct *leader;
@@ -2417,7 +2419,7 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
         * operation like this one can lead to a deadlock through kernfs
         * active_ref protection.  Let's break the protection.  Losing the
         * protection is okay as we check whether @cs is online after
-        * grabbing cpuset_mutex anyway.  This only happens on the legacy
+        * grabbing cpuset_rwsem anyway.  This only happens on the legacy
         * hierarchies.
         */
        css_get(&cs->css);
@@ -3672,7 +3674,7 @@ void __cpuset_memory_pressure_bump(void)
  *  - Used for /proc/<pid>/cpuset.
  *  - No need to task_lock(tsk) on this tsk->cpuset reference, as it
  *    doesn't really matter if tsk->cpuset changes after we read it,
- *    and we take cpuset_mutex, keeping cpuset_attach() from changing it
+ *    and we take cpuset_rwsem, keeping cpuset_attach() from changing it
  *    anyway.
  */
 int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
index 40ec9a030eecf41d5597e6c910746aab385b1da0..5c26a76e800b579a1e450b1aab962da2df7fc0d6 100644 (file)
@@ -4489,8 +4489,10 @@ static void cfi_init(struct module *mod)
        /* Fix init/exit functions to point to the CFI jump table */
        if (init)
                mod->init = *init;
+#ifdef CONFIG_MODULE_UNLOAD
        if (exit)
                mod->exit = *exit;
+#endif
 
        cfi_module_add(mod, module_addr_min);
 #endif
index 33a6b4a2443d274de3dfb1f31c11a460da118747..1b3eb1e9531f4ac71ebced9bac749ecea747064f 100644 (file)
@@ -4830,8 +4830,16 @@ void show_workqueue_state(void)
 
                for_each_pwq(pwq, wq) {
                        raw_spin_lock_irqsave(&pwq->pool->lock, flags);
-                       if (pwq->nr_active || !list_empty(&pwq->inactive_works))
+                       if (pwq->nr_active || !list_empty(&pwq->inactive_works)) {
+                               /*
+                                * Defer printing to avoid deadlocks in console
+                                * drivers that queue work while holding locks
+                                * also taken in their write paths.
+                                */
+                               printk_deferred_enter();
                                show_pwq(pwq);
+                               printk_deferred_exit();
+                       }
                        raw_spin_unlock_irqrestore(&pwq->pool->lock, flags);
                        /*
                         * We could be printing a lot from atomic context, e.g.
@@ -4849,7 +4857,12 @@ void show_workqueue_state(void)
                raw_spin_lock_irqsave(&pool->lock, flags);
                if (pool->nr_workers == pool->nr_idle)
                        goto next_pool;
-
+               /*
+                * Defer printing to avoid deadlocks in console drivers that
+                * queue work while holding locks also taken in their write
+                * paths.
+                */
+               printk_deferred_enter();
                pr_info("pool %d:", pool->id);
                pr_cont_pool_info(pool);
                pr_cont(" hung=%us workers=%d",
@@ -4864,6 +4877,7 @@ void show_workqueue_state(void)
                        first = false;
                }
                pr_cont("\n");
+               printk_deferred_exit();
        next_pool:
                raw_spin_unlock_irqrestore(&pool->lock, flags);
                /*
index 5efd1b435a37c5d138d15c608cb9e7b685ef20f6..a841be5244ac666cc727168c750c0d174f8d0698 100644 (file)
@@ -351,7 +351,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o
 obj-$(CONFIG_PLDMFW) += pldmfw/
 
 # KUnit tests
-CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240)
+CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN)
 obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
 obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
 obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
index cdbe54b165017e4a70c9e2aa12d021911519f2a2..e14a18af573dd71c8e0ad1641d2d53ae2a0c405f 100644 (file)
@@ -116,8 +116,8 @@ static void kfree_at_end(struct kunit *test, const void *to_free)
        /* kfree() handles NULL already, but avoid allocating a no-op cleanup. */
        if (IS_ERR_OR_NULL(to_free))
                return;
-       kunit_alloc_and_get_resource(test, NULL, kfree_res_free, GFP_KERNEL,
-                                    (void *)to_free);
+       kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL,
+                            (void *)to_free);
 }
 
 static struct kunit_suite *alloc_fake_suite(struct kunit *test,
index eab5fc88a002871d7487825c6895a97cb12a4af8..d8b9dbabd4a439137c408fb548ea058b1349c3a1 100644 (file)
@@ -77,8 +77,8 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
        struct rtnl_link_stats64 temp;
        const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
 
-       seq_printf(seq, "%9s: %16llu %12llu %4llu %6llu %4llu %5llu %10llu %9llu "
-                  "%16llu %12llu %4llu %6llu %4llu %5llu %7llu %10llu\n",
+       seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
+                  "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
                   dev->name, stats->rx_bytes, stats->rx_packets,
                   stats->rx_errors,
                   stats->rx_dropped + stats->rx_missed_errors,
@@ -103,11 +103,11 @@ static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
 static int dev_seq_show(struct seq_file *seq, void *v)
 {
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, "Interface|                            Receive                   "
-                             "                    |                                 Transmit\n"
-                             "         |            bytes      packets errs   drop fifo frame "
-                             "compressed multicast|            bytes      packets errs "
-                             "  drop fifo colls carrier compressed\n");
+               seq_puts(seq, "Inter-|   Receive                            "
+                             "                    |  Transmit\n"
+                             " face |bytes    packets errs drop fifo frame "
+                             "compressed multicast|bytes    packets errs "
+                             "drop fifo colls carrier compressed\n");
        else
                dev_seq_printf_stats(seq, v);
        return 0;
@@ -259,14 +259,14 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
        struct packet_type *pt = v;
 
        if (v == SEQ_START_TOKEN)
-               seq_puts(seq, "Type      Device      Function\n");
+               seq_puts(seq, "Type Device      Function\n");
        else if (pt->dev == NULL || dev_net(pt->dev) == seq_file_net(seq)) {
                if (pt->type == htons(ETH_P_ALL))
                        seq_puts(seq, "ALL ");
                else
                        seq_printf(seq, "%04x", ntohs(pt->type));
 
-               seq_printf(seq, "      %-9s   %ps\n",
+               seq_printf(seq, " %-8s %ps\n",
                           pt->dev ? pt->dev->name : "", pt->func);
        }
 
@@ -327,14 +327,12 @@ static int dev_mc_seq_show(struct seq_file *seq, void *v)
        struct netdev_hw_addr *ha;
        struct net_device *dev = v;
 
-       if (v == SEQ_START_TOKEN) {
-               seq_puts(seq, "Ifindex Interface Refcount Global_use Address\n");
+       if (v == SEQ_START_TOKEN)
                return 0;
-       }
 
        netif_addr_lock_bh(dev);
        netdev_for_each_mc_addr(ha, dev) {
-               seq_printf(seq, "%-7d %-9s %-8d %-10d %*phN\n",
+               seq_printf(seq, "%-4d %-15s %-5d %-5d %*phN\n",
                           dev->ifindex, dev->name,
                           ha->refcount, ha->global_use,
                           (int)dev->addr_len, ha->addr);
index 54828553975236d8d1d04582220ba701a03b9032..d8ee15f1c7a9ff14b8a172ecf9a5a614b461cdda 100644 (file)
@@ -101,8 +101,6 @@ config NET_DSA_TAG_RTL4_A
 
 config NET_DSA_TAG_OCELOT
        tristate "Tag driver for Ocelot family of switches, using NPI port"
-       depends on MSCC_OCELOT_SWITCH_LIB || \
-                  (MSCC_OCELOT_SWITCH_LIB=n && COMPILE_TEST)
        select PACKING
        help
          Say Y or M if you want to enable NPI tagging for the Ocelot switches
@@ -114,8 +112,6 @@ config NET_DSA_TAG_OCELOT
 
 config NET_DSA_TAG_OCELOT_8021Q
        tristate "Tag driver for Ocelot family of switches, using VLAN"
-       depends on MSCC_OCELOT_SWITCH_LIB || \
-                 (MSCC_OCELOT_SWITCH_LIB=n && COMPILE_TEST)
        help
          Say Y or M if you want to enable support for tagging frames with a
          custom VLAN-based header. Frames that require timestamping, such as
@@ -138,7 +134,6 @@ config NET_DSA_TAG_LAN9303
 
 config NET_DSA_TAG_SJA1105
        tristate "Tag driver for NXP SJA1105 switches"
-       depends on NET_DSA_SJA1105 || !NET_DSA_SJA1105
        select PACKING
        help
          Say Y or M if you want to enable support for tagging frames with the
index b29262eee00bf31160baf9d5644f7589af04afca..da18094b5a049b0e5e77c74c881cc15aa2ffe206 100644 (file)
@@ -170,7 +170,7 @@ void dsa_bridge_num_put(const struct net_device *bridge_dev, int bridge_num)
        /* Check if the bridge is still in use, otherwise it is time
         * to clean it up so we can reuse this bridge_num later.
         */
-       if (!dsa_bridge_num_find(bridge_dev))
+       if (dsa_bridge_num_find(bridge_dev) < 0)
                clear_bit(bridge_num, &dsa_fwd_offloading_bridges);
 }
 
@@ -811,7 +811,9 @@ static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds)
                if (!dsa_is_cpu_port(ds, port))
                        continue;
 
+               rtnl_lock();
                err = ds->ops->change_tag_protocol(ds, port, tag_ops->proto);
+               rtnl_unlock();
                if (err) {
                        dev_err(ds->dev, "Unable to use tag protocol \"%s\": %pe\n",
                                tag_ops->name, ERR_PTR(err));
index 1c797ec8e2c2b805a890df560c80b4f0eb45d4da..6466d0539af9ffea73dda13dfc1e656fe607cf4d 100644 (file)
@@ -168,7 +168,7 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
                if (extack._msg)
                        dev_err(ds->dev, "port %d: %s\n", info->port,
                                extack._msg);
-               if (err && err != EOPNOTSUPP)
+               if (err && err != -EOPNOTSUPP)
                        return err;
        }
 
index e5127b7d1c6a58f08a4be7fe878f7eed93398a52..b3da4b2ea11cf693e391f5beb28f2586593d188d 100644 (file)
@@ -45,6 +45,7 @@
  *   6    6       2        2      4    2       N
  */
 
+#include <linux/dsa/mv88e6xxx.h>
 #include <linux/etherdevice.h>
 #include <linux/list.h>
 #include <linux/slab.h>
@@ -129,12 +130,9 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
        u8 tag_dev, tag_port;
        enum dsa_cmd cmd;
        u8 *dsa_header;
-       u16 pvid = 0;
-       int err;
 
        if (skb->offload_fwd_mark) {
                struct dsa_switch_tree *dst = dp->ds->dst;
-               struct net_device *br = dp->bridge_dev;
 
                cmd = DSA_CMD_FORWARD;
 
@@ -144,19 +142,6 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
                 */
                tag_dev = dst->last_switch + 1 + dp->bridge_num;
                tag_port = 0;
-
-               /* If we are offloading forwarding for a VLAN-unaware bridge,
-                * inject packets to hardware using the bridge's pvid, since
-                * that's where the packets ingressed from.
-                */
-               if (!br_vlan_enabled(br)) {
-                       /* Safe because __dev_queue_xmit() runs under
-                        * rcu_read_lock_bh()
-                        */
-                       err = br_vlan_get_pvid_rcu(br, &pvid);
-                       if (err)
-                               return NULL;
-               }
        } else {
                cmd = DSA_CMD_FROM_CPU;
                tag_dev = dp->ds->index;
@@ -180,16 +165,21 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
                        dsa_header[2] &= ~0x10;
                }
        } else {
+               struct net_device *br = dp->bridge_dev;
+               u16 vid;
+
+               vid = br ? MV88E6XXX_VID_BRIDGED : MV88E6XXX_VID_STANDALONE;
+
                skb_push(skb, DSA_HLEN + extra);
                dsa_alloc_etype_header(skb, DSA_HLEN + extra);
 
-               /* Construct untagged DSA tag. */
+               /* Construct DSA header from untagged frame. */
                dsa_header = dsa_etype_header_pos_tx(skb) + extra;
 
                dsa_header[0] = (cmd << 6) | tag_dev;
                dsa_header[1] = tag_port << 3;
-               dsa_header[2] = pvid >> 8;
-               dsa_header[3] = pvid & 0xff;
+               dsa_header[2] = vid >> 8;
+               dsa_header[3] = vid & 0xff;
        }
 
        return skb;
index 8025ed778d33aa20f96702c1e71dbf4859d3034e..605b51ca692105628a1b5108d7d596bf2b8c223b 100644 (file)
@@ -2,7 +2,6 @@
 /* Copyright 2019 NXP
  */
 #include <linux/dsa/ocelot.h>
-#include <soc/mscc/ocelot.h>
 #include "dsa_priv.h"
 
 static void ocelot_xmit_common(struct sk_buff *skb, struct net_device *netdev,
index 59072930cb021e19ad2a66cac490d7edc2a898e0..3412051981d7bd99c6e58e2aeb0a82d62439bbe9 100644 (file)
@@ -9,10 +9,32 @@
  *   that on egress
  */
 #include <linux/dsa/8021q.h>
-#include <soc/mscc/ocelot.h>
-#include <soc/mscc/ocelot_ptp.h>
+#include <linux/dsa/ocelot.h>
 #include "dsa_priv.h"
 
+static struct sk_buff *ocelot_defer_xmit(struct dsa_port *dp,
+                                        struct sk_buff *skb)
+{
+       struct felix_deferred_xmit_work *xmit_work;
+       struct felix_port *felix_port = dp->priv;
+
+       xmit_work = kzalloc(sizeof(*xmit_work), GFP_ATOMIC);
+       if (!xmit_work)
+               return NULL;
+
+       /* Calls felix_port_deferred_xmit in felix.c */
+       kthread_init_work(&xmit_work->work, felix_port->xmit_work_fn);
+       /* Increase refcount so the kfree_skb in dsa_slave_xmit
+        * won't really free the packet.
+        */
+       xmit_work->dp = dp;
+       xmit_work->skb = skb_get(skb);
+
+       kthread_queue_work(felix_port->xmit_worker, &xmit_work->work);
+
+       return NULL;
+}
+
 static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
                                   struct net_device *netdev)
 {
@@ -20,18 +42,10 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
        u16 tx_vid = dsa_8021q_tx_vid(dp->ds, dp->index);
        u16 queue_mapping = skb_get_queue_mapping(skb);
        u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
-       struct ocelot *ocelot = dp->ds->priv;
-       int port = dp->index;
-       u32 rew_op = 0;
+       struct ethhdr *hdr = eth_hdr(skb);
 
-       rew_op = ocelot_ptp_rew_op(skb);
-       if (rew_op) {
-               if (!ocelot_can_inject(ocelot, 0))
-                       return NULL;
-
-               ocelot_port_inject_frame(ocelot, port, 0, rew_op, skb);
-               return NULL;
-       }
+       if (ocelot_ptp_rew_op(skb) || is_link_local_ether_addr(hdr->h_dest))
+               return ocelot_defer_xmit(dp, skb);
 
        return dsa_8021q_xmit(skb, netdev, ETH_P_8021Q,
                              ((pcp << VLAN_PRIO_SHIFT) | tx_vid));
index c054f48541c8d621ca018cb94016193789e66c37..2edede9ddac93b388508cd1ccee6f4c6103cee27 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/if_vlan.h>
 #include <linux/dsa/sja1105.h>
 #include <linux/dsa/8021q.h>
+#include <linux/skbuff.h>
 #include <linux/packing.h>
 #include "dsa_priv.h"
 
 #define SJA1110_TX_TRAILER_LEN                 4
 #define SJA1110_MAX_PADDING_LEN                        15
 
+enum sja1110_meta_tstamp {
+       SJA1110_META_TSTAMP_TX = 0,
+       SJA1110_META_TSTAMP_RX = 1,
+};
+
 /* Similar to is_link_local_ether_addr(hdr->h_dest) but also covers PTP */
 static inline bool sja1105_is_link_local(const struct sk_buff *skb)
 {
@@ -520,6 +526,43 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,
                                              is_meta);
 }
 
+static void sja1110_process_meta_tstamp(struct dsa_switch *ds, int port,
+                                       u8 ts_id, enum sja1110_meta_tstamp dir,
+                                       u64 tstamp)
+{
+       struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
+       struct dsa_port *dp = dsa_to_port(ds, port);
+       struct skb_shared_hwtstamps shwt = {0};
+       struct sja1105_port *sp = dp->priv;
+
+       if (!dsa_port_is_sja1105(dp))
+               return;
+
+       /* We don't care about RX timestamps on the CPU port */
+       if (dir == SJA1110_META_TSTAMP_RX)
+               return;
+
+       spin_lock(&sp->data->skb_txtstamp_queue.lock);
+
+       skb_queue_walk_safe(&sp->data->skb_txtstamp_queue, skb, skb_tmp) {
+               if (SJA1105_SKB_CB(skb)->ts_id != ts_id)
+                       continue;
+
+               __skb_unlink(skb, &sp->data->skb_txtstamp_queue);
+               skb_match = skb;
+
+               break;
+       }
+
+       spin_unlock(&sp->data->skb_txtstamp_queue.lock);
+
+       if (WARN_ON(!skb_match))
+               return;
+
+       shwt.hwtstamp = ns_to_ktime(sja1105_ticks_to_ns(tstamp));
+       skb_complete_tx_timestamp(skb_match, &shwt);
+}
+
 static struct sk_buff *sja1110_rcv_meta(struct sk_buff *skb, u16 rx_header)
 {
        u8 *buf = dsa_etype_header_pos_rx(skb) + SJA1110_HEADER_LEN;
index 8b30cadff708f96f4acf4a459c8e9c0397f8d305..b7e277d8a84d224cb9c034321e688d765d01c07f 100644 (file)
@@ -1054,14 +1054,19 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
        iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(iio->extobj_hdr), &_iio);
        if (!ext_hdr || !iio)
                goto send_mal_query;
-       if (ntohs(iio->extobj_hdr.length) <= sizeof(iio->extobj_hdr))
+       if (ntohs(iio->extobj_hdr.length) <= sizeof(iio->extobj_hdr) ||
+           ntohs(iio->extobj_hdr.length) > sizeof(_iio))
                goto send_mal_query;
        ident_len = ntohs(iio->extobj_hdr.length) - sizeof(iio->extobj_hdr);
+       iio = skb_header_pointer(skb, sizeof(_ext_hdr),
+                                sizeof(iio->extobj_hdr) + ident_len, &_iio);
+       if (!iio)
+               goto send_mal_query;
+
        status = 0;
        dev = NULL;
        switch (iio->extobj_hdr.class_type) {
        case ICMP_EXT_ECHO_CTYPE_NAME:
-               iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(_iio), &_iio);
                if (ident_len >= IFNAMSIZ)
                        goto send_mal_query;
                memset(buff, 0, sizeof(buff));
@@ -1069,30 +1074,24 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
                dev = dev_get_by_name(net, buff);
                break;
        case ICMP_EXT_ECHO_CTYPE_INDEX:
-               iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(iio->extobj_hdr) +
-                                        sizeof(iio->ident.ifindex), &_iio);
                if (ident_len != sizeof(iio->ident.ifindex))
                        goto send_mal_query;
                dev = dev_get_by_index(net, ntohl(iio->ident.ifindex));
                break;
        case ICMP_EXT_ECHO_CTYPE_ADDR:
-               if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) +
+               if (ident_len < sizeof(iio->ident.addr.ctype3_hdr) ||
+                   ident_len != sizeof(iio->ident.addr.ctype3_hdr) +
                                 iio->ident.addr.ctype3_hdr.addrlen)
                        goto send_mal_query;
                switch (ntohs(iio->ident.addr.ctype3_hdr.afi)) {
                case ICMP_AFI_IP:
-                       iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(iio->extobj_hdr) +
-                                                sizeof(struct in_addr), &_iio);
-                       if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) +
-                                        sizeof(struct in_addr))
+                       if (iio->ident.addr.ctype3_hdr.addrlen != sizeof(struct in_addr))
                                goto send_mal_query;
                        dev = ip_dev_find(net, iio->ident.addr.ip_addr.ipv4_addr);
                        break;
 #if IS_ENABLED(CONFIG_IPV6)
                case ICMP_AFI_IP6:
-                       iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(_iio), &_iio);
-                       if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) +
-                                        sizeof(struct in6_addr))
+                       if (iio->ident.addr.ctype3_hdr.addrlen != sizeof(struct in6_addr))
                                goto send_mal_query;
                        dev = ipv6_stub->ipv6_dev_find(net, &iio->ident.addr.ip_addr.ipv6_addr, dev);
                        dev_hold(dev);
index 5e8961004832e3e9be341c5c5d203d29ae05be3c..d128172bb54976bac370449c2204d42cd5b84e69 100644 (file)
@@ -770,6 +770,66 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,
                data += sizeof(__be32);
        }
 
+       /* bit12 undefined: filled with empty value */
+       if (trace->type.bit12) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit13 undefined: filled with empty value */
+       if (trace->type.bit13) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit14 undefined: filled with empty value */
+       if (trace->type.bit14) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit15 undefined: filled with empty value */
+       if (trace->type.bit15) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit16 undefined: filled with empty value */
+       if (trace->type.bit16) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit17 undefined: filled with empty value */
+       if (trace->type.bit17) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit18 undefined: filled with empty value */
+       if (trace->type.bit18) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit19 undefined: filled with empty value */
+       if (trace->type.bit19) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit20 undefined: filled with empty value */
+       if (trace->type.bit20) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
+       /* bit21 undefined: filled with empty value */
+       if (trace->type.bit21) {
+               *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE);
+               data += sizeof(__be32);
+       }
+
        /* opaque state snapshot */
        if (trace->type.bit22) {
                if (!sc) {
@@ -791,16 +851,10 @@ void ioam6_fill_trace_data(struct sk_buff *skb,
        struct ioam6_schema *sc;
        u8 sclen = 0;
 
-       /* Skip if Overflow flag is set OR
-        * if an unknown type (bit 12-21) is set
+       /* Skip if Overflow flag is set
         */
-       if (trace->overflow ||
-           trace->type.bit12 | trace->type.bit13 | trace->type.bit14 |
-           trace->type.bit15 | trace->type.bit16 | trace->type.bit17 |
-           trace->type.bit18 | trace->type.bit19 | trace->type.bit20 |
-           trace->type.bit21) {
+       if (trace->overflow)
                return;
-       }
 
        /* NodeLen does not include Opaque State Snapshot length. We need to
         * take it into account if the corresponding bit is set (bit 22) and
index f9ee04541c17fcfc52a2c5843d62bbdc72a2a815..9b7b726f8f45f2f0fb65b0792d2ae29e8042b7ab 100644 (file)
@@ -75,7 +75,11 @@ static bool ioam6_validate_trace_hdr(struct ioam6_trace_hdr *trace)
        u32 fields;
 
        if (!trace->type_be32 || !trace->remlen ||
-           trace->remlen > IOAM6_TRACE_DATA_SIZE_MAX / 4)
+           trace->remlen > IOAM6_TRACE_DATA_SIZE_MAX / 4 ||
+           trace->type.bit12 | trace->type.bit13 | trace->type.bit14 |
+           trace->type.bit15 | trace->type.bit16 | trace->type.bit17 |
+           trace->type.bit18 | trace->type.bit19 | trace->type.bit20 |
+           trace->type.bit21)
                return false;
 
        trace->nodelen = 0;
index e5df0b5971c86adbeaae5fc8ad86c0e8ca375ea2..d073b211138287342cf6c2faf6b0fc299c203205 100644 (file)
@@ -528,7 +528,6 @@ static bool mptcp_check_data_fin(struct sock *sk)
 
                sk->sk_shutdown |= RCV_SHUTDOWN;
                smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
-               set_bit(MPTCP_DATA_READY, &msk->flags);
 
                switch (sk->sk_state) {
                case TCP_ESTABLISHED:
@@ -742,10 +741,9 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk)
 
        /* Wake-up the reader only for in-sequence data */
        mptcp_data_lock(sk);
-       if (move_skbs_to_msk(msk, ssk)) {
-               set_bit(MPTCP_DATA_READY, &msk->flags);
+       if (move_skbs_to_msk(msk, ssk))
                sk->sk_data_ready(sk);
-       }
+
        mptcp_data_unlock(sk);
 }
 
@@ -847,7 +845,6 @@ static void mptcp_check_for_eof(struct mptcp_sock *msk)
                sk->sk_shutdown |= RCV_SHUTDOWN;
 
                smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
-               set_bit(MPTCP_DATA_READY, &msk->flags);
                sk->sk_data_ready(sk);
        }
 
@@ -1759,21 +1756,6 @@ out:
        return copied ? : ret;
 }
 
-static void mptcp_wait_data(struct sock *sk, long *timeo)
-{
-       DEFINE_WAIT_FUNC(wait, woken_wake_function);
-       struct mptcp_sock *msk = mptcp_sk(sk);
-
-       add_wait_queue(sk_sleep(sk), &wait);
-       sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
-
-       sk_wait_event(sk, timeo,
-                     test_bit(MPTCP_DATA_READY, &msk->flags), &wait);
-
-       sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
-       remove_wait_queue(sk_sleep(sk), &wait);
-}
-
 static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
                                struct msghdr *msg,
                                size_t len, int flags,
@@ -2077,19 +2059,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
                }
 
                pr_debug("block timeout %ld", timeo);
-               mptcp_wait_data(sk, &timeo);
-       }
-
-       if (skb_queue_empty_lockless(&sk->sk_receive_queue) &&
-           skb_queue_empty(&msk->receive_queue)) {
-               /* entire backlog drained, clear DATA_READY. */
-               clear_bit(MPTCP_DATA_READY, &msk->flags);
-
-               /* .. race-breaker: ssk might have gotten new data
-                * after last __mptcp_move_skbs() returned false.
-                */
-               if (unlikely(__mptcp_move_skbs(msk)))
-                       set_bit(MPTCP_DATA_READY, &msk->flags);
+               sk_wait_data(sk, &timeo, NULL);
        }
 
 out_err:
@@ -2098,9 +2068,9 @@ out_err:
                        tcp_recv_timestamp(msg, sk, &tss);
        }
 
-       pr_debug("msk=%p data_ready=%d rx queue empty=%d copied=%d",
-                msk, test_bit(MPTCP_DATA_READY, &msk->flags),
-                skb_queue_empty_lockless(&sk->sk_receive_queue), copied);
+       pr_debug("msk=%p rx queue empty=%d:%d copied=%d",
+                msk, skb_queue_empty_lockless(&sk->sk_receive_queue),
+                skb_queue_empty(&msk->receive_queue), copied);
        if (!(flags & MSG_PEEK))
                mptcp_rcv_space_adjust(msk, copied);
 
@@ -2368,7 +2338,6 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
        inet_sk_state_store(sk, TCP_CLOSE);
        sk->sk_shutdown = SHUTDOWN_MASK;
        smp_mb__before_atomic(); /* SHUTDOWN must be visible first */
-       set_bit(MPTCP_DATA_READY, &msk->flags);
        set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags);
 
        mptcp_close_wake_up(sk);
@@ -3385,8 +3354,14 @@ unlock_fail:
 
 static __poll_t mptcp_check_readable(struct mptcp_sock *msk)
 {
-       return test_bit(MPTCP_DATA_READY, &msk->flags) ? EPOLLIN | EPOLLRDNORM :
-              0;
+       /* Concurrent splices from sk_receive_queue into receive_queue will
+        * always show at least one non-empty queue when checked in this order.
+        */
+       if (skb_queue_empty_lockless(&((struct sock *)msk)->sk_receive_queue) &&
+           skb_queue_empty_lockless(&msk->receive_queue))
+               return 0;
+
+       return EPOLLIN | EPOLLRDNORM;
 }
 
 static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)
@@ -3421,7 +3396,7 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
        state = inet_sk_state_load(sk);
        pr_debug("msk=%p state=%d flags=%lx", msk, state, msk->flags);
        if (state == TCP_LISTEN)
-               return mptcp_check_readable(msk);
+               return test_bit(MPTCP_DATA_READY, &msk->flags) ? EPOLLIN | EPOLLRDNORM : 0;
 
        if (state != TCP_SYN_SENT && state != TCP_SYN_RECV) {
                mask |= mptcp_check_readable(msk);
index 6024fad905ff04f98d3788efe15815c2ea9d7526..dda323e0a4730b2eca2a7c5516ee01eb1cdd7c6e 100644 (file)
@@ -60,6 +60,9 @@ int nfc_proto_register(const struct nfc_protocol *nfc_proto)
                proto_tab[nfc_proto->id] = nfc_proto;
        write_unlock(&proto_tab_lock);
 
+       if (rc)
+               proto_unregister(nfc_proto->proto);
+
        return rc;
 }
 EXPORT_SYMBOL(nfc_proto_register);
index fefc03674f4f8333bd657d102409f5f2161ccbc2..d63d2e5dc60c97e46ae977674e113b019169682b 100644 (file)
@@ -277,6 +277,7 @@ int digital_tg_configure_hw(struct nfc_digital_dev *ddev, int type, int param)
 static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
 {
        struct digital_tg_mdaa_params *params;
+       int rc;
 
        params = kzalloc(sizeof(*params), GFP_KERNEL);
        if (!params)
@@ -291,8 +292,12 @@ static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
        get_random_bytes(params->nfcid2 + 2, NFC_NFCID2_MAXSIZE - 2);
        params->sc = DIGITAL_SENSF_FELICA_SC;
 
-       return digital_send_cmd(ddev, DIGITAL_CMD_TG_LISTEN_MDAA, NULL, params,
-                               500, digital_tg_recv_atr_req, NULL);
+       rc = digital_send_cmd(ddev, DIGITAL_CMD_TG_LISTEN_MDAA, NULL, params,
+                             500, digital_tg_recv_atr_req, NULL);
+       if (rc)
+               kfree(params);
+
+       return rc;
 }
 
 static int digital_tg_listen_md(struct nfc_digital_dev *ddev, u8 rf_tech)
index 84d2345c75a3f2a9e9b89dade25421b1d4a8acab..3adf4589852affc6cd3665857ac0eba0ff21b641 100644 (file)
@@ -465,8 +465,12 @@ static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
        skb_put_u8(skb, sel_cmd);
        skb_put_u8(skb, DIGITAL_SDD_REQ_SEL_PAR);
 
-       return digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res,
-                                  target);
+       rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res,
+                                target);
+       if (rc)
+               kfree_skb(skb);
+
+       return rc;
 }
 
 static void digital_in_recv_sens_res(struct nfc_digital_dev *ddev, void *arg,
index a2e72c0038050dee96fbb865b3df504d31338249..b911ab78bed9aa14e30ea670e978987d7f827bd1 100644 (file)
@@ -334,6 +334,8 @@ static void nci_core_conn_close_rsp_packet(struct nci_dev *ndev,
                                                         ndev->cur_conn_id);
                if (conn_info) {
                        list_del(&conn_info->list);
+                       if (conn_info == ndev->rf_conn_info)
+                               ndev->rf_conn_info = NULL;
                        devm_kfree(&ndev->nfc_dev->dev, conn_info);
                }
        }
index 8766ab5b8788042df03b0b8cdb9e35734ef1a8a7..5eb3b1b7ae5e7886789c010548e43bcff6cf4172 100644 (file)
@@ -529,22 +529,28 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
                for (i = tc.offset; i < tc.offset + tc.count; i++) {
                        struct netdev_queue *q = netdev_get_tx_queue(dev, i);
                        struct Qdisc *qdisc = rtnl_dereference(q->qdisc);
-                       struct gnet_stats_basic_cpu __percpu *cpu_bstats = NULL;
-                       struct gnet_stats_queue __percpu *cpu_qstats = NULL;
 
                        spin_lock_bh(qdisc_lock(qdisc));
+
                        if (qdisc_is_percpu_stats(qdisc)) {
-                               cpu_bstats = qdisc->cpu_bstats;
-                               cpu_qstats = qdisc->cpu_qstats;
+                               qlen = qdisc_qlen_sum(qdisc);
+
+                               __gnet_stats_copy_basic(NULL, &bstats,
+                                                       qdisc->cpu_bstats,
+                                                       &qdisc->bstats);
+                               __gnet_stats_copy_queue(&qstats,
+                                                       qdisc->cpu_qstats,
+                                                       &qdisc->qstats,
+                                                       qlen);
+                       } else {
+                               qlen            += qdisc->q.qlen;
+                               bstats.bytes    += qdisc->bstats.bytes;
+                               bstats.packets  += qdisc->bstats.packets;
+                               qstats.backlog  += qdisc->qstats.backlog;
+                               qstats.drops    += qdisc->qstats.drops;
+                               qstats.requeues += qdisc->qstats.requeues;
+                               qstats.overlimits += qdisc->qstats.overlimits;
                        }
-
-                       qlen = qdisc_qlen_sum(qdisc);
-                       __gnet_stats_copy_basic(NULL, &sch->bstats,
-                                               cpu_bstats, &qdisc->bstats);
-                       __gnet_stats_copy_queue(&sch->qstats,
-                                               cpu_qstats,
-                                               &qdisc->qstats,
-                                               qlen);
                        spin_unlock_bh(qdisc_lock(qdisc));
                }
 
index b8fa8f1a727704df07e78c0b72e77a4ecdd76b76..c7503fd6491593fc749b9af182c646a39ed2ddbc 100644 (file)
@@ -3697,7 +3697,7 @@ struct sctp_chunk *sctp_make_strreset_req(
        outlen = (sizeof(outreq) + stream_len) * out;
        inlen = (sizeof(inreq) + stream_len) * in;
 
-       retval = sctp_make_reconf(asoc, outlen + inlen);
+       retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen));
        if (!retval)
                return NULL;
 
index f23f558054a7cba4fa29e430bbd6729074a55611..99acd337ba90d828c6f11099fe2a54ac91055eaa 100644 (file)
@@ -150,9 +150,11 @@ static int smcr_cdc_get_slot_and_msg_send(struct smc_connection *conn)
 
 again:
        link = conn->lnk;
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_cdc_get_free_slot(conn, link, &wr_buf, NULL, &pend);
        if (rc)
-               return rc;
+               goto put_out;
 
        spin_lock_bh(&conn->send_lock);
        if (link != conn->lnk) {
@@ -160,6 +162,7 @@ again:
                spin_unlock_bh(&conn->send_lock);
                smc_wr_tx_put_slot(link,
                                   (struct smc_wr_tx_pend_priv *)pend);
+               smc_wr_tx_link_put(link);
                if (again)
                        return -ENOLINK;
                again = true;
@@ -167,6 +170,8 @@ again:
        }
        rc = smc_cdc_msg_send(conn, wr_buf, pend);
        spin_unlock_bh(&conn->send_lock);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
index 8280c938be80102afa7c6770dc4946d9fed0f053..d2206743dc714863472f23a0cf70166569491ca0 100644 (file)
@@ -949,7 +949,7 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
                to_lnk = &lgr->lnk[i];
                break;
        }
-       if (!to_lnk) {
+       if (!to_lnk || !smc_wr_tx_link_hold(to_lnk)) {
                smc_lgr_terminate_sched(lgr);
                return NULL;
        }
@@ -981,24 +981,26 @@ again:
                read_unlock_bh(&lgr->conns_lock);
                /* pre-fetch buffer outside of send_lock, might sleep */
                rc = smc_cdc_get_free_slot(conn, to_lnk, &wr_buf, NULL, &pend);
-               if (rc) {
-                       smcr_link_down_cond_sched(to_lnk);
-                       return NULL;
-               }
+               if (rc)
+                       goto err_out;
                /* avoid race with smcr_tx_sndbuf_nonempty() */
                spin_lock_bh(&conn->send_lock);
                smc_switch_link_and_count(conn, to_lnk);
                rc = smc_switch_cursor(smc, pend, wr_buf);
                spin_unlock_bh(&conn->send_lock);
                sock_put(&smc->sk);
-               if (rc) {
-                       smcr_link_down_cond_sched(to_lnk);
-                       return NULL;
-               }
+               if (rc)
+                       goto err_out;
                goto again;
        }
        read_unlock_bh(&lgr->conns_lock);
+       smc_wr_tx_link_put(to_lnk);
        return to_lnk;
+
+err_out:
+       smcr_link_down_cond_sched(to_lnk);
+       smc_wr_tx_link_put(to_lnk);
+       return NULL;
 }
 
 static void smcr_buf_unuse(struct smc_buf_desc *rmb_desc,
index 2e7560eba9812635c22f18f41aafc38b063dd02a..72f4b72eb1753a899f164e10aa1e75620c7e5bfa 100644 (file)
@@ -383,9 +383,11 @@ int smc_llc_send_confirm_link(struct smc_link *link,
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        confllc = (struct smc_llc_msg_confirm_link *)wr_buf;
        memset(confllc, 0, sizeof(*confllc));
        confllc->hd.common.type = SMC_LLC_CONFIRM_LINK;
@@ -402,6 +404,8 @@ int smc_llc_send_confirm_link(struct smc_link *link,
        confllc->max_links = SMC_LLC_ADD_LNK_MAX_LINKS;
        /* send llc message */
        rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
@@ -415,9 +419,11 @@ static int smc_llc_send_confirm_rkey(struct smc_link *send_link,
        struct smc_link *link;
        int i, rc, rtok_ix;
 
+       if (!smc_wr_tx_link_hold(send_link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(send_link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        rkeyllc = (struct smc_llc_msg_confirm_rkey *)wr_buf;
        memset(rkeyllc, 0, sizeof(*rkeyllc));
        rkeyllc->hd.common.type = SMC_LLC_CONFIRM_RKEY;
@@ -444,6 +450,8 @@ static int smc_llc_send_confirm_rkey(struct smc_link *send_link,
                (u64)sg_dma_address(rmb_desc->sgt[send_link->link_idx].sgl));
        /* send llc message */
        rc = smc_wr_tx_send(send_link, pend);
+put_out:
+       smc_wr_tx_link_put(send_link);
        return rc;
 }
 
@@ -456,9 +464,11 @@ static int smc_llc_send_delete_rkey(struct smc_link *link,
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        rkeyllc = (struct smc_llc_msg_delete_rkey *)wr_buf;
        memset(rkeyllc, 0, sizeof(*rkeyllc));
        rkeyllc->hd.common.type = SMC_LLC_DELETE_RKEY;
@@ -467,6 +477,8 @@ static int smc_llc_send_delete_rkey(struct smc_link *link,
        rkeyllc->rkey[0] = htonl(rmb_desc->mr_rx[link->link_idx]->rkey);
        /* send llc message */
        rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
@@ -480,9 +492,11 @@ int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[],
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        addllc = (struct smc_llc_msg_add_link *)wr_buf;
 
        memset(addllc, 0, sizeof(*addllc));
@@ -504,6 +518,8 @@ int smc_llc_send_add_link(struct smc_link *link, u8 mac[], u8 gid[],
        }
        /* send llc message */
        rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
@@ -517,9 +533,11 @@ int smc_llc_send_delete_link(struct smc_link *link, u8 link_del_id,
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        delllc = (struct smc_llc_msg_del_link *)wr_buf;
 
        memset(delllc, 0, sizeof(*delllc));
@@ -536,6 +554,8 @@ int smc_llc_send_delete_link(struct smc_link *link, u8 link_del_id,
        delllc->reason = htonl(reason);
        /* send llc message */
        rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
@@ -547,9 +567,11 @@ static int smc_llc_send_test_link(struct smc_link *link, u8 user_data[16])
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        testllc = (struct smc_llc_msg_test_link *)wr_buf;
        memset(testllc, 0, sizeof(*testllc));
        testllc->hd.common.type = SMC_LLC_TEST_LINK;
@@ -557,6 +579,8 @@ static int smc_llc_send_test_link(struct smc_link *link, u8 user_data[16])
        memcpy(testllc->user_data, user_data, sizeof(testllc->user_data));
        /* send llc message */
        rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
@@ -567,13 +591,16 @@ static int smc_llc_send_message(struct smc_link *link, void *llcbuf)
        struct smc_wr_buf *wr_buf;
        int rc;
 
-       if (!smc_link_usable(link))
+       if (!smc_wr_tx_link_hold(link))
                return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        memcpy(wr_buf, llcbuf, sizeof(union smc_llc_msg));
-       return smc_wr_tx_send(link, pend);
+       rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
+       return rc;
 }
 
 /* schedule an llc send on link, may wait for buffers,
@@ -586,13 +613,16 @@ static int smc_llc_send_message_wait(struct smc_link *link, void *llcbuf)
        struct smc_wr_buf *wr_buf;
        int rc;
 
-       if (!smc_link_usable(link))
+       if (!smc_wr_tx_link_hold(link))
                return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        memcpy(wr_buf, llcbuf, sizeof(union smc_llc_msg));
-       return smc_wr_tx_send_wait(link, pend, SMC_LLC_WAIT_TIME);
+       rc = smc_wr_tx_send_wait(link, pend, SMC_LLC_WAIT_TIME);
+put_out:
+       smc_wr_tx_link_put(link);
+       return rc;
 }
 
 /********************************* receive ***********************************/
@@ -672,9 +702,11 @@ static int smc_llc_add_link_cont(struct smc_link *link,
        struct smc_buf_desc *rmb;
        u8 n;
 
+       if (!smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_llc_add_pending_send(link, &wr_buf, &pend);
        if (rc)
-               return rc;
+               goto put_out;
        addc_llc = (struct smc_llc_msg_add_link_cont *)wr_buf;
        memset(addc_llc, 0, sizeof(*addc_llc));
 
@@ -706,7 +738,10 @@ static int smc_llc_add_link_cont(struct smc_link *link,
        addc_llc->hd.length = sizeof(struct smc_llc_msg_add_link_cont);
        if (lgr->role == SMC_CLNT)
                addc_llc->hd.flags |= SMC_LLC_FLAG_RESP;
-       return smc_wr_tx_send(link, pend);
+       rc = smc_wr_tx_send(link, pend);
+put_out:
+       smc_wr_tx_link_put(link);
+       return rc;
 }
 
 static int smc_llc_cli_rkey_exchange(struct smc_link *link,
index c79361dfcdfb9f21d9541a7249b84227ca603b38..738a4a99c82797b7b5d28afaba5208135e1983ad 100644 (file)
@@ -496,7 +496,7 @@ static int smc_tx_rdma_writes(struct smc_connection *conn,
 /* Wakeup sndbuf consumers from any context (IRQ or process)
  * since there is more data to transmit; usable snd_wnd as max transmit
  */
-static int _smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
+static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
 {
        struct smc_cdc_producer_flags *pflags = &conn->local_tx_ctrl.prod_flags;
        struct smc_link *link = conn->lnk;
@@ -505,8 +505,11 @@ static int _smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
        struct smc_wr_buf *wr_buf;
        int rc;
 
+       if (!link || !smc_wr_tx_link_hold(link))
+               return -ENOLINK;
        rc = smc_cdc_get_free_slot(conn, link, &wr_buf, &wr_rdma_buf, &pend);
        if (rc < 0) {
+               smc_wr_tx_link_put(link);
                if (rc == -EBUSY) {
                        struct smc_sock *smc =
                                container_of(conn, struct smc_sock, conn);
@@ -547,22 +550,7 @@ static int _smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
 
 out_unlock:
        spin_unlock_bh(&conn->send_lock);
-       return rc;
-}
-
-static int smcr_tx_sndbuf_nonempty(struct smc_connection *conn)
-{
-       struct smc_link *link = conn->lnk;
-       int rc = -ENOLINK;
-
-       if (!link)
-               return rc;
-
-       atomic_inc(&link->wr_tx_refcnt);
-       if (smc_link_usable(link))
-               rc = _smcr_tx_sndbuf_nonempty(conn);
-       if (atomic_dec_and_test(&link->wr_tx_refcnt))
-               wake_up_all(&link->wr_tx_wait);
+       smc_wr_tx_link_put(link);
        return rc;
 }
 
index 423b8709f1c9e4fd2462dc2bb929ebc24e01f454..2bc626f230a56dca33fb5617972443c8aecf98ee 100644 (file)
@@ -60,6 +60,20 @@ static inline void smc_wr_tx_set_wr_id(atomic_long_t *wr_tx_id, long val)
        atomic_long_set(wr_tx_id, val);
 }
 
+static inline bool smc_wr_tx_link_hold(struct smc_link *link)
+{
+       if (!smc_link_usable(link))
+               return false;
+       atomic_inc(&link->wr_tx_refcnt);
+       return true;
+}
+
+static inline void smc_wr_tx_link_put(struct smc_link *link)
+{
+       if (atomic_dec_and_test(&link->wr_tx_refcnt))
+               wake_up_all(&link->wr_tx_wait);
+}
+
 static inline void smc_wr_wakeup_tx_wait(struct smc_link *lnk)
 {
        wake_up_all(&lnk->wr_tx_wait);
index 0878ab86597bbe37c16fef56c2c55b10b64b3455..89f9e85ae970d410774e720faa0987c069aafdab 100644 (file)
@@ -828,7 +828,7 @@ static void unix_unhash(struct sock *sk)
 }
 
 struct proto unix_dgram_proto = {
-       .name                   = "UNIX-DGRAM",
+       .name                   = "UNIX",
        .owner                  = THIS_MODULE,
        .obj_size               = sizeof(struct unix_sock),
        .close                  = unix_close,
index 952e46876329a78a104ee91ef539c7e63d77c68c..4aad28480035582f0c4b99a973826597774d054e 100644 (file)
@@ -19,6 +19,10 @@ gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF)              \
                += -fplugin-arg-structleak_plugin-byref
 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)    \
                += -fplugin-arg-structleak_plugin-byref-all
+ifdef CONFIG_GCC_PLUGIN_STRUCTLEAK
+    DISABLE_STRUCTLEAK_PLUGIN += -fplugin-arg-structleak_plugin-disable
+endif
+export DISABLE_STRUCTLEAK_PLUGIN
 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)              \
                += -DSTRUCTLEAK_PLUGIN
 
index a59de24695ec9b0ea7d20dc309bdf05ef7574286..dfe5a64e19d2e0c6eed5d3d8e3b4cf73c1415d3d 100644 (file)
@@ -468,6 +468,76 @@ static int snd_pcm_ioctl_sync_ptr_x32(struct snd_pcm_substream *substream,
 }
 #endif /* CONFIG_X86_X32 */
 
+#ifdef __BIG_ENDIAN
+typedef char __pad_before_u32[4];
+typedef char __pad_after_u32[0];
+#else
+typedef char __pad_before_u32[0];
+typedef char __pad_after_u32[4];
+#endif
+
+/* PCM 2.0.15 API definition had a bug in mmap control; it puts the avail_min
+ * at the wrong offset due to a typo in padding type.
+ * The bug hits only 32bit.
+ * A workaround for incorrect read/write is needed only in 32bit compat mode.
+ */
+struct __snd_pcm_mmap_control64_buggy {
+       __pad_before_u32 __pad1;
+       __u32 appl_ptr;
+       __pad_before_u32 __pad2;        /* SiC! here is the bug */
+       __pad_before_u32 __pad3;
+       __u32 avail_min;
+       __pad_after_uframe __pad4;
+};
+
+static int snd_pcm_ioctl_sync_ptr_buggy(struct snd_pcm_substream *substream,
+                                       struct snd_pcm_sync_ptr __user *_sync_ptr)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct snd_pcm_sync_ptr sync_ptr;
+       struct __snd_pcm_mmap_control64_buggy *sync_cp;
+       volatile struct snd_pcm_mmap_status *status;
+       volatile struct snd_pcm_mmap_control *control;
+       int err;
+
+       memset(&sync_ptr, 0, sizeof(sync_ptr));
+       sync_cp = (struct __snd_pcm_mmap_control64_buggy *)&sync_ptr.c.control;
+       if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags)))
+               return -EFAULT;
+       if (copy_from_user(sync_cp, &(_sync_ptr->c.control), sizeof(*sync_cp)))
+               return -EFAULT;
+       status = runtime->status;
+       control = runtime->control;
+       if (sync_ptr.flags & SNDRV_PCM_SYNC_PTR_HWSYNC) {
+               err = snd_pcm_hwsync(substream);
+               if (err < 0)
+                       return err;
+       }
+       snd_pcm_stream_lock_irq(substream);
+       if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) {
+               err = pcm_lib_apply_appl_ptr(substream, sync_cp->appl_ptr);
+               if (err < 0) {
+                       snd_pcm_stream_unlock_irq(substream);
+                       return err;
+               }
+       } else {
+               sync_cp->appl_ptr = control->appl_ptr;
+       }
+       if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
+               control->avail_min = sync_cp->avail_min;
+       else
+               sync_cp->avail_min = control->avail_min;
+       sync_ptr.s.status.state = status->state;
+       sync_ptr.s.status.hw_ptr = status->hw_ptr;
+       sync_ptr.s.status.tstamp = status->tstamp;
+       sync_ptr.s.status.suspended_state = status->suspended_state;
+       sync_ptr.s.status.audio_tstamp = status->audio_tstamp;
+       snd_pcm_stream_unlock_irq(substream);
+       if (copy_to_user(_sync_ptr, &sync_ptr, sizeof(sync_ptr)))
+               return -EFAULT;
+       return 0;
+}
+
 /*
  */
 enum {
@@ -537,7 +607,7 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
                if (in_x32_syscall())
                        return snd_pcm_ioctl_sync_ptr_x32(substream, argp);
 #endif /* CONFIG_X86_X32 */
-               return snd_pcm_common_ioctl(file, substream, cmd, argp);
+               return snd_pcm_ioctl_sync_ptr_buggy(substream, argp);
        case SNDRV_PCM_IOCTL_HW_REFINE32:
                return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
        case SNDRV_PCM_IOCTL_HW_PARAMS32:
index 382275c5b1937e14e8b8d65187948eb847606a63..7f3fd8eb016fe825e13394576f803f0f27603fe0 100644 (file)
@@ -156,6 +156,8 @@ static int snd_seq_device_dev_free(struct snd_device *device)
        struct snd_seq_device *dev = device->device_data;
 
        cancel_autoload_drivers();
+       if (dev->private_free)
+               dev->private_free(dev);
        put_device(&dev->dev);
        return 0;
 }
@@ -183,11 +185,7 @@ static int snd_seq_device_dev_disconnect(struct snd_device *device)
 
 static void snd_seq_dev_release(struct device *dev)
 {
-       struct snd_seq_device *sdev = to_seq_dev(dev);
-
-       if (sdev->private_free)
-               sdev->private_free(sdev);
-       kfree(sdev);
+       kfree(to_seq_dev(dev));
 }
 
 /*
index 062da7a7a5861f994da1236a62b6138b158eb514..f7bd6e2db085bb666bcba9618cfdeb15541455e8 100644 (file)
@@ -421,8 +421,9 @@ int snd_hdac_bus_reset_link(struct hdac_bus *bus, bool full_reset)
        if (!full_reset)
                goto skip_reset;
 
-       /* clear STATESTS */
-       snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK);
+       /* clear STATESTS if not in reset */
+       if (snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET)
+               snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK);
 
        /* reset controller */
        snd_hdac_bus_enter_link_reset(bus);
index 2523b23389e97dba45ff600b88535c47c6b13d56..1c8bffc3eec6e674b36065bf447400db71aa0835 100644 (file)
@@ -298,29 +298,31 @@ int snd_hda_codec_configure(struct hda_codec *codec)
 {
        int err;
 
+       if (codec->configured)
+               return 0;
+
        if (is_generic_config(codec))
                codec->probe_id = HDA_CODEC_ID_GENERIC;
        else
                codec->probe_id = 0;
 
-       err = snd_hdac_device_register(&codec->core);
-       if (err < 0)
-               return err;
+       if (!device_is_registered(&codec->core.dev)) {
+               err = snd_hdac_device_register(&codec->core);
+               if (err < 0)
+                       return err;
+       }
 
        if (!codec->preset)
                codec_bind_module(codec);
        if (!codec->preset) {
                err = codec_bind_generic(codec);
                if (err < 0) {
-                       codec_err(codec, "Unable to bind the codec\n");
-                       goto error;
+                       codec_dbg(codec, "Unable to bind the codec\n");
+                       return err;
                }
        }
 
+       codec->configured = 1;
        return 0;
-
- error:
-       snd_hdac_device_unregister(&codec->core);
-       return err;
 }
 EXPORT_SYMBOL_GPL(snd_hda_codec_configure);
index a9ebefd60cf68a0e773af8fdad276226566456ea..0c4a337c9fc0d266db5afd4d37210a33c889e61e 100644 (file)
@@ -791,6 +791,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
        snd_array_free(&codec->nids);
        remove_conn_list(codec);
        snd_hdac_regmap_exit(&codec->core);
+       codec->configured = 0;
 }
 EXPORT_SYMBOL_GPL(snd_hda_codec_cleanup_for_unbind);
 
index 7cd452831fd30956fcf6fff20e989f684b94fe95..930ae4002a8187addcc97defc7b75573c804fd88 100644 (file)
@@ -25,6 +25,7 @@
 #include <sound/core.h>
 #include <sound/initval.h>
 #include "hda_controller.h"
+#include "hda_local.h"
 
 #define CREATE_TRACE_POINTS
 #include "hda_controller_trace.h"
@@ -1248,17 +1249,24 @@ EXPORT_SYMBOL_GPL(azx_probe_codecs);
 int azx_codec_configure(struct azx *chip)
 {
        struct hda_codec *codec, *next;
+       int success = 0;
 
-       /* use _safe version here since snd_hda_codec_configure() deregisters
-        * the device upon error and deletes itself from the bus list.
-        */
-       list_for_each_codec_safe(codec, next, &chip->bus) {
-               snd_hda_codec_configure(codec);
+       list_for_each_codec(codec, &chip->bus) {
+               if (!snd_hda_codec_configure(codec))
+                       success++;
        }
 
-       if (!azx_bus(chip)->num_codecs)
-               return -ENODEV;
-       return 0;
+       if (success) {
+               /* unregister failed codecs if any codec has been probed */
+               list_for_each_codec_safe(codec, next, &chip->bus) {
+                       if (!codec->configured) {
+                               codec_err(codec, "Unable to configure, disabling\n");
+                               snd_hdac_device_unregister(&codec->core);
+                       }
+               }
+       }
+
+       return success ? 0 : -ENODEV;
 }
 EXPORT_SYMBOL_GPL(azx_codec_configure);
 
index 3062f87380b1b41f5f273f4c26b2ceda0aed3575..f5bf295eb83078d2586a5985aaa1af4eb2840116 100644 (file)
@@ -41,7 +41,7 @@
 /* 24 unused */
 #define AZX_DCAPS_COUNT_LPIB_DELAY  (1 << 25)  /* Take LPIB as delay */
 #define AZX_DCAPS_PM_RUNTIME   (1 << 26)       /* runtime PM support */
-/* 27 unused */
+#define AZX_DCAPS_RETRY_PROBE  (1 << 27)       /* retry probe if no codec is configured */
 #define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28)  /* CORBRP clears itself after reset */
 #define AZX_DCAPS_NO_MSI64      (1 << 29)      /* Stick to 32-bit MSIs */
 #define AZX_DCAPS_SEPARATE_STREAM_TAG  (1 << 30) /* capture and playback use separate stream tag */
index 47777439961c36320f194c6dcc5c1e31f20b6d65..4d22e7adeee8ecf11006c951f18ed10cf8e220f9 100644 (file)
@@ -307,7 +307,8 @@ enum {
 /* quirks for AMD SB */
 #define AZX_DCAPS_PRESET_AMD_SB \
        (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_AMD_WORKAROUND |\
-        AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME)
+        AZX_DCAPS_SNOOP_TYPE(ATI) | AZX_DCAPS_PM_RUNTIME |\
+        AZX_DCAPS_RETRY_PROBE)
 
 /* quirks for Nvidia */
 #define AZX_DCAPS_PRESET_NVIDIA \
@@ -1723,7 +1724,7 @@ static void azx_check_snoop_available(struct azx *chip)
 
 static void azx_probe_work(struct work_struct *work)
 {
-       struct hda_intel *hda = container_of(work, struct hda_intel, probe_work);
+       struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work);
        azx_probe_continue(&hda->chip);
 }
 
@@ -1828,7 +1829,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
        }
 
        /* continue probing in work context as may trigger request module */
-       INIT_WORK(&hda->probe_work, azx_probe_work);
+       INIT_DELAYED_WORK(&hda->probe_work, azx_probe_work);
 
        *rchip = chip;
 
@@ -2142,7 +2143,7 @@ static int azx_probe(struct pci_dev *pci,
 #endif
 
        if (schedule_probe)
-               schedule_work(&hda->probe_work);
+               schedule_delayed_work(&hda->probe_work, 0);
 
        dev++;
        if (chip->disabled)
@@ -2228,6 +2229,11 @@ static int azx_probe_continue(struct azx *chip)
        int dev = chip->dev_index;
        int err;
 
+       if (chip->disabled || hda->init_failed)
+               return -EIO;
+       if (hda->probe_retry)
+               goto probe_retry;
+
        to_hda_bus(bus)->bus_probing = 1;
        hda->probe_continued = 1;
 
@@ -2289,10 +2295,20 @@ static int azx_probe_continue(struct azx *chip)
 #endif
        }
 #endif
+
+ probe_retry:
        if (bus->codec_mask && !(probe_only[dev] & 1)) {
                err = azx_codec_configure(chip);
-               if (err < 0)
+               if (err) {
+                       if ((chip->driver_caps & AZX_DCAPS_RETRY_PROBE) &&
+                           ++hda->probe_retry < 60) {
+                               schedule_delayed_work(&hda->probe_work,
+                                                     msecs_to_jiffies(1000));
+                               return 0; /* keep things up */
+                       }
+                       dev_err(chip->card->dev, "Cannot probe codecs, giving up\n");
                        goto out_free;
+               }
        }
 
        err = snd_card_register(chip->card);
@@ -2322,6 +2338,7 @@ out_free:
                display_power(chip, false);
        complete_all(&hda->probe_wait);
        to_hda_bus(bus)->bus_probing = 0;
+       hda->probe_retry = 0;
        return 0;
 }
 
@@ -2347,7 +2364,7 @@ static void azx_remove(struct pci_dev *pci)
                 * device during cancel_work_sync() call.
                 */
                device_unlock(&pci->dev);
-               cancel_work_sync(&hda->probe_work);
+               cancel_delayed_work_sync(&hda->probe_work);
                device_lock(&pci->dev);
 
                snd_card_free(card);
index 3fb119f090408865e2a380292807469b9bd8d369..0f39418f9328b08e7c34c2db540eed30f734100c 100644 (file)
@@ -14,7 +14,7 @@ struct hda_intel {
 
        /* sync probing */
        struct completion probe_wait;
-       struct work_struct probe_work;
+       struct delayed_work probe_work;
 
        /* card list (for power_save trigger) */
        struct list_head list;
@@ -30,6 +30,8 @@ struct hda_intel {
        unsigned int freed:1; /* resources already released */
 
        bool need_i915_power:1; /* the hda controller needs i915 power */
+
+       int probe_retry;        /* being probe-retry */
 };
 
 #endif
index 4407f7da57c40f6b0a16b3fd4b38af2b46fd5d99..22d27b12c4e756cacb569202f029e30d98452d47 100644 (file)
@@ -526,6 +526,8 @@ static void alc_shutup_pins(struct hda_codec *codec)
        struct alc_spec *spec = codec->spec;
 
        switch (codec->core.vendor_id) {
+       case 0x10ec0236:
+       case 0x10ec0256:
        case 0x10ec0283:
        case 0x10ec0286:
        case 0x10ec0288:
@@ -2537,7 +2539,8 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
        SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
        SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
-       SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
+       SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
        SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
@@ -3528,7 +3531,8 @@ static void alc256_shutup(struct hda_codec *codec)
        /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
         * when booting with headset plugged. So skip setting it for the codec alc257
         */
-       if (codec->core.vendor_id != 0x10ec0257)
+       if (spec->codec_variant != ALC269_TYPE_ALC257 &&
+           spec->codec_variant != ALC269_TYPE_ALC256)
                alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
 
        if (!spec->no_shutup_pins)
@@ -6449,6 +6453,24 @@ static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
 /* for alc285_fixup_ideapad_s740_coef() */
 #include "ideapad_s740_helper.c"
 
+static void alc256_fixup_tongfang_reset_persistent_settings(struct hda_codec *codec,
+                                                           const struct hda_fixup *fix,
+                                                           int action)
+{
+       /*
+       * A certain other OS sets these coeffs to different values. On at least one TongFang
+       * barebone these settings might survive even a cold reboot. So to restore a clean slate the
+       * values are explicitly reset to default here. Without this, the external microphone is
+       * always in a plugged-in state, while the internal microphone is always in an unplugged
+       * state, breaking the ability to use the internal microphone.
+       */
+       alc_write_coef_idx(codec, 0x24, 0x0000);
+       alc_write_coef_idx(codec, 0x26, 0x0000);
+       alc_write_coef_idx(codec, 0x29, 0x3000);
+       alc_write_coef_idx(codec, 0x37, 0xfe05);
+       alc_write_coef_idx(codec, 0x45, 0x5089);
+}
+
 enum {
        ALC269_FIXUP_GPIO2,
        ALC269_FIXUP_SONY_VAIO,
@@ -6663,7 +6685,8 @@ enum {
        ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
        ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
        ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
-       ALC287_FIXUP_13S_GEN2_SPEAKERS
+       ALC287_FIXUP_13S_GEN2_SPEAKERS,
+       ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -8344,7 +8367,7 @@ static const struct hda_fixup alc269_fixups[] = {
                .v.verbs = (const struct hda_verb[]) {
                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
                        { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
-                       { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
+                       { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
@@ -8361,6 +8384,10 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC269_FIXUP_HEADSET_MODE,
        },
+       [ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc256_fixup_tongfang_reset_persistent_settings,
+       },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -8452,6 +8479,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1028, 0x0a30, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
        SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
        SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
+       SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
+       SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
+       SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -8789,6 +8819,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
        SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
        SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
+       SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS),
        SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
        SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
@@ -10166,6 +10197,9 @@ enum {
        ALC671_FIXUP_HP_HEADSET_MIC2,
        ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
        ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
+       ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
+       ALC668_FIXUP_HEADSET_MIC,
+       ALC668_FIXUP_MIC_DET_COEF,
 };
 
 static const struct hda_fixup alc662_fixups[] = {
@@ -10549,6 +10583,29 @@ static const struct hda_fixup alc662_fixups[] = {
                .chained = true,
                .chain_id = ALC662_FIXUP_USI_FUNC
        },
+       [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x1b, 0x04a1112c },
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC668_FIXUP_HEADSET_MIC
+       },
+       [ALC668_FIXUP_HEADSET_MIC] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc269_fixup_headset_mic,
+               .chained = true,
+               .chain_id = ALC668_FIXUP_MIC_DET_COEF
+       },
+       [ALC668_FIXUP_MIC_DET_COEF] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
+                       { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
+                       {}
+               },
+       },
 };
 
 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
@@ -10584,6 +10641,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
        SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
        SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
+       SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
        SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
        SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
        SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
index 3d5848d5481be93156792793f92575f3bba850c8..53ebabf42472224ee1dee0eeea5e8f7879c4739c 100644 (file)
@@ -2450,6 +2450,8 @@ static int scarlett2_update_monitor_other(struct usb_mixer_interface *mixer)
                err = scarlett2_usb_get_config(mixer,
                                               SCARLETT2_CONFIG_TALKBACK_MAP,
                                               1, &bitmap);
+               if (err < 0)
+                       return err;
                for (i = 0; i < num_mixes; i++, bitmap >>= 1)
                        private->talkback_map[i] = bitmap & 1;
        }
index e03043f7dad3fe00fa0a0576f0f32fc620127dfc..de18fff6928037fbd4ae4356f320b8c78662fd24 100644 (file)
 /* E-Mu 0204 USB */
 { USB_DEVICE_VENDOR_SPEC(0x041e, 0x3f19) },
 
+/*
+ * Creative Technology, Ltd Live! Cam Sync HD [VF0770]
+ * The device advertises 8 formats, but only a rate of 48kHz is honored by the
+ * hardware and 24 bits give chopped audio, so only report the one working
+ * combination.
+ */
+{
+       USB_DEVICE(0x041e, 0x4095),
+       .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
+               .ifnum = QUIRK_ANY_INTERFACE,
+               .type = QUIRK_COMPOSITE,
+               .data = &(const struct snd_usb_audio_quirk[]) {
+                       {
+                               .ifnum = 2,
+                               .type = QUIRK_AUDIO_STANDARD_MIXER,
+                       },
+                       {
+                               .ifnum = 3,
+                               .type = QUIRK_AUDIO_FIXED_ENDPOINT,
+                               .data = &(const struct audioformat) {
+                                       .formats = SNDRV_PCM_FMTBIT_S16_LE,
+                                       .channels = 2,
+                                       .fmt_bits = 16,
+                                       .iface = 3,
+                                       .altsetting = 4,
+                                       .altset_idx = 4,
+                                       .endpoint = 0x82,
+                                       .ep_attr = 0x05,
+                                       .rates = SNDRV_PCM_RATE_48000,
+                                       .rate_min = 48000,
+                                       .rate_max = 48000,
+                                       .nr_rates = 1,
+                                       .rate_table = (unsigned int[]) { 48000 },
+                               },
+                       },
+                       {
+                               .ifnum = -1
+                       },
+               },
+       },
+},
+
 /*
  * HP Wireless Audio
  * When not ignored, causes instability issues for some users, forcing them to
index 6ee6d24c847fd51e968b1960f4a0fcd9363fac7f..889c855addfc81219a6571018bdb01c5df68ea98 100644 (file)
@@ -1900,6 +1900,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
                   QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY),
        VENDOR_FLG(0x07fd, /* MOTU */
                   QUIRK_FLAG_VALIDATE_RATES),
+       VENDOR_FLG(0x1235, /* Focusrite Novation */
+                  QUIRK_FLAG_VALIDATE_RATES),
        VENDOR_FLG(0x152a, /* Thesycon devices */
                   QUIRK_FLAG_DSD_RAW),
        VENDOR_FLG(0x1de7, /* Phoenix Audio */
index 5a931456e71851c3a799e2a348e968ec666d484e..ac35c61f65f5fd43457957f178f3ca72721bfedc 100755 (executable)
@@ -16,7 +16,7 @@ assert sys.version_info >= (3, 7), "Python version is too old"
 
 from collections import namedtuple
 from enum import Enum, auto
-from typing import Iterable
+from typing import Iterable, Sequence
 
 import kunit_config
 import kunit_json
@@ -186,6 +186,26 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree,
                                exec_result.elapsed_time))
        return parse_result
 
+# Problem:
+# $ kunit.py run --json
+# works as one would expect and prints the parsed test results as JSON.
+# $ kunit.py run --json suite_name
+# would *not* pass suite_name as the filter_glob and print as json.
+# argparse will consider it to be another way of writing
+# $ kunit.py run --json=suite_name
+# i.e. it would run all tests, and dump the json to a `suite_name` file.
+# So we hackily automatically rewrite --json => --json=stdout
+pseudo_bool_flag_defaults = {
+               '--json': 'stdout',
+               '--raw_output': 'kunit',
+}
+def massage_argv(argv: Sequence[str]) -> Sequence[str]:
+       def massage_arg(arg: str) -> str:
+               if arg not in pseudo_bool_flag_defaults:
+                       return arg
+               return  f'{arg}={pseudo_bool_flag_defaults[arg]}'
+       return list(map(massage_arg, argv))
+
 def add_common_opts(parser) -> None:
        parser.add_argument('--build_dir',
                            help='As in the make command, it specifies the build '
@@ -303,7 +323,7 @@ def main(argv, linux=None):
                                  help='Specifies the file to read results from.',
                                  type=str, nargs='?', metavar='input_file')
 
-       cli_args = parser.parse_args(argv)
+       cli_args = parser.parse_args(massage_argv(argv))
 
        if get_kernel_root_path():
                os.chdir(get_kernel_root_path())
index 619c4554cbff247bc1f2c9c6cb61f01c61d6b747..1edcc8373b4e3195a5b88634bcb45964381abcc2 100755 (executable)
@@ -408,6 +408,14 @@ class KUnitMainTest(unittest.TestCase):
                        self.assertNotEqual(call, mock.call(StrContains('Testing complete.')))
                        self.assertNotEqual(call, mock.call(StrContains(' 0 tests run')))
 
+       def test_run_raw_output_does_not_take_positional_args(self):
+               # --raw_output is a string flag, but we don't want it to consume
+               # any positional arguments, only ones after an '='
+               self.linux_source_mock.run_kernel = mock.Mock(return_value=[])
+               kunit.main(['run', '--raw_output', 'filter_glob'], self.linux_source_mock)
+               self.linux_source_mock.run_kernel.assert_called_once_with(
+                       args=None, build_dir='.kunit', filter_glob='filter_glob', timeout=300)
+
        def test_exec_timeout(self):
                timeout = 3453
                kunit.main(['exec', '--timeout', str(timeout)], self.linux_source_mock)
index 3caf72bb9c6a1241511bdb0b7f72c77ddce174b8..a2489ec398fe01325e23f17ac253e6c4002e27bc 100755 (executable)
@@ -468,10 +468,26 @@ out_bits()
   for i in {0..22}
   do
     ip -netns ioam-node-alpha route change db01::/64 encap ioam6 trace \
-           prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} dev veth0
-
-    run_test "out_bit$i" "${desc/<n>/$i}" ioam-node-alpha ioam-node-beta \
-           db01::2 db01::1 veth0 ${bit2type[$i]} 123
+           prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} \
+           dev veth0 &>/dev/null
+
+    local cmd_res=$?
+    local descr="${desc/<n>/$i}"
+
+    if [[ $i -ge 12 && $i -le 21 ]]
+    then
+      if [ $cmd_res != 0 ]
+      then
+        npassed=$((npassed+1))
+        log_test_passed "$descr"
+      else
+        nfailed=$((nfailed+1))
+        log_test_failed "$descr"
+      fi
+    else
+      run_test "out_bit$i" "$descr" ioam-node-alpha ioam-node-beta \
+             db01::2 db01::1 veth0 ${bit2type[$i]} 123
+    fi
   done
 
   bit2size[22]=$tmp
@@ -544,7 +560,7 @@ in_bits()
   local tmp=${bit2size[22]}
   bit2size[22]=$(( $tmp + ${#BETA[9]} + ((4 - (${#BETA[9]} % 4)) % 4) ))
 
-  for i in {0..22}
+  for i in {0..11} {22..22}
   do
     ip -netns ioam-node-alpha route change db01::/64 encap ioam6 trace \
            prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} dev veth0
index d376cb2c383c3821270fa657a6025ae5471857be..8f6997d3581612ba7379349594c79e00ebaa6e36 100644 (file)
@@ -94,16 +94,6 @@ enum {
        TEST_OUT_BIT9,
        TEST_OUT_BIT10,
        TEST_OUT_BIT11,
-       TEST_OUT_BIT12,
-       TEST_OUT_BIT13,
-       TEST_OUT_BIT14,
-       TEST_OUT_BIT15,
-       TEST_OUT_BIT16,
-       TEST_OUT_BIT17,
-       TEST_OUT_BIT18,
-       TEST_OUT_BIT19,
-       TEST_OUT_BIT20,
-       TEST_OUT_BIT21,
        TEST_OUT_BIT22,
        TEST_OUT_FULL_SUPP_TRACE,
 
@@ -125,16 +115,6 @@ enum {
        TEST_IN_BIT9,
        TEST_IN_BIT10,
        TEST_IN_BIT11,
-       TEST_IN_BIT12,
-       TEST_IN_BIT13,
-       TEST_IN_BIT14,
-       TEST_IN_BIT15,
-       TEST_IN_BIT16,
-       TEST_IN_BIT17,
-       TEST_IN_BIT18,
-       TEST_IN_BIT19,
-       TEST_IN_BIT20,
-       TEST_IN_BIT21,
        TEST_IN_BIT22,
        TEST_IN_FULL_SUPP_TRACE,
 
@@ -199,30 +179,6 @@ static int check_ioam_header(int tid, struct ioam6_trace_hdr *ioam6h,
                       ioam6h->nodelen != 2 ||
                       ioam6h->remlen;
 
-       case TEST_OUT_BIT12:
-       case TEST_IN_BIT12:
-       case TEST_OUT_BIT13:
-       case TEST_IN_BIT13:
-       case TEST_OUT_BIT14:
-       case TEST_IN_BIT14:
-       case TEST_OUT_BIT15:
-       case TEST_IN_BIT15:
-       case TEST_OUT_BIT16:
-       case TEST_IN_BIT16:
-       case TEST_OUT_BIT17:
-       case TEST_IN_BIT17:
-       case TEST_OUT_BIT18:
-       case TEST_IN_BIT18:
-       case TEST_OUT_BIT19:
-       case TEST_IN_BIT19:
-       case TEST_OUT_BIT20:
-       case TEST_IN_BIT20:
-       case TEST_OUT_BIT21:
-       case TEST_IN_BIT21:
-               return ioam6h->overflow ||
-                      ioam6h->nodelen ||
-                      ioam6h->remlen != 1;
-
        case TEST_OUT_BIT22:
        case TEST_IN_BIT22:
                return ioam6h->overflow ||
@@ -326,6 +282,66 @@ static int check_ioam6_data(__u8 **p, struct ioam6_trace_hdr *ioam6h,
                *p += sizeof(__u32);
        }
 
+       if (ioam6h->type.bit12) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit13) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit14) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit15) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit16) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit17) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit18) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit19) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit20) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
+       if (ioam6h->type.bit21) {
+               if (__be32_to_cpu(*((__u32 *)*p)) != 0xffffffff)
+                       return 1;
+               *p += sizeof(__u32);
+       }
+
        if (ioam6h->type.bit22) {
                len = cnf.sc_data ? strlen(cnf.sc_data) : 0;
                aligned = cnf.sc_data ? __ALIGN_KERNEL(len, 4) : 0;
@@ -455,26 +471,6 @@ static int str2id(const char *tname)
                return TEST_OUT_BIT10;
        if (!strcmp("out_bit11", tname))
                return TEST_OUT_BIT11;
-       if (!strcmp("out_bit12", tname))
-               return TEST_OUT_BIT12;
-       if (!strcmp("out_bit13", tname))
-               return TEST_OUT_BIT13;
-       if (!strcmp("out_bit14", tname))
-               return TEST_OUT_BIT14;
-       if (!strcmp("out_bit15", tname))
-               return TEST_OUT_BIT15;
-       if (!strcmp("out_bit16", tname))
-               return TEST_OUT_BIT16;
-       if (!strcmp("out_bit17", tname))
-               return TEST_OUT_BIT17;
-       if (!strcmp("out_bit18", tname))
-               return TEST_OUT_BIT18;
-       if (!strcmp("out_bit19", tname))
-               return TEST_OUT_BIT19;
-       if (!strcmp("out_bit20", tname))
-               return TEST_OUT_BIT20;
-       if (!strcmp("out_bit21", tname))
-               return TEST_OUT_BIT21;
        if (!strcmp("out_bit22", tname))
                return TEST_OUT_BIT22;
        if (!strcmp("out_full_supp_trace", tname))
@@ -509,26 +505,6 @@ static int str2id(const char *tname)
                return TEST_IN_BIT10;
        if (!strcmp("in_bit11", tname))
                return TEST_IN_BIT11;
-       if (!strcmp("in_bit12", tname))
-               return TEST_IN_BIT12;
-       if (!strcmp("in_bit13", tname))
-               return TEST_IN_BIT13;
-       if (!strcmp("in_bit14", tname))
-               return TEST_IN_BIT14;
-       if (!strcmp("in_bit15", tname))
-               return TEST_IN_BIT15;
-       if (!strcmp("in_bit16", tname))
-               return TEST_IN_BIT16;
-       if (!strcmp("in_bit17", tname))
-               return TEST_IN_BIT17;
-       if (!strcmp("in_bit18", tname))
-               return TEST_IN_BIT18;
-       if (!strcmp("in_bit19", tname))
-               return TEST_IN_BIT19;
-       if (!strcmp("in_bit20", tname))
-               return TEST_IN_BIT20;
-       if (!strcmp("in_bit21", tname))
-               return TEST_IN_BIT21;
        if (!strcmp("in_bit22", tname))
                return TEST_IN_BIT22;
        if (!strcmp("in_full_supp_trace", tname))
@@ -606,16 +582,6 @@ static int (*func[__TEST_MAX])(int, struct ioam6_trace_hdr *, __u32, __u16) = {
        [TEST_OUT_BIT9]         = check_ioam_header_and_data,
        [TEST_OUT_BIT10]                = check_ioam_header_and_data,
        [TEST_OUT_BIT11]                = check_ioam_header_and_data,
-       [TEST_OUT_BIT12]                = check_ioam_header,
-       [TEST_OUT_BIT13]                = check_ioam_header,
-       [TEST_OUT_BIT14]                = check_ioam_header,
-       [TEST_OUT_BIT15]                = check_ioam_header,
-       [TEST_OUT_BIT16]                = check_ioam_header,
-       [TEST_OUT_BIT17]                = check_ioam_header,
-       [TEST_OUT_BIT18]                = check_ioam_header,
-       [TEST_OUT_BIT19]                = check_ioam_header,
-       [TEST_OUT_BIT20]                = check_ioam_header,
-       [TEST_OUT_BIT21]                = check_ioam_header,
        [TEST_OUT_BIT22]                = check_ioam_header_and_data,
        [TEST_OUT_FULL_SUPP_TRACE]      = check_ioam_header_and_data,
        [TEST_IN_UNDEF_NS]              = check_ioam_header,
@@ -633,16 +599,6 @@ static int (*func[__TEST_MAX])(int, struct ioam6_trace_hdr *, __u32, __u16) = {
        [TEST_IN_BIT9]                  = check_ioam_header_and_data,
        [TEST_IN_BIT10]         = check_ioam_header_and_data,
        [TEST_IN_BIT11]         = check_ioam_header_and_data,
-       [TEST_IN_BIT12]         = check_ioam_header,
-       [TEST_IN_BIT13]         = check_ioam_header,
-       [TEST_IN_BIT14]         = check_ioam_header,
-       [TEST_IN_BIT15]         = check_ioam_header,
-       [TEST_IN_BIT16]         = check_ioam_header,
-       [TEST_IN_BIT17]         = check_ioam_header,
-       [TEST_IN_BIT18]         = check_ioam_header,
-       [TEST_IN_BIT19]         = check_ioam_header,
-       [TEST_IN_BIT20]         = check_ioam_header,
-       [TEST_IN_BIT21]         = check_ioam_header,
        [TEST_IN_BIT22]         = check_ioam_header_and_data,
        [TEST_IN_FULL_SUPP_TRACE]       = check_ioam_header_and_data,
        [TEST_FWD_FULL_SUPP_TRACE]      = check_ioam_header_and_data,