ieee1394: sbp2: change some module parameters from int to bool
[safe/jmp/linux-2.6] / drivers / ieee1394 / sbp2.c
index 2b6d9a0..e0c385a 100644 (file)
  * driver. It also registers as a SCSI lower-level driver in order to accept
  * SCSI commands for transport using SBP-2.
  *
- * You may access any attached SBP-2 storage devices as if they were SCSI
- * devices (e.g. mount /dev/sda1,  fdisk, mkfs, etc.).
+ * You may access any attached SBP-2 (usually storage devices) as regular
+ * SCSI devices. E.g. mount /dev/sda1, fdisk, mkfs, etc..
  *
- * Current Issues:
+ * See http://www.t10.org/drafts.htm#sbp2 for the final draft of the SBP-2
+ * specification and for where to purchase the official standard.
  *
- *     - Error Handling: SCSI aborts and bus reset requests are handled somewhat
- *       but the code needs additional debugging.
+ * TODO:
+ *   - look into possible improvements of the SCSI error handlers
+ *   - handle Unit_Characteristics.mgt_ORB_timeout and .ORB_size
+ *   - handle Logical_Unit_Number.ordered
+ *   - handle src == 1 in status blocks
+ *   - reimplement the DMA mapping in absence of physical DMA so that
+ *     bus_to_virt is no longer required
+ *   - debug the handling of absent physical DMA
+ *   - replace CONFIG_IEEE1394_SBP2_PHYS_DMA by automatic detection
+ *     (this is easy but depends on the previous two TODO items)
+ *   - make the parameter serialize_io configurable per device
+ *   - move all requests to fetch agent registers into non-atomic context,
+ *     replace all usages of sbp2util_node_write_no_wait by true transactions
+ * Grep for inline FIXME comments below.
  */
 
-#include <linux/blkdev.h>
 #include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/pci.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
@@ -57,6 +70,7 @@
 #include <linux/stringify.h>
 #include <linux/types.h>
 #include <linux/wait.h>
+#include <linux/workqueue.h>
 
 #include <asm/byteorder.h>
 #include <asm/errno.h>
@@ -104,16 +118,13 @@ MODULE_PARM_DESC(max_speed, "Force max speed "
                 "(3 = 800Mb/s, 2 = 400Mb/s, 1 = 200Mb/s, 0 = 100Mb/s)");
 
 /*
- * Set serialize_io to 1 if you'd like only one scsi command sent
- * down to us at a time (debugging). This might be necessary for very
- * badly behaved sbp2 devices.
- *
- * TODO: Make this configurable per device.
+ * Set serialize_io to 0 or N to use dynamically appended lists of command ORBs.
+ * This is and always has been buggy in multiple subtle ways. See above TODOs.
  */
 static int sbp2_serialize_io = 1;
-module_param_named(serialize_io, sbp2_serialize_io, int, 0444);
-MODULE_PARM_DESC(serialize_io, "Serialize I/O coming from scsi drivers "
-                "(default = 1, faster = 0)");
+module_param_named(serialize_io, sbp2_serialize_io, bool, 0444);
+MODULE_PARM_DESC(serialize_io, "Serialize requests coming from SCSI drivers "
+                "(default = Y, faster but buggy = N)");
 
 /*
  * Bump up max_sectors if you'd like to support very large sized
@@ -142,9 +153,9 @@ MODULE_PARM_DESC(max_sectors, "Change max sectors per I/O supported "
  * are possible on OXFW911 and newer Oxsemi bridges.
  */
 static int sbp2_exclusive_login = 1;
-module_param_named(exclusive_login, sbp2_exclusive_login, int, 0644);
+module_param_named(exclusive_login, sbp2_exclusive_login, bool, 0644);
 MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
