pciehp: make pciehp build for powerpc
[powerpc.git] / drivers / ieee1394 / sbp2.c
index c50aae9..b08755e 100644 (file)
@@ -38,7 +38,6 @@
  *       but the code needs additional debugging.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/string.h>
@@ -794,12 +793,12 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
        scsi_id->ud = ud;
        scsi_id->speed_code = IEEE1394_SPEED_100;
        scsi_id->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100];
+       scsi_id->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE;
        atomic_set(&scsi_id->sbp2_login_complete, 0);
        INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_inuse);
        INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
        INIT_LIST_HEAD(&scsi_id->scsi_list);
        spin_lock_init(&scsi_id->sbp2_command_orb_lock);
-       scsi_id->sbp2_lun = 0;
 
        ud->device.driver_data = scsi_id;
 
@@ -848,7 +847,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
                        &sbp2_highlevel, ud->ne->host, &sbp2_ops,
                        sizeof(struct sbp2_status_block), sizeof(quadlet_t),
                        ud->ne->host->low_addr_space, CSR1212_ALL_SPACE_END);
-       if (scsi_id->status_fifo_addr == ~0ULL) {
+       if (scsi_id->status_fifo_addr == CSR1212_INVALID_ADDR_SPACE) {
                SBP2_ERR("failed to allocate status FIFO address range");
                goto failed_alloc;
        }
@@ -1090,9 +1089,9 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
                SBP2_DMA_FREE("single query logins data");
        }
 
-       if (scsi_id->status_fifo_addr)
+       if (scsi_id->status_fifo_addr != CSR1212_INVALID_ADDR_SPACE)
                hpsb_unregister_addrspace(&sbp2_highlevel, hi->host,
-                       scsi_id->status_fifo_addr);
+                                         scsi_id->status_fifo_addr);
 
        scsi_id->ud->device.driver_data = NULL;
 
@@ -1649,6 +1648,8 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
        }
 }
 
+#define SBP2_PAYLOAD_TO_BYTES(p) (1 << ((p) + 2))
+
 /*
  * This function is called in order to determine the max speed and packet
  * size we can use in our ORBs. Note, that we (the driver and host) only
@@ -1661,6 +1662,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
 static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
 {
        struct sbp2scsi_host_info *hi = scsi_id->hi;
+       u8 payload;
 
        SBP2_DEBUG_ENTER();
 
@@ -1676,15 +1678,22 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
 
        /* Payload size is the lesser of what our speed supports and what
         * our host supports.  */
-       scsi_id->max_payload_size =
-           min(sbp2_speedto_max_payload[scsi_id->speed_code],
-               (u8) (hi->host->csr.max_rec - 1));
+       payload = min(sbp2_speedto_max_payload[scsi_id->speed_code],
+                     (u8) (hi->host->csr.max_rec - 1));
+
+       /* If physical DMA is off, work around limitation in ohci1394:
+        * packet size must not exceed PAGE_SIZE */
+       if (scsi_id->ne->host->low_addr_space < (1ULL << 32))
+               while (SBP2_PAYLOAD_TO_BYTES(payload) + 24 > PAGE_SIZE &&
+                      payload)
+                       payload--;
 
        HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
                   NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid),
                   hpsb_speedto_str[scsi_id->speed_code],
-                  1 << ((u32) scsi_id->max_payload_size + 2));
+                  SBP2_PAYLOAD_TO_BYTES(payload));
 
+       scsi_id->max_payload_size = payload;
        return 0;
 }
 
@@ -2506,6 +2515,9 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
                sdev->skip_ms_page_8 = 1;
        if (scsi_id->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
                sdev->fix_capacity = 1;
+       if (scsi_id->ne->guid_vendor_id == 0x0010b9 && /* Maxtor's OUI */
+           (sdev->type == TYPE_DISK || sdev->type == TYPE_RBC))
+               sdev->allow_restart = 1;
        return 0;
 }