diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-12-09 18:20:38 -0500 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-12-10 06:45:34 -0500 |
commit | 1d1dc5e83f3299c108a4e44d58cc4bfef48c876a (patch) | |
tree | 4acec6d605d2c04294afa8d5a7699430c34e8449 | |
parent | ec9a13cdbfc8cf29502096ca69b65f07184a9b2c (diff) |
firewire: fw-ohci: fix IOMMU resource exhaustion
There is a DMA map/ unmap imbalance whenever a block write request
packet is sent and then dequeued with ohci_cancel_packet. The latter
may happen frequently if the AR resp tasklet is executed before the AT
req tasklet for the same transaction.
Add the missing dma_unmap_single. This fixes
https://bugzilla.redhat.com/show_bug.cgi?id=475156
Reported-by: Emmanuel Kowalski
Tested-by: Emmanuel Kowalski
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/firewire/fw-ohci.c | 11 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.c | 3 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.h | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index 46610b090415..ab9c01e462ef 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c | |||
@@ -974,6 +974,7 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet) | |||
974 | packet->ack = RCODE_SEND_ERROR; | 974 | packet->ack = RCODE_SEND_ERROR; |
975 | return -1; | 975 | return -1; |
976 | } | 976 | } |
977 | packet->payload_bus = payload_bus; | ||
977 | 978 | ||
978 | d[2].req_count = cpu_to_le16(packet->payload_length); | 979 | d[2].req_count = cpu_to_le16(packet->payload_length); |
979 | d[2].data_address = cpu_to_le32(payload_bus); | 980 | d[2].data_address = cpu_to_le32(payload_bus); |
@@ -1025,7 +1026,6 @@ static int handle_at_packet(struct context *context, | |||
1025 | struct driver_data *driver_data; | 1026 | struct driver_data *driver_data; |
1026 | struct fw_packet *packet; | 1027 | struct fw_packet *packet; |
1027 | struct fw_ohci *ohci = context->ohci; | 1028 | struct fw_ohci *ohci = context->ohci; |
1028 | dma_addr_t payload_bus; | ||
1029 | int evt; | 1029 | int evt; |
1030 | 1030 | ||
1031 | if (last->transfer_status == 0) | 1031 | if (last->transfer_status == 0) |
@@ -1038,9 +1038,8 @@ static int handle_at_packet(struct context *context, | |||
1038 | /* This packet was cancelled, just continue. */ | 1038 | /* This packet was cancelled, just continue. */ |
1039 | return 1; | 1039 | return 1; |
1040 | 1040 | ||
1041 | payload_bus = le32_to_cpu(last->data_address); | 1041 | if (packet->payload_bus) |
1042 | if (payload_bus != 0) | 1042 | dma_unmap_single(ohci->card.device, packet->payload_bus, |
1043 | dma_unmap_single(ohci->card.device, payload_bus, | ||
1044 | packet->payload_length, DMA_TO_DEVICE); | 1043 | packet->payload_length, DMA_TO_DEVICE); |
1045 | 1044 | ||
1046 | evt = le16_to_cpu(last->transfer_status) & 0x1f; | 1045 | evt = le16_to_cpu(last->transfer_status) & 0x1f; |
@@ -1697,6 +1696,10 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet) | |||
1697 | if (packet->ack != 0) | 1696 | if (packet->ack != 0) |
1698 | goto out; | 1697 | goto out; |
1699 | 1698 | ||
1699 | if (packet->payload_bus) | ||
1700 | dma_unmap_single(ohci->card.device, packet->payload_bus, | ||
1701 | packet->payload_length, DMA_TO_DEVICE); | ||
1702 | |||
1700 | log_ar_at_event('T', packet->speed, packet->header, 0x20); | 1703 | log_ar_at_event('T', packet->speed, packet->header, 0x20); |
1701 | driver_data->packet = NULL; | 1704 | driver_data->packet = NULL; |
1702 | packet->ack = RCODE_CANCELLED; | 1705 | packet->ack = RCODE_CANCELLED; |
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index 022ac4fabb67..2884f876397b 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c | |||
@@ -207,6 +207,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, | |||
207 | packet->speed = speed; | 207 | packet->speed = speed; |
208 | packet->generation = generation; | 208 | packet->generation = generation; |
209 | packet->ack = 0; | 209 | packet->ack = 0; |
210 | packet->payload_bus = 0; | ||
210 | } | 211 | } |
211 | 212 | ||
212 | /** | 213 | /** |
@@ -581,6 +582,8 @@ fw_fill_response(struct fw_packet *response, u32 *request_header, | |||
581 | BUG(); | 582 | BUG(); |
582 | return; | 583 | return; |
583 | } | 584 | } |
585 | |||
586 | response->payload_bus = 0; | ||
584 | } | 587 | } |
585 | EXPORT_SYMBOL(fw_fill_response); | 588 | EXPORT_SYMBOL(fw_fill_response); |
586 | 589 | ||
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index aed7dbb17cda..839466f0a795 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
28 | #include <linux/spinlock_types.h> | 28 | #include <linux/spinlock_types.h> |
29 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
30 | #include <linux/types.h> | ||
30 | #include <linux/workqueue.h> | 31 | #include <linux/workqueue.h> |
31 | 32 | ||
32 | #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) | 33 | #define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) |
@@ -153,6 +154,7 @@ struct fw_packet { | |||
153 | size_t header_length; | 154 | size_t header_length; |
154 | void *payload; | 155 | void *payload; |
155 | size_t payload_length; | 156 | size_t payload_length; |
157 | dma_addr_t payload_bus; | ||
156 | u32 timestamp; | 158 | u32 timestamp; |
157 | 159 | ||
158 | /* | 160 | /* |