03 Oct, 2020

1 commit

  • Replace /* Fall through. */ comment with the new pseudo-keyword macro
    fallthrough[1].

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Jens Axboe

    Gustavo A. R. Silva
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

08 Aug, 2020

1 commit

  • Pull PCI updates from Bjorn Helgaas:
    "Enumeration:
    - Fix pci_cfg_wait queue locking problem (Bjorn Helgaas)
    - Convert PCIe capability PCIBIOS errors to errno (Bolarinwa Olayemi
    Saheed)
    - Align PCIe capability and PCI accessor return values (Bolarinwa
    Olayemi Saheed)
    - Fix pci_create_slot() reference count leak (Qiushi Wu)
    - Announce device after early fixups (Tiezhu Yang)

    PCI device hotplug:
    - Make rpadlpar functions static (Wei Yongjun)

    Driver binding:
    - Add device even if driver attach failed (Rajat Jain)

    Virtualization:
    - xen: Remove redundant initialization of irq (Colin Ian King)

    IOMMU:
    - Add pci_pri_supported() to check device or associated PF (Ashok Raj)
    - Release IVRS table in AMD ACS quirk (Hanjun Guo)
    - Mark AMD Navi10 GPU rev 0x00 ATS as broken (Kai-Heng Feng)
    - Treat "external-facing" devices themselves as internal (Rajat Jain)

    MSI:
    - Forward MSI-X error code in pci_alloc_irq_vectors_affinity() (Piotr
    Stankiewicz)

    Error handling:
    - Clear PCIe Device Status errors only if OS owns AER (Jonathan
    Cameron)
    - Log correctable errors as warning, not error (Matt Jolly)
    - Use 'pci_channel_state_t' instead of 'enum pci_channel_state' (Luc
    Van Oostenryck)

    Peer-to-peer DMA:
    - Allow P2PDMA on AMD Zen and newer CPUs (Logan Gunthorpe)

    ASPM:
    - Add missing newline in sysfs 'policy' (Xiongfeng Wang)

    Native PCIe controllers:
    - Convert to devm_platform_ioremap_resource_byname() (Dejin Zheng)
    - Convert to devm_platform_ioremap_resource() (Dejin Zheng)
    - Remove duplicate error message from devm_pci_remap_cfg_resource()
    callers (Dejin Zheng)
    - Fix runtime PM imbalance on error (Dinghao Liu)
    - Remove dev_err() when handing an error from platform_get_irq()
    (Krzysztof Wilczyński)
    - Use pci_host_bridge.windows list directly instead of splicing in a
    temporary list for cadence, mvebu, host-common (Rob Herring)
    - Use pci_host_probe() instead of open-coding all the pieces for
    altera, brcmstb, iproc, mobiveil, rcar, rockchip, tegra, v3,
    versatile, xgene, xilinx, xilinx-nwl (Rob Herring)
    - Default host bridge parent device to the platform device (Rob
    Herring)
    - Use pci_is_root_bus() instead of tracking root bus number
    separately in aardvark, designware (imx6, keystone,
    designware-host), mobiveil, xilinx-nwl, xilinx, rockchip, rcar (Rob
    Herring)
    - Set host bridge bus number in pci_scan_root_bus_bridge() instead of
    each driver for aardvark, designware-host, host-common, mediatek,
    rcar, tegra, v3-semi (Rob Herring)
    - Move DT resource setup into devm_pci_alloc_host_bridge() (Rob
    Herring)
    - Set bridge map_irq and swizzle_irq to default functions; drivers
    that don't support legacy IRQs (iproc) need to undo this (Rob
    Herring)

    ARM Versatile PCIe controller driver:
    - Drop flag PCI_ENABLE_PROC_DOMAINS (Rob Herring)

    Cadence PCIe controller driver:
    - Use "dma-ranges" instead of "cdns,no-bar-match-nbits" property
    (Kishon Vijay Abraham I)
    - Remove "mem" from reg binding (Kishon Vijay Abraham I)
    - Fix cdns_pcie_{host|ep}_setup() error path (Kishon Vijay Abraham I)
    - Convert all r/w accessors to perform only 32-bit accesses (Kishon
    Vijay Abraham I)
    - Add support to start link and verify link status (Kishon Vijay
    Abraham I)
    - Allow pci_host_bridge to have custom pci_ops (Kishon Vijay Abraham I)
    - Add new *ops* for CPU addr fixup (Kishon Vijay Abraham I)
    - Fix updating Vendor ID and Subsystem Vendor ID register (Kishon
    Vijay Abraham I)
    - Use bridge resources for outbound window setup (Rob Herring)
    - Remove private bus number and range storage (Rob Herring)

    Cadence PCIe endpoint driver:
    - Add MSI-X support (Alan Douglas)

    HiSilicon PCIe controller driver:
    - Remove non-ECAM HiSilicon hip05/hip06 driver (Rob Herring)

    Intel VMD host bridge driver:
    - Use Shadow MEMBAR registers for QEMU/KVM guests (Jon Derrick)

    Loongson PCIe controller driver:
    - Use DECLARE_PCI_FIXUP_EARLY for bridge_class_quirk() (Tiezhu Yang)

    Marvell Aardvark PCIe controller driver:
    - Indicate error in 'val' when config read fails (Pali Rohár)
    - Don't touch PCIe registers if no card connected (Pali Rohár)

    Marvell MVEBU PCIe controller driver:
    - Setup BAR0 in order to fix MSI (Shmuel Hazan)

    Microsoft Hyper-V host bridge driver:
    - Fix a timing issue which causes kdump to fail occasionally (Wei Hu)
    - Make some functions static (Wei Yongjun)

    NVIDIA Tegra PCIe controller driver:
    - Revert tegra124 raw_violation_fixup (Nicolas Chauvet)
    - Remove PLL power supplies (Thierry Reding)

    Qualcomm PCIe controller driver:
    - Change duplicate PCI reset to phy reset (Abhishek Sahu)
    - Add missing ipq806x clocks in PCIe driver (Ansuel Smith)
    - Add missing reset for ipq806x (Ansuel Smith)
    - Add ext reset (Ansuel Smith)
    - Use bulk clk API and assert on error (Ansuel Smith)
    - Add support for tx term offset for rev 2.1.0 (Ansuel Smith)
    - Define some PARF params needed for ipq8064 SoC (Ansuel Smith)
    - Add ipq8064 rev2 variant (Ansuel Smith)
    - Support PCI speed set for ipq806x (Sham Muthayyan)

    Renesas R-Car PCIe controller driver:
    - Use devm_pci_alloc_host_bridge() (Rob Herring)
    - Use struct pci_host_bridge.windows list directly (Rob Herring)
    - Convert rcar-gen2 to use modern host bridge probe functions (Rob
    Herring)

    TI J721E PCIe driver:
    - Add TI J721E PCIe host and endpoint driver (Kishon Vijay Abraham I)

    Xilinx Versal CPM PCIe controller driver:
    - Add Versal CPM Root Port driver and YAML schema (Bharat Kumar
    Gogada)

    MicroSemi Switchtec management driver:
    - Add missing __iomem and __user tags to fix sparse warnings (Logan
    Gunthorpe)

    Miscellaneous:
    - Replace http:// links with https:// (Alexander A. Klimov)
    - Replace lkml.org, spinics, gmane with lore.kernel.org (Bjorn
    Helgaas)
    - Remove unused pci_lost_interrupt() (Heiner Kallweit)
    - Move PCI_VENDOR_ID_REDHAT definition to pci_ids.h (Huacai Chen)
    - Fix kerneldoc warnings (Krzysztof Kozlowski)"

    * tag 'pci-v5.9-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (113 commits)
    PCI: Fix kerneldoc warnings
    PCI: xilinx-cpm: Add Versal CPM Root Port driver
    PCI: xilinx-cpm: Add YAML schemas for Versal CPM Root Port
    PCI: Set bridge map_irq and swizzle_irq to default functions
    PCI: Move DT resource setup into devm_pci_alloc_host_bridge()
    PCI: rcar-gen2: Convert to use modern host bridge probe functions
    PCI: Remove dev_err() when handing an error from platform_get_irq()
    MAINTAINERS: Add Kishon Vijay Abraham I for TI J721E SoC PCIe
    misc: pci_endpoint_test: Add J721E in pci_device_id table
    PCI: j721e: Add TI J721E PCIe driver
    PCI: switchtec: Add missing __iomem tag to fix sparse warnings
    PCI: switchtec: Add missing __iomem and __user tags to fix sparse warnings
    PCI: rpadlpar: Make functions static
    PCI/P2PDMA: Allow P2PDMA on AMD Zen and newer CPUs
    PCI: Release IVRS table in AMD ACS quirk
    PCI: Announce device after early fixups
    PCI: Mark AMD Navi10 GPU rev 0x00 ATS as broken
    PCI: Remove unused pci_lost_interrupt()
    dt-bindings: PCI: Add EP mode dt-bindings for TI's J721E SoC
    dt-bindings: PCI: Add host mode dt-bindings for TI's J721E SoC
    ...

    Linus Torvalds
     

