CPM6 Channel Separation Support
Subsystems (5)
v3 cover CPM6 Channel Separation Support
'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.
In order to use the VSEC functionality following changes have been made:
o Utilize the existing VSEC implementation to retrieve the channel separation and translate it to correct size.
o Modify the structs and functions to calculate correct DMA channel register base using the channel, direction and channel separation selected.
Devendra K Verma (2):
dmaengine: dw-edma: Enable Chan Separation via VSEC
dmaengine: dw-edma: Add changes to support Channel Separation
drivers/dma/dw-edma/dw-edma-pcie.c | 24 +++++++++++++++++--- drivers/dma/dw-edma/dw-hdma-v0-core.c | 23 +++++++++++-------- drivers/dma/dw-edma/dw-hdma-v0-debugfs.c | 17 +++++--------- drivers/dma/dw-edma/dw-hdma-v0-regs.h | 10 -------- drivers/pci/controller/dwc/pcie-designware.c | 1 + include/linux/dma/edma.h | 1 + 6 files changed, 43 insertions(+), 33 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.
Changes in v1:
o Modified dw_edma_get_ch_sep_sz() as per review comment. The function now supports ch_sep_sz up to 32KB.
o Updated to description to reflect the supported channel separation sizes.
--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +17 -3
@@ -31,8 +31,10 @@#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8) +/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)
@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {
@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */ .rg.bar =BAR_0 , .rg.off =SZ_4K ,/* 4 Kbytes */ .rg.sz =SZ_8K ,/* 8 Kbytes */
@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);
@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));
@@ -324,9 +338,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;if (!pdata)return -ENODEV ;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The parsed channel separation size (`ch_space_sz`) is never propagated to the core driver…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The parsed channel separation size (ch_space_sz) is never propagated to the core driver, rendering the commit functionally dead.
- [Medium] The newly added ch_space_sz field implicitly defaults to 0 instead of the documented 256 bytes for all non-B00F devices. --
--- Patch [1]: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC --- commit 49b6417fbdbe084d5839664db3abac6f79f818d2
Author: Devendra K Verma <[email protected]>
dmaengine: dw-edma: Enable Chan Separation via VSEC
This commit adds support for parsing the channel separation size from the DEVICE INFORMATION VSEC capability on the Xilinx B00F device. It aims to allow the user to configure the separation between DMA channel registers.
Quoted 4 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-0
[ ... ]
drivers/dma/dw-edma/dw-edma-pcie.c struct dw_edma_pcie_data { · line 79
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-0@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };
[Severity: Medium]
Does this new field implicitly default to 0 for non-B00F devices?
The commit message states "Default supported size is 256B", but static structs like snps_edda_data and xilinx_mdb_data lack explicit initialization for ch_space_sz, meaning they will be zero-initialized.
If this value is later used for channel offset calculations, could a 0-byte separation cause all DMA channels to map to the exact same memory address?
[ ... ]
drivers/dma/dw-edma/dw-edma-pcie.c static void dw_edma_pcie_get_xilinx_dma_data(struct pci_dev *pdev, · line 295
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c +4
-0@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +
[Severity: Medium]
Is this parsed value supposed to be propagated to the core driver?
It appears pdata->ch_space_sz is populated here, but looking at dw_edma_pcie_probe(), it doesn't seem to be passed along to struct dw_edma_chip before the VSEC data goes out of scope:
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;
/* missing chip->ch_space_sz = vsec_data->ch_space_sz ? */
...
}Without this propagation, does the channel separation configuration actually take effect?
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-0pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
In reply to Devendra K VermaQuoted 32 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1@@ -31,8 +31,10 @@#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)
Don't mix code cleanup or reorg into this improvement patches.
Quoted 14 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {
drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */
This typo fix have not mixed this patch.
Quoted 29 lines
drivers/dma/dw-edma/dw-edma-pcie.c +11
-0.rg.bar = BAR_0, .rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 7 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1@@ -324,9 +338,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;
unnecssary change here
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-1if (!pdata)return -ENODEV ; --2.43.0
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
Quoted 34 lines · Frank Li
Quoted 33 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -31,8 +31,10 @@
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)Don't mix code cleanup or reorg into this improvement patches.
It was recommended by you in the v1 of the same patch series that is why pushed it.
Ref: https://lore.kernel.org/all/amDbGHRbObX-lt5F@SMW015318/
Quoted 16 lines
Quoted 16 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */ This typo fix have not mixed this patch.
This is subtle change. Since the focus of this patch series is CPM6, the namings and comments should align with the appropriate name.
Quoted 31 lines
Quoted 31 lines
drivers/dma/dw-edma/dw-edma-pcie.c +11
-0.rg.bar = BAR_0, .rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));@@ -324,9 +338,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;
Quoted 9 lines
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1struct device *dev = &pdev->dev;struct dw_edma_chip *chip; +bool non_ll = false;int err, nr_irqs;int i, mask; -bool non_ll = false;unnecssary change here
Yeah, this change was part of some patch series I pushed. This change was breaking the inverted X-mas format that's why made this change.
-Devendra
Quoted 7 lines
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-1if (!pdata)return -ENODEV ; --2.43.0
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
Quoted 44 lines · Devendra
Quoted 34 lines · Frank Li
Quoted 33 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -31,8 +31,10 @@Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)Don't mix code cleanup or reorg into this improvement patches.
Quoted 4 lines
It was recommended by you in the v1 of the same patch series that is why pushed it.
Ref: https://lore.kernel.org/all/amDbGHRbObX-lt5F@SMW015318/
You can fix the order by using prep patch, which just fix order, typo or some cleanup.
But not mixed into new feature patches.
Quoted 67 lines
Quoted 17 lines
Quoted 17 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */ This typo fix have not mixed this patch.
This is subtle change. Since the focus of this patch series is CPM6, the namings and comments should align with the appropriate name.
Quoted 31 lines
Quoted 31 lines
drivers/dma/dw-edma/dw-edma-pcie.c +11
-0.rg.bar = BAR_0, .rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));@@ -324,9 +338,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;Quoted 9 lines
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1struct device *dev = &pdev->dev;struct dw_edma_chip *chip; +bool non_ll = false;int err, nr_irqs;int i, mask; -bool non_ll = false;unnecssary change here
Quoted 3 lines
Yeah, this change was part of some patch series I pushed. This change was breaking the inverted X-mas format that's why made this change.
But not related this patch. Use a small sperate patch to fix these small problem.
Use a small patch to do clean up, for example
reorder register bit defination
fix commends about CPM6
fix inverted X-mas format.
Frank
Quoted 11 lines
-Devendra
Quoted 7 lines
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-1if (!pdata)return -ENODEV ; --2.43.0
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
Quoted 48 lines · Frank Li
Quoted 47 lines · Devendra
Quoted 34 lines · Frank Li
Quoted 33 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -31,8 +31,10 @@Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)Don't mix code cleanup or reorg into this improvement patches.
It was recommended by you in the v1 of the same patch series that is why pushed it.
Quoted 33 lines
Quoted 1 line
Ref: https://lore.kernel.org/all/amDbGHRbObX-lt5F@SMW015318/
You can fix the order by using prep patch, which just fix order, typo or some cleanup.
But not mixed into new feature patches.
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */ This typo fix have not mixed this patch.
This is subtle change. Since the focus of this patch series is CPM6, the namings and comments should align with the appropriate name.
Can we take up this change along with this patch series as it is related to CPM6 only?
Quoted 45 lines
Quoted 41 lines
Quoted 31 lines
Quoted 31 lines
drivers/dma/dw-edma/dw-edma-pcie.c +11
-0.rg.bar = BAR_0, .rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));@@ -324,9 +338,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;Quoted 9 lines
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1struct device *dev = &pdev->dev;struct dw_edma_chip *chip; +bool non_ll = false;int err, nr_irqs;int i, mask; -bool non_ll = false;unnecssary change here
Quoted 3 lines
Yeah, this change was part of some patch series I pushed. This change was breaking the inverted X-mas format that's why made this change.
Quoted 9 lines
But not related this patch. Use a small sperate patch to fix these small problem.
Use a small patch to do clean up, for example
reorder register bit defination
fix commends about CPM6
fix inverted X-mas format.
The 1st and 3rd can be taken in a separate patch series but the 2nd is related to CPM6 only so having it is beneficial with this patch series, removes the misleading comment.
I will push the changes after your response.
-Devendra
Quoted 13 lines
Quoted 13 lines
Frank
-Devendra
Quoted 7 lines
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-1if (!pdata)return -ENODEV ; --2.43.0
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
Hi Frank
Could you check and provide suggestion on the comments inline?
regards,
Devendra
Quoted 146 lines · Devendra
Quoted 48 lines · Frank Li
Quoted 47 lines · Devendra
Quoted 34 lines · Frank Li
Quoted 33 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.
---
drivers/dma/dw-edma/dw-edma-pcie.c| 20 +++++++++++++++++---1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -31,8 +31,10 @@Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6 #define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8) #define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)Don't mix code cleanup or reorg into this improvement patches.
It was recommended by you in the v1 of the same patch series that is why pushed it.
Quoted 34 lines
Quoted 1 line
Ref: https://lore.kernel.org/all/amDbGHRbObX-lt5F@SMW015318/
You can fix the order by using prep patch, which just fix order, typo or some cleanup.
But not mixed into new feature patches.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16) #define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0) #define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data { u16 wr_ch_cnt; u16 rd_ch_cnt; u64 devmem_phys_off; + u32 ch_space_sz; }; static const struct dw_edma_pcie_data snps_edda_data = {@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 3 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { - /* MDB registers location */ + /* CPM6 registers location */This typo fix have not mixed this patch.
This is subtle change. Since the focus of this patch series is CPM6, the namings and comments should align with the appropriate name.
Can we take up this change along with this patch series as it is related to CPM6 only?
Quoted 49 lines
Quoted 45 lines
Quoted 35 lines
Quoted 35 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-0.rg.bar = BAR_0,.rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */
drivers/dma/dw-edma/dw-edma-pcie.c +7
-0@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr) return pci_irq_vector(to_pci_dev(dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ + if (val > 0 && val <= 7) + return 256 << val; + return 256; +} + static u64 dw_edma_pcie_address(struct device *dev, phys_addr_t cpu_addr) {struct
pci_dev*pdev =to_pci_dev(dev);drivers/dma/dw-edma/dw-edma-pcie.c +4
-0@@ -279,6 +289,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_MDB_VSEC_DMA_BAR, val); + if (pdev->device == PCI_DEVICE_ID_XILINX_B00F) + pdata->ch_space_sz = dw_edma_get_ch_space_sz + (FIELD_GET(DW_PCIE_XILINX_CPM6_VSEC_CH_SEP, val)); + pci_read_config_dword(pdev, vsec + 0xc, &val);
pdata->wr_ch_cnt=min(pdata->wr_ch_cnt, FIELD_GET(DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH, val));drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -324,9 +338,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;Quoted 9 lines
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1struct device *dev = &pdev->dev; struct dw_edma_chip *chip; + bool non_ll = false; int err, nr_irqs; int i, mask; - bool non_ll = false;unnecssary change here
Quoted 3 lines
Yeah, this change was part of some patch series I pushed. This change was breaking the inverted X-mas format that's why made this change.
Quoted 9 lines
But not related this patch. Use a small sperate patch to fix these small problem.
Use a small patch to do clean up, for example
reorder register bit defination
fix commends about CPM6
fix inverted X-mas format.
Quoted 6 lines
The 1st and 3rd can be taken in a separate patch series but the 2nd is related to CPM6 only so having it is beneficial with this patch series, removes the misleading comment.
I will push the changes after your response.
Any update on the above suggestion?
Quoted 16 lines
-Devendra
Quoted 13 lines
Quoted 13 lines
Frank
-Devendra
Quoted 7 lines
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-0if (!pdata) return -ENODEV;Signature · 1 line
2.43.0
Re: [PATCH v3 1/2] dmaengine: dw-edma: Enable Chan Separation via VSEC
In reply to Verma, DevendraQuoted 80 lines · Devendra
Quoted 78 lines · Frank Li
Quoted 44 lines · Devendra
Quoted 34 lines · Frank Li
Quoted 33 lines · Devendra K Verma
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.
HDMA IP supports the channel register space separation from 256B to 32KB. Default supported size is 256B.
Signed-off-by Devendra K Verma <[email protected]>---
Changes in v2:
o Replaced 'ch_sep_sz' with 'ch_space_sz' wherever applicable upon reviewer recommendation.
o Dropped 1/3 patch of this series, after review, now the 2/3 is 1/2 of the current patch series.Changes in v1:
o Modifieddw_edma_get_ch_sep_sz()as per review comment. The function now supportsch_sep_szup to 32KB.
o Updated to description to reflect the supported channel separation sizes.--- drivers/dma/dw-edma/dw-edma-pcie.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +0
-0@@ -31,8 +31,10 @@Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c line 35
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1#define DW_PCIE_XILINX_MDB_VSEC_DMA_ID 0x6#define DW_PCIE_XILINX_MDB_VSEC_ID 0x20 -#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)#define DW_PCIE_XILINX_MDB_VSEC_DMA_MAP GENMASK(2, 0) +#define DW_PCIE_XILINX_MDB_VSEC_DMA_BAR GENMASK(10, 8)Don't mix code cleanup or reorg into this improvement patches.
Quoted 4 lines
It was recommended by you in the v1 of the same patch series that is why pushed it.
Ref: https://lore.kernel.org/all/amDbGHRbObX-lt5F@SMW015318/
You can fix the order by using prep patch, which just fix order, typo or some cleanup.
But not mixed into new feature patches.
Quoted 23 lines
Quoted 22 lines
Quoted 15 lines
drivers/dma/dw-edma/dw-edma-pcie.c +3
-0+/* AMD CPM6 (Xilinx) supported cap */ +#define DW_PCIE_XILINX_CPM6_VSEC_CH_SEP GENMASK(18, 16)#define DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH GENMASK(9, 0)#define DW_PCIE_XILINX_MDB_VSEC_DMA_RD_CH GENMASK(25, 16)@@ -73,6 +75,7 @@ struct dw_edma_pcie_data {u16 wr_ch_cnt;u16 rd_ch_cnt;u64 devmem_phys_off; +u32 ch_space_sz; };static const struct dw_edma_pcie_data snps_edda_data = {drivers/dma/dw-edma/dw-edma-pcie.c static const struct dw_edma_pcie_data xilinx_mdb_data = { · line 133
Quoted 5 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1@@ -127,7 +130,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { };static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { -/* MDB registers location */ +/* CPM6 registers location */ This typo fix have not mixed this patch.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
This is subtle change. Since the focus of this patch series is CPM6, the namings and comments should align with the appropriate name.
Can we take up this change along with this patch series as it is related to CPM6 only?
you origial variable is "xilinx_cpm6_dma_data", but comments is "MDB register location"
You change MDB to CPM6, belong fix typo/comments in original code. Should combine with other code style cleanup patch.
Frank
Quoted 77 lines
Quoted 46 lines
Quoted 42 lines
Quoted 32 lines
Quoted 32 lines
drivers/dma/dw-edma/dw-edma-pcie.c +11
-0.rg.bar = BAR_0, .rg.off = SZ_4K, /* 4 Kbytes */ .rg.sz = SZ_8K, /* 8 Kbytes */@@ -189,6 +192,13 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr)return pci_irq_vector (to_pci_dev (dev), nr); } +static u32 dw_edma_get_ch_space_sz (u32 val) +{ +if (val >0 && val <=7 ) +return 256 << val; +return 256 ; +} +static u64 dw_edma_pcie_address (struct device *dev,phys_addr_t cpu_addr) {struct pci_dev *pdev =to_pci_dev (dev);@@ -279,6 +289,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_MDB_VSEC_DMA_BAR , val); +if (pdev->device ==PCI_DEVICE_ID_XILINX_B00F ) + pdata->ch_space_sz =dw_edma_get_ch_space_sz + (FIELD_GET (DW_PCIE_XILINX_CPM6_VSEC_CH_SEP , val)); +pci_read_config_dword (pdev, vsec +0xc , &val); pdata->wr_ch_cnt =min (pdata->wr_ch_cnt,FIELD_GET (DW_PCIE_XILINX_MDB_VSEC_DMA_WR_CH , val));@@ -324,9 +338,9 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;Quoted 9 lines
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 329
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-1struct device *dev = &pdev->dev;struct dw_edma_chip *chip; +bool non_ll = false;int err, nr_irqs;int i, mask; -bool non_ll = false;unnecssary change here
Quoted 3 lines
Yeah, this change was part of some patch series I pushed. This change was breaking the inverted X-mas format that's why made this change.
Quoted 9 lines
But not related this patch. Use a small sperate patch to fix these small problem.
Use a small patch to do clean up, for example
reorder register bit defination
fix commends about CPM6
fix inverted X-mas format.The 1st and 3rd can be taken in a separate patch series but the 2nd is related to CPM6 only so having it is beneficial with this patch series, removes the misleading comment.
I will push the changes after your response.
-Devendra
Quoted 13 lines
Quoted 13 lines
Frank
-Devendra
Quoted 7 lines
Frank
Quoted 6 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-1if (!pdata)return -ENODEV ; --2.43.0
PATCH v3 2/2 dmaengine: dw-edma: Add changes to support Channel Separation
In reply to Devendra K VermaHDMA supports configurable DMA channel register space separation which ranges from 256B to 32KB. Current implementation supports 256B as default for DMA channel register space. CPM6 supports the selection of channel register space via VSEC. The default value for channel register space for CPM6 is 512B.
Updated the functions and methods to calculate the DMA channel registers base address as per the selected channel separation available as part of 'ch_space_sz'. Removed the unused function __dw_regs() and structs, namely dw_hdma_v0_ch and dw_hdma_v0_regs.
---
Changes in v2:
o Replace 'ch_sep_sz' with 'ch_space_sz' as per review recommendations.
o As patch 1/3 of previous series dropped after review, this patch becomes 2/2 of the current series.
Changes in v1:
o Updated the description as per the review comment
o Updated ch_sep_sz for EPC driver.
--- drivers/dma/dw-edma/dw-edma-pcie.c | 4 ++++ drivers/dma/dw-edma/dw-hdma-v0-core.c | 23 ++++++++++++-------- drivers/dma/dw-edma/dw-hdma-v0-debugfs.c | 17 +++++---------- drivers/dma/dw-edma/dw-hdma-v0-regs.h | 10 --------- drivers/pci/controller/dwc/pcie-designware.c | 1 + include/linux/dma/edma.h | 1 + 6 files changed, 26 insertions(+), 30 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +4 -0
@@ -114,6 +114,7 @@ static const struct dw_edma_pcie_data snps_edda_data = { .irqs = 1, .wr_ch_cnt = 2, .rd_ch_cnt = 2, + .ch_space_sz = 256, };static const struct dw_edma_pcie_data xilinx_mdb_data = {
@@ -127,6 +128,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { .irqs = 1, .wr_ch_cnt = 8, .rd_ch_cnt = 8, + .ch_space_sz = 256, };static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = {
@@ -140,6 +142,7 @@ static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { .irqs = 1, .wr_ch_cnt = 8, .rd_ch_cnt = 8, + .ch_space_sz = 512, }; static void dw_edma_set_chan_region_offset(struct dw_edma_pcie_data *pdata,
@@ -436,6 +439,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->nr_irqs = nr_irqs; chip->ops = &dw_edma_pcie_plat_ops; chip->cfg_non_ll = non_ll; + chip->ch_space_sz = vsec_data->ch_space_sz; chip->ll_wr_cnt = vsec_data->wr_ch_cnt; chip->ll_rd_cnt = vsec_data->rd_ch_cnt;
drivers/dma/dw-edma/dw-hdma-v0-core.c +14 -9
@@ -23,18 +23,23 @@ enum dw_hdma_control { DW_HDMA_V0_LLE = BIT(9), }; -static inline struct dw_hdma_v0_regs __iomem *__dw_regs (struct dw_edma *dw) -{ -return dw->chip->reg_base; -} -static inline struct dw_hdma_v0_ch_regs __iomem *__dw_ch_regs (struct dw_edma *dw,enum dw_edma_dir dir,u16 ch) { -if (dir ==EDMA_DIR_WRITE ) -return &(__dw_regs (dw)->ch[ch].wr); -else -return &(__dw_regs (dw)->ch[ch].rd); +u32 ch_base; + +/* +* For Write, the channel register index starts at +* wr_base(ch_idx) = (2 * ch_idx) * ch_space_sz +* +* For Read channel, +* rd_base(ch_idx) = (2 * ch_idx + 1) * ch_space_sz +*/ + ch_base =2 * ch; +if (dir ==EDMA_DIR_READ ) + ch_base +=1 ; + +return dw->chip->reg_base + (ch_base * dw->chip->ch_space_sz); }#define SET_CH_32 (dw, dir, ch, name, value) \
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c +6 -11
@@ -13,22 +13,17 @@#include "dw-hdma-v0-regs.h" #include "dw-edma-core.h" -#define REGS_ADDR (dw, name) \ - ({ \ - struct dw_hdma_v0_regs __iomem *__regs = (dw)->chip->reg_base; \ - \ - (void __iomem *)&__regs->name; \ - }) -#define REGS_CH_ADDR (dw, name, _dir, _ch) \ ({ \ - struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + off_t __off = (dw)->chip->ch_space_sz; \ \ - if (_dir == EDMA_DIR_READ) \ - __ch_regs = REGS_ADDR(dw, ch[_ch].rd); \ + if ((_dir) == EDMA_DIR_READ) \ + __off *= (2 * (_ch) + 1); \ else \ - __ch_regs = REGS_ADDR(dw, ch[_ch].wr); \ + __off *= (2 * (_ch)); \ \ + __ch_regs = ((dw)->chip->reg_base + __off); \ (void __iomem *)&__ch_regs->name; \ })
drivers/dma/dw-edma/dw-hdma-v0-regs.h +0 -10
@@ -84,16 +84,6 @@ struct dw_hdma_v0_ch_regs { }; } msi_abort;u32 msi_msgdata;/* 0x00a8 */ -u32 padding_2[21 ];/* 0x00ac..0x00fc */ -} __packed; - -struct dw_hdma_v0_ch { -struct dw_hdma_v0_ch_regs wr;/* 0x0000 */ -struct dw_hdma_v0_ch_regs rd;/* 0x0100 */ -} __packed; - -struct dw_hdma_v0_regs { -struct dw_hdma_v0_ch ch[HDMA_V0_MAX_NR_CH ];/* 0x0000..0x0fa8 */ } __packed;struct dw_hdma_v0_lli {
drivers/pci/controller/dwc/pcie-designware.c +1 -0
@@ -1049,6 +1049,7 @@ static void dw_pcie_edma_init_data(struct dw_pcie *pci) pci->edma.ops = &dw_pcie_edma_ops; pci->edma.flags |=DW_EDMA_CHIP_LOCAL ; + pci->edma.ch_space_sz =256 ; }static int dw_pcie_edma_find_mf (struct dw_pcie *pci)
include/linux/dma/edma.h +1 -0
@@ -104,6 +104,7 @@ struct dw_edma_chip {struct dw_edma *dw;bool cfg_non_ll; +u32 ch_space_sz; };/* Export to the platform drivers */
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v3 2/2] dmaengine: dw-edma: Add changes to support Channel Separation
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] Out-of-Bounds MMIO Access via Untrusted ch_space_sz
Pre-existing issues:
- [High] Resource Leak (Missing IRQ Vector Cleanup)
- [High] Logic Error / Argument Swap in GET_CH_32 --
--- Patch [2]: [PATCH v3 2/2] dmaengine: dw-edma: Add changes to support Channel Separation --- commit 612eb6bce9ca000b699c0fa4968d63e211dd64db
Author: Devendra K Verma <[email protected]>
dmaengine: dw-edma: Add changes to support Channel Separation
This commit adds configurable DMA channel register space separation ranging from 256B to 32KB. It updates functions to calculate base addresses based on the selected channel separation value available in the PCIe VSEC configuration space.
Quoted 4 lines
drivers/dma/dw-edma/dw-edma-pcie.c +0
-0
[ ... ]
drivers/dma/dw-edma/dw-edma-pcie.c static int dw_edma_pcie_probe(struct pci_dev *pdev, · line 445
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-pcie.c +1
-0@@ -436,6 +439,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->nr_irqs = nr_irqs; chip->ops = &dw_edma_pcie_plat_ops; chip->cfg_non_ll = non_ll; + chip->ch_space_sz = vsec_data->ch_space_sz; chip->ll_wr_cnt = vsec_data->wr_ch_cnt; chip->ll_rd_cnt = vsec_data->rd_ch_cnt;
[Severity: High]
This is a pre-existing issue, but does this function leak IRQ vectors on error paths?
If initialization fails after pci_alloc_irq_vectors() succeeds earlier in the function, it returns directly without cleaning up the IRQs:
dw_edma_pcie_probe()
{
...
chip->reg_base = pcim_iomap_table(pdev)[vsec_data->rg.bar];
if (!chip->reg_base)
return -ENOMEM;
...
err = dw_edma_probe(chip);
if (err) {
pci_err(pdev, "eDMA probe failed\n");
return err;
}
...
}Should these error paths call pci_free_irq_vectors(pdev) to ensure we don't exhaust system IRQ capacity?
Quoted 4 lines
drivers/dma/dw-edma/dw-hdma-v0-core.c +0
-0
[ ... ]
Quoted 21 lines
drivers/dma/dw-edma/dw-hdma-v0-core.c +5
-9@@ -23,18 +23,23 @@ enum dw_hdma_control { DW_HDMA_V0_LLE = BIT(9), }; -static inline struct dw_hdma_v0_regs __iomem *__dw_regs (struct dw_edma *dw) -{ -return dw->chip->reg_base; -} -static inline struct dw_hdma_v0_ch_regs __iomem *__dw_ch_regs (struct dw_edma *dw,enum dw_edma_dir dir,u16 ch) { -if (dir ==EDMA_DIR_WRITE ) -return &(__dw_regs (dw)->ch[ch].wr); -else -return &(__dw_regs (dw)->ch[ch].rd); +u32 ch_base; + +/* +* For Write, the channel register index starts at +* wr_base(ch_idx) = (2 * ch_idx) * ch_space_sz
drivers/dma/dw-edma/dw-hdma-v0-core.c enum dw_hdma_control { · line 43
Quoted 10 lines
drivers/dma/dw-edma/dw-hdma-v0-core.c +9
-0+* +* For Read channel, +* rd_base(ch_idx) = (2 * ch_idx + 1) * ch_space_sz +*/ + ch_base =2 * ch; +if (dir ==EDMA_DIR_READ ) + ch_base +=1 ; + +return dw->chip->reg_base + (ch_base * dw->chip->ch_space_sz); }
[Severity: High]
Is it possible for this pointer arithmetic to access memory out of bounds?
The ch_space_sz value is derived dynamically from the untrusted PCIe VSEC configuration space (scaling up to 32KB per channel). If a malicious or buggy hardware endpoint presents a small BAR (e.g., 4KB) but provides a large VSEC channel separation value, multiplying ch_base by dw->chip->ch_space_sz could yield an offset well beyond the memory mapped in chip->reg_base.
Should ch_space_sz be validated against the mapped BAR size using pci_resource_len() before using it to index into the MMIO space?
[Severity: High]
This is a pre-existing issue, but does dw_hdma_v0_core_ch_status() pass arguments to the GET_CH_32 macro in the wrong order?
In dw_hdma_v0_core_ch_status(), the code does:
tmp = FIELD_GET(HDMA_V0_CH_STATUS_MASK,
GET_CH_32(dw, chan->id, chan->dir, ch_stat));
The GET_CH_32 macro expects arguments in the order (dw, dir, ch, name), but chan->id and chan->dir appear to be swapped. Can this cause the driver to calculate an incorrect register base offset and read from the wrong hardware channel registers?
Quoted 4 lines
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c +0
-0
[ ... ]
Quoted 7 lines
#define
REGS_CH_ADDR(dw, name, _dir, _ch)\drivers/dma/dw-edma/dw-hdma-v0-debugfs.c +2
-2({ \ - struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + off_t __off = (dw)->chip->ch_space_sz; \ \ - if (_dir == EDMA_DIR_READ) \
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c line 28
Quoted 10 lines
drivers/dma/dw-edma/dw-hdma-v0-debugfs.c +4
-2- __ch_regs =REGS_ADDR (dw, ch[_ch].rd); \ +if ((_dir) ==EDMA_DIR_READ ) \ + __off *= (2 * (_ch) +1 ); \else \ - __ch_regs =REGS_ADDR (dw, ch[_ch].wr); \ + __off *= (2 * (_ch)); \ \ + __ch_regs = ((dw)->chip->reg_base + __off); \ (void __iomem *)&__ch_regs->name; \ })
[Severity: High]
Can this result in an out-of-bounds MMIO read when userspace accesses debugfs attributes?
Similar to the calculation in __dw_ch_regs(), __off scales by the unvalidated ch_space_sz value. If the value isn't checked against the BAR size, could a userspace read/write to debugfs trigger an out-of-bounds access beyond the mapped memory space?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v3 2/2] dmaengine: dw-edma: Add changes to support Channel Separation
In reply to Devendra K VermaQuoted 6 lines · Devendra K Verma
HDMA supports configurable DMA channel register space separation which ranges from 256B to 32KB. Current implementation supports 256B as default for DMA channel register space. CPM6 supports the selection of channel register space via VSEC. The default value for channel register space for CPM6 is 512B.
Quoted 7 lines
Updated the functions and methods to calculate the DMA channel registers base address as per the selected channel separation available as part of '
ch_space_sz'. Removed the unused function__dw_regs()and structs, namelydw_hdma_v0_chanddw_hdma_v0_regs.Signed-off-by Devendra K Verma <[email protected]>---
Quoted 172 lines
Changes in v2:
o Replace 'ch_sep_sz' with 'ch_space_sz' as per review recommendations.
o As patch 1/3 of previous series dropped after review, this patch becomes 2/2 of the current series.Changes in v1:
o Updated the description as per the review comment
o Updatedch_sep_szfor EPC driver.--- drivers/dma/dw-edma/dw-edma-pcie.c | 4 ++++ drivers/dma/dw-edma/dw-hdma-v0-core.c | 23 ++++++++++++-------- drivers/dma/dw-edma/dw-hdma-v0-debugfs.c | 17 +++++---------- drivers/dma/dw-edma/dw-hdma-v0-regs.h | 10 --------- drivers/pci/controller/dwc/pcie-designware.c | 1 + include/linux/dma/edma.h | 1 + 6 files changed, 26 insertions(+), 30 deletions(-)drivers/dma/dw-edma/dw-edma-pcie.c +4
-0@@ -114,6 +114,7 @@ static const struct dw_edma_pcie_data snps_edda_data = { .irqs = 1, .wr_ch_cnt = 2, .rd_ch_cnt = 2, + .ch_space_sz = 256, };static const struct dw_edma_pcie_data xilinx_mdb_data = {@@ -127,6 +128,7 @@ static const struct dw_edma_pcie_data xilinx_mdb_data = { .irqs = 1, .wr_ch_cnt = 8, .rd_ch_cnt = 8, + .ch_space_sz = 256, };static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = {@@ -140,6 +142,7 @@ static const struct dw_edma_pcie_data xilinx_cpm6_dma_data = { .irqs = 1, .wr_ch_cnt = 8, .rd_ch_cnt = 8, + .ch_space_sz = 512, }; static void dw_edma_set_chan_region_offset(struct dw_edma_pcie_data *pdata,@@ -436,6 +439,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->nr_irqs = nr_irqs; chip->ops = &dw_edma_pcie_plat_ops; chip->cfg_non_ll = non_ll; + chip->ch_space_sz = vsec_data->ch_space_sz; chip->ll_wr_cnt = vsec_data->wr_ch_cnt; chip->ll_rd_cnt = vsec_data->rd_ch_cnt;drivers/dma/dw-edma/dw-hdma-v0-core.c +14
-9@@ -23,18 +23,23 @@ enum dw_hdma_control { DW_HDMA_V0_LLE = BIT(9), }; -static inline struct dw_hdma_v0_regs __iomem *__dw_regs (struct dw_edma *dw) -{ -return dw->chip->reg_base; -} -static inline struct dw_hdma_v0_ch_regs __iomem *__dw_ch_regs (struct dw_edma *dw,enum dw_edma_dir dir,u16 ch) { -if (dir ==EDMA_DIR_WRITE ) -return &(__dw_regs (dw)->ch[ch].wr); -else -return &(__dw_regs (dw)->ch[ch].rd); +u32 ch_base; + +/* +* For Write, the channel register index starts at +* wr_base(ch_idx) = (2 * ch_idx) * ch_space_sz +* +* For Read channel, +* rd_base(ch_idx) = (2 * ch_idx + 1) * ch_space_sz +*/ + ch_base =2 * ch; +if (dir ==EDMA_DIR_READ ) + ch_base +=1 ; + +return dw->chip->reg_base + (ch_base * dw->chip->ch_space_sz); }#define SET_CH_32 (dw, dir, ch, name, value) \drivers/dma/dw-edma/dw-hdma-v0-debugfs.c +6
-11@@ -13,22 +13,17 @@#include "dw-hdma-v0-regs.h" #include "dw-edma-core.h" -#define REGS_ADDR (dw, name) \ - ({ \ - struct dw_hdma_v0_regs __iomem *__regs = (dw)->chip->reg_base; \ - \ - (void __iomem *)&__regs->name; \ - }) -#define REGS_CH_ADDR (dw, name, _dir, _ch) \ ({ \ - struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + struct dw_hdma_v0_ch_regs __iomem *__ch_regs; \ + off_t __off = (dw)->chip->ch_space_sz; \ \ - if (_dir == EDMA_DIR_READ) \ - __ch_regs = REGS_ADDR(dw, ch[_ch].rd); \ + if ((_dir) == EDMA_DIR_READ) \ + __off *= (2 * (_ch) + 1); \ else \ - __ch_regs = REGS_ADDR(dw, ch[_ch].wr); \ + __off *= (2 * (_ch)); \ \ + __ch_regs = ((dw)->chip->reg_base + __off); \ (void __iomem *)&__ch_regs->name; \ })drivers/dma/dw-edma/dw-hdma-v0-regs.h +0
-10@@ -84,16 +84,6 @@ struct dw_hdma_v0_ch_regs { }; } msi_abort;u32 msi_msgdata;/* 0x00a8 */ -u32 padding_2[21 ];/* 0x00ac..0x00fc */ -} __packed; - -struct dw_hdma_v0_ch { -struct dw_hdma_v0_ch_regs wr;/* 0x0000 */ -struct dw_hdma_v0_ch_regs rd;/* 0x0100 */ -} __packed; - -struct dw_hdma_v0_regs { -struct dw_hdma_v0_ch ch[HDMA_V0_MAX_NR_CH ];/* 0x0000..0x0fa8 */ } __packed;struct dw_hdma_v0_lli {drivers/pci/controller/dwc/pcie-designware.c +1
-0@@ -1049,6 +1049,7 @@ static void dw_pcie_edma_init_data(struct dw_pcie *pci) pci->edma.ops = &dw_pcie_edma_ops; pci->edma.flags |=DW_EDMA_CHIP_LOCAL ; + pci->edma.ch_space_sz =256 ; }static int dw_pcie_edma_find_mf (struct dw_pcie *pci)include/linux/dma/edma.h +1
-1@@ -104,6 +104,7 @@ struct dw_edma_chip {struct dw_edma *dw;bool cfg_non_ll; +u32 ch_space_sz; };/* Export to the platform drivers */ --2.43.0