Skip to content

Commit da28947

Browse files
cladischStefan Richter
authored andcommitted
firewire: ohci: avoid separate DMA mapping for small AT payloads
For AT packet payloads of up to eight bytes, we have enough unused space in the DMA descriptors list so that we can put a copy of the payload there and thus avoid having to create a separate streaming DMA mapping for the payload buffer. In a CPU-bound microbenchmark that just sends 8-byte packets, bandwidth was measured to increase by 5.7 %, from 1009 KB/s to 1067 KB/s. In practice, the only performance-sensitive usage of small asynchronous packets is the SBP-2 driver's write to the ORB_POINTER register during SCSI command submission. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent ecf8328 commit da28947

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎drivers/firewire/ohci.c‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ static void context_stop(struct context *ctx)
12181218
}
12191219

12201220
struct driver_data {
1221+
u8 inline_data[8];
12211222
struct fw_packet *packet;
12221223
};
12231224

@@ -1301,20 +1302,28 @@ static int at_context_queue_packet(struct context *ctx,
13011302
return -1;
13021303
}
13031304

1305+
BUILD_BUG_ON(sizeof(struct driver_data) > sizeof(struct descriptor));
13041306
driver_data = (struct driver_data *) &d[3];
13051307
driver_data->packet = packet;
13061308
packet->driver_data = driver_data;
13071309

13081310
if (packet->payload_length > 0) {
1309-
payload_bus =
1310-
dma_map_single(ohci->card.device, packet->payload,
1311-
packet->payload_length, DMA_TO_DEVICE);
1312-
if (dma_mapping_error(ohci->card.device, payload_bus)) {
1313-
packet->ack = RCODE_SEND_ERROR;
1314-
return -1;
1311+
if (packet->payload_length > sizeof(driver_data->inline_data)) {
1312+
payload_bus = dma_map_single(ohci->card.device,
1313+
packet->payload,
1314+
packet->payload_length,
1315+
DMA_TO_DEVICE);
1316+
if (dma_mapping_error(ohci->card.device, payload_bus)) {
1317+
packet->ack = RCODE_SEND_ERROR;
1318+
return -1;
1319+
}
1320+
packet->payload_bus = payload_bus;
1321+
packet->payload_mapped = true;
1322+
} else {
1323+
memcpy(driver_data->inline_data, packet->payload,
1324+
packet->payload_length);
1325+
payload_bus = d_bus + 3 * sizeof(*d);
13151326
}
1316-
packet->payload_bus = payload_bus;
1317-
packet->payload_mapped = true;
13181327

13191328
d[2].req_count = cpu_to_le16(packet->payload_length);
13201329
d[2].data_address = cpu_to_le32(payload_bus);

0 commit comments

Comments
 (0)