Commit Graph

88 Commits

Author SHA1 Message Date
Myron Stowe 13cab74c35 PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: 22a9120479a40a56c13c5e473a0100fad2e017c0

commit 22a9120479a40a56c13c5e473a0100fad2e017c0
Author: Siddharth Vadapalli <s-vadapalli@ti.com>
Date:   Mon Nov 4 13:14:20 2024 +0530

    PCI: j721e: Deassert PERST# after a delay of PCIE_T_PVPERL_MS milliseconds

    According to Section 2.2 of the PCI Express Card Electromechanical
    Specification (Revision 5.1), in order to ensure that the power and the
    reference clock are stable, PERST# has to be deasserted after a delay of
    100 milliseconds (TPVPERL).

    Currently, it is being assumed that the power is already stable, which
    is not necessarily true.

    Hence, change the delay to PCIE_T_PVPERL_MS to guarantee that power and
    reference clock are stable.

    Fixes: f3e25911a4 ("PCI: j721e: Add TI J721E PCIe driver")
    Fixes: f96b69713733 ("PCI: j721e: Use T_PERST_CLK_US macro")
    Link: https://lore.kernel.org/r/20241104074420.1862932-1-s-vadapalli@ti.com
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:10 -07:00
Myron Stowe 0ba357bfb4 PCI: Fix typos
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: 5c7bdac783be8dcba1427460e7971445f839a5e2

commit 5c7bdac783be8dcba1427460e7971445f839a5e2
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Thu Mar 14 14:54:46 2024 -0500

    PCI: Fix typos

    Fix typos.

    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:10 -07:00
Myron Stowe 98d10f9883 PCI: j721e: Add suspend and resume support
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: c538d40f365b5b6d7433d371710f58e8b266fb19

commit c538d40f365b5b6d7433d371710f58e8b266fb19
Author: Théo Lebrun <theo.lebrun@bootlin.com>
Date:   Wed Jun 19 12:15:15 2024 +0200

    PCI: j721e: Add suspend and resume support

    Add suspend and resume support. Only the Root Complex mode is supported.

    During the suspend stage PERST# is asserted, then deasserted during the
    resume stage.

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-7-a2f9156da6c3@bootlin.com
    Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    [kwilczynski: commit log, update references to the PCI SIG specification]
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe f29f5a55ed PCI: j721e: Use T_PERST_CLK_US macro
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: f96b6971373382855bc964f1c067bd6dc41cf0ab

commit f96b6971373382855bc964f1c067bd6dc41cf0ab
Author: Thomas Richard <thomas.richard@bootlin.com>
Date:   Wed Jun 19 12:15:14 2024 +0200

    PCI: j721e: Use T_PERST_CLK_US macro

    Use the T_PERST_CLK_US macro, and the fsleep() function instead of
    usleep_range().

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-6-a2f9156da6c3@bootlin.com
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 07d95c523c PCI: j721e: Add reset GPIO to struct j721e_pcie
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: b8600b8791cb2b7c8be894846b1ecddba7291680

commit b8600b8791cb2b7c8be894846b1ecddba7291680
Author: Théo Lebrun <theo.lebrun@bootlin.com>
Date:   Wed Jun 19 12:15:12 2024 +0200

    PCI: j721e: Add reset GPIO to struct j721e_pcie

    Add reset GPIO to struct j721e_pcie, so it can be used at suspend and
    resume stages.

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-4-a2f9156da6c3@bootlin.com
    Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe db3c13f785 PCI: j721e: Use dev_err_probe() in the probe() function
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: 7d7ce746a9e109ab0aa30ad3c6107e601cf17045

commit 7d7ce746a9e109ab0aa30ad3c6107e601cf17045
Author: Thomas Richard <thomas.richard@bootlin.com>
Date:   Wed Jun 19 12:15:11 2024 +0200

    PCI: j721e: Use dev_err_probe() in the probe() function

    Use dev_err_probe() instead of dev_err() in the probe() function to
    simplify the code and standardize the error output.

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-3-a2f9156da6c3@bootlin.com
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 5604488dd5 PCI: cadence: Set cdns_pcie_host_init() global
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: 063c938928dc80c2bfd66f34df48344db22e009b

commit 063c938928dc80c2bfd66f34df48344db22e009b
Author: Thomas Richard <thomas.richard@bootlin.com>
Date:   Wed Jun 19 12:15:10 2024 +0200

    PCI: cadence: Set cdns_pcie_host_init() global

    During the resume sequence of the host, cdns_pcie_host_init() needs to be
    called, so set it global.

    The dev function parameter is removed, as it isn't used.

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-2-a2f9156da6c3@bootlin.com
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 4409af314c PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup()
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: d1b6f2e2ce4d8b17d9f3558c98a1517b864bfd03

commit d1b6f2e2ce4d8b17d9f3558c98a1517b864bfd03
Author: Thomas Richard <thomas.richard@bootlin.com>
Date:   Wed Jun 19 12:15:09 2024 +0200

    PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup()

    The function cdns_pcie_host_setup() mixes probe structure and link setup.

    The link setup must be done during the resume sequence. So extract it from
    cdns_pcie_host_setup() and create a dedicated function.

    Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-1-a2f9156da6c3@bootlin.com
    Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 12899dc9d9 PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: 82c4be4168e26a5593aaa1002b5678128a638824

commit 82c4be4168e26a5593aaa1002b5678128a638824
Author: Siddharth Vadapalli <s-vadapalli@ti.com>
Date:   Thu Aug 29 16:23:16 2024 +0530

    PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists

    The ACSPCIE module is capable of driving the reference clock required by
    the PCIe Endpoint device. It is an alternative to on-board and external
    reference clock generators. Enabling the output from the ACSPCIE module's
    PAD IO Buffers requires clearing the "PAD IO disable" bits of the
    ACSPCIE_PROXY_CTRL register in the CTRL_MMR register space.

    Add support to enable the ACSPCIE reference clock output using the optional
    device-tree property "ti,syscon-acspcie-proxy-ctrl".

    Link: https://lore.kernel.org/linux-pci/20240829105316.1483684-3-s-vadapalli@ti.com
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 1a338c0ff7 PCI: cadence: Drop excess cdns_pcie_rc.dev kerneldoc description
JIRA: https://issues.redhat.com/browse/RHEL-67693
Upstream Status: c3d95aa93fd8549588097b0701b3835920fd8533

commit c3d95aa93fd8549588097b0701b3835920fd8533
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Tue Sep 3 15:31:33 2024 -0500

    PCI: cadence: Drop excess cdns_pcie_rc.dev kerneldoc description

    Struct cdns_pcie_rc once had a .dev member, but it was removed by
    bd22885aa1 ("PCI: cadence: Refactor driver to use as a core library").
    Drop the extra kerneldoc for it.

    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2025-02-18 09:48:09 -07:00
