.. | .. |
---|
| 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. |
---|
.. | .. |
---|
9 | 10 | * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com) |
---|
10 | 11 | * 2016-2017 Microsemi Corp. (aacraid@microsemi.com) |
---|
11 | 12 | * |
---|
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 | | - * |
---|
26 | 13 | * Module Name: |
---|
27 | 14 | * aachba.c |
---|
28 | 15 | * |
---|
29 | 16 | * Abstract: Contains Interfaces to manage IOs. |
---|
30 | | - * |
---|
31 | 17 | */ |
---|
32 | 18 | |
---|
33 | 19 | #include <linux/kernel.h> |
---|
.. | .. |
---|
256 | 242 | int startup_timeout = 180; |
---|
257 | 243 | int aif_timeout = 120; |
---|
258 | 244 | int aac_sync_mode; /* Only Sync. transfer - disabled */ |
---|
259 | | -int aac_convert_sgl = 1; /* convert non-conformable s/g list - enabled */ |
---|
| 245 | +static int aac_convert_sgl = 1; /* convert non-conformable s/g list - enabled */ |
---|
260 | 246 | |
---|
261 | 247 | module_param(aac_sync_mode, int, S_IRUGO|S_IWUSR); |
---|
262 | 248 | MODULE_PARM_DESC(aac_sync_mode, "Force sync. transfer mode" |
---|
.. | .. |
---|
304 | 290 | " blocks (FIB) allocated. Valid values are 512 and down. Default is" |
---|
305 | 291 | " to use suggestion from Firmware."); |
---|
306 | 292 | |
---|
307 | | -int acbsize = -1; |
---|
| 293 | +static int acbsize = -1; |
---|
308 | 294 | module_param(acbsize, int, S_IRUGO|S_IWUSR); |
---|
309 | 295 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB)" |
---|
310 | 296 | " size. Valid values are 512, 2048, 4096 and 8192. Default is to use" |
---|
.. | .. |
---|
335 | 321 | module_param_named(reset_devices, aac_reset_devices, int, S_IRUGO|S_IWUSR); |
---|
336 | 322 | MODULE_PARM_DESC(reset_devices, "Force an adapter reset at initialization."); |
---|
337 | 323 | |
---|
338 | | -int aac_wwn = 1; |
---|
| 324 | +static int aac_wwn = 1; |
---|
339 | 325 | module_param_named(wwn, aac_wwn, int, S_IRUGO|S_IWUSR); |
---|
340 | 326 | MODULE_PARM_DESC(wwn, "Select a WWN type for the arrays:\n" |
---|
341 | 327 | "\t0 - Disable\n" |
---|
.. | .. |
---|
364 | 350 | |
---|
365 | 351 | /** |
---|
366 | 352 | * aac_get_config_status - check the adapter configuration |
---|
367 | | - * @common: adapter to query |
---|
| 353 | + * @dev: aac driver data |
---|
| 354 | + * @commit_flag: force sending CT_COMMIT_CONFIG |
---|
368 | 355 | * |
---|
369 | 356 | * Query config status, and commit the configuration if needed. |
---|
370 | 357 | */ |
---|
.. | .. |
---|
456 | 443 | |
---|
457 | 444 | /** |
---|
458 | 445 | * aac_get_containers - list containers |
---|
459 | | - * @common: adapter to probe |
---|
| 446 | + * @dev: aac driver data |
---|
460 | 447 | * |
---|
461 | 448 | * Make a list of all containers on this controller |
---|
462 | 449 | */ |
---|
.. | .. |
---|
549 | 536 | if ((le32_to_cpu(get_name_reply->status) == CT_OK) |
---|
550 | 537 | && (get_name_reply->data[0] != '\0')) { |
---|
551 | 538 | char *sp = get_name_reply->data; |
---|
552 | | - int data_size = FIELD_SIZEOF(struct aac_get_name_resp, data); |
---|
| 539 | + int data_size = sizeof_field(struct aac_get_name_resp, data); |
---|
553 | 540 | |
---|
554 | 541 | sp[data_size - 1] = '\0'; |
---|
555 | 542 | while (*sp == ' ') |
---|
.. | .. |
---|
575 | 562 | scsicmd->scsi_done(scsicmd); |
---|
576 | 563 | } |
---|
577 | 564 | |
---|
578 | | -/** |
---|
| 565 | +/* |
---|
579 | 566 | * aac_get_container_name - get container name, none blocking. |
---|
580 | 567 | */ |
---|
581 | 568 | static int aac_get_container_name(struct scsi_cmnd * scsicmd) |
---|
.. | .. |
---|
588 | 575 | |
---|
589 | 576 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
---|
590 | 577 | |
---|
591 | | - data_size = FIELD_SIZEOF(struct aac_get_name_resp, data); |
---|
| 578 | + data_size = sizeof_field(struct aac_get_name_resp, data); |
---|
592 | 579 | |
---|
593 | 580 | cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd); |
---|
594 | 581 | |
---|
.. | .. |
---|
800 | 787 | |
---|
801 | 788 | /** |
---|
802 | 789 | * aac_probe_container - query a logical volume |
---|
803 | | - * @dev: device to query |
---|
804 | | - * @cid: container identifier |
---|
| 790 | + * @scsicmd: the scsi command block |
---|
805 | 791 | * |
---|
806 | 792 | * Queries the controller about the given volume. The volume information |
---|
807 | 793 | * is updated in the struct fsa_dev_info structure rather than returned. |
---|
.. | .. |
---|
810 | 796 | { |
---|
811 | 797 | scsicmd->device = NULL; |
---|
812 | 798 | return 0; |
---|
| 799 | +} |
---|
| 800 | + |
---|
| 801 | +static void aac_probe_container_scsi_done(struct scsi_cmnd *scsi_cmnd) |
---|
| 802 | +{ |
---|
| 803 | + aac_probe_container_callback1(scsi_cmnd); |
---|
813 | 804 | } |
---|
814 | 805 | |
---|
815 | 806 | int aac_probe_container(struct aac_dev *dev, int cid) |
---|
.. | .. |
---|
823 | 814 | kfree(scsidev); |
---|
824 | 815 | return -ENOMEM; |
---|
825 | 816 | } |
---|
826 | | - scsicmd->list.next = NULL; |
---|
827 | | - scsicmd->scsi_done = (void (*)(struct scsi_cmnd*))aac_probe_container_callback1; |
---|
| 817 | + scsicmd->scsi_done = aac_probe_container_scsi_done; |
---|
828 | 818 | |
---|
829 | 819 | scsicmd->device = scsidev; |
---|
830 | 820 | scsidev->sdev_state = 0; |
---|
.. | .. |
---|
1108 | 1098 | scsicmd->scsi_done(scsicmd); |
---|
1109 | 1099 | } |
---|
1110 | 1100 | |
---|
1111 | | -/** |
---|
| 1101 | +/* |
---|
1112 | 1102 | * aac_get_container_serial - get container serial, none blocking. |
---|
1113 | 1103 | */ |
---|
1114 | 1104 | static int aac_get_container_serial(struct scsi_cmnd * scsicmd) |
---|
.. | .. |
---|
1491 | 1481 | struct aac_srb * srbcmd; |
---|
1492 | 1482 | u32 flag; |
---|
1493 | 1483 | u32 timeout; |
---|
| 1484 | + struct aac_dev *dev = fib->dev; |
---|
1494 | 1485 | |
---|
1495 | 1486 | aac_fib_init(fib); |
---|
1496 | 1487 | switch(cmd->sc_data_direction){ |
---|
.. | .. |
---|
1517 | 1508 | srbcmd->flags = cpu_to_le32(flag); |
---|
1518 | 1509 | timeout = cmd->request->timeout/HZ; |
---|
1519 | 1510 | if (timeout == 0) |
---|
1520 | | - timeout = 1; |
---|
| 1511 | + timeout = (dev->sa_firmware ? AAC_SA_TIMEOUT : AAC_ARC_TIMEOUT); |
---|
1521 | 1512 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds |
---|
1522 | 1513 | srbcmd->retry_limit = 0; /* Obsolete parameter */ |
---|
1523 | 1514 | srbcmd->cdb_size = cpu_to_le32(cmd->cmd_len); |
---|
.. | .. |
---|
1961 | 1952 | /** |
---|
1962 | 1953 | * aac_set_safw_attr_all_targets- update current hba map with data from FW |
---|
1963 | 1954 | * @dev: aac_dev structure |
---|
1964 | | - * @phys_luns: FW information from report phys luns |
---|
1965 | | - * @rescan: Indicates scan type |
---|
1966 | 1955 | * |
---|
1967 | 1956 | * Update our hba map with the information gathered from the FW |
---|
1968 | 1957 | */ |
---|
.. | .. |
---|
2240 | 2229 | } |
---|
2241 | 2230 | |
---|
2242 | 2231 | if (dev->dac_support) { |
---|
2243 | | - if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64))) { |
---|
| 2232 | + if (!dma_set_mask(&dev->pdev->dev, DMA_BIT_MASK(64))) { |
---|
2244 | 2233 | if (!dev->in_reset) |
---|
2245 | 2234 | dev_info(&dev->pdev->dev, "64 Bit DAC enabled\n"); |
---|
2246 | | - } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32))) { |
---|
| 2235 | + } else if (!dma_set_mask(&dev->pdev->dev, DMA_BIT_MASK(32))) { |
---|
2247 | 2236 | dev_info(&dev->pdev->dev, "DMA mask set failed, 64 Bit DAC disabled\n"); |
---|
2248 | 2237 | dev->dac_support = 0; |
---|
2249 | 2238 | } else { |
---|
.. | .. |
---|
2614 | 2603 | static void synchronize_callback(void *context, struct fib *fibptr) |
---|
2615 | 2604 | { |
---|
2616 | 2605 | struct aac_synchronize_reply *synchronizereply; |
---|
2617 | | - struct scsi_cmnd *cmd; |
---|
2618 | | - |
---|
2619 | | - cmd = context; |
---|
| 2606 | + struct scsi_cmnd *cmd = context; |
---|
2620 | 2607 | |
---|
2621 | 2608 | if (!aac_valid_context(cmd, fibptr)) |
---|
2622 | 2609 | return; |
---|
.. | .. |
---|
2657 | 2644 | int status; |
---|
2658 | 2645 | struct fib *cmd_fibcontext; |
---|
2659 | 2646 | struct aac_synchronize *synchronizecmd; |
---|
2660 | | - struct scsi_cmnd *cmd; |
---|
2661 | 2647 | struct scsi_device *sdev = scsicmd->device; |
---|
2662 | | - int active = 0; |
---|
2663 | 2648 | struct aac_dev *aac; |
---|
2664 | | - u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) | |
---|
2665 | | - (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5]; |
---|
2666 | | - u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8]; |
---|
2667 | | - unsigned long flags; |
---|
2668 | | - |
---|
2669 | | - /* |
---|
2670 | | - * Wait for all outstanding queued commands to complete to this |
---|
2671 | | - * specific target (block). |
---|
2672 | | - */ |
---|
2673 | | - spin_lock_irqsave(&sdev->list_lock, flags); |
---|
2674 | | - list_for_each_entry(cmd, &sdev->cmd_list, list) |
---|
2675 | | - if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) { |
---|
2676 | | - u64 cmnd_lba; |
---|
2677 | | - u32 cmnd_count; |
---|
2678 | | - |
---|
2679 | | - if (cmd->cmnd[0] == WRITE_6) { |
---|
2680 | | - cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) | |
---|
2681 | | - (cmd->cmnd[2] << 8) | |
---|
2682 | | - cmd->cmnd[3]; |
---|
2683 | | - cmnd_count = cmd->cmnd[4]; |
---|
2684 | | - if (cmnd_count == 0) |
---|
2685 | | - cmnd_count = 256; |
---|
2686 | | - } else if (cmd->cmnd[0] == WRITE_16) { |
---|
2687 | | - cmnd_lba = ((u64)cmd->cmnd[2] << 56) | |
---|
2688 | | - ((u64)cmd->cmnd[3] << 48) | |
---|
2689 | | - ((u64)cmd->cmnd[4] << 40) | |
---|
2690 | | - ((u64)cmd->cmnd[5] << 32) | |
---|
2691 | | - ((u64)cmd->cmnd[6] << 24) | |
---|
2692 | | - (cmd->cmnd[7] << 16) | |
---|
2693 | | - (cmd->cmnd[8] << 8) | |
---|
2694 | | - cmd->cmnd[9]; |
---|
2695 | | - cmnd_count = (cmd->cmnd[10] << 24) | |
---|
2696 | | - (cmd->cmnd[11] << 16) | |
---|
2697 | | - (cmd->cmnd[12] << 8) | |
---|
2698 | | - cmd->cmnd[13]; |
---|
2699 | | - } else if (cmd->cmnd[0] == WRITE_12) { |
---|
2700 | | - cmnd_lba = ((u64)cmd->cmnd[2] << 24) | |
---|
2701 | | - (cmd->cmnd[3] << 16) | |
---|
2702 | | - (cmd->cmnd[4] << 8) | |
---|
2703 | | - cmd->cmnd[5]; |
---|
2704 | | - cmnd_count = (cmd->cmnd[6] << 24) | |
---|
2705 | | - (cmd->cmnd[7] << 16) | |
---|
2706 | | - (cmd->cmnd[8] << 8) | |
---|
2707 | | - cmd->cmnd[9]; |
---|
2708 | | - } else if (cmd->cmnd[0] == WRITE_10) { |
---|
2709 | | - cmnd_lba = ((u64)cmd->cmnd[2] << 24) | |
---|
2710 | | - (cmd->cmnd[3] << 16) | |
---|
2711 | | - (cmd->cmnd[4] << 8) | |
---|
2712 | | - cmd->cmnd[5]; |
---|
2713 | | - cmnd_count = (cmd->cmnd[7] << 8) | |
---|
2714 | | - cmd->cmnd[8]; |
---|
2715 | | - } else |
---|
2716 | | - continue; |
---|
2717 | | - if (((cmnd_lba + cmnd_count) < lba) || |
---|
2718 | | - (count && ((lba + count) < cmnd_lba))) |
---|
2719 | | - continue; |
---|
2720 | | - ++active; |
---|
2721 | | - break; |
---|
2722 | | - } |
---|
2723 | | - |
---|
2724 | | - spin_unlock_irqrestore(&sdev->list_lock, flags); |
---|
2725 | | - |
---|
2726 | | - /* |
---|
2727 | | - * Yield the processor (requeue for later) |
---|
2728 | | - */ |
---|
2729 | | - if (active) |
---|
2730 | | - return SCSI_MLQUEUE_DEVICE_BUSY; |
---|
2731 | 2649 | |
---|
2732 | 2650 | aac = (struct aac_dev *)sdev->host->hostdata; |
---|
2733 | 2651 | if (aac->in_reset) |
---|
.. | .. |
---|
2736 | 2654 | /* |
---|
2737 | 2655 | * Allocate and initialize a Fib |
---|
2738 | 2656 | */ |
---|
2739 | | - if (!(cmd_fibcontext = aac_fib_alloc(aac))) |
---|
2740 | | - return SCSI_MLQUEUE_HOST_BUSY; |
---|
| 2657 | + cmd_fibcontext = aac_fib_alloc_tag(aac, scsicmd); |
---|
2741 | 2658 | |
---|
2742 | 2659 | aac_fib_init(cmd_fibcontext); |
---|
2743 | 2660 | |
---|
.. | .. |
---|
2892 | 2809 | !(dev->raw_io_64) || |
---|
2893 | 2810 | ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) |
---|
2894 | 2811 | break; |
---|
| 2812 | + fallthrough; |
---|
2895 | 2813 | case INQUIRY: |
---|
2896 | 2814 | case READ_CAPACITY: |
---|
2897 | 2815 | case TEST_UNIT_READY: |
---|
.. | .. |
---|
2966 | 2884 | /* Issue FIB to tell Firmware to flush it's cache */ |
---|
2967 | 2885 | if ((aac_cache & 6) != 2) |
---|
2968 | 2886 | return aac_synchronize(scsicmd); |
---|
| 2887 | + fallthrough; |
---|
2969 | 2888 | case INQUIRY: |
---|
2970 | 2889 | { |
---|
2971 | 2890 | struct inquiry_data inq_data; |
---|
.. | .. |
---|
3319 | 3238 | min_t(size_t, |
---|
3320 | 3239 | sizeof(dev->fsa_dev[cid].sense_data), |
---|
3321 | 3240 | SCSI_SENSE_BUFFERSIZE)); |
---|
3322 | | - break; |
---|
| 3241 | + break; |
---|
3323 | 3242 | } |
---|
| 3243 | + fallthrough; |
---|
3324 | 3244 | case RESERVE: |
---|
3325 | 3245 | case RELEASE: |
---|
3326 | 3246 | case REZERO_UNIT: |
---|
.. | .. |
---|
3333 | 3253 | case START_STOP: |
---|
3334 | 3254 | return aac_start_stop(scsicmd); |
---|
3335 | 3255 | |
---|
3336 | | - /* FALLTHRU */ |
---|
3337 | 3256 | default: |
---|
3338 | 3257 | /* |
---|
3339 | 3258 | * Unhandled commands |
---|
.. | .. |
---|
3452 | 3371 | } |
---|
3453 | 3372 | } |
---|
3454 | 3373 | |
---|
3455 | | -int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg) |
---|
| 3374 | +int aac_dev_ioctl(struct aac_dev *dev, unsigned int cmd, void __user *arg) |
---|
3456 | 3375 | { |
---|
3457 | 3376 | switch (cmd) { |
---|
3458 | 3377 | case FSACTL_QUERY_DISK: |
---|
.. | .. |
---|
3469 | 3388 | } |
---|
3470 | 3389 | |
---|
3471 | 3390 | /** |
---|
3472 | | - * |
---|
3473 | 3391 | * aac_srb_callback |
---|
3474 | 3392 | * @context: the context set in the fib - here it is scsi cmd |
---|
3475 | 3393 | * @fibptr: pointer to the fib |
---|
3476 | 3394 | * |
---|
3477 | 3395 | * Handles the completion of a scsi command to a non dasd device |
---|
3478 | | - * |
---|
3479 | 3396 | */ |
---|
3480 | | - |
---|
3481 | 3397 | static void aac_srb_callback(void *context, struct fib * fibptr) |
---|
3482 | 3398 | { |
---|
3483 | | - struct aac_dev *dev; |
---|
3484 | 3399 | struct aac_srb_reply *srbreply; |
---|
3485 | 3400 | struct scsi_cmnd *scsicmd; |
---|
3486 | 3401 | |
---|
.. | .. |
---|
3490 | 3405 | return; |
---|
3491 | 3406 | |
---|
3492 | 3407 | BUG_ON(fibptr == NULL); |
---|
3493 | | - |
---|
3494 | | - dev = fibptr->dev; |
---|
3495 | 3408 | |
---|
3496 | 3409 | srbreply = (struct aac_srb_reply *) fib_data(fibptr); |
---|
3497 | 3410 | |
---|
.. | .. |
---|
3765 | 3678 | } |
---|
3766 | 3679 | |
---|
3767 | 3680 | /** |
---|
3768 | | - * |
---|
3769 | 3681 | * aac_hba_callback |
---|
3770 | 3682 | * @context: the context set in the fib - here it is scsi cmd |
---|
3771 | 3683 | * @fibptr: pointer to the fib |
---|
3772 | 3684 | * |
---|
3773 | 3685 | * Handles the completion of a native HBA scsi command |
---|
3774 | | - * |
---|
3775 | 3686 | */ |
---|
3776 | 3687 | void aac_hba_callback(void *context, struct fib *fibptr) |
---|
3777 | 3688 | { |
---|
.. | .. |
---|
3830 | 3741 | } |
---|
3831 | 3742 | |
---|
3832 | 3743 | /** |
---|
3833 | | - * |
---|
3834 | 3744 | * aac_send_srb_fib |
---|
3835 | 3745 | * @scsicmd: the scsi command block |
---|
3836 | 3746 | * |
---|
3837 | 3747 | * This routine will form a FIB and fill in the aac_srb from the |
---|
3838 | 3748 | * scsicmd passed in. |
---|
3839 | 3749 | */ |
---|
3840 | | - |
---|
3841 | 3750 | static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) |
---|
3842 | 3751 | { |
---|
3843 | 3752 | struct fib* cmd_fibcontext; |
---|
.. | .. |
---|
3873 | 3782 | } |
---|
3874 | 3783 | |
---|
3875 | 3784 | /** |
---|
3876 | | - * |
---|
3877 | 3785 | * aac_send_hba_fib |
---|
3878 | 3786 | * @scsicmd: the scsi command block |
---|
3879 | 3787 | * |
---|
.. | .. |
---|
3921 | 3829 | |
---|
3922 | 3830 | static long aac_build_sg(struct scsi_cmnd *scsicmd, struct sgmap *psg) |
---|
3923 | 3831 | { |
---|
3924 | | - struct aac_dev *dev; |
---|
3925 | 3832 | unsigned long byte_count = 0; |
---|
3926 | 3833 | int nseg; |
---|
3927 | 3834 | struct scatterlist *sg; |
---|
3928 | 3835 | int i; |
---|
3929 | 3836 | |
---|
3930 | | - dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
---|
3931 | 3837 | // Get rid of old data |
---|
3932 | 3838 | psg->count = 0; |
---|
3933 | 3839 | psg->sg[0].addr = 0; |
---|
.. | .. |
---|
3963 | 3869 | |
---|
3964 | 3870 | static long aac_build_sg64(struct scsi_cmnd *scsicmd, struct sgmap64 *psg) |
---|
3965 | 3871 | { |
---|
3966 | | - struct aac_dev *dev; |
---|
3967 | 3872 | unsigned long byte_count = 0; |
---|
3968 | 3873 | u64 addr; |
---|
3969 | 3874 | int nseg; |
---|
3970 | 3875 | struct scatterlist *sg; |
---|
3971 | 3876 | int i; |
---|
3972 | 3877 | |
---|
3973 | | - dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
---|
3974 | 3878 | // Get rid of old data |
---|
3975 | 3879 | psg->count = 0; |
---|
3976 | 3880 | psg->sg[0].addr[0] = 0; |
---|