mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
serial: 8250_lpss: Balance reference count for PCI DMA device
The pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put(). Fixes:9a1870ce81
("serial: 8250: don't use slave_id of dma_slave_config") Depends-on:a13e19cf3d
("serial: 8250_lpss: split LPSS driver to separate module") Reported-by: Qing Wang <wangqing@vivo.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220223151240.70248-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
67ec6dd0b2
commit
5318f70da7
1 changed files with 22 additions and 6 deletions
|
@ -117,8 +117,7 @@ static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
|
|||
{
|
||||
struct dw_dma_slave *param = &lpss->dma_param;
|
||||
struct pci_dev *pdev = to_pci_dev(port->dev);
|
||||
unsigned int dma_devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0);
|
||||
struct pci_dev *dma_dev = pci_get_slot(pdev->bus, dma_devfn);
|
||||
struct pci_dev *dma_dev;
|
||||
|
||||
switch (pdev->device) {
|
||||
case PCI_DEVICE_ID_INTEL_BYT_UART1:
|
||||
|
@ -137,6 +136,8 @@ static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 0));
|
||||
|
||||
param->dma_dev = &dma_dev->dev;
|
||||
param->m_master = 0;
|
||||
param->p_master = 1;
|
||||
|
@ -152,6 +153,14 @@ static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void byt_serial_exit(struct lpss8250 *lpss)
|
||||
{
|
||||
struct dw_dma_slave *param = &lpss->dma_param;
|
||||
|
||||
/* Paired with pci_get_slot() in the byt_serial_setup() above */
|
||||
put_device(param->dma_dev);
|
||||
}
|
||||
|
||||
static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
|
||||
{
|
||||
struct uart_8250_dma *dma = &lpss->data.dma;
|
||||
|
@ -170,6 +179,13 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void ehl_serial_exit(struct lpss8250 *lpss)
|
||||
{
|
||||
struct uart_8250_port *up = serial8250_get_port(lpss->data.line);
|
||||
|
||||
up->dma = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SERIAL_8250_DMA
|
||||
static const struct dw_dma_platform_data qrk_serial_dma_pdata = {
|
||||
.nr_channels = 2,
|
||||
|
@ -344,8 +360,7 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
return 0;
|
||||
|
||||
err_exit:
|
||||
if (lpss->board->exit)
|
||||
lpss->board->exit(lpss);
|
||||
lpss->board->exit(lpss);
|
||||
pci_free_irq_vectors(pdev);
|
||||
return ret;
|
||||
}
|
||||
|
@ -356,8 +371,7 @@ static void lpss8250_remove(struct pci_dev *pdev)
|
|||
|
||||
serial8250_unregister_port(lpss->data.line);
|
||||
|
||||
if (lpss->board->exit)
|
||||
lpss->board->exit(lpss);
|
||||
lpss->board->exit(lpss);
|
||||
pci_free_irq_vectors(pdev);
|
||||
}
|
||||
|
||||
|
@ -365,12 +379,14 @@ static const struct lpss8250_board byt_board = {
|
|||
.freq = 100000000,
|
||||
.base_baud = 2764800,
|
||||
.setup = byt_serial_setup,
|
||||
.exit = byt_serial_exit,
|
||||
};
|
||||
|
||||
static const struct lpss8250_board ehl_board = {
|
||||
.freq = 200000000,
|
||||
.base_baud = 12500000,
|
||||
.setup = ehl_serial_setup,
|
||||
.exit = ehl_serial_exit,
|
||||
};
|
||||
|
||||
static const struct lpss8250_board qrk_board = {
|
||||
|
|
Loading…
Reference in a new issue