Myron Stowe 8ecbcef564 PCI: endpoint: Remove "core_init_notifier" flag
JIRA: https://issues.redhat.com/browse/RHEL-50255
Upstream Status: a01e7214bef904723d26d293eb17586078610379

commit a01e7214bef904723d26d293eb17586078610379
Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Date:   Wed Mar 27 14:43:37 2024 +0530

    PCI: endpoint: Remove "core_init_notifier" flag

    "core_init_notifier" flag is set by the glue drivers requiring refclk from
    the host to complete the DWC core initialization. Also, those drivers will
    send a notification to the EPF drivers once the initialization is fully
    completed using the pci_epc_init_notify() API. Only then, the EPF drivers
    will start functioning.

    For the rest of the drivers generating refclk locally, EPF drivers will
    start functioning post binding with them. EPF drivers rely on the
    'core_init_notifier' flag to differentiate between the drivers.
    Unfortunately, this creates two different flows for the EPF drivers.

    So to avoid that, let's get rid of the "core_init_notifier" flag and follow
    a single initialization flow for the EPF drivers. This is done by calling
    the dw_pcie_ep_init_notify() from all glue drivers after the completion of
    dw_pcie_ep_init_registers() API. This will allow all the glue drivers to
    send the notification to the EPF drivers once the initialization is fully
    completed.

    Only difference here is that, the drivers requiring refclk from host will
    send the notification once refclk is received, while others will send it
    during probe time itself.

    But this also requires the EPC core driver to deliver the notification
    after EPF driver bind. Because, the glue driver can send the notification
    before the EPF drivers bind() and in those cases the EPF drivers will miss
    the event. To accommodate this, EPC core is now caching the state of the
    EPC initialization in 'init_complete' flag and pci-ep-cfs driver sends the
    notification to EPF drivers based on that after each EPF driver bind.

    Link: https://lore.kernel.org/linux-pci/20240327-pci-dbi-rework-v12-8-082625472414@linaro.org
    Tested-by: Niklas Cassel <cassel@kernel.org>
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Frank Li <Frank.Li@nxp.com>
    Reviewed-by: Niklas Cassel <cassel@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-08-15 15:31:13 -06:00
Myron Stowe 3587299702 PCI: cadence: Set a 64-bit BAR if requested
JIRA: https://issues.redhat.com/browse/RHEL-50255
Upstream Status: 07db0fa80cf311be17da55e01f99d455f83a7c7b

