X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Ffirewire%2Ffw-transaction.c;h=03ae8a77c479f680da86de9cc1e407336bd23750;hb=6329d3021bcfa9038621e6e917d98929421d8ec8;hp=e6f1bda3894040bb3c3bd97536a0243a6568a1ae;hpb=7d3628b230ecbdc29566c18bc7800ff8ed66a71f;p=linux-2.6 diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index e6f1bda389..03ae8a77c4 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c @@ -18,7 +18,9 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +#include #include #include #include @@ -28,7 +30,6 @@ #include #include #include -#include #include "fw-transaction.h" #include "fw-topology.h" @@ -294,42 +295,58 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t, } EXPORT_SYMBOL(fw_send_request); -static void -transmit_phy_packet_callback(struct fw_packet *packet, - struct fw_card *card, int status) +struct fw_phy_packet { + struct fw_packet packet; + struct completion done; + struct kref kref; +}; + +static void phy_packet_release(struct kref *kref) { - kfree(packet); + struct fw_phy_packet *p = + container_of(kref, struct fw_phy_packet, kref); + kfree(p); } -static void send_phy_packet(struct fw_card *card, u32 data, int generation) +static void transmit_phy_packet_callback(struct fw_packet *packet, + struct fw_card *card, int status) { - struct fw_packet *packet; - - packet = kzalloc(sizeof(*packet), GFP_ATOMIC); - if (packet == NULL) - return; + struct fw_phy_packet *p = + container_of(packet, struct fw_phy_packet, packet); - packet->header[0] = data; - packet->header[1] = ~data; - packet->header_length = 8; - packet->payload_length = 0; - packet->speed = SCODE_100; - packet->generation = generation; - packet->callback = transmit_phy_packet_callback; - - card->driver->send_request(card, packet); + complete(&p->done); + kref_put(&p->kref, phy_packet_release); } void fw_send_phy_config(struct fw_card *card, int node_id, int generation, int gap_count) { - u32 q; - - q = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | - PHY_CONFIG_ROOT_ID(node_id) | - PHY_CONFIG_GAP_COUNT(gap_count); + struct fw_phy_packet *p; + long timeout = DIV_ROUND_UP(HZ, 10); + u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | + PHY_CONFIG_ROOT_ID(node_id) | + PHY_CONFIG_GAP_COUNT(gap_count); + + p = kmalloc(sizeof(*p), GFP_KERNEL); + if (p == NULL) + return; - send_phy_packet(card, q, generation); + p->packet.header[0] = data; + p->packet.header[1] = ~data; + p->packet.header_length = 8; + p->packet.payload_length = 0; + p->packet.speed = SCODE_100; + p->packet.generation = generation; + p->packet.callback = transmit_phy_packet_callback; + init_completion(&p->done); + kref_set(&p->kref, 2); + + card->driver->send_request(card, &p->packet); + timeout = wait_for_completion_timeout(&p->done, timeout); + kref_put(&p->kref, phy_packet_release); + + /* will leak p if the callback is never executed */ + WARN_ON(timeout == 0); } void fw_flush_transactions(struct fw_card *card) @@ -389,21 +406,21 @@ lookup_enclosing_address_handler(struct list_head *list, static DEFINE_SPINLOCK(address_handler_lock); static LIST_HEAD(address_handler_list); -const struct fw_address_region fw_low_memory_region = - { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; const struct fw_address_region fw_high_memory_region = { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }; +EXPORT_SYMBOL(fw_high_memory_region); + +#if 0 +const struct fw_address_region fw_low_memory_region = + { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; const struct fw_address_region fw_private_region = { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, }; const struct fw_address_region fw_csr_region = - { .start = 0xfffff0000000ULL, .end = 0xfffff0000800ULL, }; + { .start = CSR_REGISTER_BASE, + .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM_END, }; const struct fw_address_region fw_unit_space_region = { .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, }; -EXPORT_SYMBOL(fw_low_memory_region); -EXPORT_SYMBOL(fw_high_memory_region); -EXPORT_SYMBOL(fw_private_region); -EXPORT_SYMBOL(fw_csr_region); -EXPORT_SYMBOL(fw_unit_space_region); +#endif /* 0 */ /** * Allocate a range of addresses in the node space of the OHCI @@ -574,7 +591,8 @@ allocate_request(struct fw_packet *p) break; default: - BUG(); + fw_error("ERROR - corrupt request received - %08x %08x %08x\n", + p->header[0], p->header[1], p->header[2]); return NULL; } @@ -747,7 +765,8 @@ fw_core_handle_response(struct fw_card *card, struct fw_packet *p) EXPORT_SYMBOL(fw_core_handle_response); static const struct fw_address_region topology_map_region = - { .start = 0xfffff0001000ull, .end = 0xfffff0001400ull, }; + { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP, + .end = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, }; static void handle_topology_map(struct fw_card *card, struct fw_request *request, @@ -785,7 +804,8 @@ static struct fw_address_handler topology_map = { }; static const struct fw_address_region registers_region = - { .start = 0xfffff0000000ull, .end = 0xfffff0000400ull, }; + { .start = CSR_REGISTER_BASE, + .end = CSR_REGISTER_BASE | CSR_CONFIG_ROM, }; static void handle_registers(struct fw_card *card, struct fw_request *request, @@ -794,7 +814,7 @@ handle_registers(struct fw_card *card, struct fw_request *request, unsigned long long offset, void *payload, size_t length, void *callback_data) { - int reg = offset - CSR_REGISTER_BASE; + int reg = offset & ~CSR_REGISTER_BASE; unsigned long long bus_time; __be32 *data = payload;