FAILED: patch "[PATCH] dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 8ffba0171c6bbce5f093c6dba5a02c0805b31203
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072058-sadly-hatchery-b25e@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8ffba0171c6bbce5f093c6dba5a02c0805b31203 Mon Sep 17 00:00:00 2001
From: Frank Li <[email protected]>
Date: Thu, 21 May 2026 23:21:53 +0900
Subject: [PATCH] dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and
ABORT_INT_MASK
The DONE_INT_MASK and ABORT_INT_MASK registers are shared by all DMA channels, and modifying them requires a read-modify-write sequence. Because this operation is not atomic, concurrent calls to dw_edma_v0_core_start() can introduce race conditions if two channels update these registers simultaneously.
Add a spinlock to serialize access to these registers and prevent race conditions.
drivers/dma/dw-edma/dw-edma-core.h +1 -1
@@ -109,7 +109,7 @@ struct dw_edma {struct dw_edma_chan *chan; -raw_spinlock_t lock;/* Only for legacy */ +raw_spinlock_t lock;/* Protect v0 shared registers */ struct dw_edma_chip *chip;
drivers/dma/dw-edma/dw-edma-v0-core.c +6 -0
@@ -364,6 +364,7 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) {struct dw_edma_chan *chan = chunk->chan;struct dw_edma *dw = chan->dw; +unsigned long flags;u32 tmp;dw_edma_v0_core_write_chunk (chunk);
@@ -408,6 +409,8 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) } }/* Interrupt 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));
@@ -416,6 +419,9 @@ static void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) tmp =GET_RW_32 (dw, chan->dir, linked_list_err_en); tmp |=FIELD_PREP (EDMA_V0_LINKED_LIST_ERR_MASK ,BIT (chan->id));SET_RW_32 (dw, chan->dir, linked_list_err_en, tmp); + +raw_spin_unlock_irqrestore (&dw->lock, flags); +/* Channel control */ SET_CH_32 (dw, chan->dir, chan->id, ch_control1, (DW_EDMA_V0_CCS |DW_EDMA_V0_LLE ));
Sasha Levin
maintainerPATCH 1/4 PCI: Add pci_find_vsec_capability() to find a specific VSEC
From: Gustavo Pimentel <[email protected]>
[ Upstream commit c124fd9a969acaa83f6dfa5e160a99a500af9e4b ]
Add pci_find_vsec_capability() to locate a Vendor-Specific Extended Capability with the specified VSEC ID.
The Vendor-Specific Extended Capability (VSEC) allows one or more proprietary capabilities defined by the vendor which aren't standard or shared between vendors.
Stable-dep-of: 8ffba0171c6b ("dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and ABORT_INT_MASK")
--- drivers/pci/pci.c | 30 ++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 31 insertions(+)
drivers/pci/pci.c +30 -0
@@ -690,6 +690,36 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap) }EXPORT_SYMBOL_GPL (pci_find_ht_capability); +/** +* pci_find_vsec_capability - Find a vendor-specific extended capability +* @dev: PCI device to query +* @vendor: Vendor ID for which capability is defined +* @cap: Vendor-specific capability ID +* +* If @dev has Vendor ID @vendor, search for a VSEC capability with +* VSEC ID @cap. If found, return the capability offset in +* config space; otherwise return 0. +*/ +u16 pci_find_vsec_capability (struct pci_dev *dev,u16 vendor,int cap) +{ +u16 vsec =0 ; +u32 header; + +if (vendor != dev->vendor) +return 0 ; + +while ((vsec =pci_find_next_ext_capability (dev, vsec, +PCI_EXT_CAP_ID_VNDR ))) { +if (pci_read_config_dword (dev, vsec +PCI_VNDR_HEADER , + &header) ==PCIBIOS_SUCCESSFUL && +PCI_VNDR_HEADER_ID (header) == cap) +return vsec; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_find_vsec_capability); +/** * pci_find_parent_resource - return resource region of parent bus of given * region
include/linux/pci.h +1 -0
@@ -1101,6 +1101,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);int pci_find_ht_capability (struct pci_dev *dev,int ht_cap);int pci_find_next_ht_capability (struct pci_dev *dev,int pos,int ht_cap);struct pci_bus *pci_find_next_bus (const struct pci_bus *from); +u16 pci_find_vsec_capability (struct pci_dev *dev,u16 vendor,int cap);u64 pci_get_dsn (struct pci_dev *dev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 dmaengine: dw-edma: Improve the linked list and data blocks definition
From: Gustavo Pimentel <[email protected]>
[ Upstream commit 31fb8c1ff962d93ed5025f39a6a186207c9805eb ]
In the previous implementation, the driver assumed that there existed only two memory spaces that would equally distribute the amount of read/write channels.
This might not be the case on some other implementations, therefore this patch change this requirement so that each write/read channel has its own linked list and data space well defined, which allows different sizes and locations.
Stable-dep-of: 8ffba0171c6b ("dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and ABORT_INT_MASK")
--- drivers/dma/dw-edma/dw-edma-core.c | 77 ++++++----- drivers/dma/dw-edma/dw-edma-core.h | 18 ++- drivers/dma/dw-edma/dw-edma-pcie.c | 179 +++++++++++++++++++------- drivers/dma/dw-edma/dw-edma-v0-core.c | 70 +++++----- 4 files changed, 216 insertions(+), 128 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +38 -39
@@ -81,8 +81,13 @@ static struct dw_edma_chunk *dw_edma_alloc_chunk(struct dw_edma_desc *desc)* - Even chunks originate CB equal to 1 */ chunk->cb = !(desc->chunks_alloc %2 ); - chunk->ll_region.paddr = dw->ll_region.paddr + chan->ll_off; - chunk->ll_region.vaddr = dw->ll_region.vaddr + chan->ll_off; +if (chan->dir ==EDMA_DIR_WRITE ) { + chunk->ll_region.paddr = dw->ll_region_wr[chan->id].paddr; + chunk->ll_region.vaddr = dw->ll_region_wr[chan->id].vaddr; + }else { + chunk->ll_region.paddr = dw->ll_region_rd[chan->id].paddr; + chunk->ll_region.vaddr = dw->ll_region_rd[chan->id].vaddr; + }if (desc->chunk) {/* Create and add new element into the linked list */
@@ -669,24 +674,13 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write,struct device *dev = chip->dev;struct dw_edma *dw = chip->dw;struct dw_edma_chan *chan; -size_t ll_chunk, dt_chunk;struct dw_edma_irq *irq;struct dma_device *dma; -u32 i, j, cnt, ch_cnt;u32 alloc, off_alloc; +u32 i, j, cnt;int err =0 ;u32 pos; - ch_cnt = dw->wr_ch_cnt + dw->rd_ch_cnt; - ll_chunk = dw->ll_region.sz; - dt_chunk = dw->dt_region.sz; - -/* Calculate linked list chunk for each channel */ - ll_chunk /=roundup_pow_of_two (ch_cnt); - -/* Calculate linked list chunk for each channel */ - dt_chunk /=roundup_pow_of_two (ch_cnt); -if (write) { i =0 ; cnt = dw->wr_ch_cnt;
@@ -712,20 +706,21 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, chan->vc.chan.private = dt_region; chan->chip = chip; + chan->dw = dw; chan->id = j; chan->dir = write ?EDMA_DIR_WRITE :EDMA_DIR_READ ; chan->configured = false; chan->request =EDMA_REQ_NONE ; chan->status =EDMA_ST_IDLE ; - chan->ll_off = (ll_chunk * i); - chan->ll_max = (ll_chunk /EDMA_LL_SZ ) -1 ; - - chan->dt_off = (dt_chunk * i); +if (write) + chan->ll_max = (dw->ll_region_wr[j].sz /EDMA_LL_SZ ); +else + chan->ll_max = (dw->ll_region_rd[j].sz /EDMA_LL_SZ ); + chan->ll_max -=1 ; -dev_vdbg (dev,"L. List:\tChannel %s[%u] off=0x%.8lx, max_cnt=%u\n" , - write ?"write" :"read" , j, - chan->ll_off, chan->ll_max); +dev_vdbg (dev,"L. List:\tChannel %s[%u] max_cnt=%u\n" , + write ?"write" :"read" , j, chan->ll_max);if (dw->nr_irqs ==1 ) pos =0 ;
@@ -750,12 +745,15 @@ static int dw_edma_channel_setup(struct dw_edma_chip *chip, bool write, chan->vc.desc_free = vchan_free_desc;vchan_init (&chan->vc, dma); - dt_region->paddr = dw->dt_region.paddr + chan->dt_off; - dt_region->vaddr = dw->dt_region.vaddr + chan->dt_off; - dt_region->sz = dt_chunk; - -dev_vdbg (dev,"Data:\tChannel %s[%u] off=0x%.8lx\n" , - write ?"write" :"read" , j, chan->dt_off); +if (write) { + dt_region->paddr = dw->dt_region_wr[j].paddr; + dt_region->vaddr = dw->dt_region_wr[j].vaddr; + dt_region->sz = dw->dt_region_wr[j].sz; + }else { + dt_region->paddr = dw->dt_region_rd[j].paddr; + dt_region->vaddr = dw->dt_region_rd[j].vaddr; + dt_region->sz = dw->dt_region_rd[j].sz; + }dw_edma_v0_core_device_config (chan); }
@@ -824,7 +822,7 @@ static int dw_edma_irq_request(struct dw_edma_chip *chip,if (dw->nr_irqs ==1 ) {/* Common IRQ shared among all channels */ - irq = dw->ops->irq_vector (dev,0 ); + irq = dw->core->irq_vector (dev,0 ); err =request_irq (irq, dw_edma_interrupt_common,IRQF_SHARED , dw->name, &dw->irq[0 ]);if (err) {
@@ -847,7 +845,7 @@ static int dw_edma_irq_request(struct dw_edma_chip *chip,dw_edma_add_irq_mask (&rd_mask, *rd_alloc, dw->rd_ch_cnt);for (i =0 ; i < (*wr_alloc + *rd_alloc); i++) { - irq = dw->ops->irq_vector (dev, i); + irq = dw->core->irq_vector (dev, i); err = request_irq(irq, i < *wr_alloc ? dw_edma_interrupt_write :
@@ -885,19 +883,20 @@ int dw_edma_probe(struct dw_edma_chip *chip)return -EINVAL ; dw = chip->dw; -if (!dw || !dw->irq || !dw->ops || !dw->ops->irq_vector) +if (!dw || !dw->irq || !dw->core || !dw->core->irq_vector)return -EINVAL ;raw_spin_lock_init (&dw->lock); -/* Find out how many write channels are supported by hardware */ - dw->wr_ch_cnt =dw_edma_v0_core_ch_count (dw,EDMA_DIR_WRITE ); -if (!dw->wr_ch_cnt) -return -EINVAL ; + dw->wr_ch_cnt =min_t (u16, dw->wr_ch_cnt, +dw_edma_v0_core_ch_count (dw,EDMA_DIR_WRITE )); + dw->wr_ch_cnt =min_t (u16, dw->wr_ch_cnt,EDMA_MAX_WR_CH ); + + dw->rd_ch_cnt =min_t (u16, dw->rd_ch_cnt, +dw_edma_v0_core_ch_count (dw,EDMA_DIR_READ )); + dw->rd_ch_cnt =min_t (u16, dw->rd_ch_cnt,EDMA_MAX_RD_CH ); -/* Find out how many read channels are supported by hardware */ - dw->rd_ch_cnt =dw_edma_v0_core_ch_count (dw,EDMA_DIR_READ ); -if (!dw->rd_ch_cnt) +if (!dw->wr_ch_cnt && !dw->rd_ch_cnt)return -EINVAL ; dev_vdbg(dev, "Channels:\twrite=%d, read=%d\n",
@@ -939,7 +938,7 @@ int dw_edma_probe(struct dw_edma_chip *chip) err_irq_free:for (i = (dw->nr_irqs -1 ); i >=0 ; i--) -free_irq (dw->ops->irq_vector (dev, i), &dw->irq[i]); +free_irq (dw->core->irq_vector (dev, i), &dw->irq[i]); dw->nr_irqs =0 ;
@@ -959,7 +958,7 @@ int dw_edma_remove(struct dw_edma_chip *chip)/* Free irqs */ for (i = (dw->nr_irqs -1 ); i >=0 ; i--) -free_irq (dw->ops->irq_vector (dev, i), &dw->irq[i]); +free_irq (dw->core->irq_vector (dev, i), &dw->irq[i]);/* Power management */ pm_runtime_disable (dev);
drivers/dma/dw-edma/dw-edma-core.h +12 -6
@@ -15,6 +15,8 @@#include "../virt-dma.h" #define EDMA_LL_SZ 24 +#define EDMA_MAX_WR_CH 8 +#define EDMA_MAX_RD_CH 8enum dw_edma_dir {EDMA_DIR_WRITE =0 ,
@@ -40,6 +42,7 @@ enum dw_edma_status {struct dw_edma_chan ;struct dw_edma_chunk ; +struct dw_edma ;struct dw_edma_burst {struct list_head list;
@@ -79,14 +82,12 @@ struct dw_edma_desc {struct dw_edma_chan {struct virt_dma_chan vc;struct dw_edma_chip *chip; +struct dw_edma *dw;int id;enum dw_edma_dir dir; -off_t ll_off;u32 ll_max; -off_t dt_off; -struct msi_msg msi;enum dw_edma_request request;
@@ -117,8 +118,10 @@ struct dw_edma {u16 rd_ch_cnt;struct dw_edma_region rg_region;/* Registers */ -struct dw_edma_region ll_region;/* Linked list */ -struct dw_edma_region dt_region;/* Data */ +struct dw_edma_region ll_region_wr[EDMA_MAX_WR_CH ]; +struct dw_edma_region ll_region_rd[EDMA_MAX_RD_CH ]; +struct dw_edma_region dt_region_wr[EDMA_MAX_WR_CH ]; +struct dw_edma_region dt_region_rd[EDMA_MAX_RD_CH ];struct dw_edma_irq *irq;int nr_irqs;
@@ -127,9 +130,12 @@ struct dw_edma {enum dw_edma_mode mode;struct dw_edma_chan *chan; -const struct dw_edma_core_ops *ops;raw_spinlock_t lock;/* Only for legacy */ + +struct dw_edma_chip *chip; + +const struct dw_edma_core_ops *core; };struct dw_edma_sg {
drivers/dma/dw-edma/dw-edma-pcie.c +131 -48
233 lines not on this page · raw message
drivers/dma/dw-edma/dw-edma-v0-core.c +35 -35
170 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 dmaengine: dw-edma: Remove unused irq field in struct dw_edma_chip
In reply to Sasha LevinFrom: Frank Li <[email protected]>
[ Upstream commit 5a0e4529d9aee8ce348f628ad476c9ddb6cf457d ]
The "irq" field of struct dw_edma_chip was never used. Remove it.
Stable-dep-of: 8ffba0171c6b ("dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and ABORT_INT_MASK")
--- drivers/dma/dw-edma/dw-edma-pcie.c | 1 - include/linux/dma/edma.h | 2 -- 2 files changed, 3 deletions(-)
drivers/dma/dw-edma/dw-edma-pcie.c +0 -1
@@ -175,7 +175,6 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev, chip->dw = dw; chip->dev = dev; chip->id = pdev->devfn; - chip->irq = pdev->irq; dw->chip = chip; dw->version = pdata->version;
include/linux/dma/edma.h +0 -2
@@ -18,13 +18,11 @@ struct dw_edma;* struct dw_edma_chip - representation of DesignWare eDMA controller hardware * @dev: struct device of the eDMA controller * @id: instance ID -* @irq: irq line * @dw: struct dw_edma that is filed by dw_edma_probe() */ struct dw_edma_chip {struct device *dev;int id; -int irq;struct dw_edma *dw; };
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 dmaengine: dw-edma: Add spinlock to protect DONE_INT_MASK and ABORT_INT_MASK
In reply to Sasha LevinFrom: Frank Li <[email protected]>
[ Upstream commit 8ffba0171c6bbce5f093c6dba5a02c0805b31203 ]
The DONE_INT_MASK and ABORT_INT_MASK registers are shared by all DMA channels, and modifying them requires a read-modify-write sequence. Because this operation is not atomic, concurrent calls to dw_edma_v0_core_start() can introduce race conditions if two channels update these registers simultaneously.
Add a spinlock to serialize access to these registers and prevent race conditions.
--- drivers/dma/dw-edma/dw-edma-core.h | 2 +- drivers/dma/dw-edma/dw-edma-v0-core.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-core.h +1 -1
@@ -131,7 +131,7 @@ struct dw_edma {struct dw_edma_chan *chan; -raw_spinlock_t lock;/* Only for legacy */ +raw_spinlock_t lock;/* Protect v0 shared registers */ struct dw_edma_chip *chip;
drivers/dma/dw-edma/dw-edma-v0-core.c +6 -0
@@ -237,6 +237,7 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) {struct dw_edma_chan *chan = chunk->chan;struct dw_edma *dw = chan->dw; +unsigned long flags;u32 tmp;dw_edma_v0_core_write_chunk (chunk);
@@ -245,6 +246,8 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first)/* Enable engine */ SET_RW_32 (dw, chan->dir, engine_en,BIT (0 ));/* Interrupt 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));
@@ -253,6 +256,9 @@ void dw_edma_v0_core_start(struct dw_edma_chunk *chunk, bool first) tmp =GET_RW_32 (dw, chan->dir, linked_list_err_en); tmp |=FIELD_PREP (EDMA_V0_LINKED_LIST_ERR_MASK ,BIT (chan->id));SET_RW_32 (dw, chan->dir, linked_list_err_en, tmp); + +raw_spin_unlock_irqrestore (&dw->lock, flags); +/* Channel control */ SET_CH_32 (dw, chan->dir, chan->id, ch_control1, (DW_EDMA_V0_CCS |DW_EDMA_V0_LLE ));
Signature · 1 line
2.53.0