-                "(default = 1)");
+                "(default = Y, use N for concurrent initiators)");
 
 /*
  * If any of the following workarounds is required for your device to work,
@@ -182,6 +193,27 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
        ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
        ", or a combination)");
 
+/*
+ * This influences the format of the sysfs attribute
+ * /sys/bus/scsi/devices/.../ieee1394_id.
+ *
+ * The default format is like in older kernels:  %016Lx:%d:%d
+ * It contains the target's EUI-64, a number given to the logical unit by
+ * the ieee1394 driver's nodemgr (starting at 0), and the LUN.
+ *
+ * The long format is:  %016Lx:%06x:%04x
+ * It contains the target's EUI-64, the unit directory's directory_ID as per
+ * IEEE 1212 clause 7.7.19, and the LUN.  This format comes closest to the
+ * format of SBP(-3) target port and logical unit identifier as per SAM (SCSI
+ * Architecture Model) rev.2 to 4 annex A.  Therefore and because it is
+ * independent of the implementation of the ieee1394 nodemgr, the longer format
+ * is recommended for future use.
+ */
+static int sbp2_long_sysfs_ieee1394_id;
+module_param_named(long_ieee1394_id, sbp2_long_sysfs_ieee1394_id, bool, 0644);
+MODULE_PARM_DESC(long_ieee1394_id, "8+3+2 bytes format of ieee1394_id in sysfs "
+                "(default = backwards-compatible = N, SAM-conforming = Y)");
+
 
 #define SBP2_INFO(fmt, args...)        HPSB_INFO("sbp2: "fmt, ## args)
 #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
