提交 51c01e55 编写于 作者: A Andy Shevchenko 提交者: Zheng Zengkai

spi: pxa2xx-pci: Balance reference count for PCI DMA device

stable inclusion
from stable-v5.10.110
commit 18a18594ae696abf0e0ec75dccc7d43da78660a6
bugzilla: https://gitee.com/openeuler/kernel/issues/I574AL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=18a18594ae696abf0e0ec75dccc7d43da78660a6

--------------------------------

[ Upstream commit 609d7ffd ]

The pci_get_slot() increases its reference count, the caller
must decrement the reference count by calling pci_dev_put().

Fixes: 743485ea ("spi: pxa2xx-pci: Do a specific setup in a separate function")
Fixes: 25014521 ("spi: pxa2xx-pci: Enable DMA for Intel Merrifield")
Reported-by: NWang Qing <wangqing@vivo.com>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220223191637.31147-1-andriy.shevchenko@linux.intel.comSigned-off-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e81e9c25
...@@ -74,14 +74,23 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param) ...@@ -74,14 +74,23 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param)
return true; return true;
} }
static void lpss_dma_put_device(void *dma_dev)
{
pci_dev_put(dma_dev);
}
static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
{ {
struct pci_dev *dma_dev; struct pci_dev *dma_dev;
int ret;
c->num_chipselect = 1; c->num_chipselect = 1;
c->max_clk_rate = 50000000; c->max_clk_rate = 50000000;
dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
if (ret)
return ret;
if (c->tx_param) { if (c->tx_param) {
struct dw_dma_slave *slave = c->tx_param; struct dw_dma_slave *slave = c->tx_param;
...@@ -105,8 +114,9 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) ...@@ -105,8 +114,9 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
{ {
struct pci_dev *dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
struct dw_dma_slave *tx, *rx; struct dw_dma_slave *tx, *rx;
struct pci_dev *dma_dev;
int ret;
switch (PCI_FUNC(dev->devfn)) { switch (PCI_FUNC(dev->devfn)) {
case 0: case 0:
...@@ -131,6 +141,11 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) ...@@ -131,6 +141,11 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
return -ENODEV; return -ENODEV;
} }
dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
if (ret)
return ret;
tx = c->tx_param; tx = c->tx_param;
tx->dma_dev = &dma_dev->dev; tx->dma_dev = &dma_dev->dev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册