GIT a3d08165feaefb8bd5b294d5f464e30b904566a0 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git commit Author: Stefan Richter Date: Sun Jul 29 00:01:35 2007 +0200 ieee1394: pcilynx: superfluous local variables Signed-off-by: Stefan Richter commit 05495f9042c5aeed5d17f29531bc637e75c399f0 Author: Stefan Richter Date: Sat Jul 28 23:45:03 2007 +0200 ieee1394: eth1394: fix lock imbalance bad_proto can be reached from points which did not take priv->lock. Signed-off-by: Stefan Richter commit 9fc5fd1a634bf3ddb2bfc077b341d044e2b666de Author: Stefan Richter Date: Sat Jul 28 23:44:25 2007 +0200 ieee1394: eth1394: superfluous local variable Signed-off-by: Stefan Richter commit a2354f71f88568c2fb295664c6a80d89b93324bb Author: Stefan Richter Date: Sun Jul 29 20:40:04 2007 +0200 firewire: fw-core: shrink the init function by 208 bytes on x86-64, 112 bytes on i586. Signed-off-by: Stefan Richter commit 52c32d15ad031b8a3d8e5e119792609a6721d47d Author: Stefan Richter Date: Sun Jul 29 20:40:04 2007 +0200 firewire: fw-core: make two variables static Signed-off-by: Stefan Richter commit ab0f04efa6fa31b485424e28a3661ce764194367 Author: Stefan Richter Date: Thu Jul 26 01:43:40 2007 +0200 firewire: fw-sbp2: remove some log messages Signed-off-by: Stefan Richter commit ed6a36016077d831b92f8a775f340a96aa4960f5 Author: Stefan Richter Date: Sun Jul 29 19:40:07 2007 +0200 firewire: fw-sbp2: add support for multiple logical units per target This makes multiple logical units on a single target accessible to fw-sbp2. Successfully tested with the IOI FWB-IDE01AB dual LU bridge. Signed-off-by: Stefan Richter commit a8b974f5e01aba031a767a28616d439bb5be94cd Author: Stefan Richter Date: Sun Jul 29 03:04:15 2007 +0200 firewire: fw-sbp2: split logical unit data from target data struct sbp2_device is replaced by struct sbp2_target and struct sbp2_logical_unit. This prepares support of multiple logical units per target. Signed-off-by: Stefan Richter commit a2fb3f0b42e9d0012fe0036b8f8d4371ba4b858b Author: Stefan Richter Date: Sun Jul 29 03:03:07 2007 +0200 firewire: fw-sbp2: use one Scsi_Host for all targets This rework prepares support of multiple logical units per target. Instead of one instance of struct Scsi_Host per target, only one Scsi_Host global to fw-sbp2 is now used. We could also use one Scsi_Host per FireWire host, but that would add more overhead for no real benefit. The following user-visible changes result: - The generic device of the Scsi_Host is registered as a platform device. Hence it and the target devices and logical unit devices will be sitting below /sys/devices/platform/host*/ rather than within the PCI devices tree. - In the SCSI stack's H:C:T:L tuple, the H is now constant for all fw-sbp2 devices but the T is unique. We currently allocate T as stupidly as the H was allocated before: It is simply increased whenever a target is added. Neither of these changes should affect userspace, because none of the mentioned device properties have been of any interest to userspace before. Signed-off-by: Stefan Richter commit 1fbbb13a05fdc8cf8e778aa834d2e31e68193ee4 Author: Stefan Richter Date: Thu Jul 26 01:38:39 2007 +0200 firewire: remove unused macros Signed-off-by: Stefan Richter commit d9b6313c4d390dc6f4388c07d40ce0d606258458 Author: Stefan Richter Date: Sun Jul 29 01:50:37 2007 +0200 firewire: fw-sbp2: sanitize list handling - The ORB list iteration unsafely removed list items under itself. - The "ORB found" logic relied on implementation details of list_for_each_entry and was unreadable. Signed-off-by: Stefan Richter commit 644f24f97935b8de286eb6f6e6a2e67251958ce0 Author: Stefan Richter Date: Wed Jul 25 19:18:08 2007 +0200 firewire: fw-ohci: dma_free_coherent needs IRQs enabled Signed-off-by: Stefan Richter commit 5b402b97b6f98823f5950ca61d850f552ff042c9 Author: Stefan Richter Date: Sat Jul 21 22:43:05 2007 +0200 firewire: fw-sbp2: set correct maximum payload (fixes CardBus adapters) As far as I know, all CardBus FireWire 400 adapters have a maximum payload of 1024 bytes which is less than the speed-dependent limit of 2048 bytes. Fw-sbp2 has to take the host adapter's limit into account. This apparently fixes Juju's incompatibility with my CardBus cards, a NEC based card and a VIA based card. Signed-off-by: Stefan Richter commit 4e7210a2d7eac65134bcb340bd3814e5adba2c1d Author: Stefan Richter Date: Sat Jul 21 17:51:22 2007 +0200 ieee1394: sbp2: more correct Kconfig dependencies Make the option SBP2_PHYS_DMA available on all architectures where it compiles. This includes x86-64 where I runtime-tested it successfully. Signed-off-by: Stefan Richter commit 62d8f1e2e8efadb6d8f7d9c802adebef98c0081e Author: Stefan Richter Date: Tue Jul 17 02:10:16 2007 +0200 firewire: optimize fw_core_add_address_handler Potentially avoids unnecessary loop runs. Guarantee quadlet-aligned starts of address regions. Document the return values. Signed-off-by: Stefan Richter commit ccfab837384b2f125a2d1c179caf70032cbaecc8 Author: Kristian Høgsberg Date: Tue Jun 5 19:27:05 2007 -0400 firewire: Fix pci resume to not pass in a __be32 config rom. The ohci_enable() function shared between pci_probe and pci_resume takes a host endian config rom, but ohci->config_rom is __be32. This sets up the config rom in the wrong endian on little endian machine, specifically, BusOptions will be initialized to a 0 max receive size. This patch changes the way we reuse the config rom so that we avoid this problem. Signed-off-by: Kristian Hoegsberg Signed-off-by: Stefan Richter drivers/firewire/fw-device.h | 5 drivers/firewire/fw-ohci.c | 53 ++-- drivers/firewire/fw-sbp2.c | 546 +++++++++++++++++++++---------------- drivers/firewire/fw-transaction.c | 33 +- drivers/firewire/fw-transaction.h | 2 drivers/ieee1394/Kconfig | 2 drivers/ieee1394/eth1394.c | 16 - drivers/ieee1394/pcilynx.c | 3 8 files changed, 373 insertions(+), 287 deletions(-) diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index d13e6a6..894d4a9 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h @@ -102,11 +102,6 @@ #define CSR_MODEL 0x17 #define CSR_INSTANCE 0x18 #define CSR_DIRECTORY_ID 0x20 -#define SBP2_COMMAND_SET_SPECIFIER 0x38 -#define SBP2_COMMAND_SET 0x39 -#define SBP2_COMMAND_SET_REVISION 0x3b -#define SBP2_FIRMWARE_REVISION 0x3c - struct fw_csr_iterator { u32 *p; u32 *end; diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index db70375..35b2124 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c @@ -907,6 +907,8 @@ static void bus_reset_tasklet(unsigned l int self_id_count, i, j, reg; int generation, new_generation; unsigned long flags; + void *free_rom = NULL; + dma_addr_t free_rom_bus = 0; reg = reg_read(ohci, OHCI1394_NodeID); if (!(reg & OHCI1394_NodeID_idValid)) { @@ -970,8 +972,10 @@ static void bus_reset_tasklet(unsigned l */ if (ohci->next_config_rom != NULL) { - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - ohci->config_rom, ohci->config_rom_bus); + if (ohci->next_config_rom != ohci->config_rom) { + free_rom = ohci->config_rom; + free_rom_bus = ohci->config_rom_bus; + } ohci->config_rom = ohci->next_config_rom; ohci->config_rom_bus = ohci->next_config_rom_bus; ohci->next_config_rom = NULL; @@ -990,6 +994,10 @@ static void bus_reset_tasklet(unsigned l spin_unlock_irqrestore(&ohci->lock, flags); + if (free_rom) + dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, + free_rom, free_rom_bus); + fw_core_handle_bus_reset(&ohci->card, ohci->node_id, generation, self_id_count, ohci->self_id_buffer); } @@ -1140,19 +1148,30 @@ static int ohci_enable(struct fw_card *c * the right values in the bus reset tasklet. */ - ohci->next_config_rom = - dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, - &ohci->next_config_rom_bus, GFP_KERNEL); - if (ohci->next_config_rom == NULL) - return -ENOMEM; + if (config_rom) { + ohci->next_config_rom = + dma_alloc_coherent(ohci->card.device, CONFIG_ROM_SIZE, + &ohci->next_config_rom_bus, + GFP_KERNEL); + if (ohci->next_config_rom == NULL) + return -ENOMEM; - memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); - fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); + memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); + fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4); + } else { + /* + * In the suspend case, config_rom is NULL, which + * means that we just reuse the old config rom. + */ + ohci->next_config_rom = ohci->config_rom; + ohci->next_config_rom_bus = ohci->config_rom_bus; + } - ohci->next_header = config_rom[0]; + ohci->next_header = be32_to_cpu(ohci->next_config_rom[0]); ohci->next_config_rom[0] = 0; reg_write(ohci, OHCI1394_ConfigROMhdr, 0); - reg_write(ohci, OHCI1394_BusOptions, config_rom[2]); + reg_write(ohci, OHCI1394_BusOptions, + be32_to_cpu(ohci->next_config_rom[2])); reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); reg_write(ohci, OHCI1394_AsReqFilterHiSet, 0x80000000); @@ -1186,7 +1205,7 @@ ohci_set_config_rom(struct fw_card *card { struct fw_ohci *ohci; unsigned long flags; - int retval = 0; + int retval = -EBUSY; __be32 *next_config_rom; dma_addr_t next_config_rom_bus; @@ -1240,10 +1259,7 @@ ohci_set_config_rom(struct fw_card *card reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); - } else { - dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, - next_config_rom, next_config_rom_bus); - retval = -EBUSY; + retval = 0; } spin_unlock_irqrestore(&ohci->lock, flags); @@ -1257,6 +1273,9 @@ ohci_set_config_rom(struct fw_card *card */ if (retval == 0) fw_core_initiate_bus_reset(&ohci->card, 1); + else + dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, + next_config_rom, next_config_rom_bus); return retval; } @@ -1960,7 +1979,7 @@ static int pci_resume(struct pci_dev *pd return err; } - return ohci_enable(&ohci->card, ohci->config_rom, CONFIG_ROM_SIZE); + return ohci_enable(&ohci->card, NULL, 0); } #endif diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 3e4a369..4e0c057 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c @@ -28,6 +28,7 @@ * and many others. */ +#include #include #include #include @@ -39,6 +40,8 @@ #include #include #include +#include + #include #include #include @@ -66,31 +69,41 @@ typedef void (*scsi_done_fn_t)(struct sc static const char sbp2_driver_name[] = "sbp2"; -struct sbp2_device { - struct kref kref; - struct fw_unit *unit; +struct sbp2_logical_unit { + struct sbp2_target *tgt; + struct list_head tgt_list; + struct scsi_device *sdev; struct fw_address_handler address_handler; struct list_head orb_list; - u64 management_agent_address; + u64 command_block_agent_address; - u32 workarounds; + u16 lun; int login_id; /* - * We cache these addresses and only update them once we've - * logged in or reconnected to the sbp2 device. That way, any - * IO to the device will automatically fail and get retried if - * it happens in a window where the device is not ready to - * handle it (e.g. after a bus reset but before we reconnect). + * The generation is updated once we've logged in or reconnected to the + * logical unit. Thus, I/O to the device will automatically fail and + * get retried if it happens in a window where the device is not ready, + * e.g. after a bus reset but before we reconnect. */ - int node_id; - int address_high; int generation; - int retries; struct delayed_work work; }; +struct sbp2_target { + struct kref kref; + struct fw_unit *unit; + + u64 management_agent_address; + int node_id; + int address_high; + + unsigned workarounds; + int starget_id; + struct list_head lu_list; +}; + #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 #define SBP2_MAX_SECTORS 255 /* Max sectors supported */ #define SBP2_ORB_TIMEOUT 2000 /* Timeout in ms */ @@ -101,10 +114,9 @@ #define SBP2_DIRECTION_TO_MEDIA 0x0 #define SBP2_DIRECTION_FROM_MEDIA 0x1 /* Unit directory keys */ -#define SBP2_COMMAND_SET_SPECIFIER 0x38 -#define SBP2_COMMAND_SET 0x39 -#define SBP2_COMMAND_SET_REVISION 0x3b -#define SBP2_FIRMWARE_REVISION 0x3c +#define SBP2_CSR_FIRMWARE_REVISION 0x3c +#define SBP2_CSR_LOGICAL_UNIT_NUMBER 0x14 +#define SBP2_CSR_LOGICAL_UNIT_DIRECTORY 0xd4 /* Flags for detected oddities and brokeness */ #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1 @@ -218,7 +230,7 @@ struct sbp2_command_orb { } request; struct scsi_cmnd *cmd; scsi_done_fn_t done; - struct fw_unit *unit; + struct sbp2_logical_unit *lu; struct sbp2_pointer page_table[SG_ALL] __attribute__((aligned(8))); dma_addr_t page_table_bus; @@ -286,11 +298,12 @@ sbp2_status_write(struct fw_card *card, unsigned long long offset, void *payload, size_t length, void *callback_data) { - struct sbp2_device *sd = callback_data; - struct sbp2_orb *orb; + struct sbp2_logical_unit *lu = callback_data; + struct sbp2_orb *orb, *next; struct sbp2_status status; size_t header_size; unsigned long flags; + bool found = false; if (tcode != TCODE_WRITE_BLOCK_REQUEST || length == 0 || length > sizeof(status)) { @@ -310,17 +323,18 @@ sbp2_status_write(struct fw_card *card, /* Lookup the orb corresponding to this status write. */ spin_lock_irqsave(&card->lock, flags); - list_for_each_entry(orb, &sd->orb_list, link) { + list_for_each_entry_safe(orb, next, &lu->orb_list, link) { if (STATUS_GET_ORB_HIGH(status) == 0 && STATUS_GET_ORB_LOW(status) == orb->request_bus && orb->rcode == RCODE_COMPLETE) { list_del(&orb->link); + found = true; break; } } spin_unlock_irqrestore(&card->lock, flags); - if (&orb->link != &sd->orb_list) + if (found) orb->callback(orb, &status); else fw_error("status write for unknown orb\n"); @@ -345,11 +359,10 @@ complete_transaction(struct fw_card *car } static void -sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit, +sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, int node_id, int generation, u64 offset) { - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd = unit->device.driver_data; + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); unsigned long flags; orb->pointer.high = 0; @@ -357,7 +370,7 @@ sbp2_send_orb(struct sbp2_orb *orb, stru fw_memcpy_to_be32(&orb->pointer, &orb->pointer, sizeof(orb->pointer)); spin_lock_irqsave(&device->card->lock, flags); - list_add_tail(&orb->link, &sd->orb_list); + list_add_tail(&orb->link, &lu->orb_list); spin_unlock_irqrestore(&device->card->lock, flags); fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST, @@ -366,10 +379,9 @@ sbp2_send_orb(struct sbp2_orb *orb, stru complete_transaction, orb); } -static int sbp2_cancel_orbs(struct fw_unit *unit) +static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) { - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd = unit->device.driver_data; + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct sbp2_orb *orb, *next; struct list_head list; unsigned long flags; @@ -377,7 +389,7 @@ static int sbp2_cancel_orbs(struct fw_un INIT_LIST_HEAD(&list); spin_lock_irqsave(&device->card->lock, flags); - list_splice_init(&sd->orb_list, &list); + list_splice_init(&lu->orb_list, &list); spin_unlock_irqrestore(&device->card->lock, flags); list_for_each_entry_safe(orb, next, &list, link) { @@ -404,11 +416,11 @@ complete_management_orb(struct sbp2_orb } static int -sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation, - int function, int lun, void *response) +sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, + int generation, int function, int lun_or_login_id, + void *response) { - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd = unit->device.driver_data; + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct sbp2_management_orb *orb; int retval = -ENOMEM; @@ -428,12 +440,12 @@ sbp2_send_management_orb(struct fw_unit orb->request.misc = MANAGEMENT_ORB_NOTIFY | MANAGEMENT_ORB_FUNCTION(function) | - MANAGEMENT_ORB_LUN(lun); + MANAGEMENT_ORB_LUN(lun_or_login_id); orb->request.length = MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response)); - orb->request.status_fifo.high = sd->address_handler.offset >> 32; - orb->request.status_fifo.low = sd->address_handler.offset; + orb->request.status_fifo.high = lu->address_handler.offset >> 32; + orb->request.status_fifo.low = lu->address_handler.offset; if (function == SBP2_LOGIN_REQUEST) { orb->request.misc |= @@ -452,14 +464,14 @@ sbp2_send_management_orb(struct fw_unit if (dma_mapping_error(orb->base.request_bus)) goto fail_mapping_request; - sbp2_send_orb(&orb->base, unit, - node_id, generation, sd->management_agent_address); + sbp2_send_orb(&orb->base, lu, node_id, generation, + lu->tgt->management_agent_address); wait_for_completion_timeout(&orb->done, msecs_to_jiffies(SBP2_ORB_TIMEOUT)); retval = -EIO; - if (sbp2_cancel_orbs(unit) == 0) { + if (sbp2_cancel_orbs(lu) == 0) { fw_error("orb reply timed out, rcode=0x%02x\n", orb->base.rcode); goto out; @@ -504,10 +516,9 @@ complete_agent_reset_write(struct fw_car kfree(t); } -static int sbp2_agent_reset(struct fw_unit *unit) +static int sbp2_agent_reset(struct sbp2_logical_unit *lu) { - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd = unit->device.driver_data; + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct fw_transaction *t; static u32 zero; @@ -516,165 +527,193 @@ static int sbp2_agent_reset(struct fw_un return -ENOMEM; fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, - sd->node_id, sd->generation, device->max_speed, - sd->command_block_agent_address + SBP2_AGENT_RESET, + lu->tgt->node_id, lu->generation, device->max_speed, + lu->command_block_agent_address + SBP2_AGENT_RESET, &zero, sizeof(zero), complete_agent_reset_write, t); return 0; } -static void sbp2_reconnect(struct work_struct *work); -static struct scsi_host_template scsi_driver_template; - static void release_sbp2_device(struct kref *kref) { - struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref); - struct Scsi_Host *host = - container_of((void *)sd, struct Scsi_Host, hostdata[0]); - - scsi_remove_host(host); - sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation, - SBP2_LOGOUT_REQUEST, sd->login_id, NULL); - fw_core_remove_address_handler(&sd->address_handler); - fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id); - put_device(&sd->unit->device); - scsi_host_put(host); + struct sbp2_target *tgt = container_of(kref, struct sbp2_target, kref); + struct sbp2_logical_unit *lu, *next; + + list_for_each_entry_safe(lu, next, &tgt->lu_list, tgt_list) { + if (lu->sdev) + scsi_remove_device(lu->sdev); + + sbp2_send_management_orb(lu, tgt->node_id, lu->generation, + SBP2_LOGOUT_REQUEST, lu->login_id, NULL); + fw_core_remove_address_handler(&lu->address_handler); + list_del(&lu->tgt_list); + kfree(lu); + } + fw_notify("removed sbp2 unit %s\n", tgt->unit->device.bus_id); + put_device(&tgt->unit->device); + kfree(tgt); } +static void sbp2_reconnect(struct work_struct *work); + +static struct Scsi_Host *sbp2_shost; + static void sbp2_login(struct work_struct *work) { - struct sbp2_device *sd = - container_of(work, struct sbp2_device, work.work); - struct Scsi_Host *host = - container_of((void *)sd, struct Scsi_Host, hostdata[0]); - struct fw_unit *unit = sd->unit; + struct sbp2_logical_unit *lu = + container_of(work, struct sbp2_logical_unit, work.work); + struct fw_unit *unit = lu->tgt->unit; struct fw_device *device = fw_device(unit->device.parent); + int generation = device->card->generation; + int node_id = device->node->node_id; + int local_node_id = device->card->local_node->node_id; + struct scsi_device *sdev; + struct scsi_lun eight_bytes_lun = {{ 0, }}; struct sbp2_login_response response; - int generation, node_id, local_node_id, lun, retval; - - /* FIXME: Make this work for multi-lun devices. */ - lun = 0; - - generation = device->card->generation; - node_id = device->node->node_id; - local_node_id = device->card->local_node->node_id; - if (sbp2_send_management_orb(unit, node_id, generation, - SBP2_LOGIN_REQUEST, lun, &response) < 0) { - if (sd->retries++ < 5) { - schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5)); + if (sbp2_send_management_orb(lu, node_id, generation, + SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) { + if (lu->retries++ < 5) { + schedule_delayed_work(&lu->work, DIV_ROUND_UP(HZ, 5)); } else { - fw_error("failed to login to %s\n", - unit->device.bus_id); - kref_put(&sd->kref, release_sbp2_device); + fw_error("failed to login to %s LUN %04x\n", + unit->device.bus_id, lu->lun); + kref_put(&lu->tgt->kref, release_sbp2_device); } return; } - sd->generation = generation; - sd->node_id = node_id; - sd->address_high = local_node_id << 16; + lu->generation = generation; + lu->tgt->node_id = node_id; + lu->tgt->address_high = local_node_id << 16; /* Get command block agent offset and login id. */ - sd->command_block_agent_address = + lu->command_block_agent_address = ((u64) (response.command_block_agent.high & 0xffff) << 32) | response.command_block_agent.low; - sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response); + lu->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response); - fw_notify("logged in to sbp2 unit %s (%d retries)\n", - unit->device.bus_id, sd->retries); - fw_notify(" - management_agent_address: 0x%012llx\n", - (unsigned long long) sd->management_agent_address); - fw_notify(" - command_block_agent_address: 0x%012llx\n", - (unsigned long long) sd->command_block_agent_address); - fw_notify(" - status write address: 0x%012llx\n", - (unsigned long long) sd->address_handler.offset); + fw_notify("logged in to sbp2 unit %s LUN %04x (%d retries)\n", + unit->device.bus_id, lu->lun, lu->retries); #if 0 /* FIXME: The linux1394 sbp2 does this last step. */ sbp2_set_busy_timeout(scsi_id); #endif - PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect); - sbp2_agent_reset(unit); + PREPARE_DELAYED_WORK(&lu->work, sbp2_reconnect); + sbp2_agent_reset(lu); - /* FIXME: Loop over luns here. */ - lun = 0; - retval = scsi_add_device(host, 0, 0, lun); - if (retval < 0) { - sbp2_send_management_orb(unit, sd->node_id, sd->generation, - SBP2_LOGOUT_REQUEST, sd->login_id, - NULL); + eight_bytes_lun.scsi_lun[0] = (lu->lun >> 8) & 0xff; + eight_bytes_lun.scsi_lun[1] = lu->lun & 0xff; + sdev = __scsi_add_device(sbp2_shost, 0, lu->tgt->starget_id, + scsilun_to_int(&eight_bytes_lun), lu); + if (IS_ERR(sdev)) { + sbp2_send_management_orb(lu, node_id, generation, + SBP2_LOGOUT_REQUEST, lu->login_id, NULL); /* * Set this back to sbp2_login so we fall back and * retry login on bus reset. */ - PREPARE_DELAYED_WORK(&sd->work, sbp2_login); + PREPARE_DELAYED_WORK(&lu->work, sbp2_login); + } else { + lu->sdev = sdev; + scsi_device_put(sdev); } - kref_put(&sd->kref, release_sbp2_device); + kref_put(&lu->tgt->kref, release_sbp2_device); } -static int sbp2_probe(struct device *dev) +static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry) { - struct fw_unit *unit = fw_unit(dev); - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd; - struct fw_csr_iterator ci; - struct Scsi_Host *host; - int i, key, value, err; - u32 model, firmware_revision; + struct sbp2_logical_unit *lu; - err = -ENOMEM; - host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd)); - if (host == NULL) - goto fail; + lu = kmalloc(sizeof(*lu), GFP_KERNEL); + if (!lu) + return -ENOMEM; - sd = (struct sbp2_device *) host->hostdata; - unit->device.driver_data = sd; - sd->unit = unit; - INIT_LIST_HEAD(&sd->orb_list); - kref_init(&sd->kref); + lu->address_handler.length = 0x100; + lu->address_handler.address_callback = sbp2_status_write; + lu->address_handler.callback_data = lu; - sd->address_handler.length = 0x100; - sd->address_handler.address_callback = sbp2_status_write; - sd->address_handler.callback_data = sd; + if (fw_core_add_address_handler(&lu->address_handler, + &fw_high_memory_region) < 0) { + kfree(lu); + return -ENOMEM; + } - err = fw_core_add_address_handler(&sd->address_handler, - &fw_high_memory_region); - if (err < 0) - goto fail_host; + lu->tgt = tgt; + lu->sdev = NULL; + lu->lun = lun_entry & 0xffff; + lu->retries = 0; + INIT_LIST_HEAD(&lu->orb_list); + INIT_DELAYED_WORK(&lu->work, sbp2_login); - err = fw_device_enable_phys_dma(device); - if (err < 0) - goto fail_address_handler; + list_add_tail(&lu->tgt_list, &tgt->lu_list); + return 0; +} - err = scsi_add_host(host, &unit->device); - if (err < 0) - goto fail_address_handler; +static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt, u32 *directory) +{ + struct fw_csr_iterator ci; + int key, value; - /* - * Scan unit directory to get management agent address, - * firmware revison and model. Initialize firmware_revision - * and model to values that wont match anything in our table. - */ - firmware_revision = 0xff000000; - model = 0xff000000; - fw_csr_iterator_init(&ci, unit->directory); + fw_csr_iterator_init(&ci, directory); + while (fw_csr_iterator_next(&ci, &key, &value)) + if (key == SBP2_CSR_LOGICAL_UNIT_NUMBER && + sbp2_add_logical_unit(tgt, value) < 0) + return -ENOMEM; + return 0; +} + +static int sbp2_scan_unit_dir(struct sbp2_target *tgt, u32 *directory, + u32 *model, u32 *firmware_revision) +{ + struct fw_device *dev = fw_device(tgt->unit->device.parent); + struct fw_csr_iterator ci; + int key, value; + u32 *subdir; + + fw_csr_iterator_init(&ci, directory); while (fw_csr_iterator_next(&ci, &key, &value)) { switch (key) { + case CSR_DEPENDENT_INFO | CSR_OFFSET: - sd->management_agent_address = + tgt->management_agent_address = 0xfffff0000000ULL + 4 * value; break; - case SBP2_FIRMWARE_REVISION: - firmware_revision = value; - break; + case CSR_MODEL: - model = value; + *model = value; + break; + + case SBP2_CSR_FIRMWARE_REVISION: + *firmware_revision = value; + break; + + case SBP2_CSR_LOGICAL_UNIT_NUMBER: + if (sbp2_add_logical_unit(tgt, value) < 0) + return -ENOMEM; + break; + + case SBP2_CSR_LOGICAL_UNIT_DIRECTORY: + subdir = ci.p + value; + if (subdir <= dev->config_rom + 5 || + subdir >= dev->config_rom + dev->config_rom_length) + fw_error("logical unit dir out of bounds\n"); + else if (sbp2_scan_logical_unit_dir(tgt, subdir) < 0) + return -ENOMEM; break; } } + return 0; +} +static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model, + u32 firmware_revision) +{ + int i; + + tgt->workarounds = 0; for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) { if (sbp2_workarounds_table[i].firmware_revision != (firmware_revision & 0xffffff00)) @@ -682,52 +721,80 @@ static int sbp2_probe(struct device *dev if (sbp2_workarounds_table[i].model != model && sbp2_workarounds_table[i].model != ~0) continue; - sd->workarounds |= sbp2_workarounds_table[i].workarounds; + tgt->workarounds |= sbp2_workarounds_table[i].workarounds; break; } - if (sd->workarounds) + if (tgt->workarounds) fw_notify("Workarounds for node %s: 0x%x " "(firmware_revision 0x%06x, model_id 0x%06x)\n", - unit->device.bus_id, - sd->workarounds, firmware_revision, model); + tgt->unit->device.bus_id, + tgt->workarounds, firmware_revision, model); +} + +static atomic_t sbp2_starget_id = ATOMIC_INIT(-1); + +static int sbp2_probe(struct device *dev) +{ + struct fw_unit *unit = fw_unit(dev); + struct sbp2_target *tgt; + struct sbp2_logical_unit *lu; + u32 model, firmware_revision; + + tgt = kmalloc(sizeof(*tgt), GFP_KERNEL); + if (!tgt) + return -ENOMEM; + + unit->device.driver_data = tgt; + tgt->unit = unit; + kref_init(&tgt->kref); + INIT_LIST_HEAD(&tgt->lu_list); + + /* Initialize to values that won't match anything in our table. */ + model = 0xff000000; + firmware_revision = 0xff000000; + if (sbp2_scan_unit_dir(tgt, unit->directory, &model, + &firmware_revision) < 0) + goto out; + + if (fw_device_enable_phys_dma(fw_device(unit->device.parent)) < 0) + goto out; + + sbp2_init_workarounds(tgt, model, firmware_revision); + tgt->starget_id = atomic_inc_return(&sbp2_starget_id); get_device(&unit->device); /* - * We schedule work to do the login so we can easily - * reschedule retries. Always get the ref before scheduling - * work. + * We schedule work to do the login so we can easily reschedule retries. + * Always get the ref when scheduling work. */ - INIT_DELAYED_WORK(&sd->work, sbp2_login); - if (schedule_delayed_work(&sd->work, 0)) - kref_get(&sd->kref); + list_for_each_entry(lu, &tgt->lu_list, tgt_list) + if (schedule_delayed_work(&lu->work, 0)) + kref_get(&tgt->kref); return 0; + out: + kref_put(&tgt->kref, release_sbp2_device); - fail_address_handler: - fw_core_remove_address_handler(&sd->address_handler); - fail_host: - scsi_host_put(host); - fail: - return err; + return -ENOMEM; } static int sbp2_remove(struct device *dev) { struct fw_unit *unit = fw_unit(dev); - struct sbp2_device *sd = unit->device.driver_data; + struct sbp2_target *tgt = unit->device.driver_data; - kref_put(&sd->kref, release_sbp2_device); + kref_put(&tgt->kref, release_sbp2_device); return 0; } static void sbp2_reconnect(struct work_struct *work) { - struct sbp2_device *sd = - container_of(work, struct sbp2_device, work.work); - struct fw_unit *unit = sd->unit; + struct sbp2_logical_unit *lu = + container_of(work, struct sbp2_logical_unit, work.work); + struct fw_unit *unit = lu->tgt->unit; struct fw_device *device = fw_device(unit->device.parent); int generation, node_id, local_node_id; @@ -735,40 +802,43 @@ static void sbp2_reconnect(struct work_s node_id = device->node->node_id; local_node_id = device->card->local_node->node_id; - if (sbp2_send_management_orb(unit, node_id, generation, + if (sbp2_send_management_orb(lu, node_id, generation, SBP2_RECONNECT_REQUEST, - sd->login_id, NULL) < 0) { - if (sd->retries++ >= 5) { + lu->login_id, NULL) < 0) { + if (lu->retries++ >= 5) { fw_error("failed to reconnect to %s\n", unit->device.bus_id); /* Fall back and try to log in again. */ - sd->retries = 0; - PREPARE_DELAYED_WORK(&sd->work, sbp2_login); + lu->retries = 0; + PREPARE_DELAYED_WORK(&lu->work, sbp2_login); } - schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5)); + schedule_delayed_work(&lu->work, DIV_ROUND_UP(HZ, 5)); return; } - sd->generation = generation; - sd->node_id = node_id; - sd->address_high = local_node_id << 16; + lu->generation = generation; + lu->tgt->node_id = node_id; + lu->tgt->address_high = local_node_id << 16; - fw_notify("reconnected to unit %s (%d retries)\n", - unit->device.bus_id, sd->retries); - sbp2_agent_reset(unit); - sbp2_cancel_orbs(unit); - kref_put(&sd->kref, release_sbp2_device); + fw_notify("reconnected to unit %s LUN %04x (%d retries)\n", + unit->device.bus_id, lu->lun, lu->retries); + sbp2_agent_reset(lu); + sbp2_cancel_orbs(lu); + kref_put(&lu->tgt->kref, release_sbp2_device); } static void sbp2_update(struct fw_unit *unit) { - struct fw_device *device = fw_device(unit->device.parent); - struct sbp2_device *sd = unit->device.driver_data; + struct sbp2_target *tgt = unit->device.driver_data; + struct sbp2_logical_unit *lu; + + fw_device_enable_phys_dma(fw_device(unit->device.parent)); - sd->retries = 0; - fw_device_enable_phys_dma(device); - if (schedule_delayed_work(&sd->work, 0)) - kref_get(&sd->kref); + list_for_each_entry(lu, &tgt->lu_list, tgt_list) { + lu->retries = 0; + if (schedule_delayed_work(&lu->work, 0)) + kref_get(&tgt->kref); + } } #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e @@ -838,13 +908,12 @@ complete_command_orb(struct sbp2_orb *ba { struct sbp2_command_orb *orb = container_of(base_orb, struct sbp2_command_orb, base); - struct fw_unit *unit = orb->unit; - struct fw_device *device = fw_device(unit->device.parent); + struct fw_device *device = fw_device(orb->lu->tgt->unit->device.parent); int result; if (status != NULL) { if (STATUS_GET_DEAD(*status)) - sbp2_agent_reset(unit); + sbp2_agent_reset(orb->lu); switch (STATUS_GET_RESPONSE(*status)) { case SBP2_STATUS_REQUEST_COMPLETE: @@ -889,12 +958,10 @@ complete_command_orb(struct sbp2_orb *ba kfree(orb); } -static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb) +static int +sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, + struct sbp2_logical_unit *lu) { - struct sbp2_device *sd = - (struct sbp2_device *)orb->cmd->device->host->hostdata; - struct fw_unit *unit = sd->unit; - struct fw_device *device = fw_device(unit->device.parent); struct scatterlist *sg; int sg_len, l, i, j, count; dma_addr_t sg_addr; @@ -913,10 +980,9 @@ static int sbp2_command_orb_map_scatterl * tables. */ if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) { - orb->request.data_descriptor.high = sd->address_high; + orb->request.data_descriptor.high = lu->tgt->address_high; orb->request.data_descriptor.low = sg_dma_address(sg); - orb->request.misc |= - COMMAND_ORB_DATA_SIZE(sg_dma_len(sg)); + orb->request.misc |= COMMAND_ORB_DATA_SIZE(sg_dma_len(sg)); return 0; } @@ -960,7 +1026,7 @@ static int sbp2_command_orb_map_scatterl * initiator (i.e. us), but data_descriptor can refer to data * on other nodes so we need to put our ID in descriptor.high. */ - orb->request.data_descriptor.high = sd->address_high; + orb->request.data_descriptor.high = lu->tgt->address_high; orb->request.data_descriptor.low = orb->page_table_bus; orb->request.misc |= COMMAND_ORB_PAGE_TABLE_PRESENT | @@ -979,11 +1045,10 @@ static int sbp2_command_orb_map_scatterl static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) { - struct sbp2_device *sd = - (struct sbp2_device *)cmd->device->host->hostdata; - struct fw_unit *unit = sd->unit; - struct fw_device *device = fw_device(unit->device.parent); + struct sbp2_logical_unit *lu = cmd->device->hostdata; + struct fw_device *device = fw_device(lu->tgt->unit->device.parent); struct sbp2_command_orb *orb; + unsigned max_payload; /* * Bidirectional commands are not yet implemented, and unknown @@ -1005,7 +1070,7 @@ static int sbp2_scsi_queuecommand(struct /* Initialize rcode to something not RCODE_COMPLETE. */ orb->base.rcode = -1; - orb->unit = unit; + orb->lu = lu; orb->done = done; orb->cmd = cmd; @@ -1017,8 +1082,10 @@ static int sbp2_scsi_queuecommand(struct * specifies the max payload size as 2 ^ (max_payload + 2), so * if we set this to max_speed + 7, we get the right value. */ + max_payload = min(device->max_speed + 7, + device->card->max_receive - 1); orb->request.misc = - COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) | + COMMAND_ORB_MAX_PAYLOAD(max_payload) | COMMAND_ORB_SPEED(device->max_speed) | COMMAND_ORB_NOTIFY; @@ -1029,7 +1096,7 @@ static int sbp2_scsi_queuecommand(struct orb->request.misc |= COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA); - if (scsi_sg_count(cmd) && sbp2_command_orb_map_scatterlist(orb) < 0) + if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) goto fail_mapping; fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request)); @@ -1045,8 +1112,8 @@ static int sbp2_scsi_queuecommand(struct if (dma_mapping_error(orb->base.request_bus)) goto fail_mapping; - sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation, - sd->command_block_agent_address + SBP2_ORB_POINTER); + sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, lu->generation, + lu->command_block_agent_address + SBP2_ORB_POINTER); return 0; @@ -1058,32 +1125,31 @@ static int sbp2_scsi_queuecommand(struct static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) { - struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata; + unsigned workarounds = + ((struct sbp2_logical_unit *)sdev->hostdata)->tgt->workarounds; sdev->allow_restart = 1; - if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36) + if (workarounds & SBP2_WORKAROUND_INQUIRY_36) sdev->inquiry_len = 36; return 0; } static int sbp2_scsi_slave_configure(struct scsi_device *sdev) { - struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata; - struct fw_unit *unit = sd->unit; + unsigned workarounds = + ((struct sbp2_logical_unit *)sdev->hostdata)->tgt->workarounds; sdev->use_10_for_rw = 1; if (sdev->type == TYPE_ROM) sdev->use_10_for_ms = 1; if (sdev->type == TYPE_DISK && - sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8) + workarounds & SBP2_WORKAROUND_MODE_SENSE_8) sdev->skip_ms_page_8 = 1; - if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) { - fw_notify("setting fix_capacity for %s\n", unit->device.bus_id); + if (workarounds & SBP2_WORKAROUND_FIX_CAPACITY) sdev->fix_capacity = 1; - } - if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) + if (workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); return 0; } @@ -1094,13 +1160,11 @@ static int sbp2_scsi_slave_configure(str */ static int sbp2_scsi_abort(struct scsi_cmnd *cmd) { - struct sbp2_device *sd = - (struct sbp2_device *)cmd->device->host->hostdata; - struct fw_unit *unit = sd->unit; + struct sbp2_logical_unit *lu = cmd->device->hostdata; fw_notify("sbp2_scsi_abort\n"); - sbp2_agent_reset(unit); - sbp2_cancel_orbs(unit); + sbp2_agent_reset(lu); + sbp2_cancel_orbs(lu); return SUCCESS; } @@ -1117,17 +1181,17 @@ sbp2_sysfs_ieee1394_id_show(struct devic char *buf) { struct scsi_device *sdev = to_scsi_device(dev); - struct sbp2_device *sd; + struct sbp2_logical_unit *lu; struct fw_unit *unit; struct fw_device *device; u32 directory_id; struct fw_csr_iterator ci; - int key, value, lun; + int key, value; if (!sdev) return 0; - sd = (struct sbp2_device *)sdev->host->hostdata; - unit = sd->unit; + lu = sdev->hostdata; + unit = lu->tgt->unit; device = fw_device(unit->device.parent); /* implicit directory ID */ @@ -1142,12 +1206,9 @@ sbp2_sysfs_ieee1394_id_show(struct devic break; } - /* FIXME: Make this work for multi-lun devices. */ - lun = 0; - return sprintf(buf, "%08x%08x:%06x:%04x\n", device->config_rom[3], device->config_rom[4], - directory_id, lun); + directory_id, lu->lun); } static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); @@ -1185,12 +1246,35 @@ #endif static int __init sbp2_init(void) { - return driver_register(&sbp2_driver.driver); + int error = -ENOMEM; + + sbp2_shost = scsi_host_alloc(&scsi_driver_template, 0); + if (!sbp2_shost) + goto out_error; + + error = scsi_add_host(sbp2_shost, NULL); + if (error) + goto out_host_put; + + error = driver_register(&sbp2_driver.driver); + if (error) + goto out_remove_host; + + return 0; + + out_remove_host: + scsi_remove_host(sbp2_shost); + out_host_put: + scsi_host_put(sbp2_shost); + out_error: + return error; } static void __exit sbp2_cleanup(void) { driver_unregister(&sbp2_driver.driver); + scsi_remove_host(sbp2_shost); + scsi_host_put(sbp2_shost); } module_init(sbp2_init); diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index 3ce8e2f..e507bc4 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c @@ -410,7 +410,12 @@ EXPORT_SYMBOL(fw_unit_space_region); * controller. When a request is received that falls within the * specified address range, the specified callback is invoked. The * parameters passed to the callback give the details of the - * particular request + * particular request. + * + * Return value: 0 on success, non-zero otherwise. + * The start offset of the handler's address region is determined by + * fw_core_add_address_handler() and is returned in handler->offset. + * The offset is quadlet-aligned. */ int fw_core_add_address_handler(struct fw_address_handler *handler, @@ -422,14 +427,15 @@ fw_core_add_address_handler(struct fw_ad spin_lock_irqsave(&address_handler_lock, flags); - handler->offset = region->start; + handler->offset = roundup(region->start, 4); while (handler->offset + handler->length <= region->end) { other = lookup_overlapping_address_handler(&address_handler_list, handler->offset, handler->length); if (other != NULL) { - handler->offset += other->length; + handler->offset = + roundup(other->offset + other->length, 4); } else { list_add_tail(&handler->link, &address_handler_list); ret = 0; @@ -734,7 +740,7 @@ fw_core_handle_response(struct fw_card * } EXPORT_SYMBOL(fw_core_handle_response); -const struct fw_address_region topology_map_region = +static const struct fw_address_region topology_map_region = { .start = 0xfffff0001000ull, .end = 0xfffff0001400ull, }; static void @@ -772,7 +778,7 @@ static struct fw_address_handler topolog .address_callback = handle_topology_map, }; -const struct fw_address_region registers_region = +static const struct fw_address_region registers_region = { .start = 0xfffff0000000ull, .end = 0xfffff0000400ull, }; static void @@ -880,19 +886,10 @@ static int __init fw_core_init(void) return fw_cdev_major; } - retval = fw_core_add_address_handler(&topology_map, - &topology_map_region); - BUG_ON(retval < 0); - - retval = fw_core_add_address_handler(®isters, - ®isters_region); - BUG_ON(retval < 0); - - /* Add the vendor textual descriptor. */ - retval = fw_core_add_descriptor(&vendor_id_descriptor); - BUG_ON(retval < 0); - retval = fw_core_add_descriptor(&model_id_descriptor); - BUG_ON(retval < 0); + BUG_ON(fw_core_add_address_handler(&topology_map, &topology_map_region) + || fw_core_add_address_handler(®isters, ®isters_region) + || fw_core_add_descriptor(&vendor_id_descriptor) + || fw_core_add_descriptor(&model_id_descriptor)); return 0; } diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 5ceaccd..fa7967b 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h @@ -231,7 +231,7 @@ struct fw_card { unsigned long reset_jiffies; unsigned long long guid; - int max_receive; + unsigned max_receive; int link_speed; int config_rom_generation; diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig index 8012b3b..545663e 100644 --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig @@ -97,7 +97,7 @@ config IEEE1394_SBP2 config IEEE1394_SBP2_PHYS_DMA bool "Enable replacement for physical DMA in SBP2" - depends on IEEE1394 && IEEE1394_SBP2 && EXPERIMENTAL && (X86_32 || PPC_32) + depends on IEEE1394_SBP2 && VIRT_TO_BUS && EXPERIMENTAL help This builds sbp2 for use with non-OHCI host adapters which do not support physical DMA or for when ohci1394 is run with phys_dma=0. diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 3a9d7e2..eb0deee 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -1148,8 +1148,6 @@ static int ether1394_data_handler(struct pdg->sz++; lh = find_partial_datagram(pdgl, dgl); } else { - struct partial_datagram *pd; - pd = list_entry(lh, struct partial_datagram, list); if (fragment_overlap(&pd->frag_info, fg_off, fg_len)) { @@ -1217,23 +1215,19 @@ static int ether1394_data_handler(struct priv->stats.rx_errors++; priv->stats.rx_dropped++; dev_kfree_skb_any(skb); - goto bad_proto; - } - - if (netif_rx(skb) == NET_RX_DROP) { + } else if (netif_rx(skb) == NET_RX_DROP) { priv->stats.rx_errors++; priv->stats.rx_dropped++; - goto bad_proto; + } else { + priv->stats.rx_packets++; + priv->stats.rx_bytes += skb->len; } - /* Statistics */ - priv->stats.rx_packets++; - priv->stats.rx_bytes += skb->len; + spin_unlock_irqrestore(&priv->lock, flags); bad_proto: if (netif_queue_stopped(dev)) netif_wake_queue(dev); - spin_unlock_irqrestore(&priv->lock, flags); dev->last_rx = jiffies; diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index d1a5bcd..7762e43 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c @@ -765,7 +765,6 @@ static int lynx_devctl(struct hpsb_host } else { struct ti_pcl pcl; u32 ack; - struct hpsb_packet *packet; PRINT(KERN_INFO, lynx->id, "cancelling async packet, that was already in PCL"); @@ -1470,8 +1469,6 @@ #endif if (i2c_transfer(i2c_ad, msg, 2) < 0) { PRINT(KERN_ERR, lynx->id, "unable to read bus info block from i2c"); } else { - int i; - PRINT(KERN_INFO, lynx->id, "got bus info block from serial eeprom"); /* FIXME: probably we shoud rewrite the max_rec, max_ROM(1394a), * generation(1394a) and link_spd(1394a) field and recalculate