11 Jul, 2020

1 commit

  • The wrappers in include/linux/pci-dma-compat.h should go away.

    The patch has been generated with the coccinelle script bellow.
    It has been compile tested.

    This also aligns code with what is in use in '/rsxx/dma.c'

    @@
    @@
    - PCI_DMA_BIDIRECTIONAL
    + DMA_BIDIRECTIONAL

    @@
    @@
    - PCI_DMA_TODEVICE
    + DMA_TO_DEVICE

    @@
    @@
    - PCI_DMA_FROMDEVICE
    + DMA_FROM_DEVICE

    @@
    @@
    - PCI_DMA_NONE
    + DMA_NONE

    @@
    expression e1, e2, e3;
    @@
    - pci_alloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3;
    @@
    - pci_zalloc_consistent(e1, e2, e3)
    + dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_free_consistent(e1, e2, e3, e4)
    + dma_free_coherent(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_single(e1, e2, e3, e4)
    + dma_map_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_single(e1, e2, e3, e4)
    + dma_unmap_single(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4, e5;
    @@
    - pci_map_page(e1, e2, e3, e4, e5)
    + dma_map_page(&e1->dev, e2, e3, e4, e5)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_page(e1, e2, e3, e4)
    + dma_unmap_page(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_map_sg(e1, e2, e3, e4)
    + dma_map_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_unmap_sg(e1, e2, e3, e4)
    + dma_unmap_sg(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
    + dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_single_for_device(e1, e2, e3, e4)
    + dma_sync_single_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
    + dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2, e3, e4;
    @@
    - pci_dma_sync_sg_for_device(e1, e2, e3, e4)
    + dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

    @@
    expression e1, e2;
    @@
    - pci_dma_mapping_error(e1, e2)
    + dma_mapping_error(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_dma_mask(e1, e2)
    + dma_set_mask(&e1->dev, e2)

    @@
    expression e1, e2;
    @@
    - pci_set_consistent_dma_mask(e1, e2)
    + dma_set_coherent_mask(&e1->dev, e2)

    Signed-off-by: Christophe JAILLET
    Signed-off-by: Jens Axboe

    Christophe JAILLET
     

08 Jul, 2020

1 commit

  • The method struct pci_error_handlers.error_detected() is defined and
    documented as taking an 'enum pci_channel_state' for the second argument,
    but most drivers use 'pci_channel_state_t' instead.

    This 'pci_channel_state_t' is not a typedef for the enum but a typedef for
    a bitwise type in order to have better/stricter typechecking.

    Consolidate everything by using 'pci_channel_state_t' in the method's
    definition, in the related helpers and in the drivers.

    Enforce use of 'pci_channel_state_t' by replacing 'enum pci_channel_state'
    with an anonymous 'enum'.

    Note: Currently, from a typechecking point of view this patch changes
    nothing because only the constants defined by the enum are bitwise, not the
    enum itself (sparse doesn't have the notion of 'bitwise enum'). This may
    change in some not too far future, hence the patch.

    [bhelgaas: squash in
    https://lore.kernel.org/r/20200702162651.49526-3-luc.vanoostenryck@gmail.com
    https://lore.kernel.org/r/20200702162651.49526-4-luc.vanoostenryck@gmail.com]
    Link: https://lore.kernel.org/r/20200702162651.49526-2-luc.vanoostenryck@gmail.com
    Signed-off-by: Luc Van Oostenryck
    Signed-off-by: Bjorn Helgaas

    Luc Van Oostenryck
     

01 Jul, 2020

3 commits


27 May, 2020

1 commit


31 Mar, 2020

1 commit

  • Pull block driver updates from Jens Axboe:

    - floppy driver cleanup series from Willy

    - NVMe updates and fixes (Various)

    - null_blk trace improvements (Chaitanya)

    - bcache fixes (Coly)

    - md fixes (via Song)

    - loop block size change optimizations (Martijn)

    - scnprintf() use (Takashi)

    * tag 'for-5.7/drivers-2020-03-29' of git://git.kernel.dk/linux-block: (81 commits)
    null_blk: add trace in null_blk_zoned.c
    null_blk: add tracepoint helpers for zoned mode
    block: add a zone condition debug helper
    nvme: cleanup namespace identifier reporting in nvme_init_ns_head
    nvme: rename __nvme_find_ns_head to nvme_find_ns_head
    nvme: refactor nvme_identify_ns_descs error handling
    nvme-tcp: Add warning on state change failure at nvme_tcp_setup_ctrl
    nvme-rdma: Add warning on state change failure at nvme_rdma_setup_ctrl
    nvme: Fix controller creation races with teardown flow
    nvme: Make nvme_uninit_ctrl symmetric to nvme_init_ctrl
    nvme: Fix ctrl use-after-free during sysfs deletion
    nvme-pci: Re-order nvme_pci_free_ctrl
    nvme: Remove unused return code from nvme_delete_ctrl_sync
    nvme: Use nvme_state_terminal helper
    nvme: release ida resources
    nvme: Add compat_ioctl handler for NVME_IOCTL_SUBMIT_IO
    nvmet-tcp: optimize tcp stack TX when data digest is used
    nvme-fabrics: Use scnprintf() for avoiding potential buffer overflow
    nvme-multipath: do not reset on unknown status
    nvmet-rdma: allocate RW ctxs according to mdts
    ...

    Linus Torvalds
     

28 Mar, 2020

1 commit

  • Current make_request based drivers use either blk_alloc_queue_node or
    blk_alloc_queue to allocate a queue, and then set up the make_request_fn
    function pointer and a few parameters using the blk_queue_make_request
    helper. Simplify this by passing the make_request pointer to
    blk_alloc_queue, and while at it merge the _node variant into the main
    helper by always passing a node_id, and remove the superfluous gfp_mask
    parameter. A lower-level __blk_alloc_queue is kept for the blk-mq case.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

20 Mar, 2020

1 commit

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertenly introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Jens Axboe

    Gustavo A. R. Silva
     

15 Nov, 2019

1 commit


06 Jun, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


10 Apr, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    This patch fixes the following warnings:

    drivers/block/drbd/drbd_int.h:1774:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_int.h:1774:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_int.h:1774:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_int.h:1774:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_int.h:1774:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_receiver.c:3093:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_receiver.c:3120:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/block/drbd/drbd_req.c:856:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Warning level 3 was used: -Wimplicit-fallthrough=3

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough

    Reviewed-by: Chaitanya Kulkarni
    Acked-by: Roland Kammerer
    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

25 Oct, 2018

1 commit

  • Pull PCI updates from Bjorn Helgaas:

    - Fix ASPM link_state teardown on removal (Lukas Wunner)

    - Fix misleading _OSC ASPM message (Sinan Kaya)

    - Make _OSC optional for PCI (Sinan Kaya)

    - Don't initialize ASPM link state when ACPI_FADT_NO_ASPM is set
    (Patrick Talbert)

    - Remove x86 and arm64 node-local allocation for host bridge structures
    (Punit Agrawal)

    - Pay attention to device-specific _PXM node values (Jonathan Cameron)

    - Support new Immediate Readiness bit (Felipe Balbi)

    - Differentiate between pciehp surprise and safe removal (Lukas Wunner)

    - Remove unnecessary pciehp includes (Lukas Wunner)

    - Drop pciehp hotplug_slot_ops wrappers (Lukas Wunner)

    - Tolerate PCIe Slot Presence Detect being hardwired to zero to
    workaround broken hardware, e.g., the Wilocity switch/wireless device
    (Lukas Wunner)

    - Unify pciehp controller & slot structs (Lukas Wunner)

    - Constify hotplug_slot_ops (Lukas Wunner)

    - Drop hotplug_slot_info (Lukas Wunner)

    - Embed hotplug_slot struct into users instead of allocating it
    separately (Lukas Wunner)

    - Initialize PCIe port service drivers directly instead of relying on
    initcall ordering (Keith Busch)

    - Restore PCI config state after a slot reset (Keith Busch)

    - Save/restore DPC config state along with other PCI config state
    (Keith Busch)

    - Reference count devices during AER handling to avoid race issue with
    concurrent hot removal (Keith Busch)

    - If an Upstream Port reports ERR_FATAL, don't try to read the Port's
    config space because it is probably unreachable (Keith Busch)

    - During error handling, use slot-specific reset instead of secondary
    bus reset to avoid link up/down issues on hotplug ports (Keith Busch)

    - Restore previous AER/DPC handling that does not remove and
    re-enumerate devices on ERR_FATAL (Keith Busch)

    - Notify all drivers that may be affected by error recovery resets
    (Keith Busch)

    - Always generate error recovery uevents, even if a driver doesn't have
    error callbacks (Keith Busch)

    - Make PCIe link active reporting detection generic (Keith Busch)

    - Support D3cold in PCIe hierarchies during system sleep and runtime,
    including hotplug and Thunderbolt ports (Mika Westerberg)

    - Handle hpmemsize/hpiosize kernel parameters uniformly, whether slots
    are empty or occupied (Jon Derrick)

    - Remove duplicated include from pci/pcie/err.c and unused variable
    from cpqphp (YueHaibing)

    - Remove driver pci_cleanup_aer_uncorrect_error_status() calls (Oza
    Pawandeep)

    - Uninline PCI bus accessors for better ftracing (Keith Busch)

    - Remove unused AER Root Port .error_resume method (Keith Busch)

    - Use kfifo in AER instead of a local version (Keith Busch)

    - Use threaded IRQ in AER bottom half (Keith Busch)

    - Use managed resources in AER core (Keith Busch)

    - Reuse pcie_port_find_device() for AER injection (Keith Busch)

    - Abstract AER interrupt handling to disconnect error injection (Keith
    Busch)

    - Refactor AER injection callbacks to simplify future improvments
    (Keith Busch)

    - Remove unused Netronome NFP32xx Device IDs (Jakub Kicinski)

    - Use bitmap_zalloc() for dma_alias_mask (Andy Shevchenko)

    - Add switch fall-through annotations (Gustavo A. R. Silva)

    - Remove unused Switchtec quirk variable (Joshua Abraham)

    - Fix pci.c kernel-doc warning (Randy Dunlap)

    - Remove trivial PCI wrappers for DMA APIs (Christoph Hellwig)

    - Add Intel GPU device IDs to spurious interrupt quirk (Bin Meng)

    - Run Switchtec DMA aliasing quirk only on NTB endpoints to avoid
    useless dmesg errors (Logan Gunthorpe)

    - Update Switchtec NTB documentation (Wesley Yung)

    - Remove redundant "default n" from Kconfig (Bartlomiej Zolnierkiewicz)

    - Avoid panic when drivers enable MSI/MSI-X twice (Tonghao Zhang)

    - Add PCI support for peer-to-peer DMA (Logan Gunthorpe)

    - Add sysfs group for PCI peer-to-peer memory statistics (Logan
    Gunthorpe)

    - Add PCI peer-to-peer DMA scatterlist mapping interface (Logan
    Gunthorpe)

    - Add PCI configfs/sysfs helpers for use by peer-to-peer users (Logan
    Gunthorpe)

    - Add PCI peer-to-peer DMA driver writer's documentation (Logan
    Gunthorpe)

    - Add block layer flag to indicate driver support for PCI peer-to-peer
    DMA (Logan Gunthorpe)

    - Map Infiniband scatterlists for peer-to-peer DMA if they contain P2P
    memory (Logan Gunthorpe)

    - Register nvme-pci CMB buffer as PCI peer-to-peer memory (Logan
    Gunthorpe)

    - Add nvme-pci support for PCI peer-to-peer memory in requests (Logan
    Gunthorpe)

    - Use PCI peer-to-peer memory in nvme (Stephen Bates, Steve Wise,
    Christoph Hellwig, Logan Gunthorpe)

    - Cache VF config space size to optimize enumeration of many VFs
    (KarimAllah Ahmed)

    - Remove unnecessary include (Bjorn Helgaas)

    - Fix VMD AERSID quirk Device ID matching (Jon Derrick)

    - Fix Cadence PHY handling during probe (Alan Douglas)

    - Signal Cadence Endpoint interrupts via AXI region 0 instead of last
    region (Alan Douglas)

    - Write Cadence Endpoint MSI interrupts with 32 bits of data (Alan
    Douglas)

    - Remove redundant controller tests for "device_type == pci" (Rob
    Herring)

    - Document R-Car E3 (R8A77990) bindings (Tho Vu)

    - Add device tree support for R-Car r8a7744 (Biju Das)

    - Drop unused mvebu PCIe capability code (Thomas Petazzoni)

    - Add shared PCI bridge emulation code (Thomas Petazzoni)

    - Convert mvebu to use shared PCI bridge emulation (Thomas Petazzoni)

    - Add aardvark Root Port emulation (Thomas Petazzoni)

    - Support 100MHz/200MHz refclocks for i.MX6 (Lucas Stach)

    - Add initial power management for i.MX7 (Leonard Crestez)

    - Add PME_Turn_Off support for i.MX7 (Leonard Crestez)

    - Fix qcom runtime power management error handling (Bjorn Andersson)

    - Update TI dra7xx unaligned access errata workaround for host mode as
    well as endpoint mode (Vignesh R)

    - Fix kirin section mismatch warning (Nathan Chancellor)

    - Remove iproc PAXC slot check to allow VF support (Jitendra Bhivare)

    - Quirk Keystone K2G to limit MRRS to 256 (Kishon Vijay Abraham I)

    - Update Keystone to use MRRS quirk for host bridge instead of open
    coding (Kishon Vijay Abraham I)

    - Refactor Keystone link establishment (Kishon Vijay Abraham I)

    - Simplify and speed up Keystone link training (Kishon Vijay Abraham I)

    - Remove unused Keystone host_init argument (Kishon Vijay Abraham I)

    - Merge Keystone driver files into one (Kishon Vijay Abraham I)

    - Remove redundant Keystone platform_set_drvdata() (Kishon Vijay
    Abraham I)

    - Rename Keystone functions for uniformity (Kishon Vijay Abraham I)

    - Add Keystone device control module DT binding (Kishon Vijay Abraham
    I)

    - Use SYSCON API to get Keystone control module device IDs (Kishon
    Vijay Abraham I)

    - Clean up Keystone PHY handling (Kishon Vijay Abraham I)

    - Use runtime PM APIs to enable Keystone clock (Kishon Vijay Abraham I)

    - Clean up Keystone config space access checks (Kishon Vijay Abraham I)

    - Get Keystone outbound window count from DT (Kishon Vijay Abraham I)

    - Clean up Keystone outbound window configuration (Kishon Vijay Abraham
    I)

    - Clean up Keystone DBI setup (Kishon Vijay Abraham I)

    - Clean up Keystone ks_pcie_link_up() (Kishon Vijay Abraham I)

    - Fix Keystone IRQ status checking (Kishon Vijay Abraham I)

    - Add debug messages for all Keystone errors (Kishon Vijay Abraham I)

    - Clean up Keystone includes and macros (Kishon Vijay Abraham I)

    - Fix Mediatek unchecked return value from devm_pci_remap_iospace()
    (Gustavo A. R. Silva)

    - Fix Mediatek endpoint/port matching logic (Honghui Zhang)

    - Change Mediatek Root Port Class Code to PCI_CLASS_BRIDGE_PCI (Honghui
    Zhang)

    - Remove redundant Mediatek PM domain check (Honghui Zhang)

    - Convert Mediatek to pci_host_probe() (Honghui Zhang)

    - Fix Mediatek MSI enablement (Honghui Zhang)

    - Add Mediatek system PM support for MT2712 and MT7622 (Honghui Zhang)

    - Add Mediatek loadable module support (Honghui Zhang)

    - Detach VMD resources after stopping root bus to prevent orphan
    resources (Jon Derrick)

    - Convert pcitest build process to that used by other tools (iio, perf,
    etc) (Gustavo Pimentel)

    * tag 'pci-v4.20-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (140 commits)
    PCI/AER: Refactor error injection fallbacks
    PCI/AER: Abstract AER interrupt handling
    PCI/AER: Reuse existing pcie_port_find_device() interface
    PCI/AER: Use managed resource allocations
    PCI: pcie: Remove redundant 'default n' from Kconfig
    PCI: aardvark: Implement emulated root PCI bridge config space
    PCI: mvebu: Convert to PCI emulated bridge config space
    PCI: mvebu: Drop unused PCI express capability code
    PCI: Introduce PCI bridge emulated config space common logic
    PCI: vmd: Detach resources after stopping root bus
    nvmet: Optionally use PCI P2P memory
    nvmet: Introduce helper functions to allocate and free request SGLs
    nvme-pci: Add support for P2P memory in requests
    nvme-pci: Use PCI p2pmem subsystem to manage the CMB
    IB/core: Ensure we map P2P memory correctly in rdma_rw_ctx_[init|destroy]()
    block: Add PCI P2P flag for request queue
    PCI/P2PDMA: Add P2P DMA driver writer's documentation
    docs-rst: Add a new directory for PCI documentation
    PCI/P2PDMA: Introduce configfs/sysfs enable attribute helpers
    PCI/P2PDMA: Add PCI p2pmem DMA mappings to adjust the bus offset
    ...

    Linus Torvalds
     

19 Oct, 2018

1 commit


11 Oct, 2018

1 commit


28 Sep, 2018

1 commit

  • Update device_add_disk() to take an 'groups' argument so that
    individual drivers can register a device with additional sysfs
    attributes.
    This avoids race condition the driver would otherwise have if these
    groups were to be created with sysfs_add_groups().

    Signed-off-by: Martin Wilck
    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jens Axboe

    Hannes Reinecke
     

12 Sep, 2018

1 commit

  • Clang warns when more than one set of parentheses is used for a
    single conditional statement:

    drivers/block/rsxx/cregs.c:279:15: warning: equality comparison with
    extraneous parentheses [-Wparentheses-equality]
    if ((cmd->op == CREG_OP_READ)) {
    ~~~~~~~~^~~~~~~~~~~~~~~
    drivers/block/rsxx/cregs.c:279:15: note: remove extraneous parentheses
    around the comparison to silence this warning
    if ((cmd->op == CREG_OP_READ)) {
    ~ ^ ~
    drivers/block/rsxx/cregs.c:279:15: note: use '=' to turn this equality
    comparison into an assignment
    if ((cmd->op == CREG_OP_READ)) {
    ^~
    =
    1 warning generated.

    Reported-by: Nick Desaulniers
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Jens Axboe

    Nathan Chancellor
     

27 Aug, 2018

1 commit

  • Pull IDA updates from Matthew Wilcox:
    "A better IDA API:

    id = ida_alloc(ida, GFP_xxx);
    ida_free(ida, id);

    rather than the cumbersome ida_simple_get(), ida_simple_remove().

    The new IDA API is similar to ida_simple_get() but better named. The
    internal restructuring of the IDA code removes the bitmap
    preallocation nonsense.

    I hope the net -200 lines of code is convincing"

    * 'ida-4.19' of git://git.infradead.org/users/willy/linux-dax: (29 commits)
    ida: Change ida_get_new_above to return the id
    ida: Remove old API
    test_ida: check_ida_destroy and check_ida_alloc
    test_ida: Convert check_ida_conv to new API
    test_ida: Move ida_check_max
    test_ida: Move ida_check_leaf
    idr-test: Convert ida_check_nomem to new API
    ida: Start new test_ida module
    target/iscsi: Allocate session IDs from an IDA
    iscsi target: fix session creation failure handling
    drm/vmwgfx: Convert to new IDA API
    dmaengine: Convert to new IDA API
    ppc: Convert vas ID allocation to new IDA API
    media: Convert entity ID allocation to new IDA API
    ppc: Convert mmu context allocation to new IDA API
    Convert net_namespace to new IDA API
    cb710: Convert to new IDA API
    rsxx: Convert to new IDA API
    osd: Convert to new IDA API
    sd: Convert to new IDA API
    ...

    Linus Torvalds
     

22 Aug, 2018

1 commit


18 Jul, 2018

1 commit

  • Add and use a new op_stat_group() function for indexing partition stat
    fields rather than indexing them by rq_data_dir() or bio_data_dir().
    This function works similarly to op_is_sync() in that it takes the
    request::cmd_flags or bio::bi_opf flags and determines which stats
    should et updated.

    In addition, the second parameter to generic_start_io_acct() and
    generic_end_io_acct() is now a REQ_OP rather than simply a read or
    write bit and it uses op_stat_group() on the parameter to determine
    the stat group.

    Note that the partition in_flight counts are not part of the per-cpu
    statistics and as such are not indexed via this function. It's now
    indexed by op_is_write().

    tj: Refreshed on top of v4.17. Updated to pass around REQ_OP.

    Signed-off-by: Michael Callahan
    Signed-off-by: Tejun Heo
    Cc: Minchan Kim
    Cc: Dan Williams
    Cc: Joshua Morris
    Cc: Philipp Reisner
    Cc: Matias Bjorling
    Cc: Kent Overstreet
    Cc: Alasdair Kergon
    Signed-off-by: Jens Axboe

    Michael Callahan
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

25 May, 2018

1 commit

  • Convert the S_ symbolic permissions to their octal equivalents as
    using octal and not symbolic permissions is preferred by many as more
    readable.

    see: https://lkml.org/lkml/2016/8/2/1945

    Done with automated conversion via:
    $ ./scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace

    Miscellanea:

    o Wrapped modified multi-line calls to a single line where appropriate
    o Realign modified multi-line calls to open parenthesis

    Signed-off-by: Joe Perches
    Signed-off-by: Jens Axboe

    Joe Perches
     

09 Mar, 2018

1 commit

  • This patch has been generated as follows:

    for verb in set_unlocked clear_unlocked set clear; do
    replace-in-files queue_flag_${verb} blk_queue_flag_${verb%_unlocked} \
    $(git grep -lw queue_flag_${verb} drivers block/bsg*)
    done

    Except for protecting all queue flag changes with the queue lock
    this patch does not change any functionality.

    Cc: Mike Snitzer
    Cc: Shaohua Li
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Ming Lei
    Signed-off-by: Bart Van Assche
    Reviewed-by: Martin K. Petersen
    Reviewed-by: Johannes Thumshirn
    Acked-by: Martin K. Petersen
    Signed-off-by: Jens Axboe

    Bart Van Assche
     

22 Nov, 2017

2 commits

  • This converts all remaining setup_timer() calls that use a nested field
    to reach a struct timer_list. Coccinelle does not have an easy way to
    match multiple fields, so a new script is needed to change the matches of
    "&_E->_timer" into "&_E->_field1._timer" in all the rules.

    spatch --very-quiet --all-includes --include-headers \
    -I ./arch/x86/include -I ./arch/x86/include/generated \
    -I ./include -I ./arch/x86/include/uapi \
    -I ./arch/x86/include/generated/uapi -I ./include/uapi \
    -I ./include/generated/uapi --include ./include/linux/kconfig.h \
    --dir . \
    --cocci-file ~/src/data/timer_setup-2fields.cocci

    @fix_address_of depends@
    expression e;
    @@

    setup_timer(
    -&(e)
    +&e
    , ...)

    // Update any raw setup_timer() usages that have a NULL callback, but
    // would otherwise match change_timer_function_usage, since the latter
    // will update all function assignments done in the face of a NULL
    // function initialization in setup_timer().
    @change_timer_function_usage_NULL@
    expression _E;
    identifier _field1;
    identifier _timer;
    type _cast_data;
    @@

    (
    -setup_timer(&_E->_field1._timer, NULL, _E);
    +timer_setup(&_E->_field1._timer, NULL, 0);
    |
    -setup_timer(&_E->_field1._timer, NULL, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, NULL, 0);
    |
    -setup_timer(&_E._field1._timer, NULL, &_E);
    +timer_setup(&_E._field1._timer, NULL, 0);
    |
    -setup_timer(&_E._field1._timer, NULL, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, NULL, 0);
    )

    @change_timer_function_usage@
    expression _E;
    identifier _field1;
    identifier _timer;
    struct timer_list _stl;
    identifier _callback;
    type _cast_func, _cast_data;
    @@

    (
    -setup_timer(&_E->_field1._timer, _callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, &_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)&_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, &_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)&_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    _E->_field1._timer@_stl.function = _callback;
    |
    _E->_field1._timer@_stl.function = &_callback;
    |
    _E->_field1._timer@_stl.function = (_cast_func)_callback;
    |
    _E->_field1._timer@_stl.function = (_cast_func)&_callback;
    |
    _E._field1._timer@_stl.function = _callback;
    |
    _E._field1._timer@_stl.function = &_callback;
    |
    _E._field1._timer@_stl.function = (_cast_func)_callback;
    |
    _E._field1._timer@_stl.function = (_cast_func)&_callback;
    )

    // callback(unsigned long arg)
    @change_callback_handle_cast
    depends on change_timer_function_usage@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    (
    ... when != _origarg
    _handletype *_handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    )
    }

    // callback(unsigned long arg) without existing variable
    @change_callback_handle_cast_no_arg
    depends on change_timer_function_usage &&
    !change_callback_handle_cast@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    + _handletype *_origarg = from_timer(_origarg, t, _field1._timer);
    +
    ... when != _origarg
    - (_handletype *)_origarg
    + _origarg
    ... when != _origarg
    }

    // Avoid already converted callbacks.
    @match_callback_converted
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    { ... }

    // callback(struct something *handle)
    @change_callback_handle_arg
    depends on change_timer_function_usage &&
    !match_callback_converted &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_handletype *_handle
    +struct timer_list *t
    )
    {
    + _handletype *_handle = from_timer(_handle, t, _field1._timer);
    ...
    }

    // If change_callback_handle_arg ran on an empty function, remove
    // the added handler.
    @unchange_callback_handle_arg
    depends on change_timer_function_usage &&
    change_callback_handle_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    {
    - _handletype *_handle = from_timer(_handle, t, _field1._timer);
    }

    // We only want to refactor the setup_timer() data argument if we've found
    // the matching callback. This undoes changes in change_timer_function_usage.
    @unchange_timer_function_usage
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg &&
    !change_callback_handle_arg@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type change_timer_function_usage._cast_data;
    @@

    (
    -timer_setup(&_E->_field1._timer, _callback, 0);
    +setup_timer(&_E->_field1._timer, _callback, (_cast_data)_E);
    |
    -timer_setup(&_E._field1._timer, _callback, 0);
    +setup_timer(&_E._field1._timer, _callback, (_cast_data)&_E);
    )

    // If we fixed a callback from a .function assignment, fix the
    // assignment cast now.
    @change_timer_function_assignment
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_func;
    typedef TIMER_FUNC_TYPE;
    @@

    (
    _E->_field1._timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -(_cast_func)_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -&_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -(_cast_func)_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    )

    // Sometimes timer functions are called directly. Replace matched args.
    @change_timer_function_calls
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression _E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_data;
    @@

    _callback(
    (
    -(_cast_data)_E
    +&_E->_field1._timer
    |
    -(_cast_data)&_E
    +&_E._field1._timer
    |
    -_E
    +&_E->_field1._timer
    )
    )

    // If a timer has been configured without a data argument, it can be
    // converted without regard to the callback argument, since it is unused.
    @match_timer_function_unused_data@
    expression _E;
    identifier _field1;
    identifier _timer;
    identifier _callback;
    @@

    (
    -setup_timer(&_E->_field1._timer, _callback, 0);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, 0L);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, 0UL);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0L);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0UL);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0L);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0UL);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0);
    +timer_setup(_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0L);
    +timer_setup(_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0UL);
    +timer_setup(_field1._timer, _callback, 0);
    )

    @change_callback_unused_data
    depends on match_timer_function_unused_data@
    identifier match_timer_function_unused_data._callback;
    type _origtype;
    identifier _origarg;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *unused
    )
    {
    ... when != _origarg
    }

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This converts all remaining cases of the old setup_timer() API into using
    timer_setup(), where the callback argument is the structure already
    holding the struct timer_list. These should have no behavioral changes,
    since they just change which pointer is passed into the callback with
    the same available pointers after conversion. It handles the following
    examples, in addition to some other variations.

    Casting from unsigned long:

    void my_callback(unsigned long data)
    {
    struct something *ptr = (struct something *)data;
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, ptr);

    and forced object casts:

    void my_callback(struct something *ptr)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);

    become:

    void my_callback(struct timer_list *t)
    {
    struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

    Direct function assignments:

    void my_callback(unsigned long data)
    {
    struct something *ptr = (struct something *)data;
    ...
    }
    ...
    ptr->my_timer.function = my_callback;

    have a temporary cast added, along with converting the args:

    void my_callback(struct timer_list *t)
    {
    struct something *ptr = from_timer(ptr, t, my_timer);
    ...
    }
    ...
    ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;

    And finally, callbacks without a data assignment:

    void my_callback(unsigned long data)
    {
    ...
    }
    ...
    setup_timer(&ptr->my_timer, my_callback, 0);

    have their argument renamed to verify they're unused during conversion:

    void my_callback(struct timer_list *unused)
    {
    ...
    }
    ...
    timer_setup(&ptr->my_timer, my_callback, 0);

    The conversion is done with the following Coccinelle script:

    spatch --very-quiet --all-includes --include-headers \
    -I ./arch/x86/include -I ./arch/x86/include/generated \
    -I ./include -I ./arch/x86/include/uapi \
    -I ./arch/x86/include/generated/uapi -I ./include/uapi \
    -I ./include/generated/uapi --include ./include/linux/kconfig.h \
    --dir . \
    --cocci-file ~/src/data/timer_setup.cocci

    @fix_address_of@
    expression e;
    @@

    setup_timer(
    -&(e)
    +&e
    , ...)

    // Update any raw setup_timer() usages that have a NULL callback, but
    // would otherwise match change_timer_function_usage, since the latter
    // will update all function assignments done in the face of a NULL
    // function initialization in setup_timer().
    @change_timer_function_usage_NULL@
    expression _E;
    identifier _timer;
    type _cast_data;
    @@

    (
    -setup_timer(&_E->_timer, NULL, _E);
    +timer_setup(&_E->_timer, NULL, 0);
    |
    -setup_timer(&_E->_timer, NULL, (_cast_data)_E);
    +timer_setup(&_E->_timer, NULL, 0);
    |
    -setup_timer(&_E._timer, NULL, &_E);
    +timer_setup(&_E._timer, NULL, 0);
    |
    -setup_timer(&_E._timer, NULL, (_cast_data)&_E);
    +timer_setup(&_E._timer, NULL, 0);
    )

    @change_timer_function_usage@
    expression _E;
    identifier _timer;
    struct timer_list _stl;
    identifier _callback;
    type _cast_func, _cast_data;
    @@

    (
    -setup_timer(&_E->_timer, _callback, _E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, &_callback, _E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, _callback, (_cast_data)_E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, (_cast_func)_callback, _E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E._timer, _callback, (_cast_data)_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, _callback, (_cast_data)&_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
    +timer_setup(&_E._timer, _callback, 0);
    |
    _E->_timer@_stl.function = _callback;
    |
    _E->_timer@_stl.function = &_callback;
    |
    _E->_timer@_stl.function = (_cast_func)_callback;
    |
    _E->_timer@_stl.function = (_cast_func)&_callback;
    |
    _E._timer@_stl.function = _callback;
    |
    _E._timer@_stl.function = &_callback;
    |
    _E._timer@_stl.function = (_cast_func)_callback;
    |
    _E._timer@_stl.function = (_cast_func)&_callback;
    )

    // callback(unsigned long arg)
    @change_callback_handle_cast
    depends on change_timer_function_usage@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    (
    ... when != _origarg
    _handletype *_handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _timer);
    ... when != _origarg
    )
    }

    // callback(unsigned long arg) without existing variable
    @change_callback_handle_cast_no_arg
    depends on change_timer_function_usage &&
    !change_callback_handle_cast@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    + _handletype *_origarg = from_timer(_origarg, t, _timer);
    +
    ... when != _origarg
    - (_handletype *)_origarg
    + _origarg
    ... when != _origarg
    }

    // Avoid already converted callbacks.
    @match_callback_converted
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    { ... }

    // callback(struct something *handle)
    @change_callback_handle_arg
    depends on change_timer_function_usage &&
    !match_callback_converted &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_handletype *_handle
    +struct timer_list *t
    )
    {
    + _handletype *_handle = from_timer(_handle, t, _timer);
    ...
    }

    // If change_callback_handle_arg ran on an empty function, remove
    // the added handler.
    @unchange_callback_handle_arg
    depends on change_timer_function_usage &&
    change_callback_handle_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    {
    - _handletype *_handle = from_timer(_handle, t, _timer);
    }

    // We only want to refactor the setup_timer() data argument if we've found
    // the matching callback. This undoes changes in change_timer_function_usage.
    @unchange_timer_function_usage
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg &&
    !change_callback_handle_arg@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type change_timer_function_usage._cast_data;
    @@

    (
    -timer_setup(&_E->_timer, _callback, 0);
    +setup_timer(&_E->_timer, _callback, (_cast_data)_E);
    |
    -timer_setup(&_E._timer, _callback, 0);
    +setup_timer(&_E._timer, _callback, (_cast_data)&_E);
    )

    // If we fixed a callback from a .function assignment, fix the
    // assignment cast now.
    @change_timer_function_assignment
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_func;
    typedef TIMER_FUNC_TYPE;
    @@

    (
    _E->_timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_timer.function =
    -&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_timer.function =
    -(_cast_func)_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._timer.function =
    -&_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._timer.function =
    -(_cast_func)_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    )

    // Sometimes timer functions are called directly. Replace matched args.
    @change_timer_function_calls
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression _E;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_data;
    @@

    _callback(
    (
    -(_cast_data)_E
    +&_E->_timer
    |
    -(_cast_data)&_E
    +&_E._timer
    |
    -_E
    +&_E->_timer
    )
    )

    // If a timer has been configured without a data argument, it can be
    // converted without regard to the callback argument, since it is unused.
    @match_timer_function_unused_data@
    expression _E;
    identifier _timer;
    identifier _callback;
    @@

    (
    -setup_timer(&_E->_timer, _callback, 0);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, _callback, 0L);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E->_timer, _callback, 0UL);
    +timer_setup(&_E->_timer, _callback, 0);
    |
    -setup_timer(&_E._timer, _callback, 0);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, _callback, 0L);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_E._timer, _callback, 0UL);
    +timer_setup(&_E._timer, _callback, 0);
    |
    -setup_timer(&_timer, _callback, 0);
    +timer_setup(&_timer, _callback, 0);
    |
    -setup_timer(&_timer, _callback, 0L);
    +timer_setup(&_timer, _callback, 0);
    |
    -setup_timer(&_timer, _callback, 0UL);
    +timer_setup(&_timer, _callback, 0);
    |
    -setup_timer(_timer, _callback, 0);
    +timer_setup(_timer, _callback, 0);
    |
    -setup_timer(_timer, _callback, 0L);
    +timer_setup(_timer, _callback, 0);
    |
    -setup_timer(_timer, _callback, 0UL);
    +timer_setup(_timer, _callback, 0);
    )

    @change_callback_unused_data
    depends on match_timer_function_unused_data@
    identifier match_timer_function_unused_data._callback;
    type _origtype;
    identifier _origarg;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *unused
    )
    {
    ... when != _origarg
    }

    Signed-off-by: Kees Cook

    Kees Cook
     

