Netdev List
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Koichiro Den <den@valinux.co.jp>
Cc: dave.jiang@intel.com, cassel@kernel.org, mani@kernel.org,
	kwilczynski@kernel.org, kishon@kernel.org, bhelgaas@google.com,
	geert+renesas@glider.be, robh@kernel.org, vkoul@kernel.org,
	jdmason@kudzu.us, allenbh@gmail.com, jingoohan1@gmail.com,
	lpieralisi@kernel.org, linux-pci@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org,
	dmaengine@vger.kernel.org, iommu@lists.linux.dev,
	ntb@lists.linux.dev, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org, arnd@arndb.de,
	gregkh@linuxfoundation.org, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, magnus.damm@gmail.com, krzk+dt@kernel.org,
	conor+dt@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
	andriy.shevchenko@linux.intel.com, jbrunet@baylibre.com,
	utkarsh02t@gmail.com
Subject: Re: [RFC PATCH v4 02/38] dmaengine: dw-edma: Add per-channel interrupt routing control
Date: Sun, 18 Jan 2026 12:03:19 -0500	[thread overview]
Message-ID: <aW0SVx11WCxfTHoY@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260118135440.1958279-3-den@valinux.co.jp>

On Sun, Jan 18, 2026 at 10:54:04PM +0900, Koichiro Den wrote:
> DesignWare EP eDMA can generate interrupts both locally and remotely
> (LIE/RIE). Remote eDMA users need to decide, per channel, whether
> completions should be handled locally, remotely, or both. Unless
> carefully configured, the endpoint and host would race to ack the
> interrupt.
>
> Introduce a per-channel interrupt routing mode and export small APIs to
> configure and query it. Update v0 programming so that RIE and local
> done/abort interrupt masking follow the selected mode. The default mode
> keeps the original behavior, so unless the new APIs are explicitly used,
> no functional changes.
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
>  drivers/dma/dw-edma/dw-edma-core.c    | 52 +++++++++++++++++++++++++++
>  drivers/dma/dw-edma/dw-edma-core.h    |  2 ++
>  drivers/dma/dw-edma/dw-edma-v0-core.c | 26 +++++++++-----
>  include/linux/dma/edma.h              | 44 +++++++++++++++++++++++
>  4 files changed, 116 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index b9d59c3c0cb4..059b3996d383 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -768,6 +768,7 @@ static int dw_edma_channel_setup(struct dw_edma *dw, u32 wr_alloc, u32 rd_alloc)
>  		chan->configured = false;
>  		chan->request = EDMA_REQ_NONE;
>  		chan->status = EDMA_ST_IDLE;
> +		chan->irq_mode = DW_EDMA_CH_IRQ_DEFAULT;
>
>  		if (chan->dir == EDMA_DIR_WRITE)
>  			chan->ll_max = (chip->ll_region_wr[chan->id].sz / EDMA_LL_SZ);
> @@ -1062,6 +1063,57 @@ int dw_edma_remove(struct dw_edma_chip *chip)
>  }
>  EXPORT_SYMBOL_GPL(dw_edma_remove);
>
> +int dw_edma_chan_irq_config(struct dma_chan *dchan,
> +			    enum dw_edma_ch_irq_mode mode)
> +{
> +	struct dw_edma_chan *chan;
> +
> +	switch (mode) {
> +	case DW_EDMA_CH_IRQ_DEFAULT:
> +	case DW_EDMA_CH_IRQ_LOCAL:
> +	case DW_EDMA_CH_IRQ_REMOTE:
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	if (!dchan || !dchan->device)
> +		return -ENODEV;
> +
> +	chan = dchan2dw_edma_chan(dchan);
> +	if (!chan)
> +		return -ENODEV;
> +
> +	chan->irq_mode = mode;
> +
> +	dev_vdbg(chan->dw->chip->dev, "Channel: %s[%u] set irq_mode=%u\n",
> +		 str_write_read(chan->dir == EDMA_DIR_WRITE),
> +		 chan->id, mode);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(dw_edma_chan_irq_config);
> +
> +bool dw_edma_chan_ignore_irq(struct dma_chan *dchan)
> +{
> +	struct dw_edma_chan *chan;
> +	struct dw_edma *dw;
> +
> +	if (!dchan || !dchan->device)
> +		return false;
> +
> +	chan = dchan2dw_edma_chan(dchan);
> +	if (!chan)
> +		return false;
> +
> +	dw = chan->dw;
> +	if (dw->chip->flags & DW_EDMA_CHIP_LOCAL)
> +		return chan->irq_mode == DW_EDMA_CH_IRQ_REMOTE;
> +	else
> +		return chan->irq_mode == DW_EDMA_CH_IRQ_LOCAL;
> +}
> +EXPORT_SYMBOL_GPL(dw_edma_chan_ignore_irq);
> +
>  MODULE_LICENSE("GPL v2");
>  MODULE_DESCRIPTION("Synopsys DesignWare eDMA controller core driver");
>  MODULE_AUTHOR("Gustavo Pimentel <gustavo.pimentel@synopsys.com>");
> diff --git a/drivers/dma/dw-edma/dw-edma-core.h b/drivers/dma/dw-edma/dw-edma-core.h
> index 71894b9e0b15..8458d676551a 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.h
> +++ b/drivers/dma/dw-edma/dw-edma-core.h
> @@ -81,6 +81,8 @@ struct dw_edma_chan {
>
>  	struct msi_msg			msi;
>
> +	enum dw_edma_ch_irq_mode	irq_mode;
> +
>  	enum dw_edma_request		request;
>  	enum dw_edma_status		status;
>  	u8				configured;
> diff --git a/drivers/dma/dw-edma/dw-edma-v0-core.c b/drivers/dma/dw-edma/dw-edma-v0-core.c
> index 2850a9df80f5..80472148c335 100644
> --- a/drivers/dma/dw-edma/dw-edma-v0-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-v0-core.c
> @@ -256,8 +256,10 @@ dw_edma_v0_core_handle_int(struct dw_edma_irq *dw_irq, enum dw_edma_dir dir,
>  	for_each_set_bit(pos, &val, total) {
>  		chan = &dw->chan[pos + off];
>
> -		dw_edma_v0_core_clear_done_int(chan);
> -		done(chan);
> +		if (!dw_edma_chan_ignore_irq(&chan->vc.chan)) {
> +			dw_edma_v0_core_clear_done_int(chan);
> +			done(chan);
> +		}
>
>  		ret = IRQ_HANDLED;
>  	}
> @@ -267,8 +269,10 @@ dw_edma_v0_core_handle_int(struct dw_edma_irq *dw_irq, enum dw_edma_dir dir,
>  	for_each_set_bit(pos, &val, total) {
>  		chan = &dw->chan[pos + off];
>
> -		dw_edma_v0_core_clear_abort_int(chan);
> -		abort(chan);
> +		if (!dw_edma_chan_ignore_irq(&chan->vc.chan)) {
> +			dw_edma_v0_core_clear_abort_int(chan);
> +			abort(chan);
> +		}
>
>  		ret = IRQ_HANDLED;
>  	}
> @@ -331,7 +335,8 @@ static void dw_edma_v0_core_write_chunk(struct dw_edma_chunk *chunk)
>  		j--;
>  		if (!j) {
>  			control |= DW_EDMA_V0_LIE;
> -			if (!(chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL))
> +			if (!(chan->dw->chip->flags & DW_EDMA_CHIP_LOCAL) &&
> +			    chan->irq_mode != DW_EDMA_CH_IRQ_LOCAL)
>  				control |= DW_EDMA_V0_RIE;
>  		}
>
> @@ -408,12 +413,17 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)
>  				break;
>  			}
>  		}
> -		/* Interrupt unmask - done, abort */
> +		/* Interrupt mask/unmask - done, abort */
>  		raw_spin_lock_irqsave(&dw->lock, flags);
>
>  		tmp = GET_RW_32(dw, chan->dir, int_mask);
> -		tmp &= ~FIELD_PREP(EDMA_V0_DONE_INT_MASK, BIT(chan->id));
> -		tmp &= ~FIELD_PREP(EDMA_V0_ABORT_INT_MASK, BIT(chan->id));
> +		if (chan->irq_mode == DW_EDMA_CH_IRQ_REMOTE) {
> +			tmp |= FIELD_PREP(EDMA_V0_DONE_INT_MASK, BIT(chan->id));
> +			tmp |= FIELD_PREP(EDMA_V0_ABORT_INT_MASK, BIT(chan->id));
> +		} else {
> +			tmp &= ~FIELD_PREP(EDMA_V0_DONE_INT_MASK, BIT(chan->id));
> +			tmp &= ~FIELD_PREP(EDMA_V0_ABORT_INT_MASK, BIT(chan->id));
> +		}
>  		SET_RW_32(dw, chan->dir, int_mask, tmp);
>  		/* Linked list error */
>  		tmp = GET_RW_32(dw, chan->dir, linked_list_err_en);
> diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
> index ffad10ff2cd6..6f50165ac084 100644
> --- a/include/linux/dma/edma.h
> +++ b/include/linux/dma/edma.h
> @@ -60,6 +60,23 @@ enum dw_edma_chip_flags {
>  	DW_EDMA_CHIP_LOCAL	= BIT(0),
>  };
>
> +/*
> + * enum dw_edma_ch_irq_mode - per-channel interrupt routing control
> + * @DW_EDMA_CH_IRQ_DEFAULT:   LIE=1/RIE=1, local interrupt unmasked
> + * @DW_EDMA_CH_IRQ_LOCAL:     LIE=1/RIE=0
> + * @DW_EDMA_CH_IRQ_REMOTE:    LIE=1/RIE=1, local interrupt masked
> + *
> + * Some implementations require using LIE=1/RIE=1 with the local interrupt
> + * masked to generate a remote-only interrupt (rather than LIE=0/RIE=1).
> + * See the DesignWare endpoint databook 5.40, "Hint" below "Figure 8-22
> + * Write Interrupt Generation".
> + */
> +enum dw_edma_ch_irq_mode {
> +	DW_EDMA_CH_IRQ_DEFAULT	= 0,
> +	DW_EDMA_CH_IRQ_LOCAL,
> +	DW_EDMA_CH_IRQ_REMOTE,
> +};
> +
>  /**
>   * struct dw_edma_chip - representation of DesignWare eDMA controller hardware
>   * @dev:		 struct device of the eDMA controller
> @@ -105,6 +122,22 @@ struct dw_edma_chip {
>  #if IS_REACHABLE(CONFIG_DW_EDMA)
>  int dw_edma_probe(struct dw_edma_chip *chip);
>  int dw_edma_remove(struct dw_edma_chip *chip);
> +/**
> + * dw_edma_chan_irq_config - configure per-channel interrupt routing
> + * @chan: DMA channel obtained from dma_request_channel()
> + * @mode: interrupt routing mode
> + *
> + * Returns 0 on success, -EINVAL for invalid @mode, or -ENODEV if @chan does
> + * not belong to the DesignWare eDMA driver.
> + */
> +int dw_edma_chan_irq_config(struct dma_chan *chan,
> +			    enum dw_edma_ch_irq_mode mode);
> +
> +/**
> + * dw_edma_chan_ignore_irq - tell whether local IRQ handling should be ignored
> + * @chan: DMA channel obtained from dma_request_channel()
> + */
> +bool dw_edma_chan_ignore_irq(struct dma_chan *chan);
>  #else
>  static inline int dw_edma_probe(struct dw_edma_chip *chip)
>  {
> @@ -115,6 +148,17 @@ static inline int dw_edma_remove(struct dw_edma_chip *chip)
>  {
>  	return 0;
>  }
> +
> +static inline int dw_edma_chan_irq_config(struct dma_chan *chan,
> +					  enum dw_edma_ch_irq_mode mode)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline bool dw_edma_chan_ignore_irq(struct dma_chan *chan)
> +{
> +	return false;
> +}

I think it'd better go thought

struct dma_slave_config {
	...
        void *peripheral_config;
	size_t peripheral_size;

};

So DMA consumer can use standard DMAengine API, dmaengine_slave_config().

Frank
>  #endif /* CONFIG_DW_EDMA */
>
>  struct pci_epc;
> --
> 2.51.0
>

  reply	other threads:[~2026-01-18 17:03 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 13:54 [RFC PATCH v4 00/38] NTB transport backed by PCI EP embedded DMA Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 01/38] dmaengine: dw-edma: Export helper to get integrated register window Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 02/38] dmaengine: dw-edma: Add per-channel interrupt routing control Koichiro Den
2026-01-18 17:03   ` Frank Li [this message]
2026-01-19 14:26     ` Koichiro Den
2026-01-21 16:02       ` Vinod Koul
2026-01-22  2:44         ` Koichiro Den
2026-01-23 15:44         ` Frank Li
2026-01-18 13:54 ` [RFC PATCH v4 03/38] dmaengine: dw-edma: Poll completion when local IRQ handling is disabled Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 04/38] dmaengine: dw-edma: Add notify-only channels support Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 05/38] dmaengine: dw-edma: Add a helper to query linked-list region Koichiro Den
2026-01-18 17:05   ` Frank Li
2026-01-21  1:38     ` Koichiro Den
2026-01-21  8:41       ` Koichiro Den
2026-01-21 15:24         ` Frank Li
2026-01-22  1:19           ` Koichiro Den
2026-01-22  1:54             ` Frank Li
2026-01-18 13:54 ` [RFC PATCH v4 06/38] NTB: epf: Add mwN_offset support and config region versioning Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 07/38] NTB: epf: Reserve a subset of MSI vectors for non-NTB users Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 08/38] NTB: epf: Provide db_vector_count/db_vector_mask callbacks Koichiro Den
2026-01-19 20:03   ` Frank Li
2026-01-21  1:41     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 09/38] NTB: core: Add mw_set_trans_ranges() for subrange programming Koichiro Den
2026-01-19 20:07   ` Frank Li
2026-01-18 13:54 ` [RFC PATCH v4 10/38] NTB: core: Add .get_private_data() to ntb_dev_ops Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 11/38] NTB: core: Add .get_dma_dev() " Koichiro Den
2026-01-19 20:09   ` Frank Li
2026-01-21  1:44     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 12/38] NTB: core: Add driver_override support for NTB devices Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 13/38] PCI: endpoint: pci-epf-vntb: Support BAR subrange mappings for MWs Koichiro Den
2026-01-19 20:26   ` Frank Li
2026-01-21  2:08     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 14/38] PCI: endpoint: pci-epf-vntb: Implement .get_private_data() callback Koichiro Den
2026-01-19 20:27   ` Frank Li
2026-01-18 13:54 ` [RFC PATCH v4 15/38] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev() Koichiro Den
2026-01-19 20:30   ` Frank Li
2026-01-22 14:58     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 16/38] NTB: ntb_transport: Move TX memory window setup into setup_qp_mw() Koichiro Den
2026-01-19 20:36   ` Frank Li
2026-01-21  2:15     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 17/38] NTB: ntb_transport: Dynamically determine qp count Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 18/38] NTB: ntb_transport: Use ntb_get_dma_dev() Koichiro Den
2026-01-19 20:38   ` Frank Li
2026-01-18 13:54 ` [RFC PATCH v4 19/38] NTB: ntb_transport: Rename ntb_transport.c to ntb_transport_core.c Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 20/38] NTB: ntb_transport: Move internal types to ntb_transport_internal.h Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 21/38] NTB: ntb_transport: Export common helpers for modularization Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 22/38] NTB: ntb_transport: Split core library and default NTB client Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 23/38] NTB: ntb_transport: Add transport backend infrastructure Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 24/38] NTB: ntb_transport: Run ntb_set_mw() before link-up negotiation Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 25/38] NTB: hw: Add remote eDMA backend registry and DesignWare backend Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 26/38] NTB: ntb_transport: Add remote embedded-DMA transport client Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 27/38] ntb_netdev: Multi-queue support Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 28/38] iommu: ipmmu-vmsa: Add PCIe ch0 to devices_allowlist Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 29/38] iommu: ipmmu-vmsa: Add support for reserved regions Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 30/38] arm64: dts: renesas: Add Spider RC/EP DTs for NTB with remote DW PCIe eDMA Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 31/38] NTB: epf: Add per-SoC quirk to cap MRRS for DWC eDMA (128B for R-Car) Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 32/38] NTB: epf: Add an additional memory window (MW2) barno mapping on Renesas R-Car Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 33/38] Documentation: PCI: endpoint: pci-epf-vntb: Update and add mwN_offset usage Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 34/38] Documentation: driver-api: ntb: Document remote embedded-DMA transport Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 35/38] PCI: endpoint: pci-epf-test: Add pci_epf_test_next_free_bar() helper Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 36/38] PCI: endpoint: pci-epf-test: Add remote eDMA-backed mode Koichiro Den
2026-01-19 20:47   ` Frank Li
2026-01-22 14:54     ` Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 37/38] misc: pci_endpoint_test: Add remote eDMA transfer test mode Koichiro Den
2026-01-18 13:54 ` [RFC PATCH v4 38/38] selftests: pci_endpoint: Add remote eDMA transfer coverage Koichiro Den
2026-01-20 18:30 ` [RFC PATCH v4 00/38] NTB transport backed by PCI EP embedded DMA Dave Jiang
2026-01-20 18:47   ` Dave Jiang
2026-01-21  2:40     ` Koichiro Den

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aW0SVx11WCxfTHoY@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=allenbh@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dave.jiang@intel.com \
    --cc=den@valinux.co.jp \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=iommu@lists.linux.dev \
    --cc=jbrunet@baylibre.com \
    --cc=jdmason@kudzu.us \
    --cc=jingoohan1@gmail.com \
    --cc=joro@8bytes.org \
    --cc=kishon@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mani@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=skhan@linuxfoundation.org \
    --cc=utkarsh02t@gmail.com \
    --cc=vkoul@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox