All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Devendra K Verma" <devverma@amd.com>
Cc: linux-pci@vger.kernel.org, vkoul@kernel.org,
	dmaengine@vger.kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v2 2/3] dmaengine: dw-edma: Enable Chan Separation via VSEC
Date: Tue, 28 Jul 2026 09:31:31 +0000	[thread overview]
Message-ID: <20260728093132.6669C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728091744.1086942-3-devverma@amd.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] The claimed 'Channel Separation' feature is completely unused and dead code, failing to pass the parsed separation size to the core DMA driver and causing hardware register offset mismatches on non-default configurations.
- [Medium] The `ch_sep_sz` field defaults to 0 for non-XILINX_B00F devices, violating the 256B default size specification.

Pre-existing issues:
- [High] Double free risk of IRQ vectors due to mixing managed `pcim_enable_device()` with manual `pci_free_irq_vectors()`.
--

--- Patch [2]: [PATCH v2 2/3] dmaengine: dw-edma: Enable Chan Separation via VSEC ---
commit c9662ac63af55f746e4aad35cf3b04bea4688738
Author: Devendra K Verma <devverma@amd.com>

dmaengine: dw-edma: Enable Chan Separation via VSEC

As per, 'Designware Cores PCI Express DM Controller - Reference
Manual', section 3.2.34.3, VSEC for DEVICE INFORMATION supports
the channel separation mechanisms. Basically, the HDMA IP allows
the user to configure the separation between DMA channel
registers and retrieve it via the VSEC capability mentioned
above.

> diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
> index ec5e057a0f11b..d0f209082878d 100644
> --- a/drivers/dma/dw-edma/dw-edma-pcie.c
> +++ b/drivers/dma/dw-edma/dw-edma-pcie.c

[ ... ]

> @@ -73,6 +76,7 @@ struct dw_edma_pcie_data {
>  	u16				wr_ch_cnt;
>  	u16				rd_ch_cnt;
>  	u64				devmem_phys_off;
> +	u32				ch_sep_sz;

[Severity: Medium]
Does this new field need to be initialized in the existing static
configuration structures?

For example, snps_edda_data and xilinx_mdb_data are not updated in this
patch to set ch_sep_sz. Because they are static structs, ch_sep_sz will
default to 0 for non-XILINX_B00F devices.

If ch_sep_sz is passed to the core driver, would a 0-byte separation cause
all channels to overlap in memory, violating the 256B default size
specification?

>  };
>  
>  static const struct dw_edma_pcie_data snps_edda_data = {

[ ... ]

> @@ -279,6 +290,10 @@ static void dw_edma_pcie_get_xilinx_dma_data(struct pci_dev *pdev,
>  	pdata->mf = map;
>  	pdata->rg.bar = FIELD_GET(DW_PCIE_XILINX_VSEC_DMA_BAR, val);
>  
> +	if (pdev->device == PCI_DEVICE_ID_XILINX_B00F)
> +		pdata->ch_sep_sz = dw_edma_get_ch_sep_sz(FIELD_GET(DW_PCIE_XILINX_CPM6_VSEC_CH_SEP,
> +								   val));
> +

[Severity: High]
Is the parsed channel separation size actually used by the core driver?

It looks like ch_sep_sz is populated in vsec_data here, but is never
passed to the core DMA driver in dw_edma_pcie_probe():

drivers/dma/dw-edma/dw-edma-pcie.c:dw_edma_pcie_probe() {
    ...
    chip->mf = vsec_data->mf;
    chip->nr_irqs = nr_irqs;
    chip->ops = &dw_edma_pcie_plat_ops;
    chip->cfg_non_ll = non_ll;
    chip->ll_wr_cnt = vsec_data->wr_ch_cnt;
    ...
}

Additionally, does the core driver support this dynamic separation? Looking at
__dw_ch_regs() in dw-hdma-v0-core.c, the channel register offsets appear to be
calculated using fixed C structure array indexing:

    if (dir == EDMA_DIR_WRITE)
        return &(__dw_regs(dw)->ch[ch].wr);
    else
        return &(__dw_regs(dw)->ch[ch].rd);

If a 32KB separation is configured, wouldn't the core driver still calculate
MMIO offsets assuming the hardcoded structure layout, potentially reading or
writing incorrect PCI memory on non-default configurations?

>  	pci_read_config_dword(pdev, vsec + 0xc, &val);

[ ... ]

> @@ -324,9 +339,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
>  	struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;
>  	struct device *dev = &pdev->dev;
>  	struct dw_edma_chip *chip;
> +	bool non_ll = false;
>  	int err, nr_irqs;
>  	int i, mask;
> -	bool non_ll = false;
>  

[Severity: High]
This is a pre-existing issue, but I noticed a potential double free of the
IRQ vectors related to the device probing.

When pcim_enable_device() is used, IRQ allocations via
pci_alloc_irq_vectors() are managed by devres and automatically freed.

However, looking at the remove path in dw_edma_pcie_remove():

    /* Freeing IRQs */
    pci_free_irq_vectors(pdev);

Does calling pci_free_irq_vectors() manually conflict with the devres cleanup
registered automatically by pcim_enable_device(), leading to a double free
when the driver is unbound or fails to probe?

>  	if (!pdata)
>  		return -ENODEV;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728091744.1086942-1-devverma@amd.com?part=2

  reply	other threads:[~2026-07-28  9:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  9:17 [PATCH v2 0/3] CPM6 Channel Separation Support Devendra K Verma
2026-07-28  9:17 ` [PATCH v2 1/3] dmaengine: dw-edma: Make Xilinx Macros Dev Name Agnostic Devendra K Verma
2026-07-28  9:28   ` sashiko-bot
2026-07-28 15:31   ` Frank Li
2026-07-28  9:17 ` [PATCH v2 2/3] dmaengine: dw-edma: Enable Chan Separation via VSEC Devendra K Verma
2026-07-28  9:31   ` sashiko-bot [this message]
2026-07-28 15:33   ` Frank Li
2026-07-28  9:17 ` [PATCH v2 3/3] dmaengine: dw-edma: Add changes to support Channel Separation Devendra K Verma
2026-07-28  9:31   ` sashiko-bot

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=20260728093132.6669C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=devverma@amd.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.