Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329230
b: refs/heads/master
c: 4d50c44
h: refs/heads/master
v: v3
  • Loading branch information
Stefan Richter committed Sep 28, 2012
1 parent 8acbceb commit 3d8b6de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35202f7d8420fff586b372422a2419affeaba8ef
refs/heads/master: 4d50c44381c981c9caa74e82ab894d4938dac9ca
13 changes: 8 additions & 5 deletions trunk/drivers/firewire/core-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static struct fw_address_handler *lookup_enclosing_address_handler(
return NULL;
}

static DEFINE_SPINLOCK(address_handler_lock);
static DEFINE_SPINLOCK(address_handler_list_lock);
static LIST_HEAD(address_handler_list);

const struct fw_address_region fw_high_memory_region =
Expand Down Expand Up @@ -556,6 +556,7 @@ static bool is_in_fcp_region(u64 offset, size_t length)
* the specified callback is invoked. The parameters passed to the callback
* give the details of the particular request.
*
* To be called in process context.
* Return value: 0 on success, non-zero otherwise.
*
* The start offset of the handler's address region is determined by
Expand All @@ -576,7 +577,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,
handler->length == 0)
return -EINVAL;

spin_lock_bh(&address_handler_lock);
spin_lock(&address_handler_list_lock);

handler->offset = region->start;
while (handler->offset + handler->length <= region->end) {
Expand All @@ -595,7 +596,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,
}
}

spin_unlock_bh(&address_handler_lock);
spin_unlock(&address_handler_list_lock);

return ret;
}
Expand All @@ -604,14 +605,16 @@ EXPORT_SYMBOL(fw_core_add_address_handler);
/**
* fw_core_remove_address_handler() - unregister an address handler
*
* To be called in process context.
*
* When fw_core_remove_address_handler() returns, @handler->callback() is
* guaranteed to not run on any CPU anymore.
*/
void fw_core_remove_address_handler(struct fw_address_handler *handler)
{
spin_lock_bh(&address_handler_lock);
spin_lock(&address_handler_list_lock);
list_del_rcu(&handler->link);
spin_unlock_bh(&address_handler_lock);
spin_unlock(&address_handler_list_lock);
synchronize_rcu();
}
EXPORT_SYMBOL(fw_core_remove_address_handler);
Expand Down
12 changes: 10 additions & 2 deletions trunk/include/linux/firewire.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,16 @@ typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
void *data, size_t length,
void *callback_data);
/*
* Important note: Except for the FCP registers, the callback must guarantee
* that either fw_send_response() or kfree() is called on the @request.
* This callback handles an inbound request subaction. It is called in
* RCU read-side context, therefore must not sleep.
*
* The callback should not initiate outbound request subactions directly.
* Otherwise there is a danger of recursion of inbound and outbound
* transactions from and to the local node.
*
* The callback is responsible that either fw_send_response() or kfree()
* is called on the @request, except for FCP registers for which the core
* takes care of that.
*/
typedef void (*fw_address_callback_t)(struct fw_card *card,
struct fw_request *request,
Expand Down

0 comments on commit 3d8b6de

Please sign in to comment.