.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Adaptec AAC series RAID controller driver |
---|
3 | 4 | * (c) Copyright 2001 Red Hat Inc. |
---|
.. | .. |
---|
8 | 9 | * Copyright (c) 2000-2010 Adaptec, Inc. |
---|
9 | 10 | * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com) |
---|
10 | 11 | * 2016-2017 Microsemi Corp. (aacraid@microsemi.com) |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or modify |
---|
13 | | - * it under the terms of the GNU General Public License as published by |
---|
14 | | - * the Free Software Foundation; either version 2, or (at your option) |
---|
15 | | - * any later version. |
---|
16 | | - * |
---|
17 | | - * This program is distributed in the hope that it will be useful, |
---|
18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | | - * GNU General Public License for more details. |
---|
21 | | - * |
---|
22 | | - * You should have received a copy of the GNU General Public License |
---|
23 | | - * along with this program; see the file COPYING. If not, write to |
---|
24 | | - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
25 | 12 | * |
---|
26 | 13 | * Module Name: |
---|
27 | 14 | * linit.c |
---|
.. | .. |
---|
40 | 27 | #include <linux/moduleparam.h> |
---|
41 | 28 | #include <linux/pci.h> |
---|
42 | 29 | #include <linux/aer.h> |
---|
43 | | -#include <linux/pci-aspm.h> |
---|
44 | 30 | #include <linux/slab.h> |
---|
45 | 31 | #include <linux/mutex.h> |
---|
46 | 32 | #include <linux/spinlock.h> |
---|
47 | 33 | #include <linux/syscalls.h> |
---|
48 | 34 | #include <linux/delay.h> |
---|
49 | 35 | #include <linux/kthread.h> |
---|
| 36 | +#include <linux/msdos_partition.h> |
---|
50 | 37 | |
---|
51 | 38 | #include <scsi/scsi.h> |
---|
52 | 39 | #include <scsi/scsi_cmnd.h> |
---|
.. | .. |
---|
243 | 230 | |
---|
244 | 231 | /** |
---|
245 | 232 | * aac_queuecommand - queue a SCSI command |
---|
| 233 | + * @shost: Scsi host to queue command on |
---|
246 | 234 | * @cmd: SCSI command to queue |
---|
247 | | - * @done: Function to call on command completion |
---|
248 | 235 | * |
---|
249 | 236 | * Queues a command for execution by the associated Host Adapter. |
---|
250 | 237 | * |
---|
.. | .. |
---|
342 | 329 | buf = scsi_bios_ptable(bdev); |
---|
343 | 330 | if (!buf) |
---|
344 | 331 | return 0; |
---|
345 | | - if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) { |
---|
346 | | - struct partition *first = (struct partition * )buf; |
---|
347 | | - struct partition *entry = first; |
---|
| 332 | + if (*(__le16 *)(buf + 0x40) == cpu_to_le16(MSDOS_LABEL_MAGIC)) { |
---|
| 333 | + struct msdos_partition *first = (struct msdos_partition *)buf; |
---|
| 334 | + struct msdos_partition *entry = first; |
---|
348 | 335 | int saved_cylinders = param->cylinders; |
---|
349 | 336 | int num; |
---|
350 | 337 | unsigned char end_head, end_sec; |
---|
.. | .. |
---|
376 | 363 | |
---|
377 | 364 | param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors); |
---|
378 | 365 | if (num < 4 && end_sec == param->sectors) { |
---|
379 | | - if (param->cylinders != saved_cylinders) |
---|
| 366 | + if (param->cylinders != saved_cylinders) { |
---|
380 | 367 | dprintk((KERN_DEBUG "Adopting geometry: heads=%d, sectors=%d from partition table %d.\n", |
---|
381 | 368 | param->heads, param->sectors, num)); |
---|
| 369 | + } |
---|
382 | 370 | } else if (end_head > 0 || end_sec > 0) { |
---|
383 | 371 | dprintk((KERN_DEBUG "Strange geometry: heads=%d, sectors=%d in partition table %d.\n", |
---|
384 | 372 | end_head + 1, end_sec, num)); |
---|
.. | .. |
---|
405 | 393 | int chn, tid; |
---|
406 | 394 | unsigned int depth = 0; |
---|
407 | 395 | unsigned int set_timeout = 0; |
---|
| 396 | + int timeout = 0; |
---|
408 | 397 | bool set_qd_dev_type = false; |
---|
409 | 398 | u8 devtype = 0; |
---|
410 | 399 | |
---|
.. | .. |
---|
497 | 486 | |
---|
498 | 487 | /* |
---|
499 | 488 | * Firmware has an individual device recovery time typically |
---|
500 | | - * of 35 seconds, give us a margin. |
---|
| 489 | + * of 35 seconds, give us a margin. Thor devices can take longer in |
---|
| 490 | + * error recovery, hence different value. |
---|
501 | 491 | */ |
---|
502 | | - if (set_timeout && sdev->request_queue->rq_timeout < (45 * HZ)) |
---|
503 | | - blk_queue_rq_timeout(sdev->request_queue, 45*HZ); |
---|
| 492 | + if (set_timeout) { |
---|
| 493 | + timeout = aac->sa_firmware ? AAC_SA_TIMEOUT : AAC_ARC_TIMEOUT; |
---|
| 494 | + blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); |
---|
| 495 | + } |
---|
504 | 496 | |
---|
505 | 497 | if (depth > 256) |
---|
506 | 498 | depth = 256; |
---|
.. | .. |
---|
619 | 611 | NULL, |
---|
620 | 612 | }; |
---|
621 | 613 | |
---|
622 | | -static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg) |
---|
| 614 | +static int aac_ioctl(struct scsi_device *sdev, unsigned int cmd, |
---|
| 615 | + void __user *arg) |
---|
623 | 616 | { |
---|
| 617 | + int retval; |
---|
624 | 618 | struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; |
---|
625 | 619 | if (!capable(CAP_SYS_RAWIO)) |
---|
626 | 620 | return -EPERM; |
---|
| 621 | + retval = aac_adapter_check_health(dev); |
---|
| 622 | + if (retval) |
---|
| 623 | + return -EBUSY; |
---|
627 | 624 | return aac_do_ioctl(dev, cmd, arg); |
---|
628 | 625 | } |
---|
629 | 626 | |
---|
| 627 | +struct fib_count_data { |
---|
| 628 | + int mlcnt; |
---|
| 629 | + int llcnt; |
---|
| 630 | + int ehcnt; |
---|
| 631 | + int fwcnt; |
---|
| 632 | + int krlcnt; |
---|
| 633 | +}; |
---|
| 634 | + |
---|
| 635 | +static bool fib_count_iter(struct scsi_cmnd *scmnd, void *data, bool reserved) |
---|
| 636 | +{ |
---|
| 637 | + struct fib_count_data *fib_count = data; |
---|
| 638 | + |
---|
| 639 | + switch (scmnd->SCp.phase) { |
---|
| 640 | + case AAC_OWNER_FIRMWARE: |
---|
| 641 | + fib_count->fwcnt++; |
---|
| 642 | + break; |
---|
| 643 | + case AAC_OWNER_ERROR_HANDLER: |
---|
| 644 | + fib_count->ehcnt++; |
---|
| 645 | + break; |
---|
| 646 | + case AAC_OWNER_LOWLEVEL: |
---|
| 647 | + fib_count->llcnt++; |
---|
| 648 | + break; |
---|
| 649 | + case AAC_OWNER_MIDLEVEL: |
---|
| 650 | + fib_count->mlcnt++; |
---|
| 651 | + break; |
---|
| 652 | + default: |
---|
| 653 | + fib_count->krlcnt++; |
---|
| 654 | + break; |
---|
| 655 | + } |
---|
| 656 | + return true; |
---|
| 657 | +} |
---|
| 658 | + |
---|
| 659 | +/* Called during SCSI EH, so we don't need to block requests */ |
---|
630 | 660 | static int get_num_of_incomplete_fibs(struct aac_dev *aac) |
---|
631 | 661 | { |
---|
632 | | - |
---|
633 | | - unsigned long flags; |
---|
634 | | - struct scsi_device *sdev = NULL; |
---|
635 | 662 | struct Scsi_Host *shost = aac->scsi_host_ptr; |
---|
636 | | - struct scsi_cmnd *scmnd = NULL; |
---|
637 | 663 | struct device *ctrl_dev; |
---|
| 664 | + struct fib_count_data fcnt = { }; |
---|
638 | 665 | |
---|
639 | | - int mlcnt = 0; |
---|
640 | | - int llcnt = 0; |
---|
641 | | - int ehcnt = 0; |
---|
642 | | - int fwcnt = 0; |
---|
643 | | - int krlcnt = 0; |
---|
644 | | - |
---|
645 | | - __shost_for_each_device(sdev, shost) { |
---|
646 | | - spin_lock_irqsave(&sdev->list_lock, flags); |
---|
647 | | - list_for_each_entry(scmnd, &sdev->cmd_list, list) { |
---|
648 | | - switch (scmnd->SCp.phase) { |
---|
649 | | - case AAC_OWNER_FIRMWARE: |
---|
650 | | - fwcnt++; |
---|
651 | | - break; |
---|
652 | | - case AAC_OWNER_ERROR_HANDLER: |
---|
653 | | - ehcnt++; |
---|
654 | | - break; |
---|
655 | | - case AAC_OWNER_LOWLEVEL: |
---|
656 | | - llcnt++; |
---|
657 | | - break; |
---|
658 | | - case AAC_OWNER_MIDLEVEL: |
---|
659 | | - mlcnt++; |
---|
660 | | - break; |
---|
661 | | - default: |
---|
662 | | - krlcnt++; |
---|
663 | | - break; |
---|
664 | | - } |
---|
665 | | - } |
---|
666 | | - spin_unlock_irqrestore(&sdev->list_lock, flags); |
---|
667 | | - } |
---|
| 666 | + scsi_host_busy_iter(shost, fib_count_iter, &fcnt); |
---|
668 | 667 | |
---|
669 | 668 | ctrl_dev = &aac->pdev->dev; |
---|
670 | 669 | |
---|
671 | | - dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", mlcnt); |
---|
672 | | - dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", llcnt); |
---|
673 | | - dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", ehcnt); |
---|
674 | | - dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fwcnt); |
---|
675 | | - dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", krlcnt); |
---|
| 670 | + dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", fcnt.mlcnt); |
---|
| 671 | + dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", fcnt.llcnt); |
---|
| 672 | + dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", fcnt.ehcnt); |
---|
| 673 | + dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fcnt.fwcnt); |
---|
| 674 | + dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", fcnt.krlcnt); |
---|
676 | 675 | |
---|
677 | | - return mlcnt + llcnt + ehcnt + fwcnt; |
---|
| 676 | + return fcnt.mlcnt + fcnt.llcnt + fcnt.ehcnt + fcnt.fwcnt; |
---|
678 | 677 | } |
---|
679 | 678 | |
---|
680 | 679 | static int aac_eh_abort(struct scsi_cmnd* cmd) |
---|
.. | .. |
---|
766 | 765 | !(aac->raw_io_64) || |
---|
767 | 766 | ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) |
---|
768 | 767 | break; |
---|
| 768 | + fallthrough; |
---|
769 | 769 | case INQUIRY: |
---|
770 | 770 | case READ_CAPACITY: |
---|
771 | 771 | /* |
---|
.. | .. |
---|
858 | 858 | |
---|
859 | 859 | address = (u64)fib->hw_error_pa; |
---|
860 | 860 | rst->error_ptr_hi = cpu_to_le32((u32)(address >> 32)); |
---|
861 | | - rst->error_ptr_lo = cpu_to_le32 |
---|
862 | | - ((u32)(address & 0xffffffff)); |
---|
| 861 | + rst->error_ptr_lo = cpu_to_le32((u32)(address & 0xffffffff)); |
---|
863 | 862 | rst->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); |
---|
864 | 863 | fib->hbacmd_size = sizeof(*rst); |
---|
865 | 864 | |
---|
866 | 865 | return HBA_IU_TYPE_SATA_REQ; |
---|
867 | 866 | } |
---|
868 | 867 | |
---|
869 | | -void aac_tmf_callback(void *context, struct fib *fibptr) |
---|
| 868 | +static void aac_tmf_callback(void *context, struct fib *fibptr) |
---|
870 | 869 | { |
---|
871 | 870 | struct aac_hba_resp *err = |
---|
872 | 871 | &((struct aac_native_hba *)fibptr->hw_fib_va)->resp.err; |
---|
.. | .. |
---|
1080 | 1079 | * @scsi_cmd: SCSI command block causing the reset |
---|
1081 | 1080 | * |
---|
1082 | 1081 | */ |
---|
1083 | | -int aac_eh_host_reset(struct scsi_cmnd *cmd) |
---|
| 1082 | +static int aac_eh_host_reset(struct scsi_cmnd *cmd) |
---|
1084 | 1083 | { |
---|
1085 | 1084 | struct scsi_device * dev = cmd->device; |
---|
1086 | 1085 | struct Scsi_Host * host = dev->host; |
---|
.. | .. |
---|
1161 | 1160 | |
---|
1162 | 1161 | /** |
---|
1163 | 1162 | * aac_cfg_ioctl - AAC configuration request |
---|
1164 | | - * @inode: inode of device |
---|
1165 | 1163 | * @file: file handle |
---|
1166 | 1164 | * @cmd: ioctl command code |
---|
1167 | 1165 | * @arg: argument |
---|
.. | .. |
---|
1183 | 1181 | |
---|
1184 | 1182 | return aac_do_ioctl(aac, cmd, (void __user *)arg); |
---|
1185 | 1183 | } |
---|
1186 | | - |
---|
1187 | | -#ifdef CONFIG_COMPAT |
---|
1188 | | -static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) |
---|
1189 | | -{ |
---|
1190 | | - long ret; |
---|
1191 | | - switch (cmd) { |
---|
1192 | | - case FSACTL_MINIPORT_REV_CHECK: |
---|
1193 | | - case FSACTL_SENDFIB: |
---|
1194 | | - case FSACTL_OPEN_GET_ADAPTER_FIB: |
---|
1195 | | - case FSACTL_CLOSE_GET_ADAPTER_FIB: |
---|
1196 | | - case FSACTL_SEND_RAW_SRB: |
---|
1197 | | - case FSACTL_GET_PCI_INFO: |
---|
1198 | | - case FSACTL_QUERY_DISK: |
---|
1199 | | - case FSACTL_DELETE_DISK: |
---|
1200 | | - case FSACTL_FORCE_DELETE_DISK: |
---|
1201 | | - case FSACTL_GET_CONTAINERS: |
---|
1202 | | - case FSACTL_SEND_LARGE_FIB: |
---|
1203 | | - ret = aac_do_ioctl(dev, cmd, (void __user *)arg); |
---|
1204 | | - break; |
---|
1205 | | - |
---|
1206 | | - case FSACTL_GET_NEXT_ADAPTER_FIB: { |
---|
1207 | | - struct fib_ioctl __user *f; |
---|
1208 | | - |
---|
1209 | | - f = compat_alloc_user_space(sizeof(*f)); |
---|
1210 | | - ret = 0; |
---|
1211 | | - if (clear_user(f, sizeof(*f))) |
---|
1212 | | - ret = -EFAULT; |
---|
1213 | | - if (copy_in_user(f, (void __user *)arg, sizeof(struct fib_ioctl) - sizeof(u32))) |
---|
1214 | | - ret = -EFAULT; |
---|
1215 | | - if (!ret) |
---|
1216 | | - ret = aac_do_ioctl(dev, cmd, f); |
---|
1217 | | - break; |
---|
1218 | | - } |
---|
1219 | | - |
---|
1220 | | - default: |
---|
1221 | | - ret = -ENOIOCTLCMD; |
---|
1222 | | - break; |
---|
1223 | | - } |
---|
1224 | | - return ret; |
---|
1225 | | -} |
---|
1226 | | - |
---|
1227 | | -static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) |
---|
1228 | | -{ |
---|
1229 | | - struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; |
---|
1230 | | - if (!capable(CAP_SYS_RAWIO)) |
---|
1231 | | - return -EPERM; |
---|
1232 | | - return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg); |
---|
1233 | | -} |
---|
1234 | | - |
---|
1235 | | -static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long arg) |
---|
1236 | | -{ |
---|
1237 | | - if (!capable(CAP_SYS_RAWIO)) |
---|
1238 | | - return -EPERM; |
---|
1239 | | - return aac_compat_do_ioctl(file->private_data, cmd, arg); |
---|
1240 | | -} |
---|
1241 | | -#endif |
---|
1242 | 1184 | |
---|
1243 | 1185 | static ssize_t aac_show_model(struct device *device, |
---|
1244 | 1186 | struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
1289 | 1231 | if (nblank(dprintk(x))) |
---|
1290 | 1232 | len = snprintf(buf, PAGE_SIZE, "dprintk\n"); |
---|
1291 | 1233 | #ifdef AAC_DETAILED_STATUS_INFO |
---|
1292 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
1293 | | - "AAC_DETAILED_STATUS_INFO\n"); |
---|
| 1234 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
| 1235 | + "AAC_DETAILED_STATUS_INFO\n"); |
---|
1294 | 1236 | #endif |
---|
1295 | 1237 | if (dev->raw_io_interface && dev->raw_io_64) |
---|
1296 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
1297 | | - "SAI_READ_CAPACITY_16\n"); |
---|
| 1238 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
| 1239 | + "SAI_READ_CAPACITY_16\n"); |
---|
1298 | 1240 | if (dev->jbod) |
---|
1299 | | - len += snprintf(buf + len, PAGE_SIZE - len, "SUPPORTED_JBOD\n"); |
---|
| 1241 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
| 1242 | + "SUPPORTED_JBOD\n"); |
---|
1300 | 1243 | if (dev->supplement_adapter_info.supported_options2 & |
---|
1301 | 1244 | AAC_OPTION_POWER_MANAGEMENT) |
---|
1302 | | - len += snprintf(buf + len, PAGE_SIZE - len, |
---|
1303 | | - "SUPPORTED_POWER_MANAGEMENT\n"); |
---|
| 1245 | + len += scnprintf(buf + len, PAGE_SIZE - len, |
---|
| 1246 | + "SUPPORTED_POWER_MANAGEMENT\n"); |
---|
1304 | 1247 | if (dev->msi) |
---|
1305 | | - len += snprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); |
---|
| 1248 | + len += scnprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); |
---|
1306 | 1249 | return len; |
---|
1307 | 1250 | } |
---|
1308 | 1251 | |
---|
.. | .. |
---|
1523 | 1466 | .owner = THIS_MODULE, |
---|
1524 | 1467 | .unlocked_ioctl = aac_cfg_ioctl, |
---|
1525 | 1468 | #ifdef CONFIG_COMPAT |
---|
1526 | | - .compat_ioctl = aac_compat_cfg_ioctl, |
---|
| 1469 | + .compat_ioctl = aac_cfg_ioctl, |
---|
1527 | 1470 | #endif |
---|
1528 | 1471 | .open = aac_cfg_open, |
---|
1529 | 1472 | .llseek = noop_llseek, |
---|
.. | .. |
---|
1536 | 1479 | .info = aac_info, |
---|
1537 | 1480 | .ioctl = aac_ioctl, |
---|
1538 | 1481 | #ifdef CONFIG_COMPAT |
---|
1539 | | - .compat_ioctl = aac_compat_ioctl, |
---|
| 1482 | + .compat_ioctl = aac_ioctl, |
---|
1540 | 1483 | #endif |
---|
1541 | 1484 | .queuecommand = aac_queuecommand, |
---|
1542 | 1485 | .bios_param = aac_biosparm, |
---|
.. | .. |
---|
1558 | 1501 | #else |
---|
1559 | 1502 | .cmd_per_lun = AAC_NUM_IO_FIB, |
---|
1560 | 1503 | #endif |
---|
1561 | | - .use_clustering = ENABLE_CLUSTERING, |
---|
1562 | 1504 | .emulated = 1, |
---|
1563 | 1505 | .no_write_same = 1, |
---|
1564 | 1506 | }; |
---|
.. | .. |
---|
1578 | 1520 | struct fib *fib = &aac->fibs[i]; |
---|
1579 | 1521 | if (!(fib->hw_fib_va->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && |
---|
1580 | 1522 | (fib->hw_fib_va->header.XferState & cpu_to_le32(ResponseExpected))) |
---|
1581 | | - up(&fib->event_wait); |
---|
| 1523 | + complete(&fib->event_wait); |
---|
1582 | 1524 | } |
---|
1583 | 1525 | kthread_stop(aac->thread); |
---|
1584 | 1526 | aac->thread = NULL; |
---|
.. | .. |
---|
1614 | 1556 | } |
---|
1615 | 1557 | } |
---|
1616 | 1558 | |
---|
| 1559 | +void aac_reinit_aif(struct aac_dev *aac, unsigned int index) |
---|
| 1560 | +{ |
---|
| 1561 | + /* |
---|
| 1562 | + * Firmware may send a AIF messages very early and the Driver may have |
---|
| 1563 | + * ignored as it is not fully ready to process the messages. Send |
---|
| 1564 | + * AIF to firmware so that if there are any unprocessed events they |
---|
| 1565 | + * can be processed now. |
---|
| 1566 | + */ |
---|
| 1567 | + if (aac_drivers[index].quirks & AAC_QUIRK_SRC) |
---|
| 1568 | + aac_intr_normal(aac, 0, 2, 0, NULL); |
---|
| 1569 | + |
---|
| 1570 | +} |
---|
| 1571 | + |
---|
1617 | 1572 | static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) |
---|
1618 | 1573 | { |
---|
1619 | 1574 | unsigned index = id->driver_data; |
---|
.. | .. |
---|
1647 | 1602 | goto out; |
---|
1648 | 1603 | |
---|
1649 | 1604 | if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) { |
---|
1650 | | - error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
---|
| 1605 | + error = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
---|
1651 | 1606 | if (error) { |
---|
1652 | 1607 | dev_err(&pdev->dev, "PCI 32 BIT dma mask set failed"); |
---|
1653 | 1608 | goto out_disable_pdev; |
---|
.. | .. |
---|
1666 | 1621 | mask_bits = 32; |
---|
1667 | 1622 | } |
---|
1668 | 1623 | |
---|
1669 | | - error = pci_set_consistent_dma_mask(pdev, dmamask); |
---|
| 1624 | + error = dma_set_coherent_mask(&pdev->dev, dmamask); |
---|
1670 | 1625 | if (error) { |
---|
1671 | 1626 | dev_err(&pdev->dev, "PCI %d B consistent dma mask set failed\n" |
---|
1672 | 1627 | , mask_bits); |
---|
.. | .. |
---|
1684 | 1639 | shost->irq = pdev->irq; |
---|
1685 | 1640 | shost->unique_id = unique_id; |
---|
1686 | 1641 | shost->max_cmd_len = 16; |
---|
1687 | | - shost->use_cmd_list = 1; |
---|
1688 | 1642 | |
---|
1689 | 1643 | if (aac_cfg_major == AAC_CHARDEV_NEEDS_REINIT) |
---|
1690 | 1644 | aac_init_char(); |
---|
.. | .. |
---|
1715 | 1669 | mutex_init(&aac->scan_mutex); |
---|
1716 | 1670 | |
---|
1717 | 1671 | INIT_DELAYED_WORK(&aac->safw_rescan_work, aac_safw_rescan_worker); |
---|
| 1672 | + INIT_DELAYED_WORK(&aac->src_reinit_aif_worker, |
---|
| 1673 | + aac_src_reinit_aif_worker); |
---|
1718 | 1674 | /* |
---|
1719 | 1675 | * Map in the registers from the adapter. |
---|
1720 | 1676 | */ |
---|
.. | .. |
---|
1770 | 1726 | shost->max_sectors = (shost->sg_tablesize * 8) + 112; |
---|
1771 | 1727 | } |
---|
1772 | 1728 | |
---|
1773 | | - error = pci_set_dma_max_seg_size(pdev, |
---|
1774 | | - (aac->adapter_info.options & AAC_OPT_NEW_COMM) ? |
---|
1775 | | - (shost->max_sectors << 9) : 65536); |
---|
1776 | | - if (error) |
---|
1777 | | - goto out_deinit; |
---|
| 1729 | + if (aac->adapter_info.options & AAC_OPT_NEW_COMM) |
---|
| 1730 | + shost->max_segment_size = shost->max_sectors << 9; |
---|
| 1731 | + else |
---|
| 1732 | + shost->max_segment_size = 65536; |
---|
1778 | 1733 | |
---|
1779 | 1734 | /* |
---|
1780 | 1735 | * Firmware printf works only with older firmware. |
---|
.. | .. |
---|
1905 | 1860 | struct Scsi_Host *shost = pci_get_drvdata(pdev); |
---|
1906 | 1861 | struct aac_dev *aac = (struct aac_dev *)shost->hostdata; |
---|
1907 | 1862 | |
---|
1908 | | - scsi_block_requests(shost); |
---|
1909 | | - aac_cancel_safw_rescan_worker(aac); |
---|
| 1863 | + scsi_host_block(shost); |
---|
| 1864 | + aac_cancel_rescan_worker(aac); |
---|
1910 | 1865 | aac_send_shutdown(aac); |
---|
1911 | 1866 | |
---|
1912 | 1867 | aac_release_resources(aac); |
---|
.. | .. |
---|
1941 | 1896 | * aac_send_shutdown() to block ioctls from upperlayer |
---|
1942 | 1897 | */ |
---|
1943 | 1898 | aac->adapter_shutdown = 0; |
---|
1944 | | - scsi_unblock_requests(shost); |
---|
| 1899 | + scsi_host_unblock(shost, SDEV_RUNNING); |
---|
1945 | 1900 | |
---|
1946 | 1901 | return 0; |
---|
1947 | 1902 | |
---|
.. | .. |
---|
1956 | 1911 | static void aac_shutdown(struct pci_dev *dev) |
---|
1957 | 1912 | { |
---|
1958 | 1913 | struct Scsi_Host *shost = pci_get_drvdata(dev); |
---|
1959 | | - scsi_block_requests(shost); |
---|
| 1914 | + |
---|
| 1915 | + scsi_host_block(shost); |
---|
1960 | 1916 | __aac_shutdown((struct aac_dev *)shost->hostdata); |
---|
1961 | 1917 | } |
---|
1962 | 1918 | |
---|
.. | .. |
---|
1965 | 1921 | struct Scsi_Host *shost = pci_get_drvdata(pdev); |
---|
1966 | 1922 | struct aac_dev *aac = (struct aac_dev *)shost->hostdata; |
---|
1967 | 1923 | |
---|
1968 | | - aac_cancel_safw_rescan_worker(aac); |
---|
| 1924 | + aac_cancel_rescan_worker(aac); |
---|
1969 | 1925 | scsi_remove_host(shost); |
---|
1970 | 1926 | |
---|
1971 | 1927 | __aac_shutdown(aac); |
---|
.. | .. |
---|
1988 | 1944 | } |
---|
1989 | 1945 | } |
---|
1990 | 1946 | |
---|
1991 | | -static void aac_flush_ios(struct aac_dev *aac) |
---|
1992 | | -{ |
---|
1993 | | - int i; |
---|
1994 | | - struct scsi_cmnd *cmd; |
---|
1995 | | - |
---|
1996 | | - for (i = 0; i < aac->scsi_host_ptr->can_queue; i++) { |
---|
1997 | | - cmd = (struct scsi_cmnd *)aac->fibs[i].callback_data; |
---|
1998 | | - if (cmd && (cmd->SCp.phase == AAC_OWNER_FIRMWARE)) { |
---|
1999 | | - scsi_dma_unmap(cmd); |
---|
2000 | | - |
---|
2001 | | - if (aac->handle_pci_error) |
---|
2002 | | - cmd->result = DID_NO_CONNECT << 16; |
---|
2003 | | - else |
---|
2004 | | - cmd->result = DID_RESET << 16; |
---|
2005 | | - |
---|
2006 | | - cmd->scsi_done(cmd); |
---|
2007 | | - } |
---|
2008 | | - } |
---|
2009 | | -} |
---|
2010 | | - |
---|
2011 | 1947 | static pci_ers_result_t aac_pci_error_detected(struct pci_dev *pdev, |
---|
2012 | | - enum pci_channel_state error) |
---|
| 1948 | + pci_channel_state_t error) |
---|
2013 | 1949 | { |
---|
2014 | 1950 | struct Scsi_Host *shost = pci_get_drvdata(pdev); |
---|
2015 | 1951 | struct aac_dev *aac = shost_priv(shost); |
---|
.. | .. |
---|
2022 | 1958 | case pci_channel_io_frozen: |
---|
2023 | 1959 | aac->handle_pci_error = 1; |
---|
2024 | 1960 | |
---|
2025 | | - scsi_block_requests(aac->scsi_host_ptr); |
---|
2026 | | - aac_cancel_safw_rescan_worker(aac); |
---|
2027 | | - aac_flush_ios(aac); |
---|
| 1961 | + scsi_host_block(shost); |
---|
| 1962 | + aac_cancel_rescan_worker(aac); |
---|
| 1963 | + scsi_host_complete_all_commands(shost, DID_NO_CONNECT); |
---|
2028 | 1964 | aac_release_resources(aac); |
---|
2029 | 1965 | |
---|
2030 | 1966 | pci_disable_pcie_error_reporting(pdev); |
---|
.. | .. |
---|
2034 | 1970 | case pci_channel_io_perm_failure: |
---|
2035 | 1971 | aac->handle_pci_error = 1; |
---|
2036 | 1972 | |
---|
2037 | | - aac_flush_ios(aac); |
---|
| 1973 | + scsi_host_complete_all_commands(shost, DID_NO_CONNECT); |
---|
2038 | 1974 | return PCI_ERS_RESULT_DISCONNECT; |
---|
2039 | 1975 | } |
---|
2040 | 1976 | |
---|
.. | .. |
---|
2075 | 2011 | static void aac_pci_resume(struct pci_dev *pdev) |
---|
2076 | 2012 | { |
---|
2077 | 2013 | struct Scsi_Host *shost = pci_get_drvdata(pdev); |
---|
2078 | | - struct scsi_device *sdev = NULL; |
---|
2079 | 2014 | struct aac_dev *aac = (struct aac_dev *)shost_priv(shost); |
---|
2080 | | - |
---|
2081 | | - pci_cleanup_aer_uncorrect_error_status(pdev); |
---|
2082 | 2015 | |
---|
2083 | 2016 | if (aac_adapter_ioremap(aac, aac->base_size)) { |
---|
2084 | 2017 | |
---|
.. | .. |
---|
2104 | 2037 | aac->adapter_shutdown = 0; |
---|
2105 | 2038 | aac->handle_pci_error = 0; |
---|
2106 | 2039 | |
---|
2107 | | - shost_for_each_device(sdev, shost) |
---|
2108 | | - if (sdev->sdev_state == SDEV_OFFLINE) |
---|
2109 | | - sdev->sdev_state = SDEV_RUNNING; |
---|
2110 | | - scsi_unblock_requests(aac->scsi_host_ptr); |
---|
| 2040 | + scsi_host_unblock(shost, SDEV_RUNNING); |
---|
2111 | 2041 | aac_scan_host(aac); |
---|
2112 | 2042 | pci_save_state(pdev); |
---|
2113 | 2043 | |
---|