hpsa.c (2d62a33e05d471bef6b2e5478f57d05b9baded85) hpsa.c (34592254c13324add1972e6a7d5f6636d95ade33)
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2014-2015 PMC-Sierra, Inc.
4 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.

--- 261 unchanged lines hidden (view full) ---

270static void hpsa_drain_accel_commands(struct ctlr_info *h);
271static void hpsa_flush_cache(struct ctlr_info *h);
272static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
273 struct CommandList *c, u32 ioaccel_handle, u8 *cdb, int cdb_len,
274 u8 *scsi3addr, struct hpsa_scsi_dev_t *phys_disk);
275static void hpsa_command_resubmit_worker(struct work_struct *work);
276static u32 lockup_detected(struct ctlr_info *h);
277static int detect_controller_lockup(struct ctlr_info *h);
1/*
2 * Disk Array driver for HP Smart Array SAS controllers
3 * Copyright 2014-2015 PMC-Sierra, Inc.
4 * Copyright 2000,2009-2015 Hewlett-Packard Development Company, L.P.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.

--- 261 unchanged lines hidden (view full) ---

270static void hpsa_drain_accel_commands(struct ctlr_info *h);
271static void hpsa_flush_cache(struct ctlr_info *h);
272static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,
273 struct CommandList *c, u32 ioaccel_handle, u8 *cdb, int cdb_len,
274 u8 *scsi3addr, struct hpsa_scsi_dev_t *phys_disk);
275static void hpsa_command_resubmit_worker(struct work_struct *work);
276static u32 lockup_detected(struct ctlr_info *h);
277static int detect_controller_lockup(struct ctlr_info *h);
278static int hpsa_luns_changed(struct ctlr_info *h);
278
279static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
280{
281 unsigned long *priv = shost_priv(sdev->host);
282 return (struct ctlr_info *) *priv;
283}
284
285static inline struct ctlr_info *shost_to_hba(struct Scsi_Host *sh)

--- 3607 unchanged lines hidden (view full) ---

3893 tmpdevice->external =
3894 figure_external_status(h, raid_ctlr_position, i,
3895 nphysicals, nlocal_logicals);
3896
3897 figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
3898 hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
3899 this_device = currentsd[ncurrent];
3900
279
280static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
281{
282 unsigned long *priv = shost_priv(sdev->host);
283 return (struct ctlr_info *) *priv;
284}
285
286static inline struct ctlr_info *shost_to_hba(struct Scsi_Host *sh)

--- 3607 unchanged lines hidden (view full) ---

3894 tmpdevice->external =
3895 figure_external_status(h, raid_ctlr_position, i,
3896 nphysicals, nlocal_logicals);
3897
3898 figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
3899 hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
3900 this_device = currentsd[ncurrent];
3901
3902 /* Turn on discovery_polling if there are ext target devices.
3903 * Event-based change notification is unreliable for those.
3904 */
3905 if (!h->discovery_polling) {
3906 if (tmpdevice->external) {
3907 h->discovery_polling = 1;
3908 dev_info(&h->pdev->dev,
3909 "External target, activate discovery polling.\n");
3910 }
3911 }
3912
3913
3901 *this_device = *tmpdevice;
3902 this_device->physical_device = physical_device;
3903
3904 /*
3905 * Expose all devices except for physical devices that
3906 * are masked.
3907 */
3908 if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)

--- 4102 unchanged lines hidden (view full) ---

8011 return 1;
8012 }
8013 spin_lock_irqsave(&h->offline_device_lock, flags);
8014 }
8015 spin_unlock_irqrestore(&h->offline_device_lock, flags);
8016 return 0;
8017}
8018
3914 *this_device = *tmpdevice;
3915 this_device->physical_device = physical_device;
3916
3917 /*
3918 * Expose all devices except for physical devices that
3919 * are masked.
3920 */
3921 if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)

--- 4102 unchanged lines hidden (view full) ---

