]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/scsi/megaraid/megaraid_sas.c
[PATCH] irq-flags: scsi: Use the new IRQF_ constants
[mirror_ubuntu-jammy-kernel.git] / drivers / scsi / megaraid / megaraid_sas.c
index 7de267e14458ba0bafaa1138c54537796c269bff..e5c017ccda595cf14804593c6b62ddc5bd16d3e8 100644 (file)
@@ -741,7 +741,6 @@ static int
 megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
 {
        u32 frame_count;
-       unsigned long flags;
        struct megasas_cmd *cmd;
        struct megasas_instance *instance;
 
@@ -772,15 +771,11 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
                goto out_return_cmd;
 
        cmd->scmd = scmd;
-       scmd->SCp.ptr = (char *)cmd;
-       scmd->SCp.sent_command = jiffies;
 
        /*
         * Issue the command to the FW
         */
-       spin_lock_irqsave(&instance->instance_lock, flags);
-       instance->fw_outstanding++;
-       spin_unlock_irqrestore(&instance->instance_lock, flags);
+       atomic_inc(&instance->fw_outstanding);
 
        instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set);
 
@@ -793,6 +788,26 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
        return 0;
 }
 
+static int megasas_slave_configure(struct scsi_device *sdev)
+{
+       /*
+        * Don't export physical disk devices to the disk driver.
+        *
+        * FIXME: Currently we don't export them to the midlayer at all.
+        *        That will be fixed once LSI engineers have audited the
+        *        firmware for possible issues.
+        */
+       if (sdev->channel < MEGASAS_MAX_PD_CHANNELS && sdev->type == TYPE_DISK)
+               return -ENXIO;
+
+       /*
+        * The RAID firmware may require extended timeouts.
+        */
+       if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS)
+               sdev->timeout = 90 * HZ;
+       return 0;
+}
+
 /**
  * megasas_wait_for_outstanding -      Wait for all outstanding cmds
  * @instance:                          Adapter soft state
@@ -808,19 +823,20 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
 
        for (i = 0; i < wait_time; i++) {
 
-               if (!instance->fw_outstanding)
+               int outstanding = atomic_read(&instance->fw_outstanding);
+
+               if (!outstanding)
                        break;
 
                if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
                        printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
-                              "commands to complete\n", i,
-                              instance->fw_outstanding);
+                              "commands to complete\n",i,outstanding);
                }
 
                msleep(1000);
        }
 
-       if (instance->fw_outstanding) {
+       if (atomic_read(&instance->fw_outstanding)) {
                instance->hw_crit_error = 1;
                return FAILED;
        }
@@ -861,23 +877,6 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
        return ret_val;
 }
 
-static enum scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
-{
-       unsigned long seconds;
-
-       if (scmd->SCp.ptr) {
-               seconds = (jiffies - scmd->SCp.sent_command) / HZ;
-
-               if (seconds < 90) {
-                       return EH_RESET_TIMER;
-               } else {
-                       return EH_NOT_HANDLED;
-               }
-       }
-
-       return EH_HANDLED;
-}
-
 /**
  * megasas_reset_device -      Device reset handler entry point
  */
@@ -901,7 +900,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
        int ret;
 
        /*
-        * Frist wait for all commands to complete
+        * First wait for all commands to complete
         */
        ret = megasas_generic_reset(scmd);
 
@@ -943,11 +942,11 @@ static struct scsi_host_template megasas_template = {
        .module = THIS_MODULE,
        .name = "LSI Logic SAS based MegaRAID driver",
        .proc_name = "megaraid_sas",
+       .slave_configure = megasas_slave_configure,
        .queuecommand = megasas_queue_command,
        .eh_device_reset_handler = megasas_reset_device,
        .eh_bus_reset_handler = megasas_reset_bus_host,
        .eh_host_reset_handler = megasas_reset_bus_host,
-       .eh_timed_out = megasas_reset_timer,
        .use_clustering = ENABLE_CLUSTERING,
 };
 
@@ -1049,7 +1048,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 {
        int exception = 0;
        struct megasas_header *hdr = &cmd->frame->hdr;
-       unsigned long flags;
 
        if (cmd->scmd) {
                cmd->scmd->SCp.ptr = (char *)0;
@@ -1071,20 +1069,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        break;
                }
 
-               /*
-                * Don't export physical disk devices to mid-layer.
-                */
-               if (!MEGASAS_IS_LOGICAL(cmd->scmd) &&
-                   (hdr->cmd_status == MFI_STAT_OK) &&
-                   (cmd->scmd->cmnd[0] == INQUIRY)) {
-
-                       if (((*(u8 *) cmd->scmd->request_buffer) & 0x1F) ==
-                           TYPE_DISK) {
-                               cmd->scmd->result = DID_BAD_TARGET << 16;
-                               exception = 1;
-                       }
-               }
-
        case MFI_CMD_LD_READ:
        case MFI_CMD_LD_WRITE:
 
@@ -1095,9 +1079,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
 
                if (exception) {
 
-                       spin_lock_irqsave(&instance->instance_lock, flags);
-                       instance->fw_outstanding--;
-                       spin_unlock_irqrestore(&instance->instance_lock, flags);
+                       atomic_dec(&instance->fw_outstanding);
 
                        megasas_unmap_sgbuf(instance, cmd);
                        cmd->scmd->scsi_done(cmd->scmd);
@@ -1145,9 +1127,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        break;
                }
 
-               spin_lock_irqsave(&instance->instance_lock, flags);
-               instance->fw_outstanding--;
-               spin_unlock_irqrestore(&instance->instance_lock, flags);
+               atomic_dec(&instance->fw_outstanding);
 
                megasas_unmap_sgbuf(instance, cmd);
                cmd->scmd->scsi_done(cmd->scmd);
@@ -2184,11 +2164,12 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
         */
        INIT_LIST_HEAD(&instance->cmd_pool);
 
+       atomic_set(&instance->fw_outstanding,0);
+
        init_waitqueue_head(&instance->int_cmd_wait_q);
        init_waitqueue_head(&instance->abort_cmd_wait_q);
 
        spin_lock_init(&instance->cmd_pool_lock);
-       spin_lock_init(&instance->instance_lock);
 
        sema_init(&instance->aen_mutex, 1);
        sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS);
@@ -2210,7 +2191,7 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /*
         * Register IRQ
         */
-       if (request_irq(pdev->irq, megasas_isr, SA_SHIRQ, "megasas", instance)) {
+       if (request_irq(pdev->irq, megasas_isr, IRQF_SHARED, "megasas", instance)) {
                printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
                goto fail_irq;
        }