10 Aug, 2017

1 commit


28 Jun, 2017

1 commit


19 Jun, 2017

1 commit

  • blk_queue_split() is always called with the last arg being q->bio_split,
    where 'q' is the first arg.

    Also blk_queue_split() sometimes uses the passed-in 'bs' and sometimes uses
    q->bio_split.

    This is inconsistent and unnecessary. Remove the last arg and always use
    q->bio_split inside blk_queue_split()

    Reviewed-by: Christoph Hellwig
    Reviewed-by: Ming Lei
    Credit-to: Javier González (Noticed that lightnvm was missed)
    Reviewed-by: Javier González
    Tested-by: Javier González
    Signed-off-by: NeilBrown
    Signed-off-by: Jens Axboe

    NeilBrown
     

09 Jun, 2017

1 commit

  • Replace bi_error with a new bi_status to allow for a clear conversion.
    Note that device mapper overloaded bi_error with a private value, which
    we'll have to keep arround at least for now and thus propagate to a
    proper blk_status_t value.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

09 Apr, 2017

1 commit


28 Jun, 2016

1 commit

  • For block drivers that specify a parent device, convert them to use
    device_add_disk().

    This conversion was done with the following semantic patch:

    @@
    struct gendisk *disk;
    expression E;
    @@

    - disk->driverfs_dev = E;
    ...
    - add_disk(disk);
    + device_add_disk(E, disk);

    @@
    struct gendisk *disk;
    expression E1, E2;
    @@

    - disk->driverfs_dev = E1;
    ...
    E2 = disk;
    ...
    - add_disk(E2);
    + device_add_disk(E1, E2);

    ...plus some manual fixups for a few missed conversions.

    Cc: Jens Axboe
    Cc: Keith Busch
    Cc: Michael S. Tsirkin
    Cc: David Woodhouse
    Cc: David S. Miller
    Cc: James Bottomley
    Cc: Ross Zwisler
    Cc: Konrad Rzeszutek Wilk
    Cc: Martin K. Petersen
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Johannes Thumshirn
    Signed-off-by: Dan Williams

    Dan Williams
     

