diff options
| author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2019-05-09 09:45:19 +0000 |
|---|---|---|
| committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2019-05-09 09:45:19 +0000 |
| commit | eb6f534241c9cc4343a38f78e8eb07bf9eb02da4 (patch) | |
| tree | 2891d7e0a29451399cb9270f0536a260379aa6be /sys/compat/linuxkpi | |
| parent | 50ec8b3b3e9b31cf6c6b1249410c29be97a0ce89 (diff) | |
Notes
Diffstat (limited to 'sys/compat/linuxkpi')
| -rw-r--r-- | sys/compat/linuxkpi/common/src/linux_pci.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index e135298b0b96..6d04e08e20eb 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -89,6 +89,7 @@ static int linux_pdev_dma_init(struct pci_dev *pdev) { struct linux_dma_priv *priv; + int error; priv = malloc(sizeof(*priv), M_DEVBUF, M_WAITOK | M_ZERO); pdev->dev.dma_priv = priv; @@ -97,7 +98,14 @@ linux_pdev_dma_init(struct pci_dev *pdev) pctrie_init(&priv->ptree); - return (0); + /* create a default DMA tag */ + error = linux_dma_tag_init(&pdev->dev, DMA_BIT_MASK(64)); + if (error) { + mtx_destroy(&priv->lock); + free(priv, M_DEVBUF); + pdev->dev.dma_priv = NULL; + } + return (error); } static int @@ -241,7 +249,7 @@ linux_pci_attach(device_t dev) pdev->irq = pdev->dev.irq; error = linux_pdev_dma_init(pdev); if (error) - goto out; + goto out_dma_init; if (pdev->bus == NULL) { pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -255,15 +263,18 @@ linux_pci_attach(device_t dev) spin_unlock(&pci_lock); error = pdrv->probe(pdev, id); -out: - if (error) { - spin_lock(&pci_lock); - list_del(&pdev->links); - spin_unlock(&pci_lock); - put_device(&pdev->dev); - error = -error; - } - return (error); + if (error) + goto out_probe; + return (0); + +out_probe: + linux_pdev_dma_uninit(pdev); +out_dma_init: + spin_lock(&pci_lock); + list_del(&pdev->links); + spin_unlock(&pci_lock); + put_device(&pdev->dev); + return (-error); } static int |