@@ -249,12 +281,10 @@ static int sbp2_remove(struct device *);
 static int sbp2_update(struct unit_directory *);
 
 static struct hpsb_protocol_driver sbp2_driver = {
-       .name           = "SBP2 Driver",
+       .name           = SBP2_DEVICE_NAME,
        .id_table       = sbp2_id_table,
        .update         = sbp2_update,
        .driver         = {
-               .name           = SBP2_DEVICE_NAME,
-               .bus            = &ieee1394_bus_type,
                .probe          = sbp2_probe,
                .remove         = sbp2_remove,
        },
@@ -296,10 +326,11 @@ static struct scsi_host_template sbp2_shost_template = {
        .use_clustering          = ENABLE_CLUSTERING,
        .cmd_per_lun             = SBP2_MAX_CMDS,
        .can_queue               = SBP2_MAX_CMDS,
-       .emulated                = 1,
        .sdev_attrs              = sbp2_sysfs_sdev_attrs,
 };
 
+/* for match-all entries in sbp2_workarounds_table */
+#define SBP2_ROM_VALUE_WILDCARD 0x1000000
 
 /*
  * List of devices with known bugs.
@@ -321,22 +352,14 @@ static const struct {
        },
        /* Initio bridges, actually only needed for some older ones */ {
                .firmware_revision      = 0x000200,
+               .model_id               = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_INQUIRY_36,
        },
        /* Symbios bridge */ {
                .firmware_revision      = 0xa0b800,
+               .model_id               = SBP2_ROM_VALUE_WILDCARD,
                .workarounds            = SBP2_WORKAROUND_128K_MAX_TRANS,
        },
-       /*
-        * Note about the following Apple iPod blacklist entries:
-        *
-        * There are iPods (2nd gen, 3rd gen) with model_id==0.  Since our
-        * matching logic treats 0 as a wildcard, we cannot match this ID
-        * without rewriting the matching routine.  Fortunately these iPods
-        * do not feature the read_capacity bug according to one report.
-        * Read_capacity behaviour as well as model_id could change due to
-        * Apple-supplied firmware updates though.
-        */
        /* iPod 4th generation */ {
                .firmware_revision      = 0x0a2700,
                .model_id               = 0x000021,
@@ -450,47 +473,43 @@ static void sbp2util_notify_fetch_agent(struct sbp2_lu *lu, u64 offset,
 
 static void sbp2util_write_orb_pointer(struct work_struct *work)
 {
+       struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
        quadlet_t data[2];
 
-       data[0] = ORB_SET_NODE_ID((container_of(work, struct sbp2_lu, protocol_work))->hi->host->node_id);
-       data[1] = (container_of(work, struct sbp2_lu, protocol_work))->last_orb_dma;
+       data[0] = ORB_SET_NODE_ID(lu->hi->host->node_id);
+       data[1] = lu->last_orb_dma;
        sbp2util_cpu_to_be32_buffer(data, 8);
-       sbp2util_notify_fetch_agent(container_of(work, struct sbp2_lu, protocol_work), SBP2_ORB_POINTER_OFFSET, data, 8);
+       sbp2util_notify_fetch_agent(lu, SBP2_ORB_POINTER_OFFSET, data, 8);
 }
 
 static void sbp2util_write_doorbell(struct work_struct *work)
 {
-       sbp2util_notify_fetch_agent(container_of(work, struct sbp2_lu, protocol_work), SBP2_DOORBELL_OFFSET, NULL, 4);
+       struct sbp2_lu *lu = container_of(work, struct sbp2_lu, protocol_work);
+
+       sbp2util_notify_fetch_agent(lu, SBP2_DOORBELL_OFFSET, NULL, 4);
 }
 
 static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
 {
        struct sbp2_fwhost_info *hi = lu->hi;
-       int i;
-       unsigned long flags, orbs;
        struct sbp2_command_info *cmd;
+       int i, orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS;
 
-       orbs = sbp2_serialize_io ? 2 : SBP2_MAX_CMDS;
-
-       spin_lock_irqsave(&lu->cmd_orb_lock, flags);
        for (i = 0; i < orbs; i++) {
-               cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
-               if (!cmd) {
-                       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
+               cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+               if (!cmd)
                        return -ENOMEM;
-               }
-               cmd->command_orb_dma = pci_map_single(hi->host->pdev,
+               cmd->command_orb_dma = dma_map_single(hi->host->device.parent,
                                                &cmd->command_orb,
                                                sizeof(struct sbp2_command_orb),
-                                               PCI_DMA_TODEVICE);
-               cmd->sge_dma = pci_map_single(hi->host->pdev,
+                                               DMA_TO_DEVICE);
+               cmd->sge_dma = dma_map_single(hi->host->device.parent,
                                        &cmd->scatter_gather_element,
                                        sizeof(cmd->scatter_gather_element),
-                                       PCI_DMA_BIDIRECTIONAL);
+                                       DMA_TO_DEVICE);
                INIT_LIST_HEAD(&cmd->list);
                list_add_tail(&cmd->list, &lu->cmd_orb_completed);
        }
-       spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
        return 0;
 }
 
@@ -505,12 +524,13 @@ static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu)
        if (!list_empty(&lu->cmd_orb_completed))
                list_for_each_safe(lh, next, &lu->cmd_orb_completed) {
                        cmd = list_entry(lh, struct sbp2_command_info, list);
-                       pci_unmap_single(host->pdev, cmd->command_orb_dma,
+                       dma_unmap_single(host->device.parent,
+                                        cmd->command_orb_dma,
                                         sizeof(struct sbp2_command_orb),
-                                        PCI_DMA_TODEVICE);
-                       pci_unmap_single(host->pdev, cmd->sge_dma,
+                                        DMA_TO_DEVICE);
+                       dma_unmap_single(host->device.parent, cmd->sge_dma,
                                         sizeof(cmd->scatter_gather_element),
-                                        PCI_DMA_BIDIRECTIONAL);
+                                        DMA_TO_DEVICE);
                        kfree(cmd);
                }
        spin_unlock_irqrestore(&lu->cmd_orb_lock, flags);
@@ -579,47 +599,31 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
        return cmd;
 }
 
-static void sbp2util_free_command_dma(struct sbp2_command_info *cmd)
+/*
+ * Unmaps the DMAs of a command and moves the command to the completed ORB list.
+ * Must be called with lu->cmd_orb_lock held.
+ */
+static void sbp2util_mark_command_completed(struct sbp2_lu *lu,
+                                           struct sbp2_command_info *cmd)
 {
-       struct sbp2_lu *lu = (struct sbp2_lu *)
-                       cmd->Current_SCpnt->device->host->hostdata[0];
-       struct hpsb_host *host;
-
-       if (!lu) {
-               SBP2_ERR("%s: lu == NULL", __FUNCTION__);
-               return;
-       }
-
-       host = lu->ud->ne->host;
+       struct hpsb_host *host = lu->ud->ne->host;
 
        if (cmd->cmd_dma) {
                if (cmd->dma_type == CMD_DMA_SINGLE)
-                       pci_unmap_single(host->pdev, cmd->cmd_dma,
+                       dma_unmap_single(host->device.parent, cmd->cmd_dma,
                                         cmd->dma_size, cmd->dma_dir);
                else if (cmd->dma_type == CMD_DMA_PAGE)
-                       pci_unmap_page(host->pdev, cmd->cmd_dma,
+                       dma_unmap_page(host->device.parent, cmd->cmd_dma,
                                       cmd->dma_size, cmd->dma_dir);
                /* XXX: Check for CMD_DMA_NONE bug */
                cmd->dma_type = CMD_DMA_NONE;
                cmd->cmd_dma = 0;
        }
-
        if (cmd->sge_buffer) {
-               pci_unmap_sg(host->pdev, cmd->sge_buffer,
+               dma_unmap_sg(host->device.parent, cmd->sge_buffer,
                             cmd->dma_size, cmd->dma_dir);
                cmd->sge_buffer = NULL;
        }
-}
-
-/*
- * This function moves a command to the completed orb list.
- * Must be called with lu->cmd_orb_lock held.
- */
-static void sbp2util_mark_command_completed(
-               struct sbp2_lu *lu,
-               struct sbp2_command_info *cmd)
-{
-       sbp2util_free_command_dma(cmd);
        list_move_tail(&cmd->list, &lu->cmd_orb_completed);
 }
 
@@ -769,6 +773,11 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
                        SBP2_ERR("failed to register lower 4GB address range");
                        goto failed_alloc;
                }
+#else
+               if (dma_set_mask(hi->host->device.parent, DMA_32BIT_MASK)) {
+                       SBP2_ERR("failed to set 4GB DMA mask");
+                       goto failed_alloc;
+               }
 #endif
        }
 
@@ -841,47 +850,44 @@ static int sbp2_start_device(struct sbp2_lu *lu)
        struct sbp2_fwhost_info *hi = lu->hi;
        int error;
 
-       lu->login_response = pci_alloc_consistent(hi->host->pdev,
+       lu->login_response = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_login_response),
-                                    &lu->login_response_dma);
+                                    &lu->login_response_dma, GFP_KERNEL);
        if (!lu->login_response)
                goto alloc_fail;
 
