Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136015
b: refs/heads/master
c: 5d9cb7d
h: refs/heads/master
i:
  136013: 7749652
  136011: d28e46e
  136007: df3422d
  135999: a58e903
v: v3
  • Loading branch information
Stefan Richter committed Mar 24, 2009
1 parent e157d99 commit af473e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 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: 77258da403be4cfce84b6abcdb515ad0bd1f92f1
refs/heads/master: 5d9cb7d276a9c465fef5a771792eac2cf1929f2b
2 changes: 1 addition & 1 deletion trunk/drivers/firewire/fw-cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ static void iso_resource_work(struct work_struct *work)
spin_unlock_irq(&client->lock);

if (todo == ISO_RES_ALLOC && channel >= 0)
r->channels = 1ULL << (63 - channel);
r->channels = 1ULL << channel;

if (todo == ISO_RES_REALLOC && success)
goto out;
Expand Down
38 changes: 22 additions & 16 deletions trunk/drivers/firewire/fw-iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,19 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
}

static int manage_channel(struct fw_card *card, int irm_id, int generation,
__be32 channels_mask, u64 offset, bool allocate)
u32 channels_mask, u64 offset, bool allocate)
{
__be32 data[2], c, old = allocate ? cpu_to_be32(~0) : 0;
__be32 data[2], c, all, old;
int i, retry = 5;

old = all = allocate ? cpu_to_be32(~0) : 0;

for (i = 0; i < 32; i++) {
c = cpu_to_be32(1 << (31 - i));
if (!(channels_mask & c))
if (!(channels_mask & 1 << i))
continue;

if (allocate == !(old & c))
c = cpu_to_be32(1 << (31 - i));
if ((old & c) != (all & c))
continue;

data[0] = old;
Expand All @@ -233,7 +235,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
old = data[0];

/* Is the IRM 1394a-2000 compliant? */
if ((data[0] & c) != (data[1] & c))
if ((data[0] & c) == (data[1] & c))
continue;

/* 1394-1995 IRM, fall through to retry. */
Expand All @@ -249,11 +251,10 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
static void deallocate_channel(struct fw_card *card, int irm_id,
int generation, int channel)
{
__be32 mask;
u32 mask;
u64 offset;

mask = channel < 32 ? cpu_to_be32(1 << (31 - channel)) :
cpu_to_be32(1 << (63 - channel));
mask = channel < 32 ? 1 << channel : 1 << (channel - 32);
offset = channel < 32 ? CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI :
CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO;

Expand All @@ -266,25 +267,30 @@ static void deallocate_channel(struct fw_card *card, int irm_id,
* In parameters: card, generation, channels_mask, bandwidth, allocate
* Out parameters: channel, bandwidth
* This function blocks (sleeps) during communication with the IRM.
*
* Allocates or deallocates at most one channel out of channels_mask.
* channels_mask is a bitfield with MSB for channel 63 and LSB for channel 0.
* (Note, the IRM's CHANNELS_AVAILABLE is a big-endian bitfield with MSB for
* channel 0 and LSB for channel 63.)
* Allocates or deallocates as many bandwidth allocation units as specified.
*
* Returns channel < 0 if no channel was allocated or deallocated.
* Returns bandwidth = 0 if no bandwidth was allocated or deallocated.
*
* If generation is stale, deallocations succeed but allocations fail with
* channel = -EAGAIN.
*
* If channel (de)allocation fails, bandwidth (de)allocation fails too.
* If channel allocation fails, no bandwidth will be allocated either.
* If bandwidth allocation fails, no channel will be allocated either.
* If bandwidth deallocation fails, channel deallocation may still have been
* successful.
* But deallocations of channel and bandwidth are tried independently
* of each other's success.
*/
void fw_iso_resource_manage(struct fw_card *card, int generation,
u64 channels_mask, int *channel, int *bandwidth,
bool allocate)
{
__be32 channels_hi = cpu_to_be32(channels_mask >> 32);
__be32 channels_lo = cpu_to_be32(channels_mask);
u32 channels_hi = channels_mask; /* channels 31...0 */
u32 channels_lo = channels_mask >> 32; /* channels 63...32 */
int irm_id, ret, c = -EINVAL;

spin_lock_irq(&card->lock);
Expand All @@ -302,7 +308,7 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
}
*channel = c;

if (channels_mask != 0 && c < 0)
if (allocate && channels_mask != 0 && c < 0)
*bandwidth = 0;

if (*bandwidth == 0)
Expand All @@ -312,7 +318,7 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
if (ret < 0)
*bandwidth = 0;

if (ret < 0 && c >= 0 && allocate) {
if (allocate && ret < 0 && c >= 0) {
deallocate_channel(card, irm_id, generation, c);
*channel = ret;
}
Expand Down
10 changes: 4 additions & 6 deletions trunk/include/linux/firewire-cdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ struct fw_cdev_event_iso_interrupt {
* @handle: Reference by which an allocated resource can be deallocated
* @channel: Isochronous channel which was (de)allocated, if any
* @bandwidth: Bandwidth allocation units which were (de)allocated, if any
* @channels_available: Last known availability of channels
* @bandwidth_available: Last known availability of bandwidth
*
* An %FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED event is sent after an isochronous
* resource was allocated at the IRM. The client has to check @channel and
Expand Down Expand Up @@ -580,17 +578,17 @@ struct fw_cdev_get_cycle_timer {
*
* The %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE_ONCE ioctl works like
* %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE except that resources are freed
* instead of allocated. At most one channel may be specified in this ioctl.
* instead of allocated.
* An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation.
*
* To summarize, %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE allocates iso resources
* for the lifetime of the fd or handle.
* In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources
* for the duration of a bus generation.
*
* @channels is a host-endian bitfield with the most significant bit
* representing channel 0 and the least significant bit representing channel 63:
* 1ULL << (63 - c)
* @channels is a host-endian bitfield with the least significant bit
* representing channel 0 and the most significant bit representing channel 63:
* 1ULL << c for each channel c that is a candidate for (de)allocation.
*
* @bandwidth is expressed in bandwidth allocation units, i.e. the time to send
* one quadlet of data (payload or header data) at speed S1600.
Expand Down

0 comments on commit af473e5

Please sign in to comment.