8024 return 1;
8025 }
8026 spin_lock_irqsave(&h->offline_device_lock, flags);
8027 }
8028 spin_unlock_irqrestore(&h->offline_device_lock, flags);
8029 return 0;
8030}
8031
8032static int hpsa_luns_changed(struct ctlr_info *h)
8033{
8034 int rc = 1; /* assume there are changes */
8035 struct ReportLUNdata *logdev = NULL;
8036
8037 /* if we can't find out if lun data has changed,
8038 * assume that it has.
8039 */
8040
8041 if (!h->lastlogicals)
8042 goto out;
8043
8044 logdev = kzalloc(sizeof(*logdev), GFP_KERNEL);
8045 if (!logdev) {
8046 dev_warn(&h->pdev->dev,
8047 "Out of memory, can't track lun changes.\n");
8048 goto out;
8049 }
8050 if (hpsa_scsi_do_report_luns(h, 1, logdev, sizeof(*logdev), 0)) {
8051 dev_warn(&h->pdev->dev,
8052 "report luns failed, can't track lun changes.\n");
8053 goto out;
8054 }
8055 if (memcmp(logdev, h->lastlogicals, sizeof(*logdev))) {
8056 dev_info(&h->pdev->dev,
8057 "Lun changes detected.\n");
8058 memcpy(h->lastlogicals, logdev, sizeof(*logdev));
8059 goto out;
8060 } else
8061 rc = 0; /* no changes detected. */
8062out:
8063 kfree(logdev);
8064 return rc;
8065}
8066
8019static void hpsa_rescan_ctlr_worker(struct work_struct *work)
8020{
8021 unsigned long flags;
8022 struct ctlr_info *h = container_of(to_delayed_work(work),
8023 struct ctlr_info, rescan_ctlr_work);
8024
8025
8026 if (h->remove_in_progress)
8027 return;
8028
8029 if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) {
8030 scsi_host_get(h->scsi_host);
8031 hpsa_ack_ctlr_events(h);
8032 hpsa_scan_start(h->scsi_host);
8033 scsi_host_put(h->scsi_host);
8067static void hpsa_rescan_ctlr_worker(struct work_struct *work)
8068{
8069 unsigned long flags;
8070 struct ctlr_info *h = container_of(to_delayed_work(work),
8071 struct ctlr_info, rescan_ctlr_work);
8072
8073
8074 if (h->remove_in_progress)
8075 return;
8076
8077 if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) {
8078 scsi_host_get(h->scsi_host);
8079 hpsa_ack_ctlr_events(h);
8080 hpsa_scan_start(h->scsi_host);
8081 scsi_host_put(h->scsi_host);
8082 } else if (h->discovery_polling) {
8083 if (hpsa_luns_changed(h)) {
8084 struct Scsi_Host *sh = NULL;
8085
8086 dev_info(&h->pdev->dev,
8087 "driver discovery polling rescan.\n");
8088 sh = scsi_host_get(h->scsi_host);
8089 if (sh != NULL) {
8090 hpsa_scan_start(sh);
8091 scsi_host_put(sh);
8092 }
8093 }
8034 }
8035 spin_lock_irqsave(&h->lock, flags);
8036 if (!h->remove_in_progress)
8037 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
8038 h->heartbeat_sample_interval);
8039 spin_unlock_irqrestore(&h->lock, flags);
8040}
8041

--- 224 unchanged lines hidden (view full) ---

8266 /* don't goto clean, we already unallocated */
8267 return -ENODEV;
8268
8269 goto reinit_after_soft_reset;
8270 }
8271
8272 /* Enable Accelerated IO path at driver layer */
8273 h->acciopath_status = 1;
8094 }
8095 spin_lock_irqsave(&h->lock, flags);
8096 if (!h->remove_in_progress)
8097 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
8098 h->heartbeat_sample_interval);
8099 spin_unlock_irqrestore(&h->lock, flags);
8100}
8101

--- 224 unchanged lines hidden (view full) ---

