8 #include <linux/device.h>
11 #include <linux/export.h>
14 #include <linux/sched.h>
29 r->
unit = fw_unit_get(unit);
49 static unsigned int packet_bandwidth(
unsigned int max_payload_bytes,
int speed)
51 unsigned int bytes, s400_bytes;
54 bytes = 3 * 4 +
ALIGN(max_payload_bytes, 4);
58 s400_bytes = bytes * (1 << (
SCODE_400 - speed));
65 static int current_bandwidth_overhead(
struct fw_card *
card)
80 static int wait_isoch_resource_delay_after_bus_reset(
struct fw_card *
card)
107 unsigned int max_payload_bytes,
int speed)
109 struct fw_card *card = fw_parent_device(r->
unit)->card;
115 r->
bandwidth = packet_bandwidth(max_payload_bytes, speed);
117 retry_after_bus_reset:
118 spin_lock_irq(&card->
lock);
121 spin_unlock_irq(&card->
lock);
123 err = wait_isoch_resource_delay_after_bus_reset(card);
131 &channel, &bandwidth,
true);
134 goto retry_after_bus_reset;
140 if (channel == -
EBUSY)
142 "isochronous resources exhausted\n");
145 "isochronous resource allocation failed\n");
167 struct fw_card *card = fw_parent_device(r->
unit)->card;
177 spin_lock_irq(&card->
lock);
180 spin_unlock_irq(&card->
lock);
185 &channel, &bandwidth,
true);
190 if (channel < 0 && channel != -
EAGAIN) {
192 if (channel == -
EBUSY)
194 "isochronous resources exhausted\n");
197 "isochronous resource allocation failed\n");
214 struct fw_card *card = fw_parent_device(r->
unit)->card;
222 &channel, &bandwidth,
false);
225 "isochronous resource deallocation failed\n");