diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-07 18:42:53 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-14 17:10:48 -0400 |
commit | cb7c96da3651111efbe088fa12f9bed61836ea93 (patch) | |
tree | d31d9ba7e321206cd5b32753f444aabc2c76efeb /drivers/firewire | |
parent | fe242579e9f33150868f1bb79c7e262ad7953f17 (diff) |
firewire: core: optimize Topology Map creation
The Topology Map of the local node was created in CPU byte order,
then a temporary big endian copy was created to compute the CRC,
and when a read request to the Topology Map arrived it had to be
converted to big endian byte order again.
We now generate it in big endian byte order in the first place.
This also rids us of 1000 bytes stack usage in tasklet context.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-card.c | 17 | ||||
-rw-r--r-- | drivers/firewire/core-topology.c | 17 | ||||
-rw-r--r-- | drivers/firewire/core-transaction.c | 9 | ||||
-rw-r--r-- | drivers/firewire/core.h | 2 |
4 files changed, 15 insertions, 30 deletions
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index f58130789990..7083bcc1b9c7 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c | |||
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #include "core.h" | 39 | #include "core.h" |
40 | 40 | ||
41 | static int __compute_block_crc(__be32 *block) | 41 | int fw_compute_block_crc(__be32 *block) |
42 | { | 42 | { |
43 | int length; | 43 | int length; |
44 | u16 crc; | 44 | u16 crc; |
@@ -50,19 +50,6 @@ static int __compute_block_crc(__be32 *block) | |||
50 | return length; | 50 | return length; |
51 | } | 51 | } |
52 | 52 | ||
53 | int fw_compute_block_crc(u32 *block) | ||
54 | { | ||
55 | __be32 be32_block[256]; | ||
56 | int i, length; | ||
57 | |||
58 | length = (*block >> 16) & 0xff; | ||
59 | for (i = 0; i < length; i++) | ||
60 | be32_block[i] = cpu_to_be32(block[i + 1]); | ||
61 | *block |= crc_itu_t(0, (u8 *) be32_block, length * 4); | ||
62 | |||
63 | return length; | ||
64 | } | ||
65 | |||
66 | static DEFINE_MUTEX(card_mutex); | 53 | static DEFINE_MUTEX(card_mutex); |
67 | static LIST_HEAD(card_list); | 54 | static LIST_HEAD(card_list); |
68 | 55 | ||
@@ -141,7 +128,7 @@ static size_t generate_config_rom(struct fw_card *card, __be32 *config_rom) | |||
141 | * the bus info block, which is always the case for this | 128 | * the bus info block, which is always the case for this |
142 | * implementation. */ | 129 | * implementation. */ |
143 | for (i = 0; i < j; i += length + 1) | 130 | for (i = 0; i < j; i += length + 1) |
144 | length = __compute_block_crc(config_rom + i); | 131 | length = fw_compute_block_crc(config_rom + i); |
145 | 132 | ||
146 | return j; | 133 | return j; |
147 | } | 134 | } |
diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c index fddf2b358936..9a5f38c80b0e 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c | |||
@@ -28,9 +28,9 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
31 | #include <linux/string.h> | ||
32 | 31 | ||
33 | #include <asm/atomic.h> | 32 | #include <asm/atomic.h> |
33 | #include <asm/byteorder.h> | ||
34 | #include <asm/system.h> | 34 | #include <asm/system.h> |
35 | 35 | ||
36 | #include "core.h" | 36 | #include "core.h" |
@@ -510,13 +510,16 @@ static void update_tree(struct fw_card *card, struct fw_node *root) | |||
510 | static void update_topology_map(struct fw_card *card, | 510 | static void update_topology_map(struct fw_card *card, |
511 | u32 *self_ids, int self_id_count) | 511 | u32 *self_ids, int self_id_count) |
512 | { | 512 | { |
513 | int node_count; | 513 | int node_count = (card->root_node->node_id & 0x3f) + 1; |
514 | __be32 *map = card->topology_map; | ||
515 | |||
516 | *map++ = cpu_to_be32((self_id_count + 2) << 16); | ||
517 | *map++ = cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1); | ||
518 | *map++ = cpu_to_be32((node_count << 16) | self_id_count); | ||
519 | |||
520 | while (self_id_count--) | ||
521 | *map++ = cpu_to_be32p(self_ids++); | ||
514 | 522 | ||
515 | card->topology_map[1]++; | ||
516 | node_count = (card->root_node->node_id & 0x3f) + 1; | ||
517 | card->topology_map[2] = (node_count << 16) | self_id_count; | ||
518 | card->topology_map[0] = (self_id_count + 2) << 16; | ||
519 | memcpy(&card->topology_map[3], self_ids, self_id_count * 4); | ||
520 | fw_compute_block_crc(card->topology_map); | 523 | fw_compute_block_crc(card->topology_map); |
521 | } | 524 | } |
522 | 525 | ||
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index da628c72a462..203e6428bada 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c | |||
@@ -810,8 +810,7 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request | |||
810 | int speed, unsigned long long offset, | 810 | int speed, unsigned long long offset, |
811 | void *payload, size_t length, void *callback_data) | 811 | void *payload, size_t length, void *callback_data) |
812 | { | 812 | { |
813 | int i, start, end; | 813 | int start; |
814 | __be32 *map; | ||
815 | 814 | ||
816 | if (!TCODE_IS_READ_REQUEST(tcode)) { | 815 | if (!TCODE_IS_READ_REQUEST(tcode)) { |
817 | fw_send_response(card, request, RCODE_TYPE_ERROR); | 816 | fw_send_response(card, request, RCODE_TYPE_ERROR); |
@@ -824,11 +823,7 @@ static void handle_topology_map(struct fw_card *card, struct fw_request *request | |||
824 | } | 823 | } |
825 | 824 | ||
826 | start = (offset - topology_map_region.start) / 4; | 825 | start = (offset - topology_map_region.start) / 4; |
827 | end = start + length / 4; | 826 | memcpy(payload, &card->topology_map[start], length); |
828 | map = payload; | ||
829 | |||
830 | for (i = 0; i < length / 4; i++) | ||
831 | map[i] = cpu_to_be32(card->topology_map[start + i]); | ||
832 | 827 | ||
833 | fw_send_response(card, request, RCODE_COMPLETE); | 828 | fw_send_response(card, request, RCODE_COMPLETE); |
834 | } | 829 | } |
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 7adca7cb9f55..ed3b1a765c00 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h | |||
@@ -94,7 +94,7 @@ int fw_card_add(struct fw_card *card, | |||
94 | u32 max_receive, u32 link_speed, u64 guid); | 94 | u32 max_receive, u32 link_speed, u64 guid); |
95 | void fw_core_remove_card(struct fw_card *card); | 95 | void fw_core_remove_card(struct fw_card *card); |
96 | int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset); | 96 | int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset); |
97 | int fw_compute_block_crc(u32 *block); | 97 | int fw_compute_block_crc(__be32 *block); |
98 | void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); | 98 | void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); |
99 | 99 | ||
100 | static inline struct fw_card *fw_card_get(struct fw_card *card) | 100 | static inline struct fw_card *fw_card_get(struct fw_card *card) |