8326 /* don't goto clean, we already unallocated */
8327 return -ENODEV;
8328
8329 goto reinit_after_soft_reset;
8330 }
8331
8332 /* Enable Accelerated IO path at driver layer */
8333 h->acciopath_status = 1;
8334 /* Disable discovery polling.*/
8335 h->discovery_polling = 0;
8274
8275
8276 /* Turn the interrupts on so we can service requests */
8277 h->access.set_intr_mask(h, HPSA_INTR_ON);
8278
8279 hpsa_hba_inquiry(h);
8280
8336
8337
8338 /* Turn the interrupts on so we can service requests */
8339 h->access.set_intr_mask(h, HPSA_INTR_ON);
8340
8341 hpsa_hba_inquiry(h);
8342
8343 h->lastlogicals = kzalloc(sizeof(*(h->lastlogicals)), GFP_KERNEL);
8344 if (!h->lastlogicals)
8345 dev_info(&h->pdev->dev,
8346 "Can't track change to report lun data\n");
8347
8281 /* Monitor the controller for firmware lockups */
8282 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
8283 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
8284 schedule_delayed_work(&h->monitor_ctlr_work,
8285 h->heartbeat_sample_interval);
8286 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker);
8287 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
8288 h->heartbeat_sample_interval);

--- 121 unchanged lines hidden (view full) ---

8410 hpsa_free_device_info(h); /* scan */
8411
8412 kfree(h->hba_inquiry_data); /* init_one 10 */
8413 h->hba_inquiry_data = NULL; /* init_one 10 */
8414 hpsa_free_ioaccel2_sg_chain_blocks(h);
8415 hpsa_free_performant_mode(h); /* init_one 7 */
8416 hpsa_free_sg_chain_blocks(h); /* init_one 6 */
8417 hpsa_free_cmd_pool(h); /* init_one 5 */
8348 /* Monitor the controller for firmware lockups */
8349 h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
8350 INIT_DELAYED_WORK(&h->monitor_ctlr_work, hpsa_monitor_ctlr_worker);
8351 schedule_delayed_work(&h->monitor_ctlr_work,
8352 h->heartbeat_sample_interval);
8353 INIT_DELAYED_WORK(&h->rescan_ctlr_work, hpsa_rescan_ctlr_worker);
8354 queue_delayed_work(h->rescan_ctlr_wq, &h->rescan_ctlr_work,
8355 h->heartbeat_sample_interval);

--- 121 unchanged lines hidden (view full) ---

8477 hpsa_free_device_info(h); /* scan */
8478
8479 kfree(h->hba_inquiry_data); /* init_one 10 */
8480 h->hba_inquiry_data = NULL; /* init_one 10 */
8481 hpsa_free_ioaccel2_sg_chain_blocks(h);
8482 hpsa_free_performant_mode(h); /* init_one 7 */
8483 hpsa_free_sg_chain_blocks(h); /* init_one 6 */
8484 hpsa_free_cmd_pool(h); /* init_one 5 */
8485 kfree(h->lastlogicals);
8418
8419 /* hpsa_free_irqs already called via hpsa_shutdown init_one 4 */
8420
8421 scsi_host_put(h->scsi_host); /* init_one 3 */
8422 h->scsi_host = NULL; /* init_one 3 */
8423
8424 /* includes hpsa_disable_interrupt_mode - pci_init 2 */
8425 hpsa_free_pci_init(h); /* init_one 2.5 */

--- 560 unchanged lines hidden ---
8486
8487 /* hpsa_free_irqs already called via hpsa_shutdown init_one 4 */
8488
8489 scsi_host_put(h->scsi_host); /* init_one 3 */
8490 h->scsi_host = NULL; /* init_one 3 */
8491
8492 /* includes hpsa_disable_interrupt_mode - pci_init 2 */
8493 hpsa_free_pci_init(h); /* init_one 2.5 */

--- 560 unchanged lines hidden ---