From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] firewire: core: optimize Topology Map creation
Date: Thu, 8 Oct 2009 00:42:53 +0200 (CEST) [thread overview]
Message-ID: <tkrat.2d203c48cd66e49c@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.27888275592fd267@s5r6.in-berlin.de>
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>
---
drivers/firewire/core-card.c | 17 ++---------------
drivers/firewire/core-topology.c | 17 ++++++++++-------
drivers/firewire/core-transaction.c | 9 ++-------
drivers/firewire/core.h | 2 +-
include/linux/firewire.h | 2 +-
5 files changed, 16 insertions(+), 31 deletions(-)
Index: linux-2.6.31/drivers/firewire/core-card.c
===================================================================
--- linux-2.6.31.orig/drivers/firewire/core-card.c
+++ linux-2.6.31/drivers/firewire/core-card.c
@@ -38,7 +38,7 @@
#include "core.h"
-static int __compute_block_crc(__be32 *block)
+int fw_compute_block_crc(__be32 *block)
{
int length;
u16 crc;
@@ -50,19 +50,6 @@ static int __compute_block_crc(__be32 *b
return length;
}
-int fw_compute_block_crc(u32 *block)
-{
- __be32 be32_block[256];
- int i, length;
-
- length = (*block >> 16) & 0xff;
- for (i = 0; i < length; i++)
- be32_block[i] = cpu_to_be32(block[i + 1]);
- *block |= crc_itu_t(0, (u8 *) be32_block, length * 4);
-
- return length;
-}
-
static DEFINE_MUTEX(card_mutex);
static LIST_HEAD(card_list);
@@ -141,7 +128,7 @@ static size_t generate_config_rom(struct
* the bus info block, which is always the case for this
* implementation. */
for (i = 0; i < j; i += length + 1)
- length = __compute_block_crc(config_rom + i);
+ length = fw_compute_block_crc(config_rom + i);
return j;
}
Index: linux-2.6.31/drivers/firewire/core-topology.c
===================================================================
--- linux-2.6.31.orig/drivers/firewire/core-topology.c
+++ linux-2.6.31/drivers/firewire/core-topology.c
@@ -28,9 +28,9 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/string.h>
#include <asm/atomic.h>
+#include <asm/byteorder.h>
#include <asm/system.h>
#include "core.h"
@@ -510,13 +510,16 @@ static void update_tree(struct fw_card *
static void update_topology_map(struct fw_card *card,
u32 *self_ids, int self_id_count)
{
- int node_count;
+ int node_count = (card->root_node->node_id & 0x3f) + 1;
+ __be32 *map = card->topology_map;
+
+ *map++ = cpu_to_be32((self_id_count + 2) << 16);
+ *map++ = cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1);
+ *map++ = cpu_to_be32((node_count << 16) | self_id_count);
+
+ while (self_id_count--)
+ *map++ = cpu_to_be32p(self_ids++);
- card->topology_map[1]++;
- node_count = (card->root_node->node_id & 0x3f) + 1;
- card->topology_map[2] = (node_count << 16) | self_id_count;
- card->topology_map[0] = (self_id_count + 2) << 16;
- memcpy(&card->topology_map[3], self_ids, self_id_count * 4);
fw_compute_block_crc(card->topology_map);
}
Index: linux-2.6.31/drivers/firewire/core-transaction.c
===================================================================
--- linux-2.6.31.orig/drivers/firewire/core-transaction.c
+++ linux-2.6.31/drivers/firewire/core-transaction.c
@@ -810,8 +810,7 @@ static void handle_topology_map(struct f
int speed, unsigned long long offset,
void *payload, size_t length, void *callback_data)
{
- int i, start, end;
- __be32 *map;
+ int start;
if (!TCODE_IS_READ_REQUEST(tcode)) {
fw_send_response(card, request, RCODE_TYPE_ERROR);
@@ -824,11 +823,7 @@ static void handle_topology_map(struct f
}
start = (offset - topology_map_region.start) / 4;
- end = start + length / 4;
- map = payload;
-
- for (i = 0; i < length / 4; i++)
- map[i] = cpu_to_be32(card->topology_map[start + i]);
+ memcpy(payload, &card->topology_map[start], length);
fw_send_response(card, request, RCODE_COMPLETE);
}
Index: linux-2.6.31/drivers/firewire/core.h
===================================================================
--- linux-2.6.31.orig/drivers/firewire/core.h
+++ linux-2.6.31/drivers/firewire/core.h
@@ -94,7 +94,7 @@ int fw_card_add(struct fw_card *card,
u32 max_receive, u32 link_speed, u64 guid);
void fw_core_remove_card(struct fw_card *card);
int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
-int fw_compute_block_crc(u32 *block);
+int fw_compute_block_crc(__be32 *block);
void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
static inline struct fw_card *fw_card_get(struct fw_card *card)
Index: linux-2.6.31/include/linux/firewire.h
===================================================================
--- linux-2.6.31.orig/include/linux/firewire.h
+++ linux-2.6.31/include/linux/firewire.h
@@ -117,7 +117,7 @@ struct fw_card {
bool broadcast_channel_allocated;
u32 broadcast_channel;
- u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
+ __be32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
};
struct fw_attribute_group {
--
Stefan Richter
-=====-==--= =-=- -=---
http://arcgraph.de/sr/
prev parent reply other threads:[~2009-10-07 22:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 22:38 [PATCH 0/8] firewire: misc updates Stefan Richter
2009-10-07 22:39 ` [PATCH 1/8] firewire: sbp2: provide fallback if mgt_ORB_timeout is missing Stefan Richter
2009-10-07 22:39 ` [PATCH 2/8] firewire: cdev: fix memory leak in an error path Stefan Richter
2009-10-07 22:40 ` [PATCH 3/8] firewire: cdev: reduce stack usage by ioctl_dispatch Stefan Richter
2009-10-14 20:43 ` Stefan Richter
2009-10-14 21:14 ` [PATCH update] " Stefan Richter
[not found] ` <4AD6F672.705@cam.ac.uk>
2009-10-15 19:16 ` [PATCH v3] " Stefan Richter
2009-10-07 22:41 ` [PATCH 4/8] firewire: normalize style of queue_work wrappers Stefan Richter
2009-10-07 22:41 ` [PATCH 5/8] firewire: cdev: normalize variable names Stefan Richter
2009-10-07 22:41 ` [PATCH 6/8] firewire: optimize config ROM creation Stefan Richter
2009-10-07 22:42 ` [PATCH 7/8] firewire: core: clarify generate_config_rom usage Stefan Richter
2009-10-07 22:42 ` Stefan Richter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tkrat.2d203c48cd66e49c@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®