hpsa.c (d2315ce6e3d09c8dbc9ee93ef6b3f5213e8325ac) | hpsa.c (c59d04f30d4216af12930a4f5fdc35f490777171) |
---|---|
1/* 2 * Disk Array driver for HP Smart Array SAS controllers 3 * Copyright 2016 Microsemi Corporation 4 * Copyright 2014-2015 PMC-Sierra, Inc. 5 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 1845 unchanged lines hidden (view full) --- 1854 unsigned long flags; 1855 struct hpsa_scsi_dev_t **added, **removed; 1856 int nadded, nremoved; 1857 1858 /* 1859 * A reset can cause a device status to change 1860 * re-schedule the scan to see what happened. 1861 */ | 1/* 2 * Disk Array driver for HP Smart Array SAS controllers 3 * Copyright 2016 Microsemi Corporation 4 * Copyright 2014-2015 PMC-Sierra, Inc. 5 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 1845 unchanged lines hidden (view full) --- 1854 unsigned long flags; 1855 struct hpsa_scsi_dev_t **added, **removed; 1856 int nadded, nremoved; 1857 1858 /* 1859 * A reset can cause a device status to change 1860 * re-schedule the scan to see what happened. 1861 */ |
1862 spin_lock_irqsave(&h->reset_lock, flags); |
|
1862 if (h->reset_in_progress) { 1863 h->drv_req_rescan = 1; | 1863 if (h->reset_in_progress) { 1864 h->drv_req_rescan = 1; |
1865 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
1864 return; 1865 } | 1866 return; 1867 } |
1868 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
1866 1867 added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); 1868 removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); 1869 1870 if (!added || !removed) { 1871 dev_warn(&h->pdev->dev, "out of memory in " 1872 "adjust_hpsa_scsi_table\n"); 1873 goto free_and_out; --- 3739 unchanged lines hidden (view full) --- 5613 spin_unlock_irqrestore(&h->scan_lock, flags); 5614 5615 if (unlikely(lockup_detected(h))) 5616 return hpsa_scan_complete(h); 5617 5618 /* 5619 * Do the scan after a reset completion 5620 */ | 1869 1870 added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); 1871 removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); 1872 1873 if (!added || !removed) { 1874 dev_warn(&h->pdev->dev, "out of memory in " 1875 "adjust_hpsa_scsi_table\n"); 1876 goto free_and_out; --- 3739 unchanged lines hidden (view full) --- 5616 spin_unlock_irqrestore(&h->scan_lock, flags); 5617 5618 if (unlikely(lockup_detected(h))) 5619 return hpsa_scan_complete(h); 5620 5621 /* 5622 * Do the scan after a reset completion 5623 */ |
5624 spin_lock_irqsave(&h->reset_lock, flags); |
|
5621 if (h->reset_in_progress) { 5622 h->drv_req_rescan = 1; | 5625 if (h->reset_in_progress) { 5626 h->drv_req_rescan = 1; |
5627 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
5623 hpsa_scan_complete(h); 5624 return; 5625 } | 5628 hpsa_scan_complete(h); 5629 return; 5630 } |
5631 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
5626 5627 hpsa_update_scsi_devices(h); 5628 5629 hpsa_scan_complete(h); 5630} 5631 5632static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth) 5633{ --- 195 unchanged lines hidden (view full) --- 5829 return rc; 5830} 5831 5832/* Need at least one of these error handlers to keep ../scsi/hosts.c from 5833 * complaining. Doing a host- or bus-reset can't do anything good here. 5834 */ 5835static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) 5836{ | 5632 5633 hpsa_update_scsi_devices(h); 5634 5635 hpsa_scan_complete(h); 5636} 5637 5638static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth) 5639{ --- 195 unchanged lines hidden (view full) --- 5835 return rc; 5836} 5837 5838/* Need at least one of these error handlers to keep ../scsi/hosts.c from 5839 * complaining. Doing a host- or bus-reset can't do anything good here. 5840 */ 5841static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) 5842{ |
5837 int rc; | 5843 int rc = SUCCESS; |
5838 struct ctlr_info *h; 5839 struct hpsa_scsi_dev_t *dev; 5840 u8 reset_type; 5841 char msg[48]; | 5844 struct ctlr_info *h; 5845 struct hpsa_scsi_dev_t *dev; 5846 u8 reset_type; 5847 char msg[48]; |
5848 unsigned long flags; |
|
5842 5843 /* find the controller to which the command to be aborted was sent */ 5844 h = sdev_to_hba(scsicmd->device); 5845 if (h == NULL) /* paranoia */ 5846 return FAILED; 5847 | 5849 5850 /* find the controller to which the command to be aborted was sent */ 5851 h = sdev_to_hba(scsicmd->device); 5852 if (h == NULL) /* paranoia */ 5853 return FAILED; 5854 |
5848 if (lockup_detected(h)) 5849 return FAILED; | 5855 spin_lock_irqsave(&h->reset_lock, flags); 5856 h->reset_in_progress = 1; 5857 spin_unlock_irqrestore(&h->reset_lock, flags); |
5850 | 5858 |
5859 if (lockup_detected(h)) { 5860 rc = FAILED; 5861 goto return_reset_status; 5862 } 5863 |
|
5851 dev = scsicmd->device->hostdata; 5852 if (!dev) { 5853 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); | 5864 dev = scsicmd->device->hostdata; 5865 if (!dev) { 5866 dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); |
5854 return FAILED; | 5867 rc = FAILED; 5868 goto return_reset_status; |
5855 } 5856 | 5869 } 5870 |
5857 if (dev->devtype == TYPE_ENCLOSURE) 5858 return SUCCESS; | 5871 if (dev->devtype == TYPE_ENCLOSURE) { 5872 rc = SUCCESS; 5873 goto return_reset_status; 5874 } |
5859 5860 /* if controller locked up, we can guarantee command won't complete */ 5861 if (lockup_detected(h)) { 5862 snprintf(msg, sizeof(msg), 5863 "cmd %d RESET FAILED, lockup detected", 5864 hpsa_get_cmd_index(scsicmd)); 5865 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); | 5875 5876 /* if controller locked up, we can guarantee command won't complete */ 5877 if (lockup_detected(h)) { 5878 snprintf(msg, sizeof(msg), 5879 "cmd %d RESET FAILED, lockup detected", 5880 hpsa_get_cmd_index(scsicmd)); 5881 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); |
5866 return FAILED; | 5882 rc = FAILED; 5883 goto return_reset_status; |
5867 } 5868 5869 /* this reset request might be the result of a lockup; check */ 5870 if (detect_controller_lockup(h)) { 5871 snprintf(msg, sizeof(msg), 5872 "cmd %d RESET FAILED, new lockup detected", 5873 hpsa_get_cmd_index(scsicmd)); 5874 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); | 5884 } 5885 5886 /* this reset request might be the result of a lockup; check */ 5887 if (detect_controller_lockup(h)) { 5888 snprintf(msg, sizeof(msg), 5889 "cmd %d RESET FAILED, new lockup detected", 5890 hpsa_get_cmd_index(scsicmd)); 5891 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); |
5875 return FAILED; | 5892 rc = FAILED; 5893 goto return_reset_status; |
5876 } 5877 5878 /* Do not attempt on controller */ | 5894 } 5895 5896 /* Do not attempt on controller */ |
5879 if (is_hba_lunid(dev->scsi3addr)) 5880 return SUCCESS; | 5897 if (is_hba_lunid(dev->scsi3addr)) { 5898 rc = SUCCESS; 5899 goto return_reset_status; 5900 } |
5881 5882 if (is_logical_dev_addr_mode(dev->scsi3addr)) 5883 reset_type = HPSA_DEVICE_RESET_MSG; 5884 else 5885 reset_type = HPSA_PHYS_TARGET_RESET; 5886 5887 sprintf(msg, "resetting %s", 5888 reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical "); 5889 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); 5890 | 5901 5902 if (is_logical_dev_addr_mode(dev->scsi3addr)) 5903 reset_type = HPSA_DEVICE_RESET_MSG; 5904 else 5905 reset_type = HPSA_PHYS_TARGET_RESET; 5906 5907 sprintf(msg, "resetting %s", 5908 reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical "); 5909 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); 5910 |
5891 h->reset_in_progress = 1; 5892 | |
5893 /* send a reset to the SCSI LUN which the command was sent to */ 5894 rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type, 5895 DEFAULT_REPLY_QUEUE); | 5911 /* send a reset to the SCSI LUN which the command was sent to */ 5912 rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type, 5913 DEFAULT_REPLY_QUEUE); |
5914 if (rc == 0) 5915 rc = SUCCESS; 5916 else 5917 rc = FAILED; 5918 |
|
5896 sprintf(msg, "reset %s %s", 5897 reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ", | 5919 sprintf(msg, "reset %s %s", 5920 reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ", |
5898 rc == 0 ? "completed successfully" : "failed"); | 5921 rc == SUCCESS ? "completed successfully" : "failed"); |
5899 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); | 5922 hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); |
5923 5924return_reset_status: 5925 spin_lock_irqsave(&h->reset_lock, flags); |
|
5900 h->reset_in_progress = 0; | 5926 h->reset_in_progress = 0; |
5901 return rc == 0 ? SUCCESS : FAILED; | 5927 spin_unlock_irqrestore(&h->reset_lock, flags); 5928 return rc; |
5902} 5903 5904static void swizzle_abort_tag(u8 *tag) 5905{ 5906 u8 original_tag[8]; 5907 5908 memcpy(original_tag, tag, 8); 5909 tag[0] = original_tag[3]; --- 2734 unchanged lines hidden (view full) --- 8644 8645 8646 if (h->remove_in_progress) 8647 return; 8648 8649 /* 8650 * Do the scan after the reset 8651 */ | 5929} 5930 5931static void swizzle_abort_tag(u8 *tag) 5932{ 5933 u8 original_tag[8]; 5934 5935 memcpy(original_tag, tag, 8); 5936 tag[0] = original_tag[3]; --- 2734 unchanged lines hidden (view full) --- 8671 8672 8673 if (h->remove_in_progress) 8674 return; 8675 8676 /* 8677 * Do the scan after the reset 8678 */ |
8679 spin_lock_irqsave(&h->reset_lock, flags); |
|
8652 if (h->reset_in_progress) { 8653 h->drv_req_rescan = 1; | 8680 if (h->reset_in_progress) { 8681 h->drv_req_rescan = 1; |
8682 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
8654 return; 8655 } | 8683 return; 8684 } |
8685 spin_unlock_irqrestore(&h->reset_lock, flags); |
|
8656 8657 if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) { 8658 scsi_host_get(h->scsi_host); 8659 hpsa_ack_ctlr_events(h); 8660 hpsa_scan_start(h->scsi_host); 8661 scsi_host_put(h->scsi_host); 8662 } else if (h->discovery_polling) { 8663 hpsa_disable_rld_caching(h); --- 90 unchanged lines hidden (view full) --- 8754 8755 h->pdev = pdev; 8756 8757 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; 8758 INIT_LIST_HEAD(&h->offline_device_list); 8759 spin_lock_init(&h->lock); 8760 spin_lock_init(&h->offline_device_lock); 8761 spin_lock_init(&h->scan_lock); | 8686 8687 if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) { 8688 scsi_host_get(h->scsi_host); 8689 hpsa_ack_ctlr_events(h); 8690 hpsa_scan_start(h->scsi_host); 8691 scsi_host_put(h->scsi_host); 8692 } else if (h->discovery_polling) { 8693 hpsa_disable_rld_caching(h); --- 90 unchanged lines hidden (view full) --- 8784 8785 h->pdev = pdev; 8786 8787 h->intr_mode = hpsa_simple_mode ? SIMPLE_MODE_INT : PERF_MODE_INT; 8788 INIT_LIST_HEAD(&h->offline_device_list); 8789 spin_lock_init(&h->lock); 8790 spin_lock_init(&h->offline_device_lock); 8791 spin_lock_init(&h->scan_lock); |
8792 spin_lock_init(&h->reset_lock); |
|
8762 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); 8763 atomic_set(&h->abort_cmds_available, HPSA_CMDS_RESERVED_FOR_ABORTS); 8764 8765 /* Allocate and clear per-cpu variable lockup_detected */ 8766 h->lockup_detected = alloc_percpu(u32); 8767 if (!h->lockup_detected) { 8768 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); 8769 rc = -ENOMEM; --- 1279 unchanged lines hidden --- | 8793 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); 8794 atomic_set(&h->abort_cmds_available, HPSA_CMDS_RESERVED_FOR_ABORTS); 8795 8796 /* Allocate and clear per-cpu variable lockup_detected */ 8797 h->lockup_detected = alloc_percpu(u32); 8798 if (!h->lockup_detected) { 8799 dev_err(&h->pdev->dev, "Failed to allocate lockup detector\n"); 8800 rc = -ENOMEM; --- 1279 unchanged lines hidden --- |