-       lu->query_logins_orb = pci_alloc_consistent(hi->host->pdev,
+       lu->query_logins_orb = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_query_logins_orb),
-                                    &lu->query_logins_orb_dma);
+                                    &lu->query_logins_orb_dma, GFP_KERNEL);
        if (!lu->query_logins_orb)
                goto alloc_fail;
 
-       lu->query_logins_response = pci_alloc_consistent(hi->host->pdev,
+       lu->query_logins_response = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_query_logins_response),
-                                    &lu->query_logins_response_dma);
+                                    &lu->query_logins_response_dma, GFP_KERNEL);
        if (!lu->query_logins_response)
                goto alloc_fail;
 
-       lu->reconnect_orb = pci_alloc_consistent(hi->host->pdev,
+       lu->reconnect_orb = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_reconnect_orb),
-                                    &lu->reconnect_orb_dma);
+                                    &lu->reconnect_orb_dma, GFP_KERNEL);
        if (!lu->reconnect_orb)
                goto alloc_fail;
 
-       lu->logout_orb = pci_alloc_consistent(hi->host->pdev,
+       lu->logout_orb = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_logout_orb),
-                                    &lu->logout_orb_dma);
+                                    &lu->logout_orb_dma, GFP_KERNEL);
        if (!lu->logout_orb)
                goto alloc_fail;
 
