aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2023-06-04 14:44:51 +0900
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>2023-06-06 07:54:24 +0900
commit5716e58aecdd4f7225c2e46ce903a839fc54f22f (patch)
tree02ddb309dd133043a3b4cbcf897a2a8e852c9db3 /drivers/firewire
parentaeaf6aa8647182892f6bd63c5ae9faf4e73cbad0 (diff)
downloadlinux-5716e58aecdd4f7225c2e46ce903a839fc54f22f.tar.gz
firewire: ohci: release buffer for AR req/resp contexts when managed resource is released
The 1394 OHCI driver allocates several non-coherent DMA buffers for AR request and response contexts. The buffers are mapped to kernel virtual address (VMA) so that the first page locates after the last page. Even when large payload of packet is handled crossing the boundary of buffers, the driver operates continuously on VMA. No kernel API is provided for this kind of mapping, while it is possible to release the buffer when PCI device is going to be released. This commit moves the call of release helper function to the callback function of release resources. Link: https://lore.kernel.org/r/20230604054451.161076-10-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/ohci.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 298667963538e2..7e88fd4897414b 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -677,6 +677,9 @@ static void ar_context_release(struct ar_context *ctx)
struct device *dev = ctx->ohci->card.device;
unsigned int i;
+ if (!ctx->buffer)
+ return;
+
vunmap(ctx->buffer);
for (i = 0; i < AR_BUFFERS; i++) {
@@ -3556,9 +3559,13 @@ static inline void pmac_ohci_off(struct pci_dev *dev) {}
static void release_ohci(struct device *dev, void *data)
{
struct pci_dev *pdev = to_pci_dev(dev);
+ struct fw_ohci *ohci = pci_get_drvdata(pdev);
pmac_ohci_off(pdev);
+ ar_context_release(&ohci->ar_response_ctx);
+ ar_context_release(&ohci->ar_request_ctx);
+
dev_notice(dev, "removed fw-ohci device\n");
}
@@ -3643,17 +3650,17 @@ static int pci_probe(struct pci_dev *dev,
err = ar_context_init(&ohci->ar_response_ctx, ohci, PAGE_SIZE/4,
OHCI1394_AsRspRcvContextControlSet);
if (err < 0)
- goto fail_arreq_ctx;
+ return err;
err = context_init(&ohci->at_request_ctx, ohci,
OHCI1394_AsReqTrContextControlSet, handle_at_packet);
if (err < 0)
- goto fail_arrsp_ctx;
+ return err;
err = context_init(&ohci->at_response_ctx, ohci,
OHCI1394_AsRspTrContextControlSet, handle_at_packet);
if (err < 0)
- goto fail_arrsp_ctx;
+ return err;
reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0);
ohci->ir_context_channels = ~0ULL;
@@ -3663,10 +3670,8 @@ static int pci_probe(struct pci_dev *dev,
ohci->n_ir = hweight32(ohci->ir_context_mask);
size = sizeof(struct iso_context) * ohci->n_ir;
ohci->ir_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
- if (!ohci->ir_context_list) {
- err = -ENOMEM;
- goto fail_arrsp_ctx;
- }
+ if (!ohci->ir_context_list)
+ return -ENOMEM;
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0);
ohci->it_context_support = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet);
@@ -3680,10 +3685,8 @@ static int pci_probe(struct pci_dev *dev,
ohci->n_it = hweight32(ohci->it_context_mask);
size = sizeof(struct iso_context) * ohci->n_it;
ohci->it_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
- if (!ohci->it_context_list) {
- err = -ENOMEM;
- goto fail_arrsp_ctx;
- }
+ if (!ohci->it_context_list)
+ return -ENOMEM;
ohci->self_id = ohci->misc_buffer + PAGE_SIZE/2;
ohci->self_id_bus = ohci->misc_buffer_bus + PAGE_SIZE/2;
@@ -3720,10 +3723,6 @@ static int pci_probe(struct pci_dev *dev,
fail_msi:
pci_disable_msi(dev);
- fail_arrsp_ctx:
- ar_context_release(&ohci->ar_response_ctx);
- fail_arreq_ctx:
- ar_context_release(&ohci->ar_request_ctx);
return err;
}
@@ -3750,8 +3749,6 @@ static void pci_remove(struct pci_dev *dev)
software_reset(ohci);
- ar_context_release(&ohci->ar_request_ctx);
- ar_context_release(&ohci->ar_response_ctx);
pci_disable_msi(dev);
dev_notice(&dev->dev, "removing fw-ohci device\n");