Hi,

Some DesignWare PCIe endpoint platforms integrate a DesignWare eDMA
instance alongside the PCIe controller. In remote eDMA use cases, the host
needs access to the eDMA register block and the per-channel linked-list
(LL) regions via PCIe BARs, while the endpoint may still boot with a
standard EP configuration (and may also use dw-edma locally).

This series focuses on using DesignWare eDMA emulated interrupt doorbell as
a pci-ep-msi fallback, in a generalized manner without exporting any
DesignWare eDMA-specific API.

  * dmaengine:

    1. Add explicit deassert handling for eDMA interrupt emulation in the
       IRQ handler so level-triggered/shared IRQ lines don't remain stuck.
       => Patch 01/08

    2. Cache per-channel IRQ number and an interrupt-emulation doorbell
       register offset, so integrated-controller drivers can expose these
       to EPF users via the auxiliary resource metadata.
       => Patch 02/08

  * pci/endpoint:

    1. Add a generic auxiliary resource enumeration API
       (pci_epc_get_aux_resources()) for EPF drivers to discover
       controller-owned resources that can be mapped into BAR space (e.g.
       an integrated DMA MMIO window and per-channel LL regions metadata).
       => Patch 03/08 - 05/08

    2. Add an "embedded (DMA) doorbell" fallback to pci_epf_alloc_doorbell()
       (used when platform MSI doorbells are unavailable/unusable), and
       update in-tree users (pci-epf-test, pci-epf-vntb) to request IRQs
       correctly (shared IRQ constraints, required flags).
       => Patch 06/08 - 08/08

Note: As discussed in the v4 thread, v4 Patch 01/09 (dw-edma per-channel
interrupt routing control via dma_slave_config.peripheral_config) is
dropped from this series for now, so the series contains only what's needed
by the current, concrete consumer.

This series evolved out of:
https://lore.kernel.org/linux-pci/[email protected]/


Kernel base
===========

Patches 1-8 cleanly apply to pci.git 'controller/dwc':
Commit 43d324eeb08c ("PCI: dwc: Fix missing iATU setup when ECAM is enabled")


Tested on
=========

I tested the embedded (DMA) doorbell fallback path (via pci-epf-test) on
R-Car Spider boards:

  $ ./pci_endpoint_test -t DOORBELL_TEST
  TAP version 13
  1..1
  # Starting 1 tests from 1 test cases.
  #  RUN           pcie_ep_doorbell.DOORBELL_TEST ...
  #            OK  pcie_ep_doorbell.DOORBELL_TEST
  ok 1 pcie_ep_doorbell.DOORBELL_TEST
  # PASSED: 1 / 1 tests passed.
  # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0

with the following message observed on the EP side:

  [   80.464653] pci_epf_test pci_epf_test.0: Using embedded (DMA) doorbell 
fallback

(Note: for the test to pass on R-Car Spider, one of the following was required:
 - echo 1048576 > functions/pci_epf_test/func1/pci_epf_test.0/bar2_size
 - apply https://lore.kernel.org/all/[email protected]/)


Changelog
=========

* v4->v5 changes:
  - Change the series subject now that the series has evolved into a
    consumer-driven set focused on the embedded doorbell fallback and its
    in-tree users (epf-test and epf-vntb).
  - Drop [PATCH v4 01/09] (dw-edma per-channel interrupt routing control)
    from this series for now, so the series focuses on what's needed by the
    current consumer (i.e. the doorbell fallback implementation).
  - Replace the v4 embedded-doorbell "test variant + host/kselftest
    plumbing" with a generic embedded-doorbell fallback in
    pci_epf_alloc_doorbell(), including exposing required IRQ request flags
    to EPF drivers.
  - Two preparatory fix patches (Patch 6/8 and 7/8) to clean up error
    handling and state management ahead of Patch 8/8.
  - Rename *_get_remote_resource() to *_get_aux_resources() and adjust
    relevant variable namings and kernel docs. Discussion may continue.
  - Rework dw-edma per-channel metadata exposure to cache the needed info
    in dw_edma_chip (IRQ number + emulation doorbell offset) and consume it
    from the DesignWare EPC auxiliary resource provider without calling back
    to dw-edma.

* v3->v4 changes:
  - Drop dma_slave_caps.hw_id and the dmaengine selfirq callback
    registration API. Instead, add a dw-edma specific dw_edma_chan_info()
    helper and extend the EPC remote resource metadata accordingly.
  - Add explicit acking for eDMA interrupt emulation and adjust the
    dw-edma IRQ path for embedded-doorbell usage.
  - Replace the previous EPC API smoke test with an embedded doorbell
    test variant (pci-epf-test + pci_endpoint_test/selftests).
  - Rebase onto pci.git controller/dwc commit 43d324eeb08c.

* v2->v3 changes:
  - Replace DWC-specific helpers with a generic EPC remote resource query API.
  - Add pci-epf-test smoke test and host/kselftest support for the new API.
  - Drop the dw-edma-specific notify-only channel and polling approach
    ([PATCH v2 4/7] and [PATCH v2 5/7]), and rework notification handling
    around a generic dmaengine_(un)register_selfirq() API implemented
    by dw-edma.

* v1->v2 changes:
  - Combine the two previously posted series into a single set (per Frank's
    suggestion). Order dmaengine/dw-edma patches first so hw_id support
    lands before the PCI LL-region helper, which assumes
    dma_slave_caps.hw_id availability.

v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: 
https://lore.kernel.org/dmaengine/[email protected]/
    +
    
https://lore.kernel.org/linux-pci/[email protected]/

Thanks for reviewing,


Koichiro Den (8):
  dmaengine: dw-edma: Deassert emulated interrupts in the IRQ handler
  dmaengine: dw-edma: Cache per-channel IRQ and emulation doorbell
    offset
  PCI: endpoint: Add auxiliary resource query API
  PCI: dwc: Record integrated eDMA register window
  PCI: dwc: ep: Report integrated eDMA resources via EPC aux-resource
    API
  PCI: endpoint: pci-epf-test: Don't free doorbell IRQ unless requested
  PCI: endpoint: pci-ep-msi: Fix error unwind and prevent double alloc
  PCI: endpoint: pci-ep-msi: Add embedded doorbell fallback

 drivers/dma/dw-edma/dw-edma-core.c            |  57 ++++++-
 drivers/dma/dw-edma/dw-edma-core.h            |  19 +++
 drivers/dma/dw-edma/dw-edma-v0-core.c         |  22 +++
 drivers/dma/dw-edma/dw-hdma-v0-core.c         |   8 +
 .../pci/controller/dwc/pcie-designware-ep.c   |  78 ++++++++++
 drivers/pci/controller/dwc/pcie-designware.c  |   4 +
 drivers/pci/controller/dwc/pcie-designware.h  |   2 +
 drivers/pci/endpoint/functions/pci-epf-test.c |  38 ++++-
 drivers/pci/endpoint/functions/pci-epf-vntb.c |   3 +-
 drivers/pci/endpoint/pci-ep-msi.c             | 141 ++++++++++++++++--
 drivers/pci/endpoint/pci-epc-core.c           |  41 +++++
 include/linux/dma/edma.h                      |  17 +++
 include/linux/pci-epc.h                       |  46 ++++++
 include/linux/pci-epf.h                       |  17 ++-
 14 files changed, 471 insertions(+), 22 deletions(-)

-- 
2.51.0


Reply via email to