-       lu->login_orb = pci_alloc_consistent(hi->host->pdev,
+       lu->login_orb = dma_alloc_coherent(hi->host->device.parent,
                                     sizeof(struct sbp2_login_orb),
-                                    &lu->login_orb_dma);
+                                    &lu->login_orb_dma, GFP_KERNEL);
        if (!lu->login_orb)
                goto alloc_fail;
 
-       if (sbp2util_create_command_orb_pool(lu)) {
-               SBP2_ERR("sbp2util_create_command_orb_pool failed!");
-               sbp2_remove_device(lu);
-               return -ENOMEM;
-       }
+       if (sbp2util_create_command_orb_pool(lu))
+               goto alloc_fail;
 
        /* Wait a second before trying to log in. Previously logged in
         * initiators need a chance to reconnect. */
@@ -934,32 +940,32 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
        list_del(&lu->lu_list);
 
        if (lu->login_response)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_login_response),
                                    lu->login_response,
                                    lu->login_response_dma);
        if (lu->login_orb)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_login_orb),
                                    lu->login_orb,
                                    lu->login_orb_dma);
        if (lu->reconnect_orb)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_reconnect_orb),
                                    lu->reconnect_orb,
                                    lu->reconnect_orb_dma);
        if (lu->logout_orb)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_logout_orb),
                                    lu->logout_orb,
                                    lu->logout_orb_dma);
        if (lu->query_logins_orb)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_query_logins_orb),
                                    lu->query_logins_orb,
                                    lu->query_logins_orb_dma);
        if (lu->query_logins_response)
