mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
dma: dw-edma: Fix build warning in dw_edma_pcie_probe()
The function dw_edma_pcie_probe() in dw-edma-pcie.c triggered a frame size warning: ld.lld⚠️ drivers/dma/dw-edma/dw-edma-pcie.c:162:0: stack frame size (1040) exceeds limit (1024) in function 'dw_edma_pcie_probe' This patch reduces the stack usage by dynamically allocating the `vsec_data` structure using kmalloc(), rather than placing it on the stack. This eliminates the overflow warning and improves kernel robustness. Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com> Acked-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://lore.kernel.org/r/20250705160055.808165-1-abinashsinghlalotra@gmail.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
188c6ba1dd
commit
3df63fa8f2
|
@ -161,12 +161,16 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
const struct pci_device_id *pid)
|
const struct pci_device_id *pid)
|
||||||
{
|
{
|
||||||
struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;
|
struct dw_edma_pcie_data *pdata = (void *)pid->driver_data;
|
||||||
struct dw_edma_pcie_data vsec_data;
|
struct dw_edma_pcie_data *vsec_data __free(kfree) = NULL;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct dw_edma_chip *chip;
|
struct dw_edma_chip *chip;
|
||||||
int err, nr_irqs;
|
int err, nr_irqs;
|
||||||
int i, mask;
|
int i, mask;
|
||||||
|
|
||||||
|
vsec_data = kmalloc(sizeof(*vsec_data), GFP_KERNEL);
|
||||||
|
if (!vsec_data)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Enable PCI device */
|
/* Enable PCI device */
|
||||||
err = pcim_enable_device(pdev);
|
err = pcim_enable_device(pdev);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -174,23 +178,23 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&vsec_data, pdata, sizeof(struct dw_edma_pcie_data));
|
memcpy(vsec_data, pdata, sizeof(struct dw_edma_pcie_data));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tries to find if exists a PCIe Vendor-Specific Extended Capability
|
* Tries to find if exists a PCIe Vendor-Specific Extended Capability
|
||||||
* for the DMA, if one exists, then reconfigures it.
|
* for the DMA, if one exists, then reconfigures it.
|
||||||
*/
|
*/
|
||||||
dw_edma_pcie_get_vsec_dma_data(pdev, &vsec_data);
|
dw_edma_pcie_get_vsec_dma_data(pdev, vsec_data);
|
||||||
|
|
||||||
/* Mapping PCI BAR regions */
|
/* Mapping PCI BAR regions */
|
||||||
mask = BIT(vsec_data.rg.bar);
|
mask = BIT(vsec_data->rg.bar);
|
||||||
for (i = 0; i < vsec_data.wr_ch_cnt; i++) {
|
for (i = 0; i < vsec_data->wr_ch_cnt; i++) {
|
||||||
mask |= BIT(vsec_data.ll_wr[i].bar);
|
mask |= BIT(vsec_data->ll_wr[i].bar);
|
||||||
mask |= BIT(vsec_data.dt_wr[i].bar);
|
mask |= BIT(vsec_data->dt_wr[i].bar);
|
||||||
}
|
}
|
||||||
for (i = 0; i < vsec_data.rd_ch_cnt; i++) {
|
for (i = 0; i < vsec_data->rd_ch_cnt; i++) {
|
||||||
mask |= BIT(vsec_data.ll_rd[i].bar);
|
mask |= BIT(vsec_data->ll_rd[i].bar);
|
||||||
mask |= BIT(vsec_data.dt_rd[i].bar);
|
mask |= BIT(vsec_data->dt_rd[i].bar);
|
||||||
}
|
}
|
||||||
err = pcim_iomap_regions(pdev, mask, pci_name(pdev));
|
err = pcim_iomap_regions(pdev, mask, pci_name(pdev));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -213,7 +217,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* IRQs allocation */
|
/* IRQs allocation */
|
||||||
nr_irqs = pci_alloc_irq_vectors(pdev, 1, vsec_data.irqs,
|
nr_irqs = pci_alloc_irq_vectors(pdev, 1, vsec_data->irqs,
|
||||||
PCI_IRQ_MSI | PCI_IRQ_MSIX);
|
PCI_IRQ_MSI | PCI_IRQ_MSIX);
|
||||||
if (nr_irqs < 1) {
|
if (nr_irqs < 1) {
|
||||||
pci_err(pdev, "fail to alloc IRQ vector (number of IRQs=%u)\n",
|
pci_err(pdev, "fail to alloc IRQ vector (number of IRQs=%u)\n",
|
||||||
|
@ -224,22 +228,22 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
/* Data structure initialization */
|
/* Data structure initialization */
|
||||||
chip->dev = dev;
|
chip->dev = dev;
|
||||||
|
|
||||||
chip->mf = vsec_data.mf;
|
chip->mf = vsec_data->mf;
|
||||||
chip->nr_irqs = nr_irqs;
|
chip->nr_irqs = nr_irqs;
|
||||||
chip->ops = &dw_edma_pcie_plat_ops;
|
chip->ops = &dw_edma_pcie_plat_ops;
|
||||||
|
|
||||||
chip->ll_wr_cnt = vsec_data.wr_ch_cnt;
|
chip->ll_wr_cnt = vsec_data->wr_ch_cnt;
|
||||||
chip->ll_rd_cnt = vsec_data.rd_ch_cnt;
|
chip->ll_rd_cnt = vsec_data->rd_ch_cnt;
|
||||||
|
|
||||||
chip->reg_base = pcim_iomap_table(pdev)[vsec_data.rg.bar];
|
chip->reg_base = pcim_iomap_table(pdev)[vsec_data->rg.bar];
|
||||||
if (!chip->reg_base)
|
if (!chip->reg_base)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0; i < chip->ll_wr_cnt; i++) {
|
for (i = 0; i < chip->ll_wr_cnt; i++) {
|
||||||
struct dw_edma_region *ll_region = &chip->ll_region_wr[i];
|
struct dw_edma_region *ll_region = &chip->ll_region_wr[i];
|
||||||
struct dw_edma_region *dt_region = &chip->dt_region_wr[i];
|
struct dw_edma_region *dt_region = &chip->dt_region_wr[i];
|
||||||
struct dw_edma_block *ll_block = &vsec_data.ll_wr[i];
|
struct dw_edma_block *ll_block = &vsec_data->ll_wr[i];
|
||||||
struct dw_edma_block *dt_block = &vsec_data.dt_wr[i];
|
struct dw_edma_block *dt_block = &vsec_data->dt_wr[i];
|
||||||
|
|
||||||
ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar];
|
ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar];
|
||||||
if (!ll_region->vaddr.io)
|
if (!ll_region->vaddr.io)
|
||||||
|
@ -263,8 +267,8 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
for (i = 0; i < chip->ll_rd_cnt; i++) {
|
for (i = 0; i < chip->ll_rd_cnt; i++) {
|
||||||
struct dw_edma_region *ll_region = &chip->ll_region_rd[i];
|
struct dw_edma_region *ll_region = &chip->ll_region_rd[i];
|
||||||
struct dw_edma_region *dt_region = &chip->dt_region_rd[i];
|
struct dw_edma_region *dt_region = &chip->dt_region_rd[i];
|
||||||
struct dw_edma_block *ll_block = &vsec_data.ll_rd[i];
|
struct dw_edma_block *ll_block = &vsec_data->ll_rd[i];
|
||||||
struct dw_edma_block *dt_block = &vsec_data.dt_rd[i];
|
struct dw_edma_block *dt_block = &vsec_data->dt_rd[i];
|
||||||
|
|
||||||
ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar];
|
ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar];
|
||||||
if (!ll_region->vaddr.io)
|
if (!ll_region->vaddr.io)
|
||||||
|
@ -298,31 +302,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
|
||||||
pci_dbg(pdev, "Version:\tUnknown (0x%x)\n", chip->mf);
|
pci_dbg(pdev, "Version:\tUnknown (0x%x)\n", chip->mf);
|
||||||
|
|
||||||
pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p)\n",
|
pci_dbg(pdev, "Registers:\tBAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p)\n",
|
||||||
vsec_data.rg.bar, vsec_data.rg.off, vsec_data.rg.sz,
|
vsec_data->rg.bar, vsec_data->rg.off, vsec_data->rg.sz,
|
||||||
chip->reg_base);
|
chip->reg_base);
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < chip->ll_wr_cnt; i++) {
|
for (i = 0; i < chip->ll_wr_cnt; i++) {
|
||||||
pci_dbg(pdev, "L. List:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
pci_dbg(pdev, "L. List:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
||||||
i, vsec_data.ll_wr[i].bar,
|
i, vsec_data->ll_wr[i].bar,
|
||||||
vsec_data.ll_wr[i].off, chip->ll_region_wr[i].sz,
|
vsec_data->ll_wr[i].off, chip->ll_region_wr[i].sz,
|
||||||
chip->ll_region_wr[i].vaddr.io, &chip->ll_region_wr[i].paddr);
|
chip->ll_region_wr[i].vaddr.io, &chip->ll_region_wr[i].paddr);
|
||||||
|
|
||||||
pci_dbg(pdev, "Data:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
pci_dbg(pdev, "Data:\tWRITE CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
||||||
i, vsec_data.dt_wr[i].bar,
|
i, vsec_data->dt_wr[i].bar,
|
||||||
vsec_data.dt_wr[i].off, chip->dt_region_wr[i].sz,
|
vsec_data->dt_wr[i].off, chip->dt_region_wr[i].sz,
|
||||||
chip->dt_region_wr[i].vaddr.io, &chip->dt_region_wr[i].paddr);
|
chip->dt_region_wr[i].vaddr.io, &chip->dt_region_wr[i].paddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < chip->ll_rd_cnt; i++) {
|
for (i = 0; i < chip->ll_rd_cnt; i++) {
|
||||||
pci_dbg(pdev, "L. List:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
pci_dbg(pdev, "L. List:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
||||||
i, vsec_data.ll_rd[i].bar,
|
i, vsec_data->ll_rd[i].bar,
|
||||||
vsec_data.ll_rd[i].off, chip->ll_region_rd[i].sz,
|
vsec_data->ll_rd[i].off, chip->ll_region_rd[i].sz,
|
||||||
chip->ll_region_rd[i].vaddr.io, &chip->ll_region_rd[i].paddr);
|
chip->ll_region_rd[i].vaddr.io, &chip->ll_region_rd[i].paddr);
|
||||||
|
|
||||||
pci_dbg(pdev, "Data:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
pci_dbg(pdev, "Data:\tREAD CH%.2u, BAR=%u, off=0x%.8lx, sz=0x%zx bytes, addr(v=%p, p=%pa)\n",
|
||||||
i, vsec_data.dt_rd[i].bar,
|
i, vsec_data->dt_rd[i].bar,
|
||||||
vsec_data.dt_rd[i].off, chip->dt_region_rd[i].sz,
|
vsec_data->dt_rd[i].off, chip->dt_region_rd[i].sz,
|
||||||
chip->dt_region_rd[i].vaddr.io, &chip->dt_region_rd[i].paddr);
|
chip->dt_region_rd[i].vaddr.io, &chip->dt_region_rd[i].paddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user