提交 34699403 编写于 作者: L Linus Torvalds

Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394

Pull IEEE 1394 (FireWire) subsystem updates post v3.3 from Stefan Richter:

 - Some SBP-2 initiator fixes, side product from ongoing work on a target.

 - Reintroduction of an isochronous I/O feature of the older ieee1394 driver
   stack (flush buffer completions); it was evidently rarely used but not
   actually unused.  Matching libraw1394 code is already available.

 - Be sure to prefix all kernel log messages with device name or card name,
   and other logging related cleanups.

 - Misc other small cleanups, among them a small API change that affects
   sound/firewire/ too. Clemens Ladisch is aware of it.

* tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394: (26 commits)
  firewire: allow explicit flushing of iso packet completions
  firewire: prevent dropping of completed iso packet header data
  firewire: ohci: factor out iso completion flushing code
  firewire: ohci: simplify iso header pointer arithmetic
  firewire: ohci: optimize control bit checks
  firewire: ohci: remove unused excess_bytes field
  firewire: ohci: copy_iso_headers(): make comment match the code
  firewire: cdev: fix IR multichannel event documentation
  firewire: ohci: fix too-early completion of IR multichannel buffers
  firewire: ohci: move runtime debug facility out of #ifdef
  firewire: tone down some diagnostic log messages
  firewire: sbp2: replace a GFP_ATOMIC allocation
  firewire: sbp2: Fix SCSI sense data mangling
  firewire: sbp2: Ignore SBP-2 targets on the local node
  firewire: sbp2: Take into account Unit_Unique_ID
  firewire: nosy: Use the macro DMA_BIT_MASK().
  firewire: core: convert AR-req handler lock from _irqsave to _bh
  firewire: core: fix race at address_handler unregistration
  firewire: core: remove obsolete comment
  firewire: core: prefix log messages with card name
  ...