-               pci_free_consistent(hi->host->pdev,
+               dma_free_coherent(hi->host->device.parent,
                                    sizeof(struct sbp2_query_logins_response),
                                    lu->query_logins_response,
                                    lu->query_logins_response_dma);
@@ -1311,11 +1317,13 @@ static void sbp2_parse_unit_directory(struct sbp2_lu *lu,
 
        if (!(workarounds & SBP2_WORKAROUND_OVERRIDE))
                for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
-                       if (sbp2_workarounds_table[i].firmware_revision &&
+                       if (sbp2_workarounds_table[i].firmware_revision !=
+                           SBP2_ROM_VALUE_WILDCARD &&
                            sbp2_workarounds_table[i].firmware_revision !=
                            (firmware_revision & 0xffff00))
                                continue;
-                       if (sbp2_workarounds_table[i].model_id &&
+                       if (sbp2_workarounds_table[i].model_id !=
+                           SBP2_ROM_VALUE_WILDCARD &&
                            sbp2_workarounds_table[i].model_id != ud->model_id)
                                continue;
                        workarounds |= sbp2_workarounds_table[i].workarounds;
@@ -1407,7 +1415,7 @@ static int sbp2_agent_reset(struct sbp2_lu *lu, int wait)
        int retval;
        unsigned long flags;
 
-       /* cancel_delayed_work(&lu->protocol_work); */
+       /* flush lu->protocol_work */
        if (wait)
                flush_scheduled_work();
 
@@ -1450,7 +1458,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
 
                cmd->dma_size = sgpnt[0].length;
                cmd->dma_type = CMD_DMA_PAGE;
-               cmd->cmd_dma = pci_map_page(hi->host->pdev,
+               cmd->cmd_dma = dma_map_page(hi->host->device.parent,
                                            sgpnt[0].page, sgpnt[0].offset,
                                            cmd->dma_size, cmd->dma_dir);
 
@@ -1462,8 +1470,8 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
                                                &cmd->scatter_gather_element[0];
                u32 sg_count, sg_len;
                dma_addr_t sg_addr;
-               int i, count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg,
-                                         dma_dir);
+               int i, count = dma_map_sg(hi->host->device.parent, sgpnt,
+                                         scsi_use_sg, dma_dir);
 
                cmd->dma_size = scsi_use_sg;
                cmd->sge_buffer = sgpnt;
@@ -1513,7 +1521,8 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
        cmd->dma_dir = dma_dir;
        cmd->dma_size = scsi_request_bufflen;
        cmd->dma_type = CMD_DMA_SINGLE;
-       cmd->cmd_dma = pci_map_single(hi->host->pdev, scsi_request_buffer,
+       cmd->cmd_dma = dma_map_single(hi->host->device.parent,
+                                     scsi_request_buffer,
                                      cmd->dma_size, cmd->dma_dir);
        orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
        orb->misc |= ORB_SET_DIRECTION(orb_direction);
@@ -1631,12 +1640,13 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu,
        size_t length;
        unsigned long flags;
 
-       pci_dma_sync_single_for_device(hi->host->pdev, cmd->command_orb_dma,
-                                      sizeof(struct sbp2_command_orb),
-                                      PCI_DMA_TODEVICE);
-       pci_dma_sync_single_for_device(hi->host->pdev, cmd->sge_dma,
-                                      sizeof(cmd->scatter_gather_element),
-                                      PCI_DMA_BIDIRECTIONAL);
+       dma_sync_single_for_device(hi->host->device.parent,
+                                  cmd->command_orb_dma,
+                                  sizeof(struct sbp2_command_orb),
+                                  DMA_TO_DEVICE);
+       dma_sync_single_for_device(hi->host->device.parent, cmd->sge_dma,
+                                  sizeof(cmd->scatter_gather_element),
+                                  DMA_TO_DEVICE);
 
        /* check to see if there are any previous orbs to use */
        spin_lock_irqsave(&lu->cmd_orb_lock, flags);
@@ -1660,16 +1670,17 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu,
                 * The target's fetch agent may or may not have read this
                 * previous ORB yet.
                 */
-               pci_dma_sync_single_for_cpu(hi->host->pdev, last_orb_dma,
-                                           sizeof(struct sbp2_command_orb),
-                                           PCI_DMA_TODEVICE);
+               dma_sync_single_for_cpu(hi->host->device.parent, last_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
                last_orb->next_ORB_lo = cpu_to_be32(cmd->command_orb_dma);
                wmb();
                /* Tells hardware that this pointer is valid */
                last_orb->next_ORB_hi = 0;
-               pci_dma_sync_single_for_device(hi->host->pdev, last_orb_dma,
-                                              sizeof(struct sbp2_command_orb),
-                                              PCI_DMA_TODEVICE);
+               dma_sync_single_for_device(hi->host->device.parent,
+                                          last_orb_dma,
+                                          sizeof(struct sbp2_command_orb),
+                                          DMA_TO_DEVICE);
                addr += SBP2_DOORBELL_OFFSET;
                data[0] = 0;
                length = 4;
@@ -1690,8 +1701,7 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu,
                scsi_block_requests(lu->shost);
                PREPARE_WORK(&lu->protocol_work,
                             last_orb ? sbp2util_write_doorbell:
-                                       sbp2util_write_orb_pointer
-                            /* */);
+                                       sbp2util_write_orb_pointer);
                schedule_work(&lu->protocol_work);
        }
 }
@@ -1796,14 +1806,13 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
        else
                cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo);
        if (cmd) {
-               pci_dma_sync_single_for_cpu(hi->host->pdev,
-                               cmd->command_orb_dma,
-                               sizeof(struct sbp2_command_orb),
-                               PCI_DMA_TODEVICE);
-               pci_dma_sync_single_for_cpu(hi->host->pdev,
-                               cmd->sge_dma,
-                               sizeof(cmd->scatter_gather_element),
-                               PCI_DMA_BIDIRECTIONAL);
+               dma_sync_single_for_cpu(hi->host->device.parent,
+                                       cmd->command_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+               dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_TO_DEVICE);
                /* Grab SCSI command pointers and check status. */
                /*
                 * FIXME: If the src field in the status is 1, the ORB DMA must
@@ -1890,16 +1899,6 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
        if (unlikely(SCpnt->device->lun))
                goto done;
 
-       /* handle the request sense command here (auto-request sense) */
-       if (SCpnt->cmnd[0] == REQUEST_SENSE) {
-               memcpy(SCpnt->request_buffer, SCpnt->sense_buffer,
-                      SCpnt->request_bufflen);
-               memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
-               sbp2scsi_complete_command(lu, SBP2_SCSI_STATUS_GOOD, SCpnt,
-                                         done);
-               return 0;
-       }
-
        if (unlikely(!hpsb_node_entry_valid(lu->ne))) {
                SBP2_ERR("Bus reset in progress - rejecting command");
                result = DID_BUS_BUSY << 16;
@@ -1939,13 +1938,13 @@ static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status)
        while (!list_empty(&lu->cmd_orb_inuse)) {
                lh = lu->cmd_orb_inuse.next;
                cmd = list_entry(lh, struct sbp2_command_info, list);
-               pci_dma_sync_single_for_cpu(hi->host->pdev,
-                               cmd->command_orb_dma,
-                               sizeof(struct sbp2_command_orb),
-                               PCI_DMA_TODEVICE);
-               pci_dma_sync_single_for_cpu(hi->host->pdev, cmd->sge_dma,
-                               sizeof(cmd->scatter_gather_element),
-                               PCI_DMA_BIDIRECTIONAL);
+               dma_sync_single_for_cpu(hi->host->device.parent,
+                                       cmd->command_orb_dma,
+                                       sizeof(struct sbp2_command_orb),
+                                       DMA_TO_DEVICE);
+               dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma,
+                                       sizeof(cmd->scatter_gather_element),
+                                       DMA_TO_DEVICE);
                sbp2util_mark_command_completed(lu, cmd);
                if (cmd->Current_SCpnt) {
                        cmd->Current_SCpnt->result = status << 16;
@@ -2030,9 +2029,10 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
 {
        struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
 
-       blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
        sdev->use_10_for_rw = 1;
 
+       if (sdev->type == TYPE_ROM)
+               sdev->use_10_for_ms = 1;
        if (sdev->type == TYPE_DISK &&
            lu->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
                sdev->skip_ms_page_8 = 1;
@@ -2068,14 +2068,14 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
                spin_lock_irqsave(&lu->cmd_orb_lock, flags);
                cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt);
                if (cmd) {
-                       pci_dma_sync_single_for_cpu(hi->host->pdev,
+                       dma_sync_single_for_cpu(hi->host->device.parent,
                                        cmd->command_orb_dma,
                                        sizeof(struct sbp2_command_orb),
-                                       PCI_DMA_TODEVICE);
-                       pci_dma_sync_single_for_cpu(hi->host->pdev,
+                                       DMA_TO_DEVICE);
+                       dma_sync_single_for_cpu(hi->host->device.parent,
                                        cmd->sge_dma,
                                        sizeof(cmd->scatter_gather_element),
-                                       PCI_DMA_BIDIRECTIONAL);
+                                       DMA_TO_DEVICE);
                        sbp2util_mark_command_completed(lu, cmd);
                        if (cmd->Current_SCpnt) {
                                cmd->Current_SCpnt->result = DID_ABORT << 16;
@@ -2120,8 +2120,14 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
        if (!(lu = (struct sbp2_lu *)sdev->host->hostdata[0]))
                return 0;
 
-       return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)lu->ne->guid,
-                      lu->ud->id, ORB_SET_LUN(lu->lun));
+       if (sbp2_long_sysfs_ieee1394_id)
+               return sprintf(buf, "%016Lx:%06x:%04x\n",
+                               (unsigned long long)lu->ne->guid,
+                               lu->ud->directory_id, ORB_SET_LUN(lu->lun));
+       else
+               return sprintf(buf, "%016Lx:%d:%d\n",
+                               (unsigned long long)lu->ne->guid,
+                               lu->ud->id, ORB_SET_LUN(lu->lun));
 }
 
 MODULE_AUTHOR("Ben Collins <bcollins@debian.org>");