commit 07db0fa80cf311be17da55e01f99d455f83a7c7b
Author: Niklas Cassel <cassel@kernel.org>
Date:   Wed Mar 20 12:31:53 2024 +0100

    PCI: cadence: Set a 64-bit BAR if requested

    Ever since commit f25b5fae29 ("PCI: endpoint: Setting a BAR size > 4 GB
    is invalid if 64-bit flag is not set") it has been impossible to get the
    .set_bar() callback with a BAR size > 2 GB (yes, 2GB!), if the BAR was
    also not requested to be configured as a 64-bit BAR.

    Thus, forcing setting the 64-bit flag for BARs larger than 2 GB in the
    lower level driver is dead code and can be removed.

    It is however possible that an EPF driver configures a BAR as 64-bit,
    even if the requested size is < 4 GB.

    Respect the requested BAR configuration, just like how it is already
    respected with regards to the prefetchable bit.

    Link: https://lore.kernel.org/linux-pci/20240320113157.322695-7-cassel@kernel.org
    Signed-off-by: Niklas Cassel <cassel@kernel.org>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-08-15 15:31:13 -06:00
Myron Stowe 1bd9a763dc PCI: cadence: Clear the ARI Capability Next Function Number of the last function
JIRA: https://issues.redhat.com/browse/RHEL-33544
Upstream Status: 667a006d73fb7320fc6f414b6fe11a998fcf0c28

commit 667a006d73fb7320fc6f414b6fe11a998fcf0c28
Author: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
Date:   Sat Dec 2 14:20:15 2023 +0530

    PCI: cadence: Clear the ARI Capability Next Function Number of the last function

    Next Function Number field in ARI Capability Register for last function
    must be zero by default as per the PCIe specification, indicating there
    is no next higher number function but that's not happening in our case,
    so this patch clears the Next Function Number field for last function
    used.

    [kwilczynski: white spaces update for one define]
    Link: https://lore.kernel.org/linux-pci/20231202085015.3048516-1-s-vadapalli@ti.com
    Signed-off-by: Jasko-EXT Wojciech <wojciech.jasko-EXT@continental-corporation.com>
    Signed-off-by: Achal Verma <a-verma1@ti.com>
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-05-13 15:56:48 -06:00
Myron Stowe c9546ea91e PCI: cadence: Use INTX instead of legacy
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: 570e8579761a68d80c29034c291b34cff732d76d

commit 570e8579761a68d80c29034c291b34cff732d76d
Author: Damien Le Moal <dlemoal@kernel.org>
Date:   Wed Nov 22 15:03:58 2023 +0900

    PCI: cadence: Use INTX instead of legacy

    In the Cadence endpoint controller driver, rename the function
    cdns_pcie_ep_send_legacy_irq() to cdns_pcie_ep_send_intx_irq() to match
    the macro PCI_IRQ_INTX name. Related comments and messages mentioning
    "legacy" are also changed to refer to "intx".

    Link: https://lore.kernel.org/r/20231122060406.14695-9-dlemoal@kernel.org
    Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Christoph Hellwig <hch@lst.de>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe 7242e5f3dd PCI: endpoint: Drop PCI_EPC_IRQ_XXX definitions
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: 74955cb8ccc38539f8c029336e07e6b43b6a942e

commit 74955cb8ccc38539f8c029336e07e6b43b6a942e
Author: Damien Le Moal <dlemoal@kernel.org>
Date:   Wed Nov 22 15:03:52 2023 +0900

    PCI: endpoint: Drop PCI_EPC_IRQ_XXX definitions

    linux/pci.h defines the IRQ flags PCI_IRQ_INTX, PCI_IRQ_MSI and
    PCI_IRQ_MSIX. Let's use these flags directly instead of the endpoint
    definitions provided by enum pci_epc_irq_type. This removes the need
    for defining this enum type completely.

    Link: https://lore.kernel.org/r/20231122060406.14695-3-dlemoal@kernel.org
    Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe dbc851b986 PCI: j721e: Make TI J721E depend on ARCH_K3
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: 177c9ac6ab3fa585608a16877b1fa1aad832571c

commit 177c9ac6ab3fa585608a16877b1fa1aad832571c
Author: Peter Robinson <pbrobinson@gmail.com>
Date:   Thu Jan 4 21:39:06 2024 +0000

    PCI: j721e: Make TI J721E depend on ARCH_K3

    The J721E PCIe is hardware specific to TI SoC parts so add a dependency
    on that so it's available for those SoC parts and for compile testing but
    not necessarily everyone who enables the Cadence PCIe controller.

    Link: https://lore.kernel.org/linux-pci/20240104213910.1426843-1-pbrobinson@gmail.com
    Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe f8084c867a PCI: j721e: Add TI J784S4 PCIe configuration
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: e49ad667815d37dc621ffdfb7302df6a7265bab8

commit e49ad667815d37dc621ffdfb7302df6a7265bab8
Author: Matt Ranostay <mranostay@ti.com>
Date:   Tue Nov 28 11:14:02 2023 +0530

    PCI: j721e: Add TI J784S4 PCIe configuration

    Add PCIe configuration for J784S4 SoC platform which has 4x lane
    support.

    Link: https://lore.kernel.org/linux-pci/20231128054402.2155183-6-s-vadapalli@ti.com
    Tested-by: Achal Verma <a-verma1@ti.com>
    Signed-off-by: Matt Ranostay <mranostay@ti.com>
    Signed-off-by: Achal Verma <a-verma1@ti.com>
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Roger Quadros <rogerq@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe 2f50d5320a PCI: j721e: Add PCIe 4x lane selection support
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: 4490f559f75514d5a6f0e729e85235a7be6216bf

commit 4490f559f75514d5a6f0e729e85235a7be6216bf
Author: Matt Ranostay <mranostay@ti.com>
Date:   Tue Nov 28 11:14:01 2023 +0530

    PCI: j721e: Add PCIe 4x lane selection support

    Add support for setting of two-bit field that allows selection of 4x lane
    PCIe which was previously limited to only 2x lanes.

    Link: https://lore.kernel.org/linux-pci/20231128054402.2155183-5-s-vadapalli@ti.com
    Signed-off-by: Matt Ranostay <mranostay@ti.com>
    Signed-off-by: Achal Verma <a-verma1@ti.com>
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
    Reviewed-by: Roger Quadros <rogerq@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe 5a0e9b17ec PCI: j721e: Add per platform maximum lane settings
JIRA: https://issues.redhat.com/browse/RHEL-28627
Upstream Status: 3ac7f14084f54bff9c31573d1ed59d047a34fe03

commit 3ac7f14084f54bff9c31573d1ed59d047a34fe03
Author: Matt Ranostay <mranostay@ti.com>
Date:   Tue Nov 28 11:14:00 2023 +0530

    PCI: j721e: Add per platform maximum lane settings

    Various platforms have different maximum amount of lanes that can be
    selected. Add max_lanes to struct j721e_pcie to allow for detection of this
    which is needed to calculate the needed bitmask size for the possible lane
    count.

    Link: https://lore.kernel.org/linux-pci/20231128054402.2155183-4-s-vadapalli@ti.com
    Signed-off-by: Matt Ranostay <mranostay@ti.com>
    Signed-off-by: Achal Verma <a-verma1@ti.com>
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Reviewed-by: Ravi Gunasekaran <r-gunasekaran@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-03-30 14:55:37 -06:00
Myron Stowe 92b1ec81ce PCI: cadence: Use FIELD_GET()
JIRA: https://issues.redhat.com/browse/RHEL-26162
Upstream Status: b09d0f98a434bd6b9b9e0fb63bebfcac5e1a679e

commit b09d0f98a434bd6b9b9e0fb63bebfcac5e1a679e
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Wed Oct 18 14:32:48 2023 +0300

    PCI: cadence: Use FIELD_GET()

    Convert open-coded variants of PCI field access into FIELD_GET() to
    make the code easier to understand.

    Link: https://lore.kernel.org/r/20231018113254.17616-2-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-02-25 08:39:28 -07:00
Myron Stowe e2f7d4aa68 PCI: cadence: Drop unused member from struct cdns_plat_pcie
JIRA: https://issues.redhat.com/browse/RHEL-26162
Upstream Status: e111ac7025cb8aff275dda40ca09f9de9f84b7e9

commit e111ac7025cb8aff275dda40ca09f9de9f84b7e9
Author: Li Chen <me@linux.beauty>
Date:   Wed Jul 5 18:15:51 2023 +0800

    PCI: cadence: Drop unused member from struct cdns_plat_pcie

    The struct cdns_plat_pcie contains a member called is_rc that is not
    being used beyond being assigned a value within the cdns_plat_pcie_probe()
    function, which is then not used for anything.

    Thus, drop is_rc from the struct cdns_plat_pcie, especially since there
    already is an is_rc member within the struct cdns_plat_pcie_of_data that
    is actively used to convey information about the PCIe controller mode.

    [kwilczynski: commit log]
    Signed-off-by: Li Chen <lchen@ambarella.com>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2024-02-25 08:38:05 -07:00
Myron Stowe d9ae72882c PCI: Fix typos in docs and comments
JIRA: https://issues.redhat.com/browse/RHEL-15044
Upstream Status: 86b4ad7d67b26973838b7f1d4428aba9483cb5ce

commit 86b4ad7d67b26973838b7f1d4428aba9483cb5ce
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Thu Aug 24 11:44:32 2023 -0500

    PCI: Fix typos in docs and comments

    Fix typos in docs and comments.

    Link: https://lore.kernel.org/r/20230824193712.542167-11-helgaas@kernel.org
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-12-15 16:22:30 -07:00
Myron Stowe 06352c2e35 PCI: Explicitly include correct DT includes
JIRA: https://issues.redhat.com/browse/RHEL-15044
Upstream Status: c925cfaf0992f151c02f239e035ca9316224f224

commit c925cfaf0992f151c02f239e035ca9316224f224
Author: Rob Herring <robh@kernel.org>
Date:   Fri Jul 14 11:48:25 2023 -0600

    PCI: Explicitly include correct DT includes

    The DT of_device.h and of_platform.h date back to the separate
    of_platform_bus_type before it as merged into the regular platform bus.  As
    part of that merge prepping Arm DT support 13 years ago, they "temporarily"
    include each other. They also include platform_device.h and of.h. As a
    result, there's a pretty much random mix of those include files used
    throughout the tree. In order to detangle these headers and replace the
    implicit includes with struct declarations, users need to explicitly
    include the correct includes.

    Link: https://lore.kernel.org/r/20230714174827.4061572-1-robh@kernel.org
    Signed-off-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-12-15 16:22:28 -07:00
Myron Stowe 945953420e PCI: j721e: Convert to platform remove callback returning void
JIRA: https://issues.redhat.com/browse/RHEL-2570
Upstream Status: c86f4bd6008e7e9bd561e1f1ec3889cc0a5925e8

commit c86f4bd6008e7e9bd561e1f1ec3889cc0a5925e8
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Tue Mar 21 20:31:58 2023 +0100

    PCI: j721e: Convert to platform remove callback returning void

    The .remove() callback for a platform driver returns an int which makes
    many driver authors wrongly assume it's possible to do error handling by
    returning an error code. However the value returned is (mostly) ignored
    and this typically results in resource leaks. To improve here there is a
    quest to make the remove callback return void. In the first step of this
    quest all drivers are converted to .remove_new() which already returns
    void.

    Trivially convert this driver from always returning zero in the remove
    callback to the void returning variant.

    [kwilczynski: commit log]
    Link: https://lore.kernel.org/linux-pci/20230321193208.366561-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-09-19 13:32:23 -06:00
Myron Stowe e1f2f90925 PCI: cadence: Fix Gen2 Link Retraining process
JIRA: https://issues.redhat.com/browse/RHEL-2570
Upstream Status: 0e12f830236928b6fadf40d917a7527f0a048d2f

commit 0e12f830236928b6fadf40d917a7527f0a048d2f
Author: Siddharth Vadapalli <s-vadapalli@ti.com>
Date:   Wed Mar 15 12:38:00 2023 +0530

    PCI: cadence: Fix Gen2 Link Retraining process

    The Link Retraining process is initiated to account for the Gen2 defect in
    the Cadence PCIe controller in J721E SoC. The errata corresponding to this
    is i2085, documented at:
    https://www.ti.com/lit/er/sprz455c/sprz455c.pdf

    The existing workaround implemented for the errata waits for the Data Link
    initialization to complete and assumes that the link retraining process
    at the Physical Layer has completed. However, it is possible that the
    Physical Layer training might be ongoing as indicated by the
    PCI_EXP_LNKSTA_LT bit in the PCI_EXP_LNKSTA register.

    Fix the existing workaround, to ensure that the Physical Layer training
    has also completed, in addition to the Data Link initialization.

    Link: https://lore.kernel.org/r/20230315070800.1615527-1-s-vadapalli@ti.com
    Fixes: 4740b969aa ("PCI: cadence: Retrain Link to work around Gen2 training defect")
    Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-09-19 09:26:45 -06:00
Myron Stowe 13453397aa PCI: Use consistent controller Kconfig menu entry language
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2228915
Upstream Status: 80c170d7b13d0a46a46f869774baf3c02d775654

Conflict(s):
  Patching file drivers/pci/controller/Kconfig: Hunk #8 FAILED at 274.
  This is due to RHEL not having taken in upstream commit 7bb49d774f48
  (" arm64: bcmbca: Make BCM4908 drivers depend on ARCH_BCMBCA").

  Patching file drivers/pci/controller/dwc/Kconfig: Hunk #6 FAILED at 95,
  Hunk #7 FAILED at 107.  These are both due to RHEL not having taken in
  upstream commit 75c2f26da03f ("PCI: imx6: Add i.MX PCIe EP mode
  support").


commit 80c170d7b13d0a46a46f869774baf3c02d775654
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Tue Apr 18 12:43:33 2023 -0500

    PCI: Use consistent controller Kconfig menu entry language

    Use "PCIe controller" consistently instead of "host bridge", "bus driver",
    etc.  Annotate with "(host mode)" or "(endpoint mode)" as needed.

    Link: https://lore.kernel.org/r/20230418174336.145585-5-helgaas@kernel.org
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-09-05 09:16:45 -06:00
Myron Stowe fed96fd48d PCI: Remove unnecessary <linux/of_irq.h> includes
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2166398
Upstream Status: 277004d7a4a348de185fb4149ff29a651e994ff4

commit 277004d7a4a348de185fb4149ff29a651e994ff4
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Mon Oct 31 10:39:54 2022 -0500

    PCI: Remove unnecessary <linux/of_irq.h> includes

    Many host controller drivers #include <linux/of_irq.h> even though they
    don't need it.  Remove the unnecessary #includes.

    Link: https://lore.kernel.org/r/20221031153954.1163623-6-helgaas@kernel.org
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Acked-by: Roy Zang <roy.zang@nxp.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2023-03-07 18:02:03 -07:00
Myron Stowe 9697a3402c PCI: Convert to new *_PM_OPS macros
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124638
Upstream Status: 19b7858c3357df038d896c10e0d5e4572a77dd25

commit 19b7858c3357df038d896c10e0d5e4572a77dd25
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Tue Jul 19 16:13:25 2022 -0500

    PCI: Convert to new *_PM_OPS macros

    Replace SET_*_PM_OPS with *_PM_OPS, which which have the advantage that the
    compiler always sees the PM callbacks as referenced, so they don't need to
    be wrapped with "#ifdef CONFIG_PM_SLEEP" or tagged with "__maybe_unused" to
    avoid "defined but not used" warnings.

    See 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones").

    Link: https://lore.kernel.org/r/20220719215108.1583108-1-helgaas@kernel.org
    Tested-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Pali Rohár <pali@kernel.org>       # pci-mvebu.c
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-10-02 09:36:13 -06:00
Myron Stowe 61de0f6591 PCI: cadence: Clear FLR in device capabilities register
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2118429
Upstream Status: 95b00f68209e2bc9f2ee9126afcebab451e0e9d8

commit 95b00f68209e2bc9f2ee9126afcebab451e0e9d8
Author: Parshuram Thombare <pthombar@cadence.com>
Date:   Mon Oct 25 05:31:15 2021 -0700

    PCI: cadence: Clear FLR in device capabilities register

    Clear FLR (Function Level Reset) from device capabilities
    registers for all physical functions.

    During FLR, the Margining Lane Status and Margining Lane Control
    registers should not be reset, as per PCIe specification.
    However, the controller incorrectly resets these registers upon FLR.
    This causes PCISIG compliance FLR test to fail. Hence preventing
    all functions from advertising FLR support if flag quirk_disable_flr
    is set.

    Link: https://lore.kernel.org/r/1635165075-89864-1-git-send-email-pthombar@cadence.com
    Signed-off-by: Parshuram Thombare <pthombar@cadence.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-09-09 19:29:15 -06:00
Myron Stowe 95cf4209b3 PCI: cadence: Allow PTM Responder to be enabled
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2118429
Upstream Status: a1f67bc131c3935f325513cd153249fdbc22ac5b

commit a1f67bc131c3935f325513cd153249fdbc22ac5b
Author: Christian Gmeiner <christian.gmeiner@gmail.com>
Date:   Thu May 12 07:55:38 2022 +0200

    PCI: cadence: Allow PTM Responder to be enabled

    This enables the Controller [RP] to automatically respond with
    Response/ResponseD messages if CDNS_PCIE_LM_TPM_CTRL_PTMRSEN
    and PCI_PTM_CTRL_ENABLE bits are both set.

    Link: https://lore.kernel.org/r/20220512055539.1782437-1-christian.gmeiner@gmail.com
    Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-09-09 19:29:15 -06:00
Myron Stowe 1fe73aae16 PCI: cadence: Fix find_first_zero_bit() limit
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2118429
Upstream Status: 0aa3a0937feeb91a0e4e438c3c063b749b194192

commit 0aa3a0937feeb91a0e4e438c3c063b749b194192
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Mar 15 09:58:29 2022 +0300

    PCI: cadence: Fix find_first_zero_bit() limit

    The ep->ob_region_map bitmap is a long and it has BITS_PER_LONG bits.

    Link: https://lore.kernel.org/r/20220315065829.GA13572@kili
    Fixes: 37dddf14f1 ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-09-09 19:29:15 -06:00
Myron Stowe 6650c67c43 PCI: j721e: Initialize pcie->cdns_pcie before using it
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066898
Upstream Status: 053ca37c87af65f41f5842070c68aa53c3d035f5

commit 053ca37c87af65f41f5842070c68aa53c3d035f5
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Thu Jan 27 15:49:49 2022 -0600

    PCI: j721e: Initialize pcie->cdns_pcie before using it

    Christian reported a NULL pointer dereference in j721e_pcie_probe() caused
    by 19e863828acf ("PCI: j721e: Drop redundant struct device *"), which
    removed struct j721e_pcie.dev since there's another copy in struct
    cdns_pcie.dev reachable via j721e_pcie->cdns_pcie->dev.

    The problem is that j721e_pcie->cdns_pcie was dereferenced before being
    initialized:

      j721e_pcie_probe
        pcie = devm_kzalloc()             # struct j721e_pcie
        j721e_pcie_ctrl_init(pcie)
          dev = pcie->cdns_pcie->dev      <-- dereference cdns_pcie
        switch (mode) {
        case PCI_MODE_RC:
          cdns_pcie = ...                 # alloc as part of pci_host_bridge
          pcie->cdns_pcie = cdns_pcie     <-- initialize pcie->cdns_pcie

    Move the cdns_pcie initialization earlier so it is done before it is used.
    This also simplifies the error exits.

    Fixes: 19e863828acf ("PCI: j721e: Drop redundant struct device *")
    Link: https://lore.kernel.org/r/20220127222951.GA144828@bhelgaas
    Link: https://lore.kernel.org/r/20220124122132.435743-1-christian.gmeiner@gmail.com
    Reported-by: Christian Gmeiner <christian.gmeiner@gmail.com>
    Tested-by: Christian Gmeiner <christian.gmeiner@gmail.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-20 10:14:12 -06:00
Myron Stowe 802394ab0a PCI: j721e: Drop redundant struct device *
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066898
Upstream Status: 19e863828acf6d8ac8475ba1fd93c0fe17fdc4ef

commit 19e863828acf6d8ac8475ba1fd93c0fe17fdc4ef
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Wed Dec 22 19:10:40 2021 -0600

    PCI: j721e: Drop redundant struct device *

    The struct cdns_pcie already contains the struct device for the j721e PCIe
    controller.  There's no need to store another copy in struct j721e_pcie.
    Remove the redundant copy from struct j721e_pcie.

    Link: https://lore.kernel.org/r/20211223011054.1227810-10-helgaas@kernel.org
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: Kishon Vijay Abraham I <kishon@ti.com>
    Cc: Tom Joseph <tjoseph@cadence.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-20 10:14:09 -06:00
Myron Stowe 0dd127fd34 PCI: j721e: Drop pointless of_device_get_match_data() cast
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066898
Upstream Status: 72de208f2bda3c6a0d99e744ce7bedf3d3b8011a

commit 72de208f2bda3c6a0d99e744ce7bedf3d3b8011a
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Wed Dec 22 19:10:39 2021 -0600

    PCI: j721e: Drop pointless of_device_get_match_data() cast

    of_device_get_match_data() returns "void *", so no cast is needed when
    assigning the result to a pointer type.  Drop the unnecessary cast.

    Link: https://lore.kernel.org/r/20211223011054.1227810-9-helgaas@kernel.org
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: Kishon Vijay Abraham I <kishon@ti.com>
    Cc: Tom Joseph <tjoseph@cadence.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-20 10:14:08 -06:00
Myron Stowe 268b1f0a21 PCI: cadence: Prefer of_device_get_match_data()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066898
Upstream Status: 131748ad2939dfaf20b3178112dbd52591d39148

commit 131748ad2939dfaf20b3178112dbd52591d39148
Author: Fan Fei <ffclaire1224@gmail.com>
Date:   Wed Dec 22 19:10:34 2021 -0600

    PCI: cadence: Prefer of_device_get_match_data()

    The cadence driver only needs the device data, not the whole struct
    of_device_id.  Use of_device_get_match_data() instead of of_match_device().
    No functional change intended.

    [bhelgaas: commit log]
    Link: https://lore.kernel.org/r/20211223011054.1227810-4-helgaas@kernel.org
    Signed-off-by: Fan Fei <ffclaire1224@gmail.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: Tom Joseph <tjoseph@cadence.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-20 10:14:08 -06:00
Myron Stowe 7d77b763e1 PCI: Correct misspelled words
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066898
Upstream Status: ccd36795be48956248dc308f4525c06c7f419d76

commit ccd36795be48956248dc308f4525c06c7f419d76
Author: Krzysztof Wilczyński <kw@linux.com>
Date:   Fri Jan 7 22:59:42 2022 +0000

    PCI: Correct misspelled words

    Fix a number of misspelled words, and while at it, correct two phrases used
    to indicate a status of an operation where words used have been cleverly
    truncated and thus always trigger a spellchecking error while performing a
    static code analysis over the PCI tree.

    [bhelgaas: reverse sense of quirk ternary]
    Link: https://lore.kernel.org/r/20220107225942.121484-1-kw@linux.com
    Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-20 10:14:03 -06:00
Myron Stowe fbc768b163 PCI: cadence: Add cdns_plat_pcie_probe() missing return
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2052155
Upstream Status: 27cd7e3c9bb1ae13bc16f08138edd6e4df3cd211

commit 27cd7e3c9bb1ae13bc16f08138edd6e4df3cd211
Author: Li Chen <lchen@ambarella.com>
Date:   Thu Oct 21 02:50:19 2021 +0000

    PCI: cadence: Add cdns_plat_pcie_probe() missing return

    When cdns_plat_pcie_probe() succeeds, return success instead of falling
    into the error handling code.

    Fixes: bd22885aa1 ("PCI: cadence: Refactor driver to use as a core library")
    Link: https://lore.kernel.org/r/DM6PR19MB40271B93057D949310F0B0EDA0BF9@DM6PR19MB4027.namprd19.prod.outlook.com
    Signed-off-by: Xuliang Zhang <xlzhanga@ambarella.com>
    Signed-off-by: Li Chen <lchen@ambarella.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-12 08:47:07 -06:00
Myron Stowe 5329adbed2 PCI: j721e: Fix j721e_pcie_probe() error path
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2052155
Upstream Status: 496bb18483cc0474913e81e18a6b313aaea4c120

commit 496bb18483cc0474913e81e18a6b313aaea4c120
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Sun Jun 27 13:46:24 2021 +0200

    PCI: j721e: Fix j721e_pcie_probe() error path

    If an error occurs after a successful cdns_pcie_init_phy() call, it must be
    undone by a cdns_pcie_disable_phy() call, as already done above and below.

    Update the goto to branch at the correct place of the error handling path.

    Link: https://lore.kernel.org/r/db477b0cb444891a17c4bb424467667dc30d0bab.1624794264.git.christophe.jaillet@wanadoo.fr
    Fixes: 49e0efdce7 ("PCI: j721e: Add support to provide refclk to PCIe connector")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Krzysztof Wilczyński <kw@linux.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-04-12 08:47:07 -06:00
Myron Stowe d8c29373ce PCI: cadence: Add support to configure virtual functions
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: e19a0adf6e8bb0b93a546b8d4c7f8f6891115bbb

commit e19a0adf6e8bb0b93a546b8d4c7f8f6891115bbb
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Thu Aug 19 18:03:41 2021 +0530

    PCI: cadence: Add support to configure virtual functions

    Now that support for SR-IOV is added in PCIe endpoint core, add support
    to configure virtual functions in the Cadence PCIe EP driver.

    Link: https://lore.kernel.org/r/20210819123343.1951-7-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:42 -07:00
Myron Stowe ab4111aac3 PCI: cadence: Simplify code to get register base address for configuring BAR
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: 0cf985d6119cc21fc39774b4b29dcf1e0148bf55

commit 0cf985d6119cc21fc39774b4b29dcf1e0148bf55
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Thu Aug 19 18:03:40 2021 +0530

    PCI: cadence: Simplify code to get register base address for configuring BAR

    No functional change. Simplify code to get register base address for
    configuring PCI BAR.

    Link: https://lore.kernel.org/r/20210819123343.1951-6-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:42 -07:00
Myron Stowe 6e5f65c71e PCI: endpoint: Add virtual function number in pci_epc ops
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: 53fd3cbe5e9d791d6bb6059f73a3851f155ce7c6

commit 53fd3cbe5e9d791d6bb6059f73a3851f155ce7c6
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Thu Aug 19 18:03:39 2021 +0530

    PCI: endpoint: Add virtual function number in pci_epc ops

    Add virtual function number in pci_epc ops. EPC controller driver
    can perform virtual function specific initialization based on the
    virtual function number.

    Link: https://lore.kernel.org/r/20210819123343.1951-5-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:42 -07:00
Myron Stowe c69070a379 PCI: j721e: Add PCIe support for AM64
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: c8a375a8e15ac31293d7fda08008d6da8f5df3db

commit c8a375a8e15ac31293d7fda08008d6da8f5df3db
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Wed Aug 11 18:03:35 2021 +0530

    PCI: j721e: Add PCIe support for AM64

    AM64 has the same PCIe IP as in J7200 with certain erratas not
    applicable (quirk_detect_quiet_flag). Add support for "ti,am64-pcie-host"
    compatible and "ti,am64-pcie-ep" compatible that is specific to AM64.

    Link: https://lore.kernel.org/r/20210811123336.31357-5-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:37 -07:00
Myron Stowe c5fa356d0b PCI: j721e: Add PCIe support for J7200
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: f1de58802f0fff364cf49f5e47d1be744baa434f

commit f1de58802f0fff364cf49f5e47d1be744baa434f
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Wed Aug 11 18:03:34 2021 +0530

    PCI: j721e: Add PCIe support for J7200

    J7200 has the same PCIe IP as in J721E with minor changes in the
    wrapper. J7200 allows byte access of bridge configuration space
    registers and the register field for LINK_DOWN interrupt is different.
    J7200 also requires "quirk_detect_quiet_flag" to be set. Configure these
    changes as part of driver data applicable only to J7200.

    Link: https://lore.kernel.org/r/20210811123336.31357-4-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:37 -07:00
Myron Stowe ba12321d94 PCI: cadence: Add quirk flag to set minimum delay in LTSSM Detect.Quiet state
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: 09c24094b2e3a15ef3fc44f54a191b3db522fb11

commit 09c24094b2e3a15ef3fc44f54a191b3db522fb11
Author: Nadeem Athani <nadeem@cadence.com>
Date:   Wed Aug 11 18:03:33 2021 +0530

    PCI: cadence: Add quirk flag to set minimum delay in LTSSM Detect.Quiet state

    PCIe fails to link up if SERDES lanes not used by PCIe are assigned to
    another protocol. For example, link training fails if lanes 2 and 3 are
    assigned to another protocol while lanes 0 and 1 are used for PCIe to
    form a two lane link. This failure is due to an incorrect tie-off on an
    internal status signal indicating electrical idle.

    Status signals going from SERDES to PCIe Controller are tied-off when a
    lane is not assigned to PCIe. Signal indicating electrical idle is
    incorrectly tied-off to a state that indicates non-idle. As a result,
    PCIe sees unused lanes to be out of electrical idle and this causes
    LTSSM to exit Detect.Quiet state without waiting for 12ms timeout to
    occur. If a receiver is not detected on the first receiver detection
    attempt in Detect.Active state, LTSSM goes back to Detect.Quiet and
    again moves forward to Detect.Active state without waiting for 12ms as
    required by PCIe base specification. Since wait time in Detect.Quiet is
    skipped, multiple receiver detect operations are performed back-to-back
    without allowing time for capacitance on the transmit lines to
    discharge. This causes subsequent receiver detection to always fail even
    if a receiver gets connected eventually.

    Add a quirk flag "quirk_detect_quiet_flag" to program the minimum
    time the LTSSM should wait on entering Detect.Quiet state here.
    This has to be set for J7200 as it has an incorrect tie-off on unused
    lanes.

    Link: https://lore.kernel.org/r/20210811123336.31357-3-kishon@ti.com
    Signed-off-by: Nadeem Athani <nadeem@cadence.com>
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:37 -07:00
Myron Stowe fee0259c40 PCI: cadence: Use bitfield for *quirk_retrain_flag* instead of bool
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045254
Upstream Status: f4455748b2126a9ba2bcc9cfb2fbcaa08de29bb2

commit f4455748b2126a9ba2bcc9cfb2fbcaa08de29bb2
Author: Kishon Vijay Abraham I <kishon@ti.com>
Date:   Wed Aug 11 18:03:32 2021 +0530

    PCI: cadence: Use bitfield for *quirk_retrain_flag* instead of bool

    No functional change. As we are intending to add additional 1-bit
    members in struct j721e_pcie_data/struct cdns_pcie_rc, use bitfields
    instead of bool since it takes less space. As discussed in [1],
    the preference is to use bitfileds instead of bool inside structures.

    [1] -> https://lore.kernel.org/linux-fsdevel/CA+55aFzKQ6Pj18TB8p4Yr0M4t+S+BsiHH=BJNmn=76-NcjTj-g@mail.gmail.com/

    Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
    Link: https://lore.kernel.org/r/20210811123336.31357-2-kishon@ti.com
    Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

Signed-off-by: Myron Stowe <mstowe@redhat.com>
2022-03-03 20:43:36 -07:00
Krzysztof Wilczyński 347269c113 PCI: Fix kernel-doc formatting
Fix kernel-doc formatting throughout drivers/pci and related include files.
No change to functionality intended.

Check for warnings:

  $ find include drivers/pci -type f -path "*pci*.[ch]" | xargs scripts/kernel-doc -none

[bhelgaas: squashed to one commit]
Link: https://lore.kernel.org/r/20210509030237.368540-1-kw@linux.com
Link: https://lore.kernel.org/r/20210703151306.1922450-1-kw@linux.com
Link: https://lore.kernel.org/r/20210703151306.1922450-2-kw@linux.com
Link: https://lore.kernel.org/r/20210703151306.1922450-3-kw@linux.com
Link: https://lore.kernel.org/r/20210703151306.1922450-4-kw@linux.com
Link: https://lore.kernel.org/r/20210703151306.1922450-5-kw@linux.com
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2021-07-06 10:37:46 -05:00
Linus Torvalds 57151b502c pci-v5.13-changes
-----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAmCRp48UHGJoZWxnYWFz
 QGdvb2dsZS5jb20ACgkQWYigwDrT+vwsVRAAsIYueNKzZczpkeQwHigYzf4HLdKm
 yyT2c/Zlj9REAUOe7ApkowVAJWiMGDJP0J361KIluAGvAxnkMP1V6WlVdByorYd0
 CrXc/UhD//cs+3QDo4SmJRHyL8q5QQTDa8Z/8seVJUYTR/t5OhSpMOuEJPhpeQ1s
 nqUk0yWNJRoN6wn6T/7KqgYEvPhARXo9epuWy5MNPZ5f8E7SRi/QG/6hP8/YOLpK
 A+8beIOX5LAvUJaXxEovwv5UQnSUkeZTGDyRietQYE6xXNeHPKCvZ7vDjjSE7NOW
 mIodD6JcG3n/riYV3sMA5PKDZgsPI3P/qJU6Y6vWBBYOaO/kQX/c7CZ+M2bcZay4
 mh1dW0vOqoTy/pAVwQB2aq08Rrg2SAskpNdeyzduXllmuTyuwCMPXzG4RKmbQ8I1
 qMFb8qOyNulRAWcTKgSMKByEQYASQsFA5yShtaba6h0+vqrseuP6hchBKKOEan8F
 9THTI3ZflKwRvGjkI0MDbp0z0+wPYmNhrcZDpAJ3bEltw58E8TL/9aBtuhajmo8+
 wJ64mZclFuMmSyhsfkAXOvjeKXMlEBaw7vinZGbcACmv4ZGI0MV7r4vVYQbQltcy
 myzB6xJxcWB8N07UpKpUbsGMb9JjTUPlaT36eZNvUZQDntrE1ljt8RSq3nphDrcD
 KmBRU8ru74I2RE0=
 =WvTD
 -----END PGP SIGNATURE-----

Merge tag 'pci-v5.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull pci updates from Bjorn Helgaas:
 "Enumeration:
   - Release OF node when pci_scan_device() fails (Dmitry Baryshkov)
   - Add pci_disable_parity() (Bjorn Helgaas)
   - Disable Mellanox Tavor parity reporting (Heiner Kallweit)
   - Disable N2100 r8169 parity reporting (Heiner Kallweit)
   - Fix RCiEP device to RCEC association (Qiuxu Zhuo)
   - Convert sysfs "config", "rom", "reset", "label", "index",
     "acpi_index" to static attributes to help fix races in device
     enumeration (Krzysztof Wilczyński)
   - Convert sysfs "vpd" to static attribute (Heiner Kallweit, Krzysztof
     Wilczyński)
   - Use sysfs_emit() in "show" functions (Krzysztof Wilczyński)
   - Remove unused alloc_pci_root_info() return value (Krzysztof
     Wilczyński)

  PCI device hotplug:
   - Fix acpiphp reference count leak (Feilong Lin)

  Power management:
   - Fix acpi_pci_set_power_state() debug message (Rafael J. Wysocki)
   - Fix runtime PM imbalance (Dinghao Liu)

  Virtualization:
   - Increase delay after FLR to work around Intel DC P4510 NVMe erratum
     (Raphael Norwitz)

  MSI:
   - Convert rcar, tegra, xilinx to MSI domains (Marc Zyngier)
   - For rcar, xilinx, use controller address as MSI doorbell (Marc
     Zyngier)
   - Remove unused hv msi_controller struct (Marc Zyngier)
   - Remove unused PCI core msi_controller support (Marc Zyngier)
   - Remove struct msi_controller altogether (Marc Zyngier)
   - Remove unused default_teardown_msi_irqs() (Marc Zyngier)
   - Let host bridges declare their reliance on MSI domains (Marc
     Zyngier)
   - Make pci_host_common_probe() declare its reliance on MSI domains
     (Marc Zyngier)
   - Advertise mediatek lack of built-in MSI handling (Thomas Gleixner)
   - Document ways of ending up with NO_MSI (Marc Zyngier)
   - Refactor HT advertising of NO_MSI flag (Marc Zyngier)

  VPD:
   - Remove obsolete Broadcom NIC VPD length-limiting quirk (Heiner
     Kallweit)
   - Remove sysfs VPD size checking dead code (Heiner Kallweit)
   - Convert VPF sysfs file to static attribute (Heiner Kallweit)
   - Remove unnecessary pci_set_vpd_size() (Heiner Kallweit)
   - Tone down "missing VPD" message (Heiner Kallweit)

  Endpoint framework:
   - Fix NULL pointer dereference when epc_features not implemented
     (Shradha Todi)
   - Add missing destroy_workqueue() in endpoint test (Yang Yingliang)

  Amazon Annapurna Labs PCIe controller driver:
   - Fix compile testing without CONFIG_PCI_ECAM (Arnd Bergmann)
   - Fix "no symbols" warnings when compile testing with
     CONFIG_TRIM_UNUSED_KSYMS (Arnd Bergmann)

  APM X-Gene PCIe controller driver:
   - Fix cfg resource mapping regression (Dejin Zheng)

  Broadcom iProc PCIe controller driver:
   - Return zero for success of iproc_msi_irq_domain_alloc() (Pali
     Rohár)

  Broadcom STB PCIe controller driver:
   - Add reset_control_rearm() stub for !CONFIG_RESET_CONTROLLER (Jim
     Quinlan)
   - Fix use of BCM7216 reset controller (Jim Quinlan)
   - Use reset/rearm for Broadcom STB pulse reset instead of
     deassert/assert (Jim Quinlan)
   - Fix brcm_pcie_probe() error return for unsupported revision (Wei
     Yongjun)

  Cavium ThunderX PCIe controller driver:
   - Fix compile testing (Arnd Bergmann)
   - Fix "no symbols" warnings when compile testing with
     CONFIG_TRIM_UNUSED_KSYMS (Arnd Bergmann)

  Freescale Layerscape PCIe controller driver:
   - Fix ls_pcie_ep_probe() syntax error (comma for semicolon)
     (Krzysztof Wilczyński)
   - Remove layerscape-gen4 dependencies on OF and ARM64, add dependency
     on ARCH_LAYERSCAPE (Geert Uytterhoeven)

  HiSilicon HIP PCIe controller driver:
   - Remove obsolete HiSilicon PCIe DT description (Dongdong Liu)

  Intel Gateway PCIe controller driver:
   - Remove unused pcie_app_rd() (Jiapeng Chong)

  Intel VMD host bridge driver:
   - Program IRTE with Requester ID of VMD endpoint, not child device
     (Jon Derrick)
   - Disable VMD MSI-X remapping when possible so children can use more
     MSI-X vectors (Jon Derrick)

  MediaTek PCIe controller driver:
   - Configure FC and FTS for functions other than 0 (Ryder Lee)
   - Add YAML schema for MediaTek (Jianjun Wang)
   - Export pci_pio_to_address() for module use (Jianjun Wang)
   - Add MediaTek MT8192 PCIe controller driver (Jianjun Wang)
   - Add MediaTek MT8192 INTx support (Jianjun Wang)
   - Add MediaTek MT8192 MSI support (Jianjun Wang)
   - Add MediaTek MT8192 system power management support (Jianjun Wang)
   - Add missing MODULE_DEVICE_TABLE (Qiheng Lin)

  Microchip PolarFlare PCIe controller driver:
   - Make several symbols static (Wei Yongjun)

  NVIDIA Tegra PCIe controller driver:
   - Add MCFG quirks for Tegra194 ECAM errata (Vidya Sagar)
   - Make several symbols const (Rikard Falkeborn)
   - Fix Kconfig host/endpoint typo (Wesley Sheng)

  SiFive FU740 PCIe controller driver:
   - Add pcie_aux clock to prci driver (Greentime Hu)
   - Use reset-simple in prci driver for PCIe (Greentime Hu)
   - Add SiFive FU740 PCIe host controller driver and DT binding (Paul
     Walmsley, Greentime Hu)

  Synopsys DesignWare PCIe controller driver:
   - Move MSI Receiver init to dw_pcie_host_init() so it is
     re-initialized along with the RC in resume (Jisheng Zhang)
   - Move iATU detection earlier to fix regression (Hou Zhiqiang)

  TI J721E PCIe driver:
   - Add DT binding and TI j721e support for refclk to PCIe connector
     (Kishon Vijay Abraham I)
   - Add host mode and endpoint mode DT bindings for TI AM64 SoC (Kishon
     Vijay Abraham I)

  TI Keystone PCIe controller driver:
   - Use generic config accessors for TI AM65x (K3) to fix regression
     (Kishon Vijay Abraham I)

  Xilinx NWL PCIe controller driver:
   - Add support for coherent PCIe DMA traffic using CCI (Bharat Kumar
     Gogada)
   - Add optional "dma-coherent" DT property (Bharat Kumar Gogada)

  Miscellaneous:
   - Fix kernel-doc warnings (Krzysztof Wilczyński)
   - Remove unused MicroGate SyncLink device IDs (Jiri Slaby)
   - Remove redundant dev_err() for devm_ioremap_resource() failure
     (Chen Hui)
   - Remove redundant initialization (Colin Ian King)
   - Drop redundant dev_err() for platform_get_irq() errors (Krzysztof
     Wilczyński)"

* tag 'pci-v5.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (98 commits)
  riscv: dts: Add PCIe support for the SiFive FU740-C000 SoC
  PCI: fu740: Add SiFive FU740 PCIe host controller driver
  dt-bindings: PCI: Add SiFive FU740 PCIe host controller
  MAINTAINERS: Add maintainers for SiFive FU740 PCIe driver
  clk: sifive: Use reset-simple in prci driver for PCIe driver
  clk: sifive: Add pcie_aux clock in prci driver for PCIe driver
  PCI: brcmstb: Use reset/rearm instead of deassert/assert
  ata: ahci_brcm: Fix use of BCM7216 reset controller
  reset: add missing empty function reset_control_rearm()
  PCI: Allow VPD access for QLogic ISP2722
  PCI/VPD: Add helper pci_get_func0_dev()
  PCI/VPD: Remove pci_vpd_find_tag() SRDT handling
  PCI/VPD: Remove pci_vpd_find_tag() 'offset' argument
  PCI/VPD: Change pci_vpd_init() return type to void
  PCI/VPD: Make missing VPD message less alarming
  PCI/VPD: Remove pci_set_vpd_size()
  x86/PCI: Remove unused alloc_pci_root_info() return value
  MAINTAINERS: Add Jianjun Wang as MediaTek PCI co-maintainer
  PCI: mediatek-gen3: Add system PM support
  PCI: mediatek-gen3: Add MSI support
  ...
2021-05-05 13:24:11 -07:00
Bjorn Helgaas 3ec17ca688 Merge branch 'remotes/lorenzo/pci/cadence'
- Add DT binding and TI j721e support for refclk to PCIe connector (Kishon
  Vijay Abraham I)

- Add host mode and endpoint mode DT bindings for TI AM64 SoC (Kishon Vijay
  Abraham I)

* remotes/lorenzo/pci/cadence:
  PCI: j721e: Add support to provide refclk to PCIe connector
  dt-bindings: PCI: ti,j721e: Add endpoint mode dt-bindings for TI's AM64 SoC
  dt-bindings: PCI: ti,j721e: Add host mode dt-bindings for TI's AM64 SoC
  dt-bindings: PCI: ti,j721e: Add binding to represent refclk to the connector
2021-05-04 10:43:26 -05:00
Sami Tolvanen 4f0f586bf0 treewide: Change list_sort to use const pointers
list_sort() internally casts the comparison function passed to it
to a different type with constant struct list_head pointers, and
uses this pointer to call the functions, which trips indirect call
Control-Flow Integrity (CFI) checking.

Instead of removing the consts, this change defines the
list_cmp_func_t type and changes the comparison function types of
all list_sort() callers to use const pointers, thus avoiding type
mismatches.

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210408182843.1754385-10-samitolvanen@google.com
2021-04-08 16:04:22 -07:00
Kishon Vijay Abraham I 49e0efdce7 PCI: j721e: Add support to provide refclk to PCIe connector
Add support to provide refclk to PCIe connector.

Link: https://lore.kernel.org/r/20210308063550.6227-5-kishon@ti.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2021-03-23 10:33:53 +00:00