...@@ -28,11 +28,6 @@ config FIREWIRE_OHCI ...@@ -28,11 +28,6 @@ config FIREWIRE_OHCI
To compile this driver as a module, say M here: The module will be To compile this driver as a module, say M here: The module will be
called firewire-ohci. called firewire-ohci.
config FIREWIRE_OHCI_DEBUG
bool
depends on FIREWIRE_OHCI
default y
config FIREWIRE_SBP2 config FIREWIRE_SBP2
tristate "Storage devices (SBP-2 protocol)" tristate "Storage devices (SBP-2 protocol)"
depends on FIREWIRE && SCSI depends on FIREWIRE && SCSI
......
...@@ -37,6 +37,22 @@ ...@@ -37,6 +37,22 @@
#include "core.h" #include "core.h"
#define define_fw_printk_level(func, kern_level) \
void func(const struct fw_card *card, const char *fmt, ...) \
{ \
struct va_format vaf; \
va_list args; \
\
va_start(args, fmt); \
vaf.fmt = fmt; \
vaf.va = &args; \
printk(kern_level KBUILD_MODNAME " %s: %pV", \
dev_name(card->device), &vaf); \
va_end(args); \
}
define_fw_printk_level(fw_err, KERN_ERR);
define_fw_printk_level(fw_notice, KERN_NOTICE);
int fw_compute_block_crc(__be32 *block) int fw_compute_block_crc(__be32 *block)
{ {
int length; int length;
...@@ -260,7 +276,7 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation) ...@@ -260,7 +276,7 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation)
fw_iso_resource_manage(card, generation, 1ULL << 31, fw_iso_resource_manage(card, generation, 1ULL << 31,
&channel, &bandwidth, true); &channel, &bandwidth, true);
if (channel != 31) { if (channel != 31) {
fw_notify("failed to allocate broadcast channel\n"); fw_notice(card, "failed to allocate broadcast channel\n");
return; return;
} }
card->broadcast_channel_allocated = true; card->broadcast_channel_allocated = true;
...@@ -343,14 +359,14 @@ static void bm_work(struct work_struct *work) ...@@ -343,14 +359,14 @@ static void bm_work(struct work_struct *work)
if (!card->irm_node->link_on) { if (!card->irm_node->link_on) {
new_root_id = local_id; new_root_id = local_id;
fw_notify("%s, making local node (%02x) root.\n", fw_notice(card, "%s, making local node (%02x) root\n",
"IRM has link off", new_root_id); "IRM has link off", new_root_id);
goto pick_me; goto pick_me;
} }
if (irm_is_1394_1995_only && !keep_this_irm) { if (irm_is_1394_1995_only && !keep_this_irm) {
new_root_id = local_id; new_root_id = local_id;
fw_notify("%s, making local node (%02x) root.\n", fw_notice(card, "%s, making local node (%02x) root\n",
"IRM is not 1394a compliant", new_root_id); "IRM is not 1394a compliant", new_root_id);
goto pick_me; goto pick_me;
} }
...@@ -405,7 +421,7 @@ static void bm_work(struct work_struct *work) ...@@ -405,7 +421,7 @@ static void bm_work(struct work_struct *work)
* root, and thus, IRM. * root, and thus, IRM.
*/ */
new_root_id = local_id; new_root_id = local_id;
fw_notify("%s, making local node (%02x) root.\n", fw_notice(card, "%s, making local node (%02x) root\n",
"BM lock failed", new_root_id); "BM lock failed", new_root_id);
goto pick_me; goto pick_me;
} }
...@@ -478,8 +494,8 @@ static void bm_work(struct work_struct *work) ...@@ -478,8 +494,8 @@ static void bm_work(struct work_struct *work)
spin_unlock_irq(&card->lock); spin_unlock_irq(&card->lock);
if (do_reset) { if (do_reset) {
fw_notify("phy config: card %d, new root=%x, gap_count=%d\n", fw_notice(card, "phy config: new root=%x, gap_count=%d\n",
card->index, new_root_id, gap_count); new_root_id, gap_count);
fw_send_phy_config(card, new_root_id, generation, gap_count); fw_send_phy_config(card, new_root_id, generation, gap_count);
reset_bus(card, true); reset_bus(card, true);
/* Will allocate broadcast channel after the reset. */ /* Will allocate broadcast channel after the reset. */
...@@ -634,6 +650,11 @@ static void dummy_flush_queue_iso(struct fw_iso_context *ctx) ...@@ -634,6 +650,11 @@ static void dummy_flush_queue_iso(struct fw_iso_context *ctx)
{ {
} }
static int dummy_flush_iso_completions(struct fw_iso_context *ctx)
{
return -ENODEV;
}
static const struct fw_card_driver dummy_driver_template = { static const struct fw_card_driver dummy_driver_template = {
.read_phy_reg = dummy_read_phy_reg, .read_phy_reg = dummy_read_phy_reg,
.update_phy_reg = dummy_update_phy_reg, .update_phy_reg = dummy_update_phy_reg,
...@@ -646,6 +667,7 @@ static const struct fw_card_driver dummy_driver_template = { ...@@ -646,6 +667,7 @@ static const struct fw_card_driver dummy_driver_template = {
.set_iso_channels = dummy_set_iso_channels, .set_iso_channels = dummy_set_iso_channels,
.queue_iso = dummy_queue_iso, .queue_iso = dummy_queue_iso,
.flush_queue_iso = dummy_flush_queue_iso, .flush_queue_iso = dummy_flush_queue_iso,
.flush_iso_completions = dummy_flush_iso_completions,
}; };
void fw_card_release(struct kref *kref) void fw_card_release(struct kref *kref)
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/* /*
* ABI version history is documented in linux/firewire-cdev.h. * ABI version history is documented in linux/firewire-cdev.h.
*/ */
#define FW_CDEV_KERNEL_VERSION 4 #define FW_CDEV_KERNEL_VERSION 5
#define FW_CDEV_VERSION_EVENT_REQUEST2 4 #define FW_CDEV_VERSION_EVENT_REQUEST2 4
#define FW_CDEV_VERSION_ALLOCATE_REGION_END 4 #define FW_CDEV_VERSION_ALLOCATE_REGION_END 4
...@@ -389,7 +389,7 @@ static void queue_bus_reset_event(struct client *client) ...@@ -389,7 +389,7 @@ static void queue_bus_reset_event(struct client *client)
e = kzalloc(sizeof(*e), GFP_KERNEL); e = kzalloc(sizeof(*e), GFP_KERNEL);
if (e == NULL) { if (e == NULL) {
fw_notify("Out of memory when allocating event\n"); fw_notice(client->device->card, "out of memory when allocating event\n");
return; return;
} }
...@@ -438,6 +438,7 @@ union ioctl_arg { ...@@ -438,6 +438,7 @@ union ioctl_arg {
struct fw_cdev_send_phy_packet send_phy_packet; struct fw_cdev_send_phy_packet send_phy_packet;
struct fw_cdev_receive_phy_packets receive_phy_packets; struct fw_cdev_receive_phy_packets receive_phy_packets;
struct fw_cdev_set_iso_channels set_iso_channels; struct fw_cdev_set_iso_channels set_iso_channels;
struct fw_cdev_flush_iso flush_iso;
}; };
static int ioctl_get_info(struct client *client, union ioctl_arg *arg) static int ioctl_get_info(struct client *client, union ioctl_arg *arg)
...@@ -691,7 +692,7 @@ static void handle_request(struct fw_card *card, struct fw_request *request, ...@@ -691,7 +692,7 @@ static void handle_request(struct fw_card *card, struct fw_request *request,
r = kmalloc(sizeof(*r), GFP_ATOMIC); r = kmalloc(sizeof(*r), GFP_ATOMIC);
e = kmalloc(sizeof(*e), GFP_ATOMIC); e = kmalloc(sizeof(*e), GFP_ATOMIC);
if (r == NULL || e == NULL) { if (r == NULL || e == NULL) {
fw_notify("Out of memory when allocating event\n"); fw_notice(card, "out of memory when allocating event\n");
goto failed; goto failed;
} }
r->card = card; r->card = card;
...@@ -928,7 +929,7 @@ static void iso_callback(struct fw_iso_context *context, u32 cycle, ...@@ -928,7 +929,7 @@ static void iso_callback(struct fw_iso_context *context, u32 cycle,
e = kmalloc(sizeof(*e) + header_length, GFP_ATOMIC); e = kmalloc(sizeof(*e) + header_length, GFP_ATOMIC);
if (e == NULL) { if (e == NULL) {
fw_notify("Out of memory when allocating event\n"); fw_notice(context->card, "out of memory when allocating event\n");
return; return;
} }
e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT; e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT;
...@@ -948,7 +949,7 @@ static void iso_mc_callback(struct fw_iso_context *context, ...@@ -948,7 +949,7 @@ static void iso_mc_callback(struct fw_iso_context *context,
e = kmalloc(sizeof(*e), GFP_ATOMIC); e = kmalloc(sizeof(*e), GFP_ATOMIC);
if (e == NULL) { if (e == NULL) {
fw_notify("Out of memory when allocating event\n"); fw_notice(context->card, "out of memory when allocating event\n");
return; return;
} }
e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL; e->interrupt.type = FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL;
...@@ -1168,6 +1169,16 @@ static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg) ...@@ -1168,6 +1169,16 @@ static int ioctl_stop_iso(struct client *client, union ioctl_arg *arg)
return fw_iso_context_stop(client->iso_context); return fw_iso_context_stop(client->iso_context);
} }
static int ioctl_flush_iso(struct client *client, union ioctl_arg *arg)
{
struct fw_cdev_flush_iso *a = &arg->flush_iso;
if (client->iso_context == NULL || a->handle != 0)
return -EINVAL;
return fw_iso_context_flush_completions(client->iso_context);
}
static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg)
{ {
struct fw_cdev_get_cycle_timer2 *a = &arg->get_cycle_timer2; struct fw_cdev_get_cycle_timer2 *a = &arg->get_cycle_timer2;
...@@ -1548,7 +1559,7 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p) ...@@ -1548,7 +1559,7 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p)
list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) {
e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC); e = kmalloc(sizeof(*e) + 8, GFP_ATOMIC);
if (e == NULL) { if (e == NULL) {
fw_notify("Out of memory when allocating event\n"); fw_notice(card, "out of memory when allocating event\n");
break; break;
} }
e->phy_packet.closure = client->phy_receiver_closure; e->phy_packet.closure = client->phy_receiver_closure;
...@@ -1589,6 +1600,7 @@ static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = { ...@@ -1589,6 +1600,7 @@ static int (* const ioctl_handlers[])(struct client *, union ioctl_arg *) = {
[0x15] = ioctl_send_phy_packet, [0x15] = ioctl_send_phy_packet,
[0x16] = ioctl_receive_phy_packets, [0x16] = ioctl_receive_phy_packets,
[0x17] = ioctl_set_iso_channels, [0x17] = ioctl_set_iso_channels,
[0x18] = ioctl_flush_iso,
}; };
static int dispatch_ioctl(struct client *client, static int dispatch_ioctl(struct client *client,
......
...@@ -485,6 +485,7 @@ static int read_rom(struct fw_device *device, ...@@ -485,6 +485,7 @@ static int read_rom(struct fw_device *device,
*/ */
static int read_config_rom(struct fw_device *device, int generation) static int read_config_rom(struct fw_device *device, int generation)
{ {
struct fw_card *card = device->card;
const u32 *old_rom, *new_rom; const u32 *old_rom, *new_rom;
u32 *rom, *stack; u32 *rom, *stack;
u32 sp, key; u32 sp, key;
...@@ -529,12 +530,12 @@ static int read_config_rom(struct fw_device *device, int generation) ...@@ -529,12 +530,12 @@ static int read_config_rom(struct fw_device *device, int generation)
*/ */
if ((rom[2] & 0x7) < device->max_speed || if ((rom[2] & 0x7) < device->max_speed ||
device->max_speed == SCODE_BETA || device->max_speed == SCODE_BETA ||
device->card->beta_repeaters_present) { card->beta_repeaters_present) {
u32 dummy; u32 dummy;
/* for S1600 and S3200 */ /* for S1600 and S3200 */
if (device->max_speed == SCODE_BETA) if (device->max_speed == SCODE_BETA)
device->max_speed = device->card->link_speed; device->max_speed = card->link_speed;
while (device->max_speed > SCODE_100) { while (device->max_speed > SCODE_100) {
if (read_rom(device, generation, 0, &dummy) == if (read_rom(device, generation, 0, &dummy) ==
...@@ -576,9 +577,9 @@ static int read_config_rom(struct fw_device *device, int generation) ...@@ -576,9 +577,9 @@ static int read_config_rom(struct fw_device *device, int generation)
* a firmware bug. Ignore this whole block, i.e. * a firmware bug. Ignore this whole block, i.e.
* simply set a fake block length of 0. * simply set a fake block length of 0.
*/ */
fw_error("skipped invalid ROM block %x at %llx\n", fw_err(card, "skipped invalid ROM block %x at %llx\n",
rom[i], rom[i],
i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM);
rom[i] = 0; rom[i] = 0;
end = i; end = i;
} }
...@@ -604,9 +605,10 @@ static int read_config_rom(struct fw_device *device, int generation) ...@@ -604,9 +605,10 @@ static int read_config_rom(struct fw_device *device, int generation)
* the ROM don't have to check offsets all the time. * the ROM don't have to check offsets all the time.
*/ */
if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) { if (i + (rom[i] & 0xffffff) >= MAX_CONFIG_ROM_SIZE) {
fw_error("skipped unsupported ROM entry %x at %llx\n", fw_err(card,
rom[i], "skipped unsupported ROM entry %x at %llx\n",
i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM); rom[i],
i * 4 | CSR_REGISTER_BASE | CSR_CONFIG_ROM);
rom[i] = 0; rom[i] = 0;
continue; continue;
} }
...@@ -641,6 +643,7 @@ static void fw_unit_release(struct device *dev) ...@@ -641,6 +643,7 @@ static void fw_unit_release(struct device *dev)
{ {
struct fw_unit *unit = fw_unit(dev); struct fw_unit *unit = fw_unit(dev);
fw_device_put(fw_parent_device(unit));
kfree(unit); kfree(unit);
} }
...@@ -672,7 +675,7 @@ static void create_units(struct fw_device *device) ...@@ -672,7 +675,7 @@ static void create_units(struct fw_device *device)
*/ */
unit = kzalloc(sizeof(*unit), GFP_KERNEL); unit = kzalloc(sizeof(*unit), GFP_KERNEL);
if (unit == NULL) { if (unit == NULL) {
fw_error("failed to allocate memory for unit\n"); fw_err(device->card, "out of memory for unit\n");
continue; continue;
} }
...@@ -692,6 +695,7 @@ static void create_units(struct fw_device *device) ...@@ -692,6 +695,7 @@ static void create_units(struct fw_device *device)
if (device_register(&unit->device) < 0) if (device_register(&unit->device) < 0)
goto skip_unit; goto skip_unit;
fw_device_get(device);
continue; continue;
skip_unit: skip_unit:
...@@ -873,7 +877,7 @@ static int lookup_existing_device(struct device *dev, void *data) ...@@ -873,7 +877,7 @@ static int lookup_existing_device(struct device *dev, void *data)
smp_wmb(); /* update node_id before generation */ smp_wmb(); /* update node_id before generation */
old->generation = card->generation; old->generation = card->generation;
old->config_rom_retries = 0; old->config_rom_retries = 0;
fw_notify("rediscovered device %s\n", dev_name(dev)); fw_notice(card, "rediscovered device %s\n", dev_name(dev));
PREPARE_DELAYED_WORK(&old->work, fw_device_update); PREPARE_DELAYED_WORK(&old->work, fw_device_update);
fw_schedule_device_work(old, 0); fw_schedule_device_work(old, 0);
...@@ -954,6 +958,7 @@ static void fw_device_init(struct work_struct *work) ...@@ -954,6 +958,7 @@ static void fw_device_init(struct work_struct *work)
{ {
struct fw_device *device = struct fw_device *device =
container_of(work, struct fw_device, work.work); container_of(work, struct fw_device, work.work);
struct fw_card *card = device->card;
struct device *revived_dev; struct device *revived_dev;
int minor, ret; int minor, ret;
...@@ -970,16 +975,16 @@ static void fw_device_init(struct work_struct *work) ...@@ -970,16 +975,16 @@ static void fw_device_init(struct work_struct *work)
fw_schedule_device_work(device, RETRY_DELAY); fw_schedule_device_work(device, RETRY_DELAY);
} else { } else {
if (device->node->link_on) if (device->node->link_on)
fw_notify("giving up on config rom for node id %x\n", fw_notice(card, "giving up on Config ROM for node id %x\n",
device->node_id); device->node_id);
if (device->node == device->card->root_node) if (device->node == card->root_node)
fw_schedule_bm_work(device->card, 0); fw_schedule_bm_work(card, 0);
fw_device_release(&device->device); fw_device_release(&device->device);
} }
return; return;
} }
revived_dev = device_find_child(device->card->device, revived_dev = device_find_child(card->device,
device, lookup_existing_device); device, lookup_existing_device);
if (revived_dev) { if (revived_dev) {
put_device(revived_dev); put_device(revived_dev);
...@@ -1002,7 +1007,7 @@ static void fw_device_init(struct work_struct *work) ...@@ -1002,7 +1007,7 @@ static void fw_device_init(struct work_struct *work)
device->device.bus = &fw_bus_type; device->device.bus = &fw_bus_type;
device->device.type = &fw_device_type; device->device.type = &fw_device_type;
device->device.parent = device->card->device; device->device.parent = card->device;
device->device.devt = MKDEV(fw_cdev_major, minor); device->device.devt = MKDEV(fw_cdev_major, minor);
dev_set_name(&device->device, "fw%d", minor); dev_set_name(&device->device, "fw%d", minor);
...@@ -1014,7 +1019,7 @@ static void fw_device_init(struct work_struct *work) ...@@ -1014,7 +1019,7 @@ static void fw_device_init(struct work_struct *work)
&device->attribute_group); &device->attribute_group);
if (device_add(&device->device)) { if (device_add(&device->device)) {
fw_error("Failed to add device.\n"); fw_err(card, "failed to add device\n");
goto error_with_cdev; goto error_with_cdev;
} }
...@@ -1035,18 +1040,10 @@ static void fw_device_init(struct work_struct *work) ...@@ -1035,18 +1040,10 @@ static void fw_device_init(struct work_struct *work)
PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
fw_schedule_device_work(device, SHUTDOWN_DELAY); fw_schedule_device_work(device, SHUTDOWN_DELAY);
} else { } else {
if (device->config_rom_retries) fw_notice(card, "created device %s: GUID %08x%08x, S%d00\n",
fw_notify("created device %s: GUID %08x%08x, S%d00, " dev_name(&device->device),
"%d config ROM retries\n", device->config_rom[3], device->config_rom[4],
dev_name(&device->device), 1 << device->max_speed);
device->config_rom[3], device->config_rom[4],
1 << device->max_speed,
device->config_rom_retries);
else
fw_notify("created device %s: GUID %08x%08x, S%d00\n",
dev_name(&device->device),
device->config_rom[3], device->config_rom[4],
1 << device->max_speed);
device->config_rom_retries = 0; device->config_rom_retries = 0;
set_broadcast_channel(device, device->generation); set_broadcast_channel(device, device->generation);
...@@ -1058,8 +1055,8 @@ static void fw_device_init(struct work_struct *work) ...@@ -1058,8 +1055,8 @@ static void fw_device_init(struct work_struct *work)
* just end up running the IRM work a couple of extra times - * just end up running the IRM work a couple of extra times -
* pretty harmless. * pretty harmless.
*/ */
if (device->node == device->card->root_node) if (device->node == card->root_node)
fw_schedule_bm_work(device->card, 0); fw_schedule_bm_work(card, 0);
return; return;
...@@ -1163,12 +1160,13 @@ static void fw_device_refresh(struct work_struct *work) ...@@ -1163,12 +1160,13 @@ static void fw_device_refresh(struct work_struct *work)
FW_DEVICE_RUNNING) == FW_DEVICE_GONE) FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
goto gone; goto gone;
fw_notify("refreshed device %s\n", dev_name(&device->device)); fw_notice(card, "refreshed device %s\n", dev_name(&device->device));
device->config_rom_retries = 0; device->config_rom_retries = 0;
goto out; goto out;
give_up: give_up:
fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); fw_notice(card, "giving up on refresh of device %s\n",
dev_name(&device->device));
gone: gone:
atomic_set(&device->state, FW_DEVICE_GONE); atomic_set(&device->state, FW_DEVICE_GONE);
PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
......
...@@ -192,6 +192,12 @@ void fw_iso_context_queue_flush(struct fw_iso_context *ctx) ...@@ -192,6 +192,12 @@ void fw_iso_context_queue_flush(struct fw_iso_context *ctx)
} }
EXPORT_SYMBOL(fw_iso_context_queue_flush); EXPORT_SYMBOL(fw_iso_context_queue_flush);
int fw_iso_context_flush_completions(struct fw_iso_context *ctx)
{
return ctx->card->driver->flush_iso_completions(ctx);
}
EXPORT_SYMBOL(fw_iso_context_flush_completions);
int fw_iso_context_stop(struct fw_iso_context *ctx) int fw_iso_context_stop(struct fw_iso_context *ctx)
{ {
return ctx->card->driver->stop_iso(ctx); return ctx->card->driver->stop_iso(ctx);
......
...@@ -205,19 +205,19 @@ static struct fw_node *build_tree(struct fw_card *card, ...@@ -205,19 +205,19 @@ static struct fw_node *build_tree(struct fw_card *card,
next_sid = count_ports(sid, &port_count, &child_port_count); next_sid = count_ports(sid, &port_count, &child_port_count);
if (next_sid == NULL) { if (next_sid == NULL) {
fw_error("Inconsistent extended self IDs.\n"); fw_err(card, "inconsistent extended self IDs\n");
return NULL; return NULL;
} }
q = *sid; q = *sid;
if (phy_id != SELF_ID_PHY_ID(q)) { if (phy_id != SELF_ID_PHY_ID(q)) {
fw_error("PHY ID mismatch in self ID: %d != %d.\n", fw_err(card, "PHY ID mismatch in self ID: %d != %d\n",
phy_id, SELF_ID_PHY_ID(q)); phy_id, SELF_ID_PHY_ID(q));
return NULL; return NULL;
} }
if (child_port_count > stack_depth) { if (child_port_count > stack_depth) {
fw_error("Topology stack underflow\n"); fw_err(card, "topology stack underflow\n");
return NULL; return NULL;
} }
...@@ -235,7 +235,7 @@ static struct fw_node *build_tree(struct fw_card *card, ...@@ -235,7 +235,7 @@ static struct fw_node *build_tree(struct fw_card *card,
node = fw_node_create(q, port_count, card->color); node = fw_node_create(q, port_count, card->color);
if (node == NULL) { if (node == NULL) {
fw_error("Out of memory while building topology.\n"); fw_err(card, "out of memory while building topology\n");
return NULL; return NULL;
} }
...@@ -284,8 +284,8 @@ static struct fw_node *build_tree(struct fw_card *card, ...@@ -284,8 +284,8 @@ static struct fw_node *build_tree(struct fw_card *card,
*/ */
if ((next_sid == end && parent_count != 0) || if ((next_sid == end && parent_count != 0) ||
(next_sid < end && parent_count != 1)) { (next_sid < end && parent_count != 1)) {
fw_error("Parent port inconsistency for node %d: " fw_err(card, "parent port inconsistency for node %d: "
"parent_count=%d\n", phy_id, parent_count); "parent_count=%d\n", phy_id, parent_count);
return NULL; return NULL;
} }
...@@ -530,7 +530,6 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, ...@@ -530,7 +530,6 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,
*/ */
if (!is_next_generation(generation, card->generation) && if (!is_next_generation(generation, card->generation) &&
card->local_node != NULL) { card->local_node != NULL) {
fw_notify("skipped bus generations, destroying all nodes\n");
fw_destroy_nodes(card); fw_destroy_nodes(card);
card->bm_retries = 0; card->bm_retries = 0;
} }
...@@ -557,7 +556,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, ...@@ -557,7 +556,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,
card->color++; card->color++;
if (local_node == NULL) { if (local_node == NULL) {
fw_error("topology build failed\n"); fw_err(card, "topology build failed\n");
/* FIXME: We need to issue a bus reset in this case. */ /* FIXME: We need to issue a bus reset in this case. */
} else if (card->local_node == NULL) { } else if (card->local_node == NULL) {
card->local_node = local_node; card->local_node = local_node;
......
...@@ -565,7 +565,6 @@ int fw_core_add_address_handler(struct fw_address_handler *handler, ...@@ -565,7 +565,6 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,
const struct fw_address_region *region) const struct fw_address_region *region)
{ {
struct fw_address_handler *other; struct fw_address_handler *other;
unsigned long flags;
int ret = -EBUSY; int ret = -EBUSY;
if (region->start & 0xffff000000000003ULL || if (region->start & 0xffff000000000003ULL ||
...@@ -575,7 +574,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler, ...@@ -575,7 +574,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,
handler->length == 0) handler->length == 0)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&address_handler_lock, flags); spin_lock_bh(&address_handler_lock);
handler->offset = region->start; handler->offset = region->start;
while (handler->offset + handler->length <= region->end) { while (handler->offset + handler->length <= region->end) {
...@@ -594,7 +593,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler, ...@@ -594,7 +593,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,
} }
} }
spin_unlock_irqrestore(&address_handler_lock, flags); spin_unlock_bh(&address_handler_lock);
return ret; return ret;
} }
...@@ -602,14 +601,15 @@ EXPORT_SYMBOL(fw_core_add_address_handler); ...@@ -602,14 +601,15 @@ EXPORT_SYMBOL(fw_core_add_address_handler);
/** /**
* fw_core_remove_address_handler() - unregister an address handler * fw_core_remove_address_handler() - unregister an address handler
*
* 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) void fw_core_remove_address_handler(struct fw_address_handler *handler)
{ {
unsigned long flags; spin_lock_bh(&address_handler_lock);
spin_lock_irqsave(&address_handler_lock, flags);
list_del(&handler->link); list_del(&handler->link);
spin_unlock_irqrestore(&address_handler_lock, flags); spin_unlock_bh(&address_handler_lock);
} }
EXPORT_SYMBOL(fw_core_remove_address_handler); EXPORT_SYMBOL(fw_core_remove_address_handler);
...@@ -770,7 +770,7 @@ static struct fw_request *allocate_request(struct fw_card *card, ...@@ -770,7 +770,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
break; break;
default: default:
fw_error("ERROR - corrupt request received - %08x %08x %08x\n", fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n",
p->header[0], p->header[1], p->header[2]); p->header[0], p->header[1], p->header[2]);
return NULL; return NULL;
} }
...@@ -826,7 +826,6 @@ static void handle_exclusive_region_request(struct fw_card *card, ...@@ -826,7 +826,6 @@ static void handle_exclusive_region_request(struct fw_card *card,
unsigned long long offset) unsigned long long offset)
{ {
struct fw_address_handler *handler; struct fw_address_handler *handler;
unsigned long flags;
int tcode, destination, source; int tcode, destination, source;
destination = HEADER_GET_DESTINATION(p->header[0]); destination = HEADER_GET_DESTINATION(p->header[0]);
...@@ -835,27 +834,19 @@ static void handle_exclusive_region_request(struct fw_card *card, ...@@ -835,27 +834,19 @@ static void handle_exclusive_region_request(struct fw_card *card,
if (tcode == TCODE_LOCK_REQUEST) if (tcode == TCODE_LOCK_REQUEST)
tcode = 0x10 + HEADER_GET_EXTENDED_TCODE(p->header[3]); tcode = 0x10 + HEADER_GET_EXTENDED_TCODE(p->header[3]);
spin_lock_irqsave(&address_handler_lock, flags); spin_lock_bh(&address_handler_lock);
handler = lookup_enclosing_address_handler(&address_handler_list, handler = lookup_enclosing_address_handler(&address_handler_list,
offset, request->length); offset, request->length);
spin_unlock_irqrestore(&address_handler_lock, flags); if (handler)
/*
* FIXME: lookup the fw_node corresponding to the sender of
* this request and pass that to the address handler instead
* of the node ID. We may also want to move the address
* allocations to fw_node so we only do this callback if the
* upper layers registered it for this node.
*/
if (handler == NULL)
fw_send_response(card, request, RCODE_ADDRESS_ERROR);
else
handler->address_callback(card, request, handler->address_callback(card, request,
tcode, destination, source, tcode, destination, source,
p->generation, offset, p->generation, offset,
request->data, request->length, request->data, request->length,
handler->callback_data); handler->callback_data);
spin_unlock_bh(&address_handler_lock);
if (!handler)
fw_send_response(card, request, RCODE_ADDRESS_ERROR);
} }
static void handle_fcp_region_request(struct fw_card *card, static void handle_fcp_region_request(struct fw_card *card,
...@@ -864,7 +855,6 @@ static void handle_fcp_region_request(struct fw_card *card, ...@@ -864,7 +855,6 @@ static void handle_fcp_region_request(struct fw_card *card,
unsigned long long offset) unsigned long long offset)
{ {
struct fw_address_handler *handler; struct fw_address_handler *handler;
unsigned long flags;
int tcode, destination, source; int tcode, destination, source;
if ((offset != (CSR_REGISTER_BASE | CSR_FCP_COMMAND) && if ((offset != (CSR_REGISTER_BASE | CSR_FCP_COMMAND) &&
...@@ -886,7 +876,7 @@ static void handle_fcp_region_request(struct fw_card *card, ...@@ -886,7 +876,7 @@ static void handle_fcp_region_request(struct fw_card *card,
return; return;
} }
spin_lock_irqsave(&address_handler_lock, flags); spin_lock_bh(&address_handler_lock);
list_for_each_entry(handler, &address_handler_list, link) { list_for_each_entry(handler, &address_handler_list, link) {
if (is_enclosing_handler(handler, offset, request->length)) if (is_enclosing_handler(handler, offset, request->length))
handler->address_callback(card, NULL, tcode, handler->address_callback(card, NULL, tcode,
...@@ -896,7 +886,7 @@ static void handle_fcp_region_request(struct fw_card *card, ...@@ -896,7 +886,7 @@ static void handle_fcp_region_request(struct fw_card *card,
request->length, request->length,
handler->callback_data); handler->callback_data);
} }
spin_unlock_irqrestore(&address_handler_lock, flags); spin_unlock_bh(&address_handler_lock);
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
} }
...@@ -960,7 +950,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) ...@@ -960,7 +950,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
if (&t->link == &card->transaction_list) { if (&t->link == &card->transaction_list) {
timed_out: timed_out:
fw_notify("Unsolicited response (source %x, tlabel %x)\n", fw_notice(card, "unsolicited response (source %x, tlabel %x)\n",
source, tlabel); source, tlabel);
return; return;
} }
......
#ifndef _FIREWIRE_CORE_H #ifndef _FIREWIRE_CORE_H
#define _FIREWIRE_CORE_H #define _FIREWIRE_CORE_H
#include <linux/compiler.h>
#include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/idr.h> #include <linux/idr.h>
...@@ -23,6 +25,11 @@ struct fw_packet; ...@@ -23,6 +25,11 @@ struct fw_packet;
/* -card */ /* -card */
extern __printf(2, 3)
void fw_err(const struct fw_card *card, const char *fmt, ...);
extern __printf(2, 3)
void fw_notice(const struct fw_card *card, const char *fmt, ...);
/* bitfields within the PHY registers */ /* bitfields within the PHY registers */
#define PHY_LINK_ACTIVE 0x80 #define PHY_LINK_ACTIVE 0x80
#define PHY_CONTENDER 0x40 #define PHY_CONTENDER 0x40
...@@ -99,6 +106,8 @@ struct fw_card_driver { ...@@ -99,6 +106,8 @@ struct fw_card_driver {
void (*flush_queue_iso)(struct fw_iso_context *ctx); void (*flush_queue_iso)(struct fw_iso_context *ctx);
int (*flush_iso_completions)(struct fw_iso_context *ctx);
int (*stop_iso)(struct fw_iso_context *ctx); int (*stop_iso)(struct fw_iso_context *ctx);
}; };
...@@ -141,6 +150,18 @@ extern struct rw_semaphore fw_device_rwsem; ...@@ -141,6 +150,18 @@ extern struct rw_semaphore fw_device_rwsem;
extern struct idr fw_device_idr; extern struct idr fw_device_idr;
extern int fw_cdev_major; extern int fw_cdev_major;
static inline struct fw_device *fw_device_get(struct fw_device *device)
{
get_device(&device->device);
return device;
}
static inline void fw_device_put(struct fw_device *device)
{
put_device(&device->device);
}
struct fw_device *fw_device_get_by_devt(dev_t devt); struct fw_device *fw_device_get_by_devt(dev_t devt);
int fw_device_set_broadcast_channel(struct device *dev, void *gen); int fw_device_set_broadcast_channel(struct device *dev, void *gen);
void fw_node_event(struct fw_card *card, struct fw_node *node, int event); void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
......
...@@ -256,8 +256,8 @@ static int fwnet_header_rebuild(struct sk_buff *skb) ...@@ -256,8 +256,8 @@ static int fwnet_header_rebuild(struct sk_buff *skb)
if (get_unaligned_be16(&h->h_proto) == ETH_P_IP) if (get_unaligned_be16(&h->h_proto) == ETH_P_IP)
return arp_find((unsigned char *)&h->h_dest, skb); return arp_find((unsigned char *)&h->h_dest, skb);
fw_notify("%s: unable to resolve type %04x addresses\n", dev_notice(&skb->dev->dev, "unable to resolve type %04x addresses\n",
skb->dev->name, be16_to_cpu(h->h_proto)); be16_to_cpu(h->h_proto));
return 0; return 0;
} }
...@@ -369,7 +369,7 @@ static struct fwnet_fragment_info *fwnet_frag_new( ...@@ -369,7 +369,7 @@ static struct fwnet_fragment_info *fwnet_frag_new(
new = kmalloc(sizeof(*new), GFP_ATOMIC); new = kmalloc(sizeof(*new), GFP_ATOMIC);
if (!new) { if (!new) {
fw_error("out of memory\n"); dev_err(&pd->skb->dev->dev, "out of memory\n");
return NULL; return NULL;
} }
...@@ -414,7 +414,7 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net, ...@@ -414,7 +414,7 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net,
fail_w_new: fail_w_new:
kfree(new); kfree(new);
fail: fail:
fw_error("out of memory\n"); dev_err(&net->dev, "out of memory\n");
return NULL; return NULL;
} }
...@@ -554,7 +554,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net, ...@@ -554,7 +554,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
sspd = arp1394->sspd; sspd = arp1394->sspd;
/* Sanity check. OS X 10.3 PPC reportedly sends 131. */ /* Sanity check. OS X 10.3 PPC reportedly sends 131. */
if (sspd > SCODE_3200) { if (sspd > SCODE_3200) {
fw_notify("sspd %x out of range\n", sspd); dev_notice(&net->dev, "sspd %x out of range\n", sspd);
sspd = SCODE_3200; sspd = SCODE_3200;
} }
max_payload = fwnet_max_payload(arp1394->max_rec, sspd); max_payload = fwnet_max_payload(arp1394->max_rec, sspd);
...@@ -574,8 +574,9 @@ static int fwnet_finish_incoming_packet(struct net_device *net, ...@@ -574,8 +574,9 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
if (!peer) { if (!peer) {
fw_notify("No peer for ARP packet from %016llx\n", dev_notice(&net->dev,
(unsigned long long)peer_guid); "no peer for ARP packet from %016llx\n",
(unsigned long long)peer_guid);
goto no_peer; goto no_peer;
} }
...@@ -691,7 +692,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len, ...@@ -691,7 +692,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
skb = dev_alloc_skb(len + net->hard_header_len + 15); skb = dev_alloc_skb(len + net->hard_header_len + 15);
if (unlikely(!skb)) { if (unlikely(!skb)) {
fw_error("out of memory\n"); dev_err(&net->dev, "out of memory\n");
net->stats.rx_dropped++; net->stats.rx_dropped++;
return -ENOMEM; return -ENOMEM;
...@@ -814,7 +815,7 @@ static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r, ...@@ -814,7 +815,7 @@ static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r,
rcode = RCODE_TYPE_ERROR; rcode = RCODE_TYPE_ERROR;
else if (fwnet_incoming_packet(dev, payload, length, else if (fwnet_incoming_packet(dev, payload, length,
source, generation, false) != 0) { source, generation, false) != 0) {
fw_error("Incoming packet failure\n"); dev_err(&dev->netdev->dev, "incoming packet failure\n");
rcode = RCODE_CONFLICT_ERROR; rcode = RCODE_CONFLICT_ERROR;
} else } else
rcode = RCODE_COMPLETE; rcode = RCODE_COMPLETE;
...@@ -881,7 +882,7 @@ static void fwnet_receive_broadcast(struct fw_iso_context *context, ...@@ -881,7 +882,7 @@ static void fwnet_receive_broadcast(struct fw_iso_context *context,
if (retval >= 0) if (retval >= 0)
fw_iso_context_queue_flush(dev->broadcast_rcv_context); fw_iso_context_queue_flush(dev->broadcast_rcv_context);
else else
fw_error("requeue failed\n"); dev_err(&dev->netdev->dev, "requeue failed\n");
} }
static struct kmem_cache *fwnet_packet_task_cache; static struct kmem_cache *fwnet_packet_task_cache;
...@@ -936,9 +937,10 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask) ...@@ -936,9 +937,10 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
case RFC2374_HDR_LASTFRAG: case RFC2374_HDR_LASTFRAG:
case RFC2374_HDR_UNFRAG: case RFC2374_HDR_UNFRAG:
default: default:
fw_error("Outstanding packet %x lf %x, header %x,%x\n", dev_err(&dev->netdev->dev,
ptask->outstanding_pkts, lf, ptask->hdr.w0, "outstanding packet %x lf %x, header %x,%x\n",
ptask->hdr.w1); ptask->outstanding_pkts, lf, ptask->hdr.w0,
ptask->hdr.w1);
BUG(); BUG();
case RFC2374_HDR_FIRSTFRAG: case RFC2374_HDR_FIRSTFRAG:
...@@ -1010,8 +1012,9 @@ static void fwnet_write_complete(struct fw_card *card, int rcode, ...@@ -1010,8 +1012,9 @@ static void fwnet_write_complete(struct fw_card *card, int rcode,
fwnet_transmit_packet_failed(ptask); fwnet_transmit_packet_failed(ptask);
if (printk_timed_ratelimit(&j, 1000) || rcode != last_rcode) { if (printk_timed_ratelimit(&j, 1000) || rcode != last_rcode) {
fw_error("fwnet_write_complete: " dev_err(&ptask->dev->netdev->dev,
"failed: %x (skipped %d)\n", rcode, errors_skipped); "fwnet_write_complete failed: %x (skipped %d)\n",
rcode, errors_skipped);
errors_skipped = 0; errors_skipped = 0;
last_rcode = rcode; last_rcode = rcode;
...@@ -1539,14 +1542,12 @@ static int fwnet_probe(struct device *_dev) ...@@ -1539,14 +1542,12 @@ static int fwnet_probe(struct device *_dev)
put_unaligned_be64(card->guid, net->dev_addr); put_unaligned_be64(card->guid, net->dev_addr);
put_unaligned_be64(~0ULL, net->broadcast); put_unaligned_be64(~0ULL, net->broadcast);
ret = register_netdev(net); ret = register_netdev(net);
if (ret) { if (ret)
fw_error("Cannot register the driver\n");
goto out; goto out;
}
list_add_tail(&dev->dev_link, &fwnet_device_list); list_add_tail(&dev->dev_link, &fwnet_device_list);
fw_notify("%s: IPv4 over FireWire on device %016llx\n", dev_notice(&net->dev, "IPv4 over IEEE 1394 on card %s\n",
net->name, (unsigned long long)card->guid); dev_name(card->device));
have_dev: have_dev:
ret = fwnet_add_peer(dev, unit, device); ret = fwnet_add_peer(dev, unit, device);
if (ret && allocated_netdev) { if (ret && allocated_netdev) {
...@@ -1648,7 +1649,7 @@ static const struct ieee1394_device_id fwnet_id_table[] = { ...@@ -1648,7 +1649,7 @@ static const struct ieee1394_device_id fwnet_id_table[] = {
static struct fw_driver fwnet_driver = { static struct fw_driver fwnet_driver = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "net", .name = KBUILD_MODNAME,
.bus = &fw_bus_type, .bus = &fw_bus_type,
.probe = fwnet_probe, .probe = fwnet_probe,
.remove = fwnet_remove, .remove = fwnet_remove,
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <linux/timex.h> #include <linux/timex.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/dma-mapping.h>
#include <linux/atomic.h> #include <linux/atomic.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -536,7 +536,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused) ...@@ -536,7 +536,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
u32 p, end; u32 p, end;
int ret, i; int ret, i;
if (pci_set_dma_mask(dev, 0xffffffff)) { if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) {
dev_err(&dev->dev, dev_err(&dev->dev,
"DMA address limits not supported for PCILynx hardware\n"); "DMA address limits not supported for PCILynx hardware\n");
return -ENXIO; return -ENXIO;
......
此差异已折叠。
...@@ -125,8 +125,6 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0" ...@@ -125,8 +125,6 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
", or a combination)"); ", or a combination)");
static const char sbp2_driver_name[] = "sbp2";
/* /*
* We create one struct sbp2_logical_unit per SBP-2 Logical Unit Number Entry * We create one struct sbp2_logical_unit per SBP-2 Logical Unit Number Entry
* and one struct scsi_device per sbp2_logical_unit. * and one struct scsi_device per sbp2_logical_unit.
...@@ -165,7 +163,6 @@ static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay) ...@@ -165,7 +163,6 @@ static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay)
*/ */
struct sbp2_target { struct sbp2_target {
struct fw_unit *unit; struct fw_unit *unit;
const char *bus_id;
struct list_head lu_list; struct list_head lu_list;
u64 management_agent_address; u64 management_agent_address;
...@@ -181,11 +178,21 @@ struct sbp2_target { ...@@ -181,11 +178,21 @@ struct sbp2_target {
int blocked; /* ditto */ int blocked; /* ditto */
}; };
static struct fw_device *target_device(struct sbp2_target *tgt) static struct fw_device *target_parent_device(struct sbp2_target *tgt)
{ {
return fw_parent_device(tgt->unit); return fw_parent_device(tgt->unit);
} }
static const struct device *tgt_dev(const struct sbp2_target *tgt)
{
return &tgt->unit->device;
}
static const struct device *lu_dev(const struct sbp2_logical_unit *lu)
{
return &lu->tgt->unit->device;
}
/* Impossible login_id, to detect logout attempt before successful login */ /* Impossible login_id, to detect logout attempt before successful login */
#define INVALID_LOGIN_ID 0x10000 #define INVALID_LOGIN_ID 0x10000
...@@ -211,6 +218,7 @@ static struct fw_device *target_device(struct sbp2_target *tgt) ...@@ -211,6 +218,7 @@ static struct fw_device *target_device(struct sbp2_target *tgt)
#define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a #define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a
#define SBP2_CSR_FIRMWARE_REVISION 0x3c #define SBP2_CSR_FIRMWARE_REVISION 0x3c
#define SBP2_CSR_LOGICAL_UNIT_NUMBER 0x14 #define SBP2_CSR_LOGICAL_UNIT_NUMBER 0x14
#define SBP2_CSR_UNIT_UNIQUE_ID 0x8d
#define SBP2_CSR_LOGICAL_UNIT_DIRECTORY 0xd4 #define SBP2_CSR_LOGICAL_UNIT_DIRECTORY 0xd4
/* Management orb opcodes */ /* Management orb opcodes */
...@@ -430,7 +438,8 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request, ...@@ -430,7 +438,8 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
memcpy(status.data, payload + 8, length - 8); memcpy(status.data, payload + 8, length - 8);
if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) { if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
fw_notify("non-orb related status write, not handled\n"); dev_notice(lu_dev(lu),
"non-ORB related status write, not handled\n");
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
return; return;
} }
...@@ -451,7 +460,7 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request, ...@@ -451,7 +460,7 @@ static void sbp2_status_write(struct fw_card *card, struct fw_request *request,
orb->callback(orb, &status); orb->callback(orb, &status);
kref_put(&orb->kref, free_orb); /* orb callback reference */ kref_put(&orb->kref, free_orb); /* orb callback reference */
} else { } else {
fw_error("status write for unknown orb\n"); dev_err(lu_dev(lu), "status write for unknown ORB\n");
} }
fw_send_response(card, request, RCODE_COMPLETE); fw_send_response(card, request, RCODE_COMPLETE);
...@@ -492,7 +501,7 @@ static void complete_transaction(struct fw_card *card, int rcode, ...@@ -492,7 +501,7 @@ static void complete_transaction(struct fw_card *card, int rcode,
static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
int node_id, int generation, u64 offset) int node_id, int generation, u64 offset)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
struct sbp2_pointer orb_pointer; struct sbp2_pointer orb_pointer;
unsigned long flags; unsigned long flags;
...@@ -513,7 +522,7 @@ static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, ...@@ -513,7 +522,7 @@ static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
struct sbp2_orb *orb, *next; struct sbp2_orb *orb, *next;
struct list_head list; struct list_head list;
unsigned long flags; unsigned long flags;
...@@ -552,7 +561,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, ...@@ -552,7 +561,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
int generation, int function, int generation, int function,
int lun_or_login_id, void *response) int lun_or_login_id, void *response)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
struct sbp2_management_orb *orb; struct sbp2_management_orb *orb;
unsigned int timeout; unsigned int timeout;
int retval = -ENOMEM; int retval = -ENOMEM;
...@@ -560,7 +569,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, ...@@ -560,7 +569,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
if (function == SBP2_LOGOUT_REQUEST && fw_device_is_shutdown(device)) if (function == SBP2_LOGOUT_REQUEST && fw_device_is_shutdown(device))
return 0; return 0;
orb = kzalloc(sizeof(*orb), GFP_ATOMIC); orb = kzalloc(sizeof(*orb), GFP_NOIO);
if (orb == NULL) if (orb == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -612,20 +621,20 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, ...@@ -612,20 +621,20 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
retval = -EIO; retval = -EIO;
if (sbp2_cancel_orbs(lu) == 0) { if (sbp2_cancel_orbs(lu) == 0) {
fw_error("%s: orb reply timed out, rcode=0x%02x\n", dev_err(lu_dev(lu), "ORB reply timed out, rcode 0x%02x\n",
lu->tgt->bus_id, orb->base.rcode); orb->base.rcode);
goto out; goto out;
} }
if (orb->base.rcode != RCODE_COMPLETE) { if (orb->base.rcode != RCODE_COMPLETE) {
fw_error("%s: management write failed, rcode 0x%02x\n", dev_err(lu_dev(lu), "management write failed, rcode 0x%02x\n",
lu->tgt->bus_id, orb->base.rcode); orb->base.rcode);
goto out; goto out;
} }
if (STATUS_GET_RESPONSE(orb->status) != 0 || if (STATUS_GET_RESPONSE(orb->status) != 0 ||
STATUS_GET_SBP_STATUS(orb->status) != 0) { STATUS_GET_SBP_STATUS(orb->status) != 0) {
fw_error("%s: error status: %d:%d\n", lu->tgt->bus_id, dev_err(lu_dev(lu), "error status: %d:%d\n",
STATUS_GET_RESPONSE(orb->status), STATUS_GET_RESPONSE(orb->status),
STATUS_GET_SBP_STATUS(orb->status)); STATUS_GET_SBP_STATUS(orb->status));
goto out; goto out;
...@@ -648,7 +657,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, ...@@ -648,7 +657,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
static void sbp2_agent_reset(struct sbp2_logical_unit *lu) static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
__be32 d = 0; __be32 d = 0;
fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
...@@ -665,7 +674,7 @@ static void complete_agent_reset_write_no_wait(struct fw_card *card, ...@@ -665,7 +674,7 @@ static void complete_agent_reset_write_no_wait(struct fw_card *card,
static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
struct fw_transaction *t; struct fw_transaction *t;
static __be32 d; static __be32 d;
...@@ -704,7 +713,7 @@ static inline void sbp2_allow_block(struct sbp2_logical_unit *lu) ...@@ -704,7 +713,7 @@ static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
static void sbp2_conditionally_block(struct sbp2_logical_unit *lu) static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
{ {
struct sbp2_target *tgt = lu->tgt; struct sbp2_target *tgt = lu->tgt;
struct fw_card *card = target_device(tgt)->card; struct fw_card *card = target_parent_device(tgt)->card;
struct Scsi_Host *shost = struct Scsi_Host *shost =
container_of((void *)tgt, struct Scsi_Host, hostdata[0]); container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
unsigned long flags; unsigned long flags;
...@@ -728,7 +737,7 @@ static void sbp2_conditionally_block(struct sbp2_logical_unit *lu) ...@@ -728,7 +737,7 @@ static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu) static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
{ {
struct sbp2_target *tgt = lu->tgt; struct sbp2_target *tgt = lu->tgt;
struct fw_card *card = target_device(tgt)->card; struct fw_card *card = target_parent_device(tgt)->card;
struct Scsi_Host *shost = struct Scsi_Host *shost =
container_of((void *)tgt, struct Scsi_Host, hostdata[0]); container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
unsigned long flags; unsigned long flags;
...@@ -753,7 +762,7 @@ static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu) ...@@ -753,7 +762,7 @@ static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
*/ */
static void sbp2_unblock(struct sbp2_target *tgt) static void sbp2_unblock(struct sbp2_target *tgt)
{ {
struct fw_card *card = target_device(tgt)->card; struct fw_card *card = target_parent_device(tgt)->card;
struct Scsi_Host *shost = struct Scsi_Host *shost =
container_of((void *)tgt, struct Scsi_Host, hostdata[0]); container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
unsigned long flags; unsigned long flags;
...@@ -794,7 +803,7 @@ static int sbp2_lun2int(u16 lun) ...@@ -794,7 +803,7 @@ static int sbp2_lun2int(u16 lun)
*/ */
static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
{ {
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
__be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
...@@ -809,7 +818,7 @@ static void sbp2_login(struct work_struct *work) ...@@ -809,7 +818,7 @@ static void sbp2_login(struct work_struct *work)
struct sbp2_logical_unit *lu = struct sbp2_logical_unit *lu =
container_of(work, struct sbp2_logical_unit, work.work); container_of(work, struct sbp2_logical_unit, work.work);
struct sbp2_target *tgt = lu->tgt; struct sbp2_target *tgt = lu->tgt;
struct fw_device *device = target_device(tgt); struct fw_device *device = target_parent_device(tgt);
struct Scsi_Host *shost; struct Scsi_Host *shost;
struct scsi_device *sdev; struct scsi_device *sdev;
struct sbp2_login_response response; struct sbp2_login_response response;
...@@ -833,8 +842,8 @@ static void sbp2_login(struct work_struct *work) ...@@ -833,8 +842,8 @@ static void sbp2_login(struct work_struct *work)
if (lu->retries++ < 5) { if (lu->retries++ < 5) {
sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
} else { } else {
fw_error("%s: failed to login to LUN %04x\n", dev_err(tgt_dev(tgt), "failed to login to LUN %04x\n",
tgt->bus_id, lu->lun); lu->lun);
/* Let any waiting I/O fail from now on. */ /* Let any waiting I/O fail from now on. */
sbp2_unblock(lu->tgt); sbp2_unblock(lu->tgt);
} }
...@@ -851,8 +860,8 @@ static void sbp2_login(struct work_struct *work) ...@@ -851,8 +860,8 @@ static void sbp2_login(struct work_struct *work)
<< 32) | be32_to_cpu(response.command_block_agent.low); << 32) | be32_to_cpu(response.command_block_agent.low);
lu->login_id = be32_to_cpu(response.misc) & 0xffff; lu->login_id = be32_to_cpu(response.misc) & 0xffff;
fw_notify("%s: logged in to LUN %04x (%d retries)\n", dev_notice(tgt_dev(tgt), "logged in to LUN %04x (%d retries)\n",
tgt->bus_id, lu->lun, lu->retries); lu->lun, lu->retries);
/* set appropriate retry limit(s) in BUSY_TIMEOUT register */ /* set appropriate retry limit(s) in BUSY_TIMEOUT register */
sbp2_set_busy_timeout(lu); sbp2_set_busy_timeout(lu);
...@@ -919,7 +928,7 @@ static void sbp2_reconnect(struct work_struct *work) ...@@ -919,7 +928,7 @@ static void sbp2_reconnect(struct work_struct *work)
struct sbp2_logical_unit *lu = struct sbp2_logical_unit *lu =
container_of(work, struct sbp2_logical_unit, work.work); container_of(work, struct sbp2_logical_unit, work.work);
struct sbp2_target *tgt = lu->tgt; struct sbp2_target *tgt = lu->tgt;
struct fw_device *device = target_device(tgt); struct fw_device *device = target_parent_device(tgt);
int generation, node_id, local_node_id; int generation, node_id, local_node_id;
if (fw_device_is_shutdown(device)) if (fw_device_is_shutdown(device))
...@@ -943,7 +952,7 @@ static void sbp2_reconnect(struct work_struct *work) ...@@ -943,7 +952,7 @@ static void sbp2_reconnect(struct work_struct *work)
smp_rmb(); /* get current card generation */ smp_rmb(); /* get current card generation */
if (generation == device->card->generation || if (generation == device->card->generation ||
lu->retries++ >= 5) { lu->retries++ >= 5) {
fw_error("%s: failed to reconnect\n", tgt->bus_id); dev_err(tgt_dev(tgt), "failed to reconnect\n");
lu->retries = 0; lu->retries = 0;
PREPARE_DELAYED_WORK(&lu->work, sbp2_login); PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
} }
...@@ -957,8 +966,8 @@ static void sbp2_reconnect(struct work_struct *work) ...@@ -957,8 +966,8 @@ static void sbp2_reconnect(struct work_struct *work)
smp_wmb(); /* node IDs must not be older than generation */ smp_wmb(); /* node IDs must not be older than generation */
lu->generation = generation; lu->generation = generation;
fw_notify("%s: reconnected to LUN %04x (%d retries)\n", dev_notice(tgt_dev(tgt), "reconnected to LUN %04x (%d retries)\n",
tgt->bus_id, lu->lun, lu->retries); lu->lun, lu->retries);
sbp2_agent_reset(lu); sbp2_agent_reset(lu);
sbp2_cancel_orbs(lu); sbp2_cancel_orbs(lu);
...@@ -997,6 +1006,13 @@ static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry) ...@@ -997,6 +1006,13 @@ static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry)
return 0; return 0;
} }
static void sbp2_get_unit_unique_id(struct sbp2_target *tgt,
const u32 *leaf)
{
if ((leaf[0] & 0xffff0000) == 0x00020000)
tgt->guid = (u64)leaf[1] << 32 | leaf[2];
}
static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt, static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt,
const u32 *directory) const u32 *directory)
{ {
...@@ -1048,6 +1064,10 @@ static int sbp2_scan_unit_dir(struct sbp2_target *tgt, const u32 *directory, ...@@ -1048,6 +1064,10 @@ static int sbp2_scan_unit_dir(struct sbp2_target *tgt, const u32 *directory,
return -ENOMEM; return -ENOMEM;
break; break;
case SBP2_CSR_UNIT_UNIQUE_ID:
sbp2_get_unit_unique_id(tgt, ci.p - 1 + value);
break;
case SBP2_CSR_LOGICAL_UNIT_DIRECTORY: case SBP2_CSR_LOGICAL_UNIT_DIRECTORY:
/* Adjust for the increment in the iterator */ /* Adjust for the increment in the iterator */
if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0) if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0)
...@@ -1068,8 +1088,8 @@ static void sbp2_clamp_management_orb_timeout(struct sbp2_target *tgt) ...@@ -1068,8 +1088,8 @@ static void sbp2_clamp_management_orb_timeout(struct sbp2_target *tgt)
unsigned int timeout = tgt->mgt_orb_timeout; unsigned int timeout = tgt->mgt_orb_timeout;
if (timeout > 40000) if (timeout > 40000)
fw_notify("%s: %ds mgt_ORB_timeout limited to 40s\n", dev_notice(tgt_dev(tgt), "%ds mgt_ORB_timeout limited to 40s\n",
tgt->bus_id, timeout / 1000); timeout / 1000);
tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000); tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000);
} }
...@@ -1081,9 +1101,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model, ...@@ -1081,9 +1101,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
unsigned int w = sbp2_param_workarounds; unsigned int w = sbp2_param_workarounds;
if (w) if (w)
fw_notify("Please notify linux1394-devel@lists.sourceforge.net " dev_notice(tgt_dev(tgt),
"if you need the workarounds parameter for %s\n", "Please notify linux1394-devel@lists.sf.net "
tgt->bus_id); "if you need the workarounds parameter\n");
if (w & SBP2_WORKAROUND_OVERRIDE) if (w & SBP2_WORKAROUND_OVERRIDE)
goto out; goto out;
...@@ -1103,9 +1123,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model, ...@@ -1103,9 +1123,9 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
} }
out: out:
if (w) if (w)
fw_notify("Workarounds for %s: 0x%x " dev_notice(tgt_dev(tgt), "workarounds 0x%x "
"(firmware_revision 0x%06x, model_id 0x%06x)\n", "(firmware_revision 0x%06x, model_id 0x%06x)\n",
tgt->bus_id, w, firmware_revision, model); w, firmware_revision, model);
tgt->workarounds = w; tgt->workarounds = w;
} }
...@@ -1121,6 +1141,10 @@ static int sbp2_probe(struct device *dev) ...@@ -1121,6 +1141,10 @@ static int sbp2_probe(struct device *dev)
struct Scsi_Host *shost; struct Scsi_Host *shost;
u32 model, firmware_revision; u32 model, firmware_revision;
/* cannot (or should not) handle targets on the local node */
if (device->is_local)
return -ENODEV;
if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE) if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE)
BUG_ON(dma_set_max_seg_size(device->card->device, BUG_ON(dma_set_max_seg_size(device->card->device,
SBP2_MAX_SEG_SIZE)); SBP2_MAX_SEG_SIZE));
...@@ -1133,7 +1157,6 @@ static int sbp2_probe(struct device *dev) ...@@ -1133,7 +1157,6 @@ static int sbp2_probe(struct device *dev)
dev_set_drvdata(&unit->device, tgt); dev_set_drvdata(&unit->device, tgt);
tgt->unit = unit; tgt->unit = unit;
INIT_LIST_HEAD(&tgt->lu_list); INIT_LIST_HEAD(&tgt->lu_list);
tgt->bus_id = dev_name(&unit->device);
tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4]; tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
if (fw_device_enable_phys_dma(device) < 0) if (fw_device_enable_phys_dma(device) < 0)
...@@ -1239,7 +1262,7 @@ static int sbp2_remove(struct device *dev) ...@@ -1239,7 +1262,7 @@ static int sbp2_remove(struct device *dev)
kfree(lu); kfree(lu);
} }
scsi_remove_host(shost); scsi_remove_host(shost);
fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no); dev_notice(dev, "released target %d:0:0\n", shost->host_no);
scsi_host_put(shost); scsi_host_put(shost);
return 0; return 0;
...@@ -1261,7 +1284,7 @@ static const struct ieee1394_device_id sbp2_id_table[] = { ...@@ -1261,7 +1284,7 @@ static const struct ieee1394_device_id sbp2_id_table[] = {
static struct fw_driver sbp2_driver = { static struct fw_driver sbp2_driver = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = sbp2_driver_name, .name = KBUILD_MODNAME,
.bus = &fw_bus_type, .bus = &fw_bus_type,
.probe = sbp2_probe, .probe = sbp2_probe,
.remove = sbp2_remove, .remove = sbp2_remove,
...@@ -1286,10 +1309,19 @@ static void sbp2_unmap_scatterlist(struct device *card_device, ...@@ -1286,10 +1309,19 @@ static void sbp2_unmap_scatterlist(struct device *card_device,
static unsigned int sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) static unsigned int sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
{ {
int sam_status; int sam_status;
int sfmt = (sbp2_status[0] >> 6) & 0x03;
if (sfmt == 2 || sfmt == 3) {
/*
* Reserved for future standardization (2) or
* Status block format vendor-dependent (3)
*/
return DID_ERROR << 16;
}
sense_data[0] = 0x70; sense_data[0] = 0x70 | sfmt | (sbp2_status[1] & 0x80);
sense_data[1] = 0x0; sense_data[1] = 0x0;
sense_data[2] = sbp2_status[1]; sense_data[2] = ((sbp2_status[1] << 1) & 0xe0) | (sbp2_status[1] & 0x0f);
sense_data[3] = sbp2_status[4]; sense_data[3] = sbp2_status[4];
sense_data[4] = sbp2_status[5]; sense_data[4] = sbp2_status[5];
sense_data[5] = sbp2_status[6]; sense_data[5] = sbp2_status[6];
...@@ -1325,7 +1357,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb, ...@@ -1325,7 +1357,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
{ {
struct sbp2_command_orb *orb = struct sbp2_command_orb *orb =
container_of(base_orb, struct sbp2_command_orb, base); container_of(base_orb, struct sbp2_command_orb, base);
struct fw_device *device = target_device(orb->lu->tgt); struct fw_device *device = target_parent_device(orb->lu->tgt);
int result; int result;
if (status != NULL) { if (status != NULL) {
...@@ -1433,7 +1465,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost, ...@@ -1433,7 +1465,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
struct scsi_cmnd *cmd) struct scsi_cmnd *cmd)
{ {
struct sbp2_logical_unit *lu = cmd->device->hostdata; struct sbp2_logical_unit *lu = cmd->device->hostdata;
struct fw_device *device = target_device(lu->tgt); struct fw_device *device = target_parent_device(lu->tgt);
struct sbp2_command_orb *orb; struct sbp2_command_orb *orb;
int generation, retval = SCSI_MLQUEUE_HOST_BUSY; int generation, retval = SCSI_MLQUEUE_HOST_BUSY;
...@@ -1442,7 +1474,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost, ...@@ -1442,7 +1474,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
* transfer direction not handled. * transfer direction not handled.
*/ */
if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) { if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n"); dev_err(lu_dev(lu), "cannot handle bidirectional command\n");
cmd->result = DID_ERROR << 16; cmd->result = DID_ERROR << 16;
cmd->scsi_done(cmd); cmd->scsi_done(cmd);
return 0; return 0;
...@@ -1450,7 +1482,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost, ...@@ -1450,7 +1482,7 @@ static int sbp2_scsi_queuecommand(struct Scsi_Host *shost,
orb = kzalloc(sizeof(*orb), GFP_ATOMIC); orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
if (orb == NULL) { if (orb == NULL) {
fw_notify("failed to alloc orb\n"); dev_notice(lu_dev(lu), "failed to alloc ORB\n");
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
...@@ -1550,7 +1582,7 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd) ...@@ -1550,7 +1582,7 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
{ {
struct sbp2_logical_unit *lu = cmd->device->hostdata; struct sbp2_logical_unit *lu = cmd->device->hostdata;
fw_notify("%s: sbp2_scsi_abort\n", lu->tgt->bus_id); dev_notice(lu_dev(lu), "sbp2_scsi_abort\n");
sbp2_agent_reset(lu); sbp2_agent_reset(lu);
sbp2_cancel_orbs(lu); sbp2_cancel_orbs(lu);
...@@ -1590,7 +1622,7 @@ static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { ...@@ -1590,7 +1622,7 @@ static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
static struct scsi_host_template scsi_driver_template = { static struct scsi_host_template scsi_driver_template = {
.module = THIS_MODULE, .module = THIS_MODULE,
.name = "SBP-2 IEEE-1394", .name = "SBP-2 IEEE-1394",
.proc_name = sbp2_driver_name, .proc_name = "sbp2",
.queuecommand = sbp2_scsi_queuecommand, .queuecommand = sbp2_scsi_queuecommand,
.slave_alloc = sbp2_scsi_slave_alloc, .slave_alloc = sbp2_scsi_slave_alloc,
.slave_configure = sbp2_scsi_slave_configure, .slave_configure = sbp2_scsi_slave_configure,
......
...@@ -207,12 +207,16 @@ struct fw_cdev_event_request2 { ...@@ -207,12 +207,16 @@ struct fw_cdev_event_request2 {
* @closure: See &fw_cdev_event_common; * @closure: See &fw_cdev_event_common;
* set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl * set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
* @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
* @cycle: Cycle counter of the interrupt packet * @cycle: Cycle counter of the last completed packet
* @header_length: Total length of following headers, in bytes * @header_length: Total length of following headers, in bytes
* @header: Stripped headers, if any * @header: Stripped headers, if any
* *
* This event is sent when the controller has completed an &fw_cdev_iso_packet * This event is sent when the controller has completed an &fw_cdev_iso_packet
* with the %FW_CDEV_ISO_INTERRUPT bit set. * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with
* %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets
* without the interrupt bit set that the kernel's internal buffer for @header
* is about to overflow. (In the last case, kernels with ABI version < 5 drop
* header data up to the next interrupt packet.)
* *
* Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT): * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT):
* *
...@@ -267,9 +271,9 @@ struct fw_cdev_event_iso_interrupt { ...@@ -267,9 +271,9 @@ struct fw_cdev_event_iso_interrupt {
* *
* This event is sent in multichannel contexts (context type * This event is sent in multichannel contexts (context type
* %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL) for &fw_cdev_iso_packet buffer
* chunks that have the %FW_CDEV_ISO_INTERRUPT bit set. Whether this happens * chunks that have been completely filled and that have the
* when a packet is completed and/or when a buffer chunk is completed depends * %FW_CDEV_ISO_INTERRUPT bit set, or when explicitly requested with
* on the hardware implementation. * %FW_CDEV_IOC_FLUSH_ISO.
* *
* The buffer is continuously filled with the following data, per packet: * The buffer is continuously filled with the following data, per packet:
* - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt, * - the 1394 iso packet header as described at &fw_cdev_event_iso_interrupt,
...@@ -419,6 +423,9 @@ union fw_cdev_event { ...@@ -419,6 +423,9 @@ union fw_cdev_event {
#define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets) #define FW_CDEV_IOC_RECEIVE_PHY_PACKETS _IOW('#', 0x16, struct fw_cdev_receive_phy_packets)
#define FW_CDEV_IOC_SET_ISO_CHANNELS _IOW('#', 0x17, struct fw_cdev_set_iso_channels) #define FW_CDEV_IOC_SET_ISO_CHANNELS _IOW('#', 0x17, struct fw_cdev_set_iso_channels)
/* available since kernel version 3.4 */
#define FW_CDEV_IOC_FLUSH_ISO _IOW('#', 0x18, struct fw_cdev_flush_iso)
/* /*
* ABI version history * ABI version history
* 1 (2.6.22) - initial version * 1 (2.6.22) - initial version
...@@ -441,6 +448,9 @@ union fw_cdev_event { ...@@ -441,6 +448,9 @@ union fw_cdev_event {
* - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL, * - added %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL,
* %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and
* %FW_CDEV_IOC_SET_ISO_CHANNELS * %FW_CDEV_IOC_SET_ISO_CHANNELS
* 5 (3.4) - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to
* avoid dropping data
* - added %FW_CDEV_IOC_FLUSH_ISO
*/ */
/** /**
...@@ -850,6 +860,25 @@ struct fw_cdev_stop_iso { ...@@ -850,6 +860,25 @@ struct fw_cdev_stop_iso {
__u32 handle; __u32 handle;
}; };
/**
* struct fw_cdev_flush_iso - flush completed iso packets
* @handle: handle of isochronous context to flush
*
* For %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE contexts,
* report any completed packets.
*
* For %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL contexts, report the current
* offset in the receive buffer, if it has changed; this is typically in the
* middle of some buffer chunk.
*
* Any %FW_CDEV_EVENT_ISO_INTERRUPT or %FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL
* events generated by this ioctl are sent synchronously, i.e., are available
* for reading from the file descriptor when this ioctl returns.
*/
struct fw_cdev_flush_iso {
__u32 handle;
};
/** /**
* struct fw_cdev_get_cycle_timer - read cycle timer register * struct fw_cdev_get_cycle_timer - read cycle timer register
* @local_time: system time, in microseconds since the Epoch * @local_time: system time, in microseconds since the Epoch
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
#include <linux/atomic.h> #include <linux/atomic.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args)
#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
#define CSR_REGISTER_BASE 0xfffff0000000ULL #define CSR_REGISTER_BASE 0xfffff0000000ULL
/* register offsets are relative to CSR_REGISTER_BASE */ /* register offsets are relative to CSR_REGISTER_BASE */
...@@ -203,18 +200,6 @@ static inline int fw_device_is_shutdown(struct fw_device *device) ...@@ -203,18 +200,6 @@ static inline int fw_device_is_shutdown(struct fw_device *device)
return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN;
} }
static inline struct fw_device *fw_device_get(struct fw_device *device)
{
get_device(&device->device);
return device;
}
static inline void fw_device_put(struct fw_device *device)
{
put_device(&device->device);
}
int fw_device_enable_phys_dma(struct fw_device *device); int fw_device_enable_phys_dma(struct fw_device *device);
/* /*
...@@ -441,6 +426,7 @@ int fw_iso_context_queue(struct fw_iso_context *ctx, ...@@ -441,6 +426,7 @@ int fw_iso_context_queue(struct fw_iso_context *ctx,
struct fw_iso_buffer *buffer, struct fw_iso_buffer *buffer,
unsigned long payload); unsigned long payload);
void fw_iso_context_queue_flush(struct fw_iso_context *ctx); void fw_iso_context_queue_flush(struct fw_iso_context *ctx);
int fw_iso_context_flush_completions(struct fw_iso_context *ctx);
int fw_iso_context_start(struct fw_iso_context *ctx, int fw_iso_context_start(struct fw_iso_context *ctx,
int cycle, int sync, int tags); int cycle, int sync, int tags);
int fw_iso_context_stop(struct fw_iso_context *ctx); int fw_iso_context_stop(struct fw_iso_context *ctx);
......
...@@ -611,7 +611,6 @@ static void isight_card_free(struct snd_card *card) ...@@ -611,7 +611,6 @@ static void isight_card_free(struct snd_card *card)
fw_iso_resources_destroy(&isight->resources); fw_iso_resources_destroy(&isight->resources);
fw_unit_put(isight->unit); fw_unit_put(isight->unit);
fw_device_put(isight->device);
mutex_destroy(&isight->mutex); mutex_destroy(&isight->mutex);
} }
...@@ -644,7 +643,7 @@ static int isight_probe(struct device *unit_dev) ...@@ -644,7 +643,7 @@ static int isight_probe(struct device *unit_dev)
isight->card = card; isight->card = card;
mutex_init(&isight->mutex); mutex_init(&isight->mutex);
isight->unit = fw_unit_get(unit); isight->unit = fw_unit_get(unit);
isight->device = fw_device_get(fw_dev); isight->device = fw_dev;
isight->audio_base = get_unit_base(unit); isight->audio_base = get_unit_base(unit);
if (!isight->audio_base) { if (!isight->audio_base) {
dev_err(&unit->device, "audio unit base not found\n"); dev_err(&unit->device, "audio unit base not found\n");
...@@ -681,7 +680,6 @@ static int isight_probe(struct device *unit_dev) ...@@ -681,7 +680,6 @@ static int isight_probe(struct device *unit_dev)
err_unit: err_unit:
fw_unit_put(isight->unit); fw_unit_put(isight->unit);
fw_device_put(isight->device);
mutex_destroy(&isight->mutex); mutex_destroy(&isight->mutex);
error: error:
snd_card_free(card); snd_card_free(card);
......
...@@ -656,12 +656,10 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit) ...@@ -656,12 +656,10 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit)
static void fwspk_card_free(struct snd_card *card) static void fwspk_card_free(struct snd_card *card)
{ {
struct fwspk *fwspk = card->private_data; struct fwspk *fwspk = card->private_data;
struct fw_device *dev = fw_parent_device(fwspk->unit);
amdtp_out_stream_destroy(&fwspk->stream); amdtp_out_stream_destroy(&fwspk->stream);
cmp_connection_destroy(&fwspk->connection); cmp_connection_destroy(&fwspk->connection);
fw_unit_put(fwspk->unit); fw_unit_put(fwspk->unit);
fw_device_put(dev);
mutex_destroy(&fwspk->mutex); mutex_destroy(&fwspk->mutex);
} }
...@@ -718,7 +716,6 @@ static int __devinit fwspk_probe(struct device *unit_dev) ...@@ -718,7 +716,6 @@ static int __devinit fwspk_probe(struct device *unit_dev)
fwspk = card->private_data; fwspk = card->private_data;
fwspk->card = card; fwspk->card = card;
mutex_init(&fwspk->mutex); mutex_init(&fwspk->mutex);
fw_device_get(fw_dev);
fwspk->unit = fw_unit_get(unit); fwspk->unit = fw_unit_get(unit);
fwspk->device_info = fwspk_detect(fw_dev); fwspk->device_info = fwspk_detect(fw_dev);
if (!fwspk->device_info) { if (!fwspk->device_info) {
...@@ -767,7 +764,6 @@ static int __devinit fwspk_probe(struct device *unit_dev) ...@@ -767,7 +764,6 @@ static int __devinit fwspk_probe(struct device *unit_dev)
cmp_connection_destroy(&fwspk->connection); cmp_connection_destroy(&fwspk->connection);
err_unit: err_unit:
fw_unit_put(fwspk->unit); fw_unit_put(fwspk->unit);
fw_device_put(fw_dev);
mutex_destroy(&fwspk->mutex); mutex_destroy(&fwspk->mutex);
error: error:
snd_card_free(card); snd_card_free(card);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册