08 Jun, 2016

1 commit

  • This patch converts the simple bi_rw use cases in the block,
    drivers, mm and fs code to set/get the bio operation using
    bio_set_op_attrs/bio_op

    These should be simple one or two liner cases, so I just did them
    in one patch. The next patches handle the more complicated
    cases in a module per patch.

    Signed-off-by: Mike Christie
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Mike Christie
     

06 Jan, 2016

1 commit


08 Nov, 2015

1 commit


14 Aug, 2015

1 commit

  • The way the block layer is currently written, it goes to great lengths
    to avoid having to split bios; upper layer code (such as bio_add_page())
    checks what the underlying device can handle and tries to always create
    bios that don't need to be split.

    But this approach becomes unwieldy and eventually breaks down with
    stacked devices and devices with dynamic limits, and it adds a lot of
    complexity. If the block layer could split bios as needed, we could
    eliminate a lot of complexity elsewhere - particularly in stacked
    drivers. Code that creates bios can then create whatever size bios are
    convenient, and more importantly stacked drivers don't have to deal with
    both their own bio size limitations and the limitations of the
    (potentially multiple) devices underneath them. In the future this will
    let us delete merge_bvec_fn and a bunch of other code.

    We do this by adding calls to blk_queue_split() to the various
    make_request functions that need it - a few can already handle arbitrary
    size bios. Note that we add the call _after_ any call to
    blk_queue_bounce(); this means that blk_queue_split() and
    blk_recalc_rq_segments() don't need to be concerned with bouncing
    affecting segment merging.

    Some make_request_fn() callbacks were simple enough to audit and verify
    they don't need blk_queue_split() calls. The skipped ones are:

    * nfhd_make_request (arch/m68k/emu/nfblock.c)
    * axon_ram_make_request (arch/powerpc/sysdev/axonram.c)
    * simdisk_make_request (arch/xtensa/platforms/iss/simdisk.c)
    * brd_make_request (ramdisk - drivers/block/brd.c)
    * mtip_submit_request (drivers/block/mtip32xx/mtip32xx.c)
    * loop_make_request
    * null_queue_bio
    * bcache's make_request fns

    Some others are almost certainly safe to remove now, but will be left
    for future patches.

    Cc: Jens Axboe
    Cc: Christoph Hellwig
    Cc: Al Viro
    Cc: Ming Lei
    Cc: Neil Brown
    Cc: Alasdair Kergon
    Cc: Mike Snitzer
    Cc: dm-devel@redhat.com
    Cc: Lars Ellenberg
    Cc: drbd-user@lists.linbit.com
    Cc: Jiri Kosina
    Cc: Geoff Levand
    Cc: Jim Paris
    Cc: Philip Kelleher
    Cc: Minchan Kim
    Cc: Nitin Gupta
    Cc: Oleg Drokin
    Cc: Andreas Dilger
    Acked-by: NeilBrown (for the 'md/md.c' bits)
    Acked-by: Mike Snitzer
    Reviewed-by: Martin K. Petersen
    Signed-off-by: Kent Overstreet
    [dpark: skip more mq-based drivers, resolve merge conflicts, etc.]
    Signed-off-by: Dongsu Park
    Signed-off-by: Ming Lin
    Signed-off-by: Jens Axboe

    Kent Overstreet