diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-07 18:41:59 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-14 17:10:48 -0400 |
commit | 8e85973efc87dfae8508f1a3440fd44612897458 (patch) | |
tree | 9b8f0f0d1adf5a2611b58565db4d9da0ebd1cc9c /drivers/firewire/ohci.c | |
parent | e21fcf798e246202d7b60e864f1d7302ebaaf41c (diff) |
firewire: optimize config ROM creation
The config ROM image of the local node was created in CPU byte order,
then a temporary big endian copy was created to compute the CRC, and
finally the card driver created its own big endian copy.
We now generate it in big endian byte order in the first place to avoid
one byte order conversion and the temporary on-stack copy of the ROM
image (1000 bytes stack usage in process context). Furthermore, two
1000 bytes memset()s are replaced by one 1000 bytes - ROM length sized
memset.
The trivial fw_memcpy_{from,to}_be32() helpers are now superfluous and
removed. The newly added __compute_block_crc() function will be folded
into fw_compute_block_crc() in a subsequent change.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/ohci.c')
-rw-r--r-- | drivers/firewire/ohci.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 5d524254499e..418415564791 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -205,7 +205,7 @@ struct fw_ohci { | |||
205 | dma_addr_t config_rom_bus; | 205 | dma_addr_t config_rom_bus; |
206 | __be32 *next_config_rom; | 206 | __be32 *next_config_rom; |
207 | dma_addr_t next_config_rom_bus; | 207 | dma_addr_t next_config_rom_bus; |
208 | u32 next_header; | 208 | __be32 next_header; |
209 | 209 | ||
210 | struct ar_context ar_request_ctx; | 210 | struct ar_context ar_request_ctx; |
211 | struct ar_context ar_response_ctx; | 211 | struct ar_context ar_response_ctx; |
@@ -1355,8 +1355,9 @@ static void bus_reset_tasklet(unsigned long data) | |||
1355 | */ | 1355 | */ |
1356 | reg_write(ohci, OHCI1394_BusOptions, | 1356 | reg_write(ohci, OHCI1394_BusOptions, |
1357 | be32_to_cpu(ohci->config_rom[2])); | 1357 | be32_to_cpu(ohci->config_rom[2])); |
1358 | ohci->config_rom[0] = cpu_to_be32(ohci->next_header); | 1358 | ohci->config_rom[0] = ohci->next_header; |
1359 | reg_write(ohci, OHCI1394_ConfigROMhdr, ohci->next_header); | 1359 | reg_write(ohci, OHCI1394_ConfigROMhdr, |
1360 | be32_to_cpu(ohci->next_header)); | ||
1360 | } | 1361 | } |
1361 | 1362 | ||
1362 | #ifdef CONFIG_FIREWIRE_OHCI_REMOTE_DMA | 1363 | #ifdef CONFIG_FIREWIRE_OHCI_REMOTE_DMA |
@@ -1464,7 +1465,17 @@ static int software_reset(struct fw_ohci *ohci) | |||
1464 | return -EBUSY; | 1465 | return -EBUSY; |
1465 | } | 1466 | } |
1466 | 1467 | ||
1467 | static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | 1468 | static void copy_config_rom(__be32 *dest, const __be32 *src, size_t length) |
1469 | { | ||
1470 | size_t size = length * 4; | ||
1471 | |||
1472 | memcpy(dest, src, size); | ||
1473 | if (size < CONFIG_ROM_SIZE) | ||
1474 | memset(&dest[length], 0, CONFIG_ROM_SIZE - size); | ||
1475 | } | ||
1476 | |||
1477 | static int ohci_enable(struct fw_card *card, | ||
1478 | const __be32 *config_rom, size_t length) | ||
1468 | { | 1479 | { |
1469 | struct fw_ohci *ohci = fw_ohci(card); | 1480 | struct fw_ohci *ohci = fw_ohci(card); |
1470 | struct pci_dev *dev = to_pci_dev(card->device); | 1481 | struct pci_dev *dev = to_pci_dev(card->device); |
@@ -1565,8 +1576,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | |||
1565 | if (ohci->next_config_rom == NULL) | 1576 | if (ohci->next_config_rom == NULL) |
1566 | return -ENOMEM; | 1577 | return -ENOMEM; |
1567 | 1578 | ||
1568 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); | 1579 | copy_config_rom(ohci->next_config_rom, config_rom, length); |
1569 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); | ||
1570 | } else { | 1580 | } else { |
1571 | /* | 1581 | /* |
1572 | * In the suspend case, config_rom is NULL, which | 1582 | * In the suspend case, config_rom is NULL, which |
@@ -1576,7 +1586,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | |||
1576 | ohci->next_config_rom_bus = ohci->config_rom_bus; | 1586 | ohci->next_config_rom_bus = ohci->config_rom_bus; |
1577 | } | 1587 | } |
1578 | 1588 | ||
1579 | ohci->next_header = be32_to_cpu(ohci->next_config_rom[0]); | 1589 | ohci->next_header = ohci->next_config_rom[0]; |
1580 | ohci->next_config_rom[0] = 0; | 1590 | ohci->next_config_rom[0] = 0; |
1581 | reg_write(ohci, OHCI1394_ConfigROMhdr, 0); | 1591 | reg_write(ohci, OHCI1394_ConfigROMhdr, 0); |
1582 | reg_write(ohci, OHCI1394_BusOptions, | 1592 | reg_write(ohci, OHCI1394_BusOptions, |
@@ -1610,7 +1620,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) | |||
1610 | } | 1620 | } |
1611 | 1621 | ||
1612 | static int ohci_set_config_rom(struct fw_card *card, | 1622 | static int ohci_set_config_rom(struct fw_card *card, |
1613 | u32 *config_rom, size_t length) | 1623 | const __be32 *config_rom, size_t length) |
1614 | { | 1624 | { |
1615 | struct fw_ohci *ohci; | 1625 | struct fw_ohci *ohci; |
1616 | unsigned long flags; | 1626 | unsigned long flags; |
@@ -1659,9 +1669,7 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
1659 | ohci->next_config_rom = next_config_rom; | 1669 | ohci->next_config_rom = next_config_rom; |
1660 | ohci->next_config_rom_bus = next_config_rom_bus; | 1670 | ohci->next_config_rom_bus = next_config_rom_bus; |
1661 | 1671 | ||
1662 | memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); | 1672 | copy_config_rom(ohci->next_config_rom, config_rom, length); |
1663 | fw_memcpy_to_be32(ohci->next_config_rom, config_rom, | ||
1664 | length * 4); | ||
1665 | 1673 | ||
1666 | ohci->next_header = config_rom[0]; | 1674 | ohci->next_header = config_rom[0]; |
1667 | ohci->next_config_rom[0] = 0; | 1675 | ohci->next_config_rom[0] = 0; |