Merge patch series "scsi: documentation: clean up docs and fix kernel-doc"
authorMartin K. Petersen <martin.petersen@oracle.com>
Tue, 9 Apr 2024 02:16:25 +0000 (22:16 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 9 Apr 2024 02:16:25 +0000 (22:16 -0400)
Randy Dunlap <rdunlap@infradead.org> says:

Clean up some SCSI doc files and fix kernel-doc in 6 header files in
include/scsi/.

Link: https://lore.kernel.org/r/20240408025425.18778-1-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
95 files changed:
drivers/ata/libata-sata.c
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/scsi/FlashPoint.c
drivers/scsi/Kconfig
drivers/scsi/a3000.c
drivers/scsi/a4000t.c
drivers/scsi/aic7xxx/Kconfig.aic79xx
drivers/scsi/aic7xxx/Kconfig.aic7xxx
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/atari_scsi.c
drivers/scsi/ch.c
drivers/scsi/csiostor/csio_init.c
drivers/scsi/cxlflash/lunmgt.c
drivers/scsi/cxlflash/main.c
drivers/scsi/cxlflash/superpipe.c
drivers/scsi/cxlflash/superpipe.h
drivers/scsi/cxlflash/vlun.c
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
drivers/scsi/isci/init.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_bsg.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_mbox.c
drivers/scsi/lpfc/lpfc_nportdisc.c
drivers/scsi/lpfc/lpfc_nvme.c
drivers/scsi/lpfc/lpfc_nvmet.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_sli.h
drivers/scsi/lpfc/lpfc_sli4.h
drivers/scsi/lpfc/lpfc_version.h
drivers/scsi/lpfc/lpfc_vport.c
drivers/scsi/mac_scsi.c
drivers/scsi/megaraid/Kconfig.megaraid
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h
drivers/scsi/mpi3mr/mpi/mpi30_image.h
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h
drivers/scsi/mpi3mr/mpi/mpi30_transport.h
drivers/scsi/mpi3mr/mpi3mr.h
drivers/scsi/mpi3mr/mpi3mr_app.c
drivers/scsi/mpi3mr/mpi3mr_fw.c
drivers/scsi/mpi3mr/mpi3mr_os.c
drivers/scsi/mpt3sas/mpt3sas_base.c
drivers/scsi/mpt3sas/mpt3sas_transport.c
drivers/scsi/mvsas/mv_init.c
drivers/scsi/pm8001/pm8001_ctl.c
drivers/scsi/pm8001/pm8001_init.c
drivers/scsi/pm8001/pm8001_sas.h
drivers/scsi/pmcraid.c
drivers/scsi/qedf/qedf_main.c
drivers/scsi/qla2xxx/Kconfig
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla2xxx/qla_version.h
drivers/scsi/qla4xxx/ql4_mbx.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi_devinfo.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/sd.c
drivers/scsi/ses.c
drivers/scsi/sg.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/scsi/snic/snic_attrs.c
drivers/scsi/sr.c
drivers/scsi/st.c
drivers/scsi/wd33c93.c
drivers/target/iscsi/iscsi_target_erl1.c
drivers/ufs/core/ufs-mcq.c
drivers/ufs/core/ufshcd.c
drivers/ufs/host/cdns-pltfrm.c
drivers/ufs/host/ufs-mediatek-sip.h [new file with mode: 0644]
drivers/ufs/host/ufs-mediatek.c
drivers/ufs/host/ufs-mediatek.h
drivers/ufs/host/ufs-qcom.c
drivers/ufs/host/ufs-qcom.h
include/linux/libata.h
include/scsi/libsas.h
include/scsi/sas_ata.h
include/scsi/scsi_driver.h
include/ufs/ufshcd.h
include/ufs/ufshci.h

index 0fb1934875f2084a753216cf54ff443aa601361b..a8d773003d74bf44763f1219ef2408038f46b23d 100644 (file)
@@ -848,80 +848,143 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
            ata_scsi_lpm_show, ata_scsi_lpm_store);
 EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
 
-static ssize_t ata_ncq_prio_supported_show(struct device *device,
-                                          struct device_attribute *attr,
-                                          char *buf)
+/**
+ *     ata_ncq_prio_supported - Check if device supports NCQ Priority
+ *     @ap: ATA port of the target device
+ *     @sdev: SCSI device
+ *     @supported: Address of a boolean to store the result
+ *
+ *     Helper to check if device supports NCQ Priority feature.
+ *
+ *     Context: Any context. Takes and releases @ap->lock.
+ *
+ *     Return:
+ *     * %0            - OK. Status is stored into @supported
+ *     * %-ENODEV      - Failed to find the ATA device
+ */
+int ata_ncq_prio_supported(struct ata_port *ap, struct scsi_device *sdev,
+                          bool *supported)
 {
-       struct scsi_device *sdev = to_scsi_device(device);
-       struct ata_port *ap = ata_shost_to_port(sdev->host);
        struct ata_device *dev;
-       bool ncq_prio_supported;
+       unsigned long flags;
        int rc = 0;
 
-       spin_lock_irq(ap->lock);
+       spin_lock_irqsave(ap->lock, flags);
        dev = ata_scsi_find_dev(ap, sdev);
        if (!dev)
                rc = -ENODEV;
        else
-               ncq_prio_supported = dev->flags & ATA_DFLAG_NCQ_PRIO;
-       spin_unlock_irq(ap->lock);
+               *supported = dev->flags & ATA_DFLAG_NCQ_PRIO;
+       spin_unlock_irqrestore(ap->lock, flags);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(ata_ncq_prio_supported);
+
+static ssize_t ata_ncq_prio_supported_show(struct device *device,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct scsi_device *sdev = to_scsi_device(device);
+       struct ata_port *ap = ata_shost_to_port(sdev->host);
+       bool supported;
+       int rc;
+
+       rc = ata_ncq_prio_supported(ap, sdev, &supported);
+       if (rc)
+               return rc;
 
-       return rc ? rc : sysfs_emit(buf, "%u\n", ncq_prio_supported);
+       return sysfs_emit(buf, "%d\n", supported);
 }
 
 DEVICE_ATTR(ncq_prio_supported, S_IRUGO, ata_ncq_prio_supported_show, NULL);
 EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_supported);
 
-static ssize_t ata_ncq_prio_enable_show(struct device *device,
-                                       struct device_attribute *attr,
-                                       char *buf)
+/**
+ *     ata_ncq_prio_enabled - Check if NCQ Priority is enabled
+ *     @ap: ATA port of the target device
+ *     @sdev: SCSI device
+ *     @enabled: Address of a boolean to store the result
+ *
+ *     Helper to check if NCQ Priority feature is enabled.
+ *
+ *     Context: Any context. Takes and releases @ap->lock.
+ *
+ *     Return:
+ *     * %0            - OK. Status is stored into @enabled
+ *     * %-ENODEV      - Failed to find the ATA device
+ */
+int ata_ncq_prio_enabled(struct ata_port *ap, struct scsi_device *sdev,
+                        bool *enabled)
 {
-       struct scsi_device *sdev = to_scsi_device(device);
-       struct ata_port *ap = ata_shost_to_port(sdev->host);
        struct ata_device *dev;
-       bool ncq_prio_enable;
+       unsigned long flags;
        int rc = 0;
 
-       spin_lock_irq(ap->lock);
+       spin_lock_irqsave(ap->lock, flags);
        dev = ata_scsi_find_dev(ap, sdev);
        if (!dev)
                rc = -ENODEV;
        else
-               ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED;
-       spin_unlock_irq(ap->lock);
+               *enabled = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED;
+       spin_unlock_irqrestore(ap->lock, flags);
 
-       return rc ? rc : sysfs_emit(buf, "%u\n", ncq_prio_enable);
+       return rc;
 }
+EXPORT_SYMBOL_GPL(ata_ncq_prio_enabled);
 
-static ssize_t ata_ncq_prio_enable_store(struct device *device,
-                                        struct device_attribute *attr,
-                                        const char *buf, size_t len)
+static ssize_t ata_ncq_prio_enable_show(struct device *device,
+                                       struct device_attribute *attr,
+                                       char *buf)
 {
        struct scsi_device *sdev = to_scsi_device(device);
-       struct ata_port *ap;
-       struct ata_device *dev;
-       long int input;
-       int rc = 0;
+       struct ata_port *ap = ata_shost_to_port(sdev->host);
+       bool enabled;
+       int rc;
 
-       rc = kstrtol(buf, 10, &input);
+       rc = ata_ncq_prio_enabled(ap, sdev, &enabled);
        if (rc)
                return rc;
-       if ((input < 0) || (input > 1))
-               return -EINVAL;
 
-       ap = ata_shost_to_port(sdev->host);
-       dev = ata_scsi_find_dev(ap, sdev);
-       if (unlikely(!dev))
-               return  -ENODEV;
+       return sysfs_emit(buf, "%d\n", enabled);
+}
+
+/**
+ *     ata_ncq_prio_enable - Enable/disable NCQ Priority
+ *     @ap: ATA port of the target device
+ *     @sdev: SCSI device
+ *     @enable: true - enable NCQ Priority, false - disable NCQ Priority
+ *
+ *     Helper to enable/disable NCQ Priority feature.
+ *
+ *     Context: Any context. Takes and releases @ap->lock.
+ *
+ *     Return:
+ *     * %0            - OK. Status is stored into @enabled
+ *     * %-ENODEV      - Failed to find the ATA device
+ *     * %-EINVAL      - NCQ Priority is not supported or CDL is enabled
+ */
+int ata_ncq_prio_enable(struct ata_port *ap, struct scsi_device *sdev,
+                       bool enable)
+{
+       struct ata_device *dev;
+       unsigned long flags;
+       int rc = 0;
+
+       spin_lock_irqsave(ap->lock, flags);
 
-       spin_lock_irq(ap->lock);
+       dev = ata_scsi_find_dev(ap, sdev);
+       if (!dev) {
+               rc = -ENODEV;
+               goto unlock;
+       }
 
        if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) {
                rc = -EINVAL;
                goto unlock;
        }
 
-       if (input) {
+       if (enable) {
                if (dev->flags & ATA_DFLAG_CDL_ENABLED) {
                        ata_dev_err(dev,
                                "CDL must be disabled to enable NCQ priority\n");
@@ -934,9 +997,30 @@ static ssize_t ata_ncq_prio_enable_store(struct device *device,
        }
 
 unlock:
-       spin_unlock_irq(ap->lock);
+       spin_unlock_irqrestore(ap->lock, flags);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(ata_ncq_prio_enable);
+
+static ssize_t ata_ncq_prio_enable_store(struct device *device,
+                                        struct device_attribute *attr,
+                                        const char *buf, size_t len)
+{
+       struct scsi_device *sdev = to_scsi_device(device);
+       struct ata_port *ap = ata_shost_to_port(sdev->host);
+       bool enable;
+       int rc;
+
+       rc = kstrtobool(buf, &enable);
+       if (rc)
+               return rc;
+
+       rc = ata_ncq_prio_enable(ap, sdev, enable);
+       if (rc)
+               return rc;
 
-       return rc ? rc : len;
+       return len;
 }
 
 DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
index c278f8893042b3a88466452cd205348aebac609c..d39e198fe8dbe8f6f32df9a74fb8ce506470ca0c 100644 (file)
@@ -1351,7 +1351,7 @@ static int qed_slowpath_start(struct qed_dev *cdev,
                                      (params->drv_rev << 8) |
                                      (params->drv_eng);
                strscpy(drv_version.name, params->name,
-                       MCP_DRV_VER_STR_SIZE - 4);
+                       sizeof(drv_version.name));
                rc = qed_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
                                              &drv_version);
                if (rc) {
index 3d9c56ac82240e0741d667679f0eb5e9329dee1f..9e77b8e1ea7c16d1fd1a6a622d0733311b232a66 100644 (file)
@@ -2631,7 +2631,6 @@ static void FPT_sres(u32 port, unsigned char p_card,
        WRW_HARPOON((port + hp_fiforead), (unsigned short)0x00);
 
        our_target = (unsigned char)(RD_HARPOON(port + hp_select_id) >> 4);
-       currTar_Info = &FPT_sccbMgrTbl[p_card][our_target];
 
        msgRetryCount = 0;
        do {
index 634f2f501c6c6a99952576945f2c743307e3bc48..065db86d60216422f0bac791792ec722a85c8477 100644 (file)
@@ -53,7 +53,7 @@ config SCSI_ESP_PIO
 
 config SCSI_NETLINK
        bool
-       default n
+       default n
        depends on NET
 
 config SCSI_PROC_FS
@@ -327,7 +327,7 @@ config ISCSI_TCP
 
 config ISCSI_BOOT_SYSFS
        tristate "iSCSI Boot Sysfs Interface"
-       default n
+       default n
        help
          This option enables support for exposing iSCSI boot information
          via sysfs to userspace. If you wish to export this information,
index 378906f77909b1ff1f6442612148c8a31ff7eca6..ad39797890e59a004f96c8e2d35e0e0482f08b7a 100644 (file)
@@ -295,7 +295,13 @@ static void __exit amiga_a3000_scsi_remove(struct platform_device *pdev)
        release_mem_region(res->start, resource_size(res));
 }
 
-static struct platform_driver amiga_a3000_scsi_driver = {
+/*
+ * amiga_a3000_scsi_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver amiga_a3000_scsi_driver __refdata = {
        .remove_new = __exit_p(amiga_a3000_scsi_remove),
        .driver   = {
                .name   = "amiga-a3000-scsi",
index e435fc06a6246b816a761434d3cab61b4c7b617e..d9103adc87fef49d838f0cfc90e7c97d4a336e49 100644 (file)
@@ -108,7 +108,13 @@ static void __exit amiga_a4000t_scsi_remove(struct platform_device *pdev)
        release_mem_region(res->start, resource_size(res));
 }
 
-static struct platform_driver amiga_a4000t_scsi_driver = {
+/*
+ * amiga_a4000t_scsi_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver amiga_a4000t_scsi_driver __refdata = {
        .remove_new = __exit_p(amiga_a4000t_scsi_remove),
        .driver   = {
                .name   = "amiga-a4000t-scsi",
index 4bc53eec4c83f7a39fed723fc73f75d1cb8c3c59..863f0932ef59e20af3d0f3c056308f75de156f2a 100644 (file)
@@ -8,79 +8,80 @@ config SCSI_AIC79XX
        depends on PCI && HAS_IOPORT && SCSI
        select SCSI_SPI_ATTRS
        help
-       This driver supports all of Adaptec's Ultra 320 PCI-X
-       based SCSI controllers.
+         This driver supports all of Adaptec's Ultra 320 PCI-X
+         based SCSI controllers.
 
 config AIC79XX_CMDS_PER_DEVICE
        int "Maximum number of TCQ commands per device"
        depends on SCSI_AIC79XX
        default "32"
        help
-       Specify the number of commands you would like to allocate per SCSI
-       device when Tagged Command Queueing (TCQ) is enabled on that device.
+         Specify the number of commands you would like to allocate per SCSI
+         device when Tagged Command Queueing (TCQ) is enabled on that device.
 
-       This is an upper bound value for the number of tagged transactions
-       to be used for any device.  The aic7xxx driver will automatically
-       vary this number based on device behavior.  For devices with a
-       fixed maximum, the driver will eventually lock to this maximum
-       and display a console message indicating this value.
+         This is an upper bound value for the number of tagged transactions
+         to be used for any device.  The aic7xxx driver will automatically
+         vary this number based on device behavior.  For devices with a
+         fixed maximum, the driver will eventually lock to this maximum
+         and display a console message indicating this value.
 
-       Due to resource allocation issues in the Linux SCSI mid-layer, using
-       a high number of commands per device may result in memory allocation
-       failures when many devices are attached to the system.  For this reason,
-       the default is set to 32.  Higher values may result in higher performance
-       on some devices.  The upper bound is 253.  0 disables tagged queueing.
+         Due to resource allocation issues in the Linux SCSI mid-layer, using
+         a high number of commands per device may result in memory allocation
+         failures when many devices are attached to the system.  For this
+         reason, the default is set to 32. Higher values may result in higher
+         performance on some devices. The upper bound is 253. 0 disables
+         tagged queueing.
 
-       Per device tag depth can be controlled via the kernel command line
-       "tag_info" option.  See Documentation/scsi/aic79xx.rst for details.
+         Per device tag depth can be controlled via the kernel command line
+         "tag_info" option.  See Documentation/scsi/aic79xx.rst for details.
 
 config AIC79XX_RESET_DELAY_MS
        int "Initial bus reset delay in milli-seconds"
        depends on SCSI_AIC79XX
        default "5000"
        help
-       The number of milliseconds to delay after an initial bus reset.
-       The bus settle delay following all error recovery actions is
-       dictated by the SCSI layer and is not affected by this value.
+         The number of milliseconds to delay after an initial bus reset.
+         The bus settle delay following all error recovery actions is
+         dictated by the SCSI layer and is not affected by this value.
 
-       Default: 5000 (5 seconds)
+         Default: 5000 (5 seconds)
 
 config AIC79XX_BUILD_FIRMWARE
        bool "Build Adapter Firmware with Kernel Build"
        depends on SCSI_AIC79XX && !PREVENT_FIRMWARE_BUILD
        help
-       This option should only be enabled if you are modifying the firmware
-       source to the aic79xx driver and wish to have the generated firmware
-       include files updated during a normal kernel build.  The assembler
-       for the firmware requires lex and yacc or their equivalents, as well
-       as the db v1 library.  You may have to install additional packages
-       or modify the assembler Makefile or the files it includes if your
-       build environment is different than that of the author.
+         This option should only be enabled if you are modifying the firmware
+         source to the aic79xx driver and wish to have the generated firmware
+         include files updated during a normal kernel build.  The assembler
+         for the firmware requires lex and yacc or their equivalents, as well
+         as the db v1 library.  You may have to install additional packages
+         or modify the assembler Makefile or the files it includes if your
+         build environment is different than that of the author.
 
 config AIC79XX_DEBUG_ENABLE
        bool "Compile in Debugging Code"
        depends on SCSI_AIC79XX
        default y
        help
-       Compile in aic79xx debugging code that can be useful in diagnosing
-       driver errors.
+         Compile in aic79xx debugging code that can be useful in diagnosing
+         driver errors.
 
 config AIC79XX_DEBUG_MASK
        int "Debug code enable mask (16383 for all debugging)"
        depends on SCSI_AIC79XX
        default "0"
        help
-       Bit mask of debug options that is only valid if the
-       CONFIG_AIC79XX_DEBUG_ENABLE option is enabled.  The bits in this mask
-       are defined in the drivers/scsi/aic7xxx/aic79xx.h - search for the
-       variable ahd_debug in that file to find them.
+         Bit mask of debug options that is only valid if the
+         CONFIG_AIC79XX_DEBUG_ENABLE option is enabled.  The bits in this mask
+         are defined in the drivers/scsi/aic7xxx/aic79xx.h - search for the
+         variable ahd_debug in that file to find them.
 
 config AIC79XX_REG_PRETTY_PRINT
        bool "Decode registers during diagnostics"
        depends on SCSI_AIC79XX
        default y
        help
-       Compile in register value tables for the output of expanded register
-       contents in diagnostics.  This make it much easier to understand debug
-       output without having to refer to a data book and/or the aic7xxx.reg
-       file.
+         Compile in register value tables for the output of expanded register
+         contents in diagnostics.  This make it much easier to understand debug
+         output without having to refer to a data book and/or the aic7xxx.reg
+         file.
index f0425145a5f4d8a878344d02c4f82794dff0f025..8f87f2d8ba9f9fcf7853754877945b96c74be53d 100644 (file)
@@ -8,84 +8,85 @@ config SCSI_AIC7XXX
        depends on (PCI || EISA) && HAS_IOPORT && SCSI
        select SCSI_SPI_ATTRS
        help
-       This driver supports all of Adaptec's Fast through Ultra 160 PCI
-       based SCSI controllers as well as the aic7770 based EISA and VLB
-       SCSI controllers (the 274x and 284x series).  For AAA and ARO based
-       configurations, only SCSI functionality is provided.
+         This driver supports all of Adaptec's Fast through Ultra 160 PCI
+         based SCSI controllers as well as the aic7770 based EISA and VLB
+         SCSI controllers (the 274x and 284x series).  For AAA and ARO based
+         configurations, only SCSI functionality is provided.
 
-       To compile this driver as a module, choose M here: the
-       module will be called aic7xxx.
+         To compile this driver as a module, choose M here: the
+         module will be called aic7xxx.
 
 config AIC7XXX_CMDS_PER_DEVICE
        int "Maximum number of TCQ commands per device"
        depends on SCSI_AIC7XXX
        default "32"
        help
-       Specify the number of commands you would like to allocate per SCSI
-       device when Tagged Command Queueing (TCQ) is enabled on that device.
+         Specify the number of commands you would like to allocate per SCSI
+         device when Tagged Command Queueing (TCQ) is enabled on that device.
 
-       This is an upper bound value for the number of tagged transactions
-       to be used for any device.  The aic7xxx driver will automatically
-       vary this number based on device behavior.  For devices with a
-       fixed maximum, the driver will eventually lock to this maximum
-       and display a console message indicating this value.
+         This is an upper bound value for the number of tagged transactions
+         to be used for any device.  The aic7xxx driver will automatically
+         vary this number based on device behavior.  For devices with a
+         fixed maximum, the driver will eventually lock to this maximum
+         and display a console message indicating this value.
 
-       Due to resource allocation issues in the Linux SCSI mid-layer, using
-       a high number of commands per device may result in memory allocation
-       failures when many devices are attached to the system.  For this reason,
-       the default is set to 32.  Higher values may result in higher performance
-       on some devices.  The upper bound is 253.  0 disables tagged queueing.
+         Due to resource allocation issues in the Linux SCSI mid-layer, using
+         a high number of commands per device may result in memory allocation
+         failures when many devices are attached to the system.  For this
+         reason, the default is set to 32.  Higher values may result in higher
+         performance on some devices. The upper bound is 253. 0 disables tagged
+         queueing.
 
-       Per device tag depth can be controlled via the kernel command line
-       "tag_info" option.  See Documentation/scsi/aic7xxx.rst for details.
+         Per device tag depth can be controlled via the kernel command line
+         "tag_info" option.  See Documentation/scsi/aic7xxx.rst for details.
 
 config AIC7XXX_RESET_DELAY_MS
        int "Initial bus reset delay in milli-seconds"
        depends on SCSI_AIC7XXX
        default "5000"
        help
-       The number of milliseconds to delay after an initial bus reset.
-       The bus settle delay following all error recovery actions is
-       dictated by the SCSI layer and is not affected by this value.
+         The number of milliseconds to delay after an initial bus reset.
+         The bus settle delay following all error recovery actions is
+         dictated by the SCSI layer and is not affected by this value.
 
-       Default: 5000 (5 seconds)
+         Default: 5000 (5 seconds)
 
 config AIC7XXX_BUILD_FIRMWARE
        bool "Build Adapter Firmware with Kernel Build"
        depends on SCSI_AIC7XXX && !PREVENT_FIRMWARE_BUILD
        help
-       This option should only be enabled if you are modifying the firmware
-       source to the aic7xxx driver and wish to have the generated firmware
-       include files updated during a normal kernel build.  The assembler
-       for the firmware requires lex and yacc or their equivalents, as well
-       as the db v1 library.  You may have to install additional packages
-       or modify the assembler Makefile or the files it includes if your
-       build environment is different than that of the author.
+         This option should only be enabled if you are modifying the firmware
+         source to the aic7xxx driver and wish to have the generated firmware
+         include files updated during a normal kernel build.  The assembler
+         for the firmware requires lex and yacc or their equivalents, as well
+         as the db v1 library.  You may have to install additional packages
+         or modify the assembler Makefile or the files it includes if your
+         build environment is different than that of the author.
 
 config AIC7XXX_DEBUG_ENABLE
        bool "Compile in Debugging Code"
        depends on SCSI_AIC7XXX
        default y
        help
-       Compile in aic7xxx debugging code that can be useful in diagnosing
-       driver errors.
+         Compile in aic7xxx debugging code that can be useful in diagnosing
+         driver errors.
 
 config AIC7XXX_DEBUG_MASK
-        int "Debug code enable mask (2047 for all debugging)"
-        depends on SCSI_AIC7XXX
-        default "0"
-        help
-       Bit mask of debug options that is only valid if the
-       CONFIG_AIC7XXX_DEBUG_ENABLE option is enabled.  The bits in this mask
-       are defined in the drivers/scsi/aic7xxx/aic7xxx.h - search for the
-       variable ahc_debug in that file to find them.
+       int "Debug code enable mask (2047 for all debugging)"
+       depends on SCSI_AIC7XXX
+       default "0"
+       help
+         Bit mask of debug options that is only valid if the
+         CONFIG_AIC7XXX_DEBUG_ENABLE option is enabled.  The bits in this mask
+         are defined in the drivers/scsi/aic7xxx/aic7xxx.h - search for the
+         variable ahc_debug in that file to find them.
 
 config AIC7XXX_REG_PRETTY_PRINT
-        bool "Decode registers during diagnostics"
-        depends on SCSI_AIC7XXX
+       bool "Decode registers during diagnostics"
+       depends on SCSI_AIC7XXX
        default y
-        help
-       Compile in register value tables for the output of expanded register
-       contents in diagnostics.  This make it much easier to understand debug
-       output without having to refer to a data book and/or the aic7xxx.reg
-       file.
+       help
+         Compile in register value tables for the output of expanded register
+         contents in diagnostics.  This make it much easier to understand debug
+         output without having to refer to a data book and/or the aic7xxx.reg
+         file.
index 8a3340d8d7ad41edc4964a7bab4a7e51f9716370..538a5867e8ab460fbe76ae14003a53b969626570 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/firmware.h>
 #include <linux/slab.h>
 
+#include <scsi/sas_ata.h>
 #include <scsi/scsi_host.h>
 
 #include "aic94xx.h"
@@ -24,6 +25,7 @@
 
 /* The format is "version.release.patchlevel" */
 #define ASD_DRIVER_VERSION "1.0.3"
+#define DRV_NAME "aic94xx"
 
 static int use_msi = 0;
 module_param_named(use_msi, use_msi, int, S_IRUGO);
@@ -34,32 +36,16 @@ MODULE_PARM_DESC(use_msi, "\n"
 static struct scsi_transport_template *aic94xx_transport_template;
 static int asd_scan_finished(struct Scsi_Host *, unsigned long);
 static void asd_scan_start(struct Scsi_Host *);
+static const struct attribute_group *asd_sdev_groups[];
 
 static const struct scsi_host_template aic94xx_sht = {
-       .module                 = THIS_MODULE,
-       /* .name is initialized */
-       .name                   = "aic94xx",
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
-       .slave_configure        = sas_slave_configure,
+       LIBSAS_SHT_BASE
        .scan_finished          = asd_scan_finished,
        .scan_start             = asd_scan_start,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
        .can_queue              = 1,
-       .this_id                = -1,
        .sg_tablesize           = SG_ALL,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler        = sas_eh_device_reset_handler,
-       .eh_target_reset_handler        = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .track_queue_depth      = 1,
+       .sdev_groups            = asd_sdev_groups,
 };
 
 static int asd_map_memio(struct asd_ha_struct *asd_ha)
@@ -951,6 +937,11 @@ static void asd_remove_driver_attrs(struct device_driver *driver)
        driver_remove_file(driver, &driver_attr_version);
 }
 
+static const struct attribute_group *asd_sdev_groups[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
+
 static struct sas_domain_function_template aic94xx_transport_functions = {
        .lldd_dev_found         = asd_dev_found,
        .lldd_dev_gone          = asd_dev_gone,
index d99e709148176567034397771afa3edc3e064052..742625ac7d992ece9f50c7961a42b40d7a577b51 100644 (file)
@@ -878,7 +878,13 @@ static void __exit atari_scsi_remove(struct platform_device *pdev)
                atari_stram_free(atari_dma_buffer);
 }
 
-static struct platform_driver atari_scsi_driver = {
+/*
+ * atari_scsi_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver atari_scsi_driver __refdata = {
        .remove_new = __exit_p(atari_scsi_remove),
        .driver = {
                .name   = DRV_MODULE_NAME,
index 1befcd5b2a0f935afa86935f619bc2cb8ca331ae..fa07a6f54003ee3651a4af982534d0f1135ceed7 100644 (file)
@@ -102,7 +102,9 @@ do {                                                                        \
 
 #define MAX_RETRIES   1
 
-static struct class * ch_sysfs_class;
+static const struct class ch_sysfs_class = {
+       .name = "scsi_changer",
+};
 
 typedef struct {
        struct kref         ref;
@@ -930,7 +932,7 @@ static int ch_probe(struct device *dev)
        mutex_init(&ch->lock);
        kref_init(&ch->ref);
        ch->device = sd;
-       class_dev = device_create(ch_sysfs_class, dev,
+       class_dev = device_create(&ch_sysfs_class, dev,
                                  MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch,
                                  "s%s", ch->name);
        if (IS_ERR(class_dev)) {
@@ -955,7 +957,7 @@ static int ch_probe(struct device *dev)
 
        return 0;
 destroy_dev:
-       device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
+       device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
 put_device:
        scsi_device_put(sd);
 remove_idr:
@@ -974,7 +976,7 @@ static int ch_remove(struct device *dev)
        dev_set_drvdata(dev, NULL);
        spin_unlock(&ch_index_lock);
 
-       device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
+       device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
        scsi_device_put(ch->device);
        kref_put(&ch->ref, ch_destroy);
        return 0;
@@ -1003,11 +1005,9 @@ static int __init init_ch_module(void)
        int rc;
 
        printk(KERN_INFO "SCSI Media Changer driver v" VERSION " \n");
-        ch_sysfs_class = class_create("scsi_changer");
-        if (IS_ERR(ch_sysfs_class)) {
-               rc = PTR_ERR(ch_sysfs_class);
+       rc = class_register(&ch_sysfs_class);
+       if (rc)
                return rc;
-        }
        rc = register_chrdev(SCSI_CHANGER_MAJOR,"ch",&changer_fops);
        if (rc < 0) {
                printk("Unable to get major %d for SCSI-Changer\n",
@@ -1022,7 +1022,7 @@ static int __init init_ch_module(void)
  fail2:
        unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
  fail1:
-       class_destroy(ch_sysfs_class);
+       class_unregister(&ch_sysfs_class);
        return rc;
 }
 
@@ -1030,7 +1030,7 @@ static void __exit exit_ch_module(void)
 {
        scsi_unregister_driver(&ch_template.gendrv);
        unregister_chrdev(SCSI_CHANGER_MAJOR, "ch");
-       class_destroy(ch_sysfs_class);
+       class_unregister(&ch_sysfs_class);
        idr_destroy(&ch_index_idr);
 }
 
index d649b7a2a879e833c9f4a7a630a8f358e8911023..9a3f2ed050bd8e059be06ddc5f35904590ced39b 100644 (file)
@@ -1185,9 +1185,6 @@ static struct pci_error_handlers csio_err_handler = {
 
 static struct pci_driver csio_pci_driver = {
        .name           = KBUILD_MODNAME,
-       .driver         = {
-               .owner  = THIS_MODULE,
-       },
        .id_table       = csio_pci_tbl,
        .probe          = csio_probe_one,
        .remove         = csio_remove_one,
index e0e15b44a2e6aac9751e6e3cb330914a15614e58..52405c6462f8097370e09a2e63e224dc57f34d62 100644 (file)
@@ -216,7 +216,7 @@ void cxlflash_term_global_luns(void)
 /**
  * cxlflash_manage_lun() - handles LUN management activities
  * @sdev:      SCSI device associated with LUN.
- * @manage:    Manage ioctl data structure.
+ * @arg:       Manage ioctl data structure.
  *
  * This routine is used to notify the driver about a LUN's WWID and associate
  * SCSI devices (sdev) with a global LUN instance. Additionally it serves to
@@ -224,9 +224,9 @@ void cxlflash_term_global_luns(void)
  *
  * Return: 0 on success, -errno on failure
  */
-int cxlflash_manage_lun(struct scsi_device *sdev,
-                       struct dk_cxlflash_manage_lun *manage)
+int cxlflash_manage_lun(struct scsi_device *sdev, void *arg)
 {
+       struct dk_cxlflash_manage_lun *manage = arg;
        struct cxlflash_cfg *cfg = shost_priv(sdev->host);
        struct device *dev = &cfg->dev->dev;
        struct llun_info *lli = NULL;
index debd3697411974aa10b59d222b04aab919b5aeb1..e4b45b7e327774dde48ca8e6045b0c4777bd76c4 100644 (file)
@@ -28,7 +28,12 @@ MODULE_AUTHOR("Manoj N. Kumar <manoj@linux.vnet.ibm.com>");
 MODULE_AUTHOR("Matthew R. Ochs <mrochs@linux.vnet.ibm.com>");
 MODULE_LICENSE("GPL");
 
-static struct class *cxlflash_class;
+static char *cxlflash_devnode(const struct device *dev, umode_t *mode);
+static const struct class cxlflash_class = {
+       .name = "cxlflash",
+       .devnode = cxlflash_devnode,
+};
+
 static u32 cxlflash_major;
 static DECLARE_BITMAP(cxlflash_minor, CXLFLASH_MAX_ADAPTERS);
 
@@ -3275,13 +3280,13 @@ static char *decode_hioctl(unsigned int cmd)
 /**
  * cxlflash_lun_provision() - host LUN provisioning handler
  * @cfg:       Internal structure associated with the host.
- * @lunprov:   Kernel copy of userspace ioctl data structure.
+ * @arg:       Kernel copy of userspace ioctl data structure.
  *
  * Return: 0 on success, -errno on failure
  */
-static int cxlflash_lun_provision(struct cxlflash_cfg *cfg,
-                                 struct ht_cxlflash_lun_provision *lunprov)
+static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, void *arg)
 {
+       struct ht_cxlflash_lun_provision *lunprov = arg;
        struct afu *afu = cfg->afu;
        struct device *dev = &cfg->dev->dev;
        struct sisl_ioarcb rcb;
@@ -3366,16 +3371,16 @@ out:
 /**
  * cxlflash_afu_debug() - host AFU debug handler
  * @cfg:       Internal structure associated with the host.
- * @afu_dbg:   Kernel copy of userspace ioctl data structure.
+ * @arg:       Kernel copy of userspace ioctl data structure.
  *
  * For debug requests requiring a data buffer, always provide an aligned
  * (cache line) buffer to the AFU to appease any alignment requirements.
  *
  * Return: 0 on success, -errno on failure
  */
-static int cxlflash_afu_debug(struct cxlflash_cfg *cfg,
-                             struct ht_cxlflash_afu_debug *afu_dbg)
+static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, void *arg)
 {
+       struct ht_cxlflash_afu_debug *afu_dbg = arg;
        struct afu *afu = cfg->afu;
        struct device *dev = &cfg->dev->dev;
        struct sisl_ioarcb rcb;
@@ -3489,10 +3494,8 @@ static long cxlflash_chr_ioctl(struct file *file, unsigned int cmd,
                size_t size;
                hioctl ioctl;
        } ioctl_tbl[] = {       /* NOTE: order matters here */
-       { sizeof(struct ht_cxlflash_lun_provision),
-               (hioctl)cxlflash_lun_provision },
-       { sizeof(struct ht_cxlflash_afu_debug),
-               (hioctl)cxlflash_afu_debug },
+       { sizeof(struct ht_cxlflash_lun_provision), cxlflash_lun_provision },
+       { sizeof(struct ht_cxlflash_afu_debug), cxlflash_afu_debug },
        };
 
        /* Hold read semaphore so we can drain if needed */
@@ -3602,7 +3605,7 @@ static int init_chrdev(struct cxlflash_cfg *cfg)
                goto err1;
        }
 
-       char_dev = device_create(cxlflash_class, NULL, devno,
+       char_dev = device_create(&cxlflash_class, NULL, devno,
                                 NULL, "cxlflash%d", minor);
        if (IS_ERR(char_dev)) {
                rc = PTR_ERR(char_dev);
@@ -3880,14 +3883,12 @@ static int cxlflash_class_init(void)
 
        cxlflash_major = MAJOR(devno);
 
-       cxlflash_class = class_create("cxlflash");
-       if (IS_ERR(cxlflash_class)) {
-               rc = PTR_ERR(cxlflash_class);
+       rc = class_register(&cxlflash_class);
+       if (rc) {
                pr_err("%s: class_create failed rc=%d\n", __func__, rc);
                goto err;
        }
 
-       cxlflash_class->devnode = cxlflash_devnode;
 out:
        pr_debug("%s: returning rc=%d\n", __func__, rc);
        return rc;
@@ -3903,7 +3904,7 @@ static void cxlflash_class_exit(void)
 {
        dev_t devno = MKDEV(cxlflash_major, 0);
 
-       class_destroy(cxlflash_class);
+       class_unregister(&cxlflash_class);
        unregister_chrdev_region(devno, CXLFLASH_MAX_ADAPTERS);
 }
 
index e1b55b03e81243b4be5df158c07bd501b1e78f78..2d356fe2457a2a02fc1d49caf5dea4bd2c74b3a1 100644 (file)
@@ -729,8 +729,7 @@ out:
        return rc;
 }
 
-int cxlflash_disk_release(struct scsi_device *sdev,
-                         struct dk_cxlflash_release *release)
+int cxlflash_disk_release(struct scsi_device *sdev, void *release)
 {
        return _cxlflash_disk_release(sdev, NULL, release);
 }
@@ -955,8 +954,7 @@ out:
        return rc;
 }
 
-static int cxlflash_disk_detach(struct scsi_device *sdev,
-                               struct dk_cxlflash_detach *detach)
+static int cxlflash_disk_detach(struct scsi_device *sdev, void *detach)
 {
        return _cxlflash_disk_detach(sdev, NULL, detach);
 }
@@ -1305,7 +1303,7 @@ retry:
 /**
  * cxlflash_disk_attach() - attach a LUN to a context
  * @sdev:      SCSI device associated with LUN.
- * @attach:    Attach ioctl data structure.
+ * @arg:       Attach ioctl data structure.
  *
  * Creates a context and attaches LUN to it. A LUN can only be attached
  * one time to a context (subsequent attaches for the same context/LUN pair
@@ -1314,9 +1312,9 @@ retry:
  *
  * Return: 0 on success, -errno on failure
  */
-static int cxlflash_disk_attach(struct scsi_device *sdev,
-                               struct dk_cxlflash_attach *attach)
+static int cxlflash_disk_attach(struct scsi_device *sdev, void *arg)
 {
+       struct dk_cxlflash_attach *attach = arg;
        struct cxlflash_cfg *cfg = shost_priv(sdev->host);
        struct device *dev = &cfg->dev->dev;
        struct afu *afu = cfg->afu;
@@ -1621,7 +1619,7 @@ err1:
 /**
  * cxlflash_afu_recover() - initiates AFU recovery
  * @sdev:      SCSI device associated with LUN.
- * @recover:   Recover ioctl data structure.
+ * @arg:       Recover ioctl data structure.
  *
  * Only a single recovery is allowed at a time to avoid exhausting CXL
  * resources (leading to recovery failure) in the event that we're up
@@ -1648,9 +1646,9 @@ err1:
  *
  * Return: 0 on success, -errno on failure
  */
-static int cxlflash_afu_recover(struct scsi_device *sdev,
-                               struct dk_cxlflash_recover_afu *recover)
+static int cxlflash_afu_recover(struct scsi_device *sdev, void *arg)
 {
+       struct dk_cxlflash_recover_afu *recover = arg;
        struct cxlflash_cfg *cfg = shost_priv(sdev->host);
        struct device *dev = &cfg->dev->dev;
        struct llun_info *lli = sdev->hostdata;
@@ -1829,13 +1827,13 @@ out:
 /**
  * cxlflash_disk_verify() - verifies a LUN is the same and handle size changes
  * @sdev:      SCSI device associated with LUN.
- * @verify:    Verify ioctl data structure.
+ * @arg:       Verify ioctl data structure.
  *
  * Return: 0 on success, -errno on failure
  */
-static int cxlflash_disk_verify(struct scsi_device *sdev,
-                               struct dk_cxlflash_verify *verify)
+static int cxlflash_disk_verify(struct scsi_device *sdev, void *arg)
 {
+       struct dk_cxlflash_verify *verify = arg;
        int rc = 0;
        struct ctx_info *ctxi = NULL;
        struct cxlflash_cfg *cfg = shost_priv(sdev->host);
@@ -2111,16 +2109,16 @@ int cxlflash_ioctl(struct scsi_device *sdev, unsigned int cmd, void __user *arg)
                size_t size;
                sioctl ioctl;
        } ioctl_tbl[] = {       /* NOTE: order matters here */
-       {sizeof(struct dk_cxlflash_attach), (sioctl)cxlflash_disk_attach},
+       {sizeof(struct dk_cxlflash_attach), cxlflash_disk_attach},
        {sizeof(struct dk_cxlflash_udirect), cxlflash_disk_direct_open},
-       {sizeof(struct dk_cxlflash_release), (sioctl)cxlflash_disk_release},
-       {sizeof(struct dk_cxlflash_detach), (sioctl)cxlflash_disk_detach},
-       {sizeof(struct dk_cxlflash_verify), (sioctl)cxlflash_disk_verify},
-       {sizeof(struct dk_cxlflash_recover_afu), (sioctl)cxlflash_afu_recover},
-       {sizeof(struct dk_cxlflash_manage_lun), (sioctl)cxlflash_manage_lun},
+       {sizeof(struct dk_cxlflash_release), cxlflash_disk_release},
+       {sizeof(struct dk_cxlflash_detach), cxlflash_disk_detach},
+       {sizeof(struct dk_cxlflash_verify), cxlflash_disk_verify},
+       {sizeof(struct dk_cxlflash_recover_afu), cxlflash_afu_recover},
+       {sizeof(struct dk_cxlflash_manage_lun), cxlflash_manage_lun},
        {sizeof(struct dk_cxlflash_uvirtual), cxlflash_disk_virtual_open},
-       {sizeof(struct dk_cxlflash_resize), (sioctl)cxlflash_vlun_resize},
-       {sizeof(struct dk_cxlflash_clone), (sioctl)cxlflash_disk_clone},
+       {sizeof(struct dk_cxlflash_resize), cxlflash_vlun_resize},
+       {sizeof(struct dk_cxlflash_clone), cxlflash_disk_clone},
        };
 
        /* Hold read semaphore so we can drain if needed */
index 0e3b4596406691b23d1d4dc3173eadad1dc10e33..fe8c975d13d72abf2e333f36c9009945907a88e4 100644 (file)
@@ -114,18 +114,16 @@ struct cxlflash_global {
        struct page *err_page; /* One page of all 0xF for error notification */
 };
 
-int cxlflash_vlun_resize(struct scsi_device *sdev,
-                        struct dk_cxlflash_resize *resize);
+int cxlflash_vlun_resize(struct scsi_device *sdev, void *resize);
 int _cxlflash_vlun_resize(struct scsi_device *sdev, struct ctx_info *ctxi,
                          struct dk_cxlflash_resize *resize);
 
 int cxlflash_disk_release(struct scsi_device *sdev,
-                         struct dk_cxlflash_release *release);
+                         void *release);
 int _cxlflash_disk_release(struct scsi_device *sdev, struct ctx_info *ctxi,
                           struct dk_cxlflash_release *release);
 
-int cxlflash_disk_clone(struct scsi_device *sdev,
-                       struct dk_cxlflash_clone *clone);
+int cxlflash_disk_clone(struct scsi_device *sdev, void *arg);
 
 int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg);
 
@@ -145,8 +143,7 @@ void rhte_checkin(struct ctx_info *ctxi, struct sisl_rht_entry *rhte);
 
 void cxlflash_ba_terminate(struct ba_lun *ba_lun);
 
-int cxlflash_manage_lun(struct scsi_device *sdev,
-                       struct dk_cxlflash_manage_lun *manage);
+int cxlflash_manage_lun(struct scsi_device *sdev, void *manage);
 
 int check_state(struct cxlflash_cfg *cfg);
 
index cbd5a648a131be646ef9ccfbea8c8eca689418de..35326e31199131f250c8df8184bf47756f34d287 100644 (file)
@@ -819,8 +819,7 @@ out:
        return rc;
 }
 
-int cxlflash_vlun_resize(struct scsi_device *sdev,
-                        struct dk_cxlflash_resize *resize)
+int cxlflash_vlun_resize(struct scsi_device *sdev, void *resize)
 {
        return _cxlflash_vlun_resize(sdev, NULL, resize);
 }
@@ -1178,7 +1177,7 @@ err:
 /**
  * cxlflash_disk_clone() - clone a context by making snapshot of another
  * @sdev:      SCSI device associated with LUN owning virtual LUN.
- * @clone:     Clone ioctl data structure.
+ * @arg:       Clone ioctl data structure.
  *
  * This routine effectively performs cxlflash_disk_open operation for each
  * in-use virtual resource in the source context. Note that the destination
@@ -1187,9 +1186,9 @@ err:
  *
  * Return: 0 on success, -errno on failure
  */
-int cxlflash_disk_clone(struct scsi_device *sdev,
-                       struct dk_cxlflash_clone *clone)
+int cxlflash_disk_clone(struct scsi_device *sdev, void *arg)
 {
+       struct dk_cxlflash_clone *clone = arg;
        struct cxlflash_cfg *cfg = shost_priv(sdev->host);
        struct device *dev = &cfg->dev->dev;
        struct llun_info *lli = sdev->hostdata;
index 3c555579f9a1cf04d2011c88efbdbe3abc808cb8..161feae3acaba272253e7ce8dd38660b3d52b368 100644 (file)
@@ -1735,28 +1735,12 @@ static struct attribute *host_v1_hw_attrs[] = {
 ATTRIBUTE_GROUPS(host_v1_hw);
 
 static const struct scsi_host_template sht_v1_hw = {
-       .name                   = DRV_NAME,
-       .proc_name              = DRV_NAME,
-       .module                 = THIS_MODULE,
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
+       LIBSAS_SHT_BASE_NO_SLAVE_INIT
        .slave_configure        = hisi_sas_slave_configure,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
-       .this_id                = -1,
        .sg_tablesize           = HISI_SAS_SGE_PAGE_CNT,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler = sas_eh_device_reset_handler,
-       .eh_target_reset_handler = sas_eh_target_reset_handler,
        .slave_alloc            = hisi_sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .shost_groups           = host_v1_hw_groups,
        .host_reset             = hisi_sas_host_reset,
 };
index 73b378837da7bd210a741ec9e28c72cb31ad885f..d89e97e8f5c2c260752271020d11707ad8db119f 100644 (file)
@@ -3544,6 +3544,11 @@ static struct attribute *host_v2_hw_attrs[] = {
 
 ATTRIBUTE_GROUPS(host_v2_hw);
 
+static const struct attribute_group *sdev_groups_v2_hw[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
+
 static void map_queues_v2_hw(struct Scsi_Host *shost)
 {
        struct hisi_hba *hisi_hba = shost_priv(shost);
@@ -3562,29 +3567,14 @@ static void map_queues_v2_hw(struct Scsi_Host *shost)
 }
 
 static const struct scsi_host_template sht_v2_hw = {
-       .name                   = DRV_NAME,
-       .proc_name              = DRV_NAME,
-       .module                 = THIS_MODULE,
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
+       LIBSAS_SHT_BASE_NO_SLAVE_INIT
        .slave_configure        = hisi_sas_slave_configure,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
-       .this_id                = -1,
        .sg_tablesize           = HISI_SAS_SGE_PAGE_CNT,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler = sas_eh_device_reset_handler,
-       .eh_target_reset_handler = sas_eh_target_reset_handler,
        .slave_alloc            = hisi_sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .shost_groups           = host_v2_hw_groups,
+       .sdev_groups            = sdev_groups_v2_hw,
        .host_reset             = hisi_sas_host_reset,
        .map_queues             = map_queues_v2_hw,
        .host_tagset            = 1,
index 7d2a33514538c2cd8083733d8303f4dc5934de7d..756660588a1e88cd637192e15470b908cc4de5d9 100644 (file)
@@ -2929,6 +2929,11 @@ static struct attribute *host_v3_hw_attrs[] = {
 
 ATTRIBUTE_GROUPS(host_v3_hw);
 
+static const struct attribute_group *sdev_groups_v3_hw[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
+
 #define HISI_SAS_DEBUGFS_REG(x) {#x, x}
 
 struct hisi_sas_debugfs_reg_lu {
@@ -3315,31 +3320,16 @@ static void hisi_sas_map_queues(struct Scsi_Host *shost)
 }
 
 static const struct scsi_host_template sht_v3_hw = {
-       .name                   = DRV_NAME,
-       .proc_name              = DRV_NAME,
-       .module                 = THIS_MODULE,
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
+       LIBSAS_SHT_BASE_NO_SLAVE_INIT
        .slave_configure        = slave_configure_v3_hw,
        .scan_finished          = hisi_sas_scan_finished,
        .scan_start             = hisi_sas_scan_start,
        .map_queues             = hisi_sas_map_queues,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
-       .this_id                = -1,
        .sg_tablesize           = HISI_SAS_SGE_PAGE_CNT,
        .sg_prot_tablesize      = HISI_SAS_SGE_PAGE_CNT,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler = sas_eh_device_reset_handler,
-       .eh_target_reset_handler = sas_eh_target_reset_handler,
        .slave_alloc            = hisi_sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .shost_groups           = host_v3_hw_groups,
+       .sdev_groups            = sdev_groups_v3_hw,
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,
        .host_reset             = hisi_sas_host_reset,
        .host_tagset            = 1,
index c582a3932ceab74a6cda37cc6c243b4d943f529b..de2aefcf20892aed98d09aec1591a89bc7331a00 100644 (file)
@@ -149,33 +149,20 @@ static struct attribute *isci_host_attrs[] = {
 
 ATTRIBUTE_GROUPS(isci_host);
 
-static const struct scsi_host_template isci_sht = {
+static const struct attribute_group *isci_sdev_groups[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
 
-       .module                         = THIS_MODULE,
-       .name                           = DRV_NAME,
-       .proc_name                      = DRV_NAME,
-       .queuecommand                   = sas_queuecommand,
-       .dma_need_drain                 = ata_scsi_dma_need_drain,
-       .target_alloc                   = sas_target_alloc,
-       .slave_configure                = sas_slave_configure,
+static const struct scsi_host_template isci_sht = {
+       LIBSAS_SHT_BASE
        .scan_finished                  = isci_host_scan_finished,
        .scan_start                     = isci_host_start,
-       .change_queue_depth             = sas_change_queue_depth,
-       .bios_param                     = sas_bios_param,
        .can_queue                      = ISCI_CAN_QUEUE_VAL,
-       .this_id                        = -1,
        .sg_tablesize                   = SG_ALL,
-       .max_sectors                    = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_abort_handler               = sas_eh_abort_handler,
-       .eh_device_reset_handler        = sas_eh_device_reset_handler,
-       .eh_target_reset_handler        = sas_eh_target_reset_handler,
-       .slave_alloc                    = sas_slave_alloc,
-       .target_destroy                 = sas_target_destroy,
-       .ioctl                          = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl                   = sas_ioctl,
-#endif
+       .eh_abort_handler               = sas_eh_abort_handler,
        .shost_groups                   = isci_host_groups,
+       .sdev_groups                    = isci_sdev_groups,
        .track_queue_depth              = 1,
 };
 
index 12e2653846e3f0d93a9dee938eee0ba65df169e2..4c69fc63c119669310fbaef8b97268b75cf90e12 100644 (file)
@@ -964,3 +964,87 @@ int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id)
                               force_phy_id, &tmf_task);
 }
 EXPORT_SYMBOL_GPL(sas_execute_ata_cmd);
+
+static ssize_t sas_ncq_prio_supported_show(struct device *device,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct scsi_device *sdev = to_scsi_device(device);
+       struct domain_device *ddev = sdev_to_domain_dev(sdev);
+       bool supported;
+       int rc;
+
+       rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev, &supported);
+       if (rc)
+               return rc;
+
+       return sysfs_emit(buf, "%d\n", supported);
+}
+
+static struct device_attribute dev_attr_sas_ncq_prio_supported =
+       __ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
+
+static ssize_t sas_ncq_prio_enable_show(struct device *device,
+                                       struct device_attribute *attr,
+                                       char *buf)
+{
+       struct scsi_device *sdev = to_scsi_device(device);
+       struct domain_device *ddev = sdev_to_domain_dev(sdev);
+       bool enabled;
+       int rc;
+
+       rc = ata_ncq_prio_enabled(ddev->sata_dev.ap, sdev, &enabled);
+       if (rc)
+               return rc;
+
+       return sysfs_emit(buf, "%d\n", enabled);
+}
+
+static ssize_t sas_ncq_prio_enable_store(struct device *device,
+                                        struct device_attribute *attr,
+                                        const char *buf, size_t len)
+{
+       struct scsi_device *sdev = to_scsi_device(device);
+       struct domain_device *ddev = sdev_to_domain_dev(sdev);
+       bool enable;
+       int rc;
+
+       rc = kstrtobool(buf, &enable);
+       if (rc)
+               return rc;
+
+       rc = ata_ncq_prio_enable(ddev->sata_dev.ap, sdev, enable);
+       if (rc)
+               return rc;
+
+       return len;
+}
+
+static struct device_attribute dev_attr_sas_ncq_prio_enable =
+       __ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
+              sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
+
+static struct attribute *sas_ata_sdev_attrs[] = {
+       &dev_attr_sas_ncq_prio_supported.attr,
+       &dev_attr_sas_ncq_prio_enable.attr,
+       NULL
+};
+
+static umode_t sas_ata_attr_is_visible(struct kobject *kobj,
+                                      struct attribute *attr, int i)
+{
+       struct device *dev = kobj_to_dev(kobj);
+       struct scsi_device *sdev = to_scsi_device(dev);
+       struct domain_device *ddev = sdev_to_domain_dev(sdev);
+
+       if (!dev_is_sata(ddev))
+               return 0;
+
+       return attr->mode;
+}
+
+const struct attribute_group sas_ata_sdev_attr_group = {
+       .attrs = sas_ata_sdev_attrs,
+       .is_visible = sas_ata_attr_is_visible,
+};
+EXPORT_SYMBOL_GPL(sas_ata_sdev_attr_group);
index a2204674b6808fa3df84288d7f5b134680232fd1..5c261005b74e47063172d3a0d10fb6e34cf74764 100644 (file)
@@ -1621,6 +1621,16 @@ out_err:
 
 /* ---------- Domain revalidation ---------- */
 
+static void sas_get_sas_addr_and_dev_type(struct smp_disc_resp *disc_resp,
+                                         u8 *sas_addr,
+                                         enum sas_device_type *type)
+{
+       memcpy(sas_addr, disc_resp->disc.attached_sas_addr, SAS_ADDR_SIZE);
+       *type = to_dev_type(&disc_resp->disc);
+       if (*type == SAS_PHY_UNUSED)
+               memset(sas_addr, 0, SAS_ADDR_SIZE);
+}
+
 static int sas_get_phy_discover(struct domain_device *dev,
                                int phy_id, struct smp_disc_resp *disc_resp)
 {
@@ -1674,13 +1684,8 @@ int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
                return -ENOMEM;
 
        res = sas_get_phy_discover(dev, phy_id, disc_resp);
-       if (res == 0) {
-               memcpy(sas_addr, disc_resp->disc.attached_sas_addr,
-                      SAS_ADDR_SIZE);
-               *type = to_dev_type(&disc_resp->disc);
-               if (*type == 0)
-                       memset(sas_addr, 0, SAS_ADDR_SIZE);
-       }
+       if (res == 0)
+               sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, type);
        kfree(disc_resp);
        return res;
 }
@@ -1940,6 +1945,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
        struct expander_device *ex = &dev->ex_dev;
        struct ex_phy *phy = &ex->ex_phy[phy_id];
        enum sas_device_type type = SAS_PHY_UNUSED;
+       struct smp_disc_resp *disc_resp;
        u8 sas_addr[SAS_ADDR_SIZE];
        char msg[80] = "";
        int res;
@@ -1951,33 +1957,41 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
                 SAS_ADDR(dev->sas_addr), phy_id, msg);
 
        memset(sas_addr, 0, SAS_ADDR_SIZE);
-       res = sas_get_phy_attached_dev(dev, phy_id, sas_addr, &type);
+       disc_resp = alloc_smp_resp(DISCOVER_RESP_SIZE);
+       if (!disc_resp)
+               return -ENOMEM;
+
+       res = sas_get_phy_discover(dev, phy_id, disc_resp);
        switch (res) {
        case SMP_RESP_NO_PHY:
                phy->phy_state = PHY_NOT_PRESENT;
                sas_unregister_devs_sas_addr(dev, phy_id, last);
-               return res;
+               goto out_free_resp;
        case SMP_RESP_PHY_VACANT:
                phy->phy_state = PHY_VACANT;
                sas_unregister_devs_sas_addr(dev, phy_id, last);
-               return res;
+               goto out_free_resp;
        case SMP_RESP_FUNC_ACC:
                break;
        case -ECOMM:
                break;
        default:
-               return res;
+               goto out_free_resp;
        }
 
+       if (res == 0)
+               sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, &type);
+
        if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) {
                phy->phy_state = PHY_EMPTY;
                sas_unregister_devs_sas_addr(dev, phy_id, last);
                /*
-                * Even though the PHY is empty, for convenience we discover
-                * the PHY to update the PHY info, like negotiated linkrate.
+                * Even though the PHY is empty, for convenience we update
+                * the PHY info, like negotiated linkrate.
                 */
-               sas_ex_phy_discover(dev, phy_id);
-               return res;
+               if (res == 0)
+                       sas_set_ex_phy(dev, phy_id, disc_resp);
+               goto out_free_resp;
        } else if (SAS_ADDR(sas_addr) == SAS_ADDR(phy->attached_sas_addr) &&
                   dev_type_flutter(type, phy->attached_dev_type)) {
                struct domain_device *ata_dev = sas_ex_to_ata(dev, phy_id);
@@ -1989,7 +2003,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
                        action = ", needs recovery";
                pr_debug("ex %016llx phy%02d broadcast flutter%s\n",
                         SAS_ADDR(dev->sas_addr), phy_id, action);
-               return res;
+               goto out_free_resp;
        }
 
        /* we always have to delete the old device when we went here */
@@ -1998,7 +2012,10 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id,
                SAS_ADDR(phy->attached_sas_addr));
        sas_unregister_devs_sas_addr(dev, phy_id, last);
 
-       return sas_discover_new(dev, phy_id);
+       res = sas_discover_new(dev, phy_id);
+out_free_resp:
+       kfree(disc_resp);
+       return res;
 }
 
 /**
index 30d20d37554f6deb28ce816a7307c41db4ae264a..98ca7df003efb377427ceed6ac431b0c1e6a97d5 100644 (file)
@@ -1333,7 +1333,6 @@ struct lpfc_hba {
        struct timer_list fabric_block_timer;
        unsigned long bit_flags;
        atomic_t num_rsrc_err;
-       atomic_t num_cmd_success;
        unsigned long last_rsrc_error_time;
        unsigned long last_ramp_down_time;
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
@@ -1438,6 +1437,7 @@ struct lpfc_hba {
        struct timer_list inactive_vmid_poll;
 
        /* RAS Support */
+       spinlock_t ras_fwlog_lock; /* do not take while holding another lock */
        struct lpfc_ras_fwlog ras_fwlog;
 
        uint32_t iocb_cnt;
index 365c7e96070bb7aec4cad7fa09f17eb0aa8b6345..3c534b3cfe9186857b6109f668c161af704eda6d 100644 (file)
@@ -5865,9 +5865,9 @@ lpfc_ras_fwlog_buffsize_set(struct lpfc_hba  *phba, uint val)
        if (phba->cfg_ras_fwlog_func != PCI_FUNC(phba->pcidev->devfn))
                return -EINVAL;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        state = phba->ras_fwlog.state;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (state == REG_INPROGRESS) {
                lpfc_printf_log(phba, KERN_ERR, LOG_SLI, "6147 RAS Logging "
index d80e6e81053b0a9d61aec5574d2d5d3a2d241e64..529df1768fa89f50dfb3af58b1d72ddb9c5d319e 100644 (file)
@@ -2513,7 +2513,7 @@ static int lpfcdiag_loop_self_reg(struct lpfc_hba *phba, uint16_t *rpi)
                return -ENOMEM;
        }
 
-       dmabuff = (struct lpfc_dmabuf *)mbox->ctx_buf;
+       dmabuff = mbox->ctx_buf;
        mbox->ctx_buf = NULL;
        mbox->ctx_ndlp = NULL;
        status = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO);
@@ -3169,10 +3169,10 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job)
        }
 
        cmdwqe = &cmdiocbq->wqe;
-       memset(cmdwqe, 0, sizeof(union lpfc_wqe));
+       memset(cmdwqe, 0, sizeof(*cmdwqe));
        if (phba->sli_rev < LPFC_SLI_REV4) {
                rspwqe = &rspiocbq->wqe;
-               memset(rspwqe, 0, sizeof(union lpfc_wqe));
+               memset(rspwqe, 0, sizeof(*rspwqe));
        }
 
        INIT_LIST_HEAD(&head);
@@ -3376,7 +3376,7 @@ lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
        unsigned long flags;
        uint8_t *pmb, *pmb_buf;
 
-       dd_data = pmboxq->ctx_ndlp;
+       dd_data = pmboxq->ctx_u.dd_data;
 
        /*
         * The outgoing buffer is readily referred from the dma buffer,
@@ -3553,7 +3553,7 @@ lpfc_bsg_issue_mbox_ext_handle_job(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
        struct lpfc_sli_config_mbox *sli_cfg_mbx;
        uint8_t *pmbx;
 
-       dd_data = pmboxq->ctx_buf;
+       dd_data = pmboxq->ctx_u.dd_data;
 
        /* Determine if job has been aborted */
        spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -3940,7 +3940,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, struct bsg_job *job,
        pmboxq->mbox_cmpl = lpfc_bsg_issue_read_mbox_ext_cmpl;
 
        /* context fields to callback function */
-       pmboxq->ctx_buf = dd_data;
+       pmboxq->ctx_u.dd_data = dd_data;
        dd_data->type = TYPE_MBOX;
        dd_data->set_job = job;
        dd_data->context_un.mbox.pmboxq = pmboxq;
@@ -4112,7 +4112,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct bsg_job *job,
                pmboxq->mbox_cmpl = lpfc_bsg_issue_write_mbox_ext_cmpl;
 
                /* context fields to callback function */
-               pmboxq->ctx_buf = dd_data;
+               pmboxq->ctx_u.dd_data = dd_data;
                dd_data->type = TYPE_MBOX;
                dd_data->set_job = job;
                dd_data->context_un.mbox.pmboxq = pmboxq;
@@ -4460,7 +4460,7 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct bsg_job *job,
                pmboxq->mbox_cmpl = lpfc_bsg_issue_write_mbox_ext_cmpl;
 
                /* context fields to callback function */
-               pmboxq->ctx_buf = dd_data;
+               pmboxq->ctx_u.dd_data = dd_data;
                dd_data->type = TYPE_MBOX;
                dd_data->set_job = job;
                dd_data->context_un.mbox.pmboxq = pmboxq;
@@ -4747,7 +4747,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct bsg_job *job,
        if (mbox_req->inExtWLen || mbox_req->outExtWLen) {
                from = pmbx;
                ext = from + sizeof(MAILBOX_t);
-               pmboxq->ctx_buf = ext;
+               pmboxq->ext_buf = ext;
                pmboxq->in_ext_byte_len =
                        mbox_req->inExtWLen * sizeof(uint32_t);
                pmboxq->out_ext_byte_len =
@@ -4875,7 +4875,7 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct bsg_job *job,
        pmboxq->mbox_cmpl = lpfc_bsg_issue_mbox_cmpl;
 
        /* setup context field to pass wait_queue pointer to wake function */
-       pmboxq->ctx_ndlp = dd_data;
+       pmboxq->ctx_u.dd_data = dd_data;
        dd_data->type = TYPE_MBOX;
        dd_data->set_job = job;
        dd_data->context_un.mbox.pmboxq = pmboxq;
@@ -5070,12 +5070,12 @@ lpfc_bsg_get_ras_config(struct bsg_job *job)
                bsg_reply->reply_data.vendor_reply.vendor_rsp;
 
        /* Current logging state */
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (ras_fwlog->state == ACTIVE)
                ras_reply->state = LPFC_RASLOG_STATE_RUNNING;
        else
                ras_reply->state = LPFC_RASLOG_STATE_STOPPED;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        ras_reply->log_level = phba->ras_fwlog.fw_loglevel;
        ras_reply->log_buff_sz = phba->cfg_ras_fwlog_buffsize;
@@ -5132,13 +5132,13 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
 
        if (action == LPFC_RASACTION_STOP_LOGGING) {
                /* Check if already disabled */
-               spin_lock_irq(&phba->hbalock);
+               spin_lock_irq(&phba->ras_fwlog_lock);
                if (ras_fwlog->state != ACTIVE) {
-                       spin_unlock_irq(&phba->hbalock);
+                       spin_unlock_irq(&phba->ras_fwlog_lock);
                        rc = -ESRCH;
                        goto ras_job_error;
                }
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
 
                /* Disable logging */
                lpfc_ras_stop_fwlog(phba);
@@ -5149,10 +5149,10 @@ lpfc_bsg_set_ras_config(struct bsg_job *job)
                 * FW-logging with new log-level. Return status
                 * "Logging already Running" to caller.
                 **/
-               spin_lock_irq(&phba->hbalock);
+               spin_lock_irq(&phba->ras_fwlog_lock);
                if (ras_fwlog->state != INACTIVE)
                        action_status = -EINPROGRESS;
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
 
                /* Enable logging */
                rc = lpfc_sli4_ras_fwlog_init(phba, log_level,
@@ -5268,13 +5268,13 @@ lpfc_bsg_get_ras_fwlog(struct bsg_job *job)
                goto ras_job_error;
 
        /* Logging to be stopped before reading */
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (ras_fwlog->state == ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                rc = -EINPROGRESS;
                goto ras_job_error;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (job->request_len <
            sizeof(struct fc_bsg_request) +
index ab5af10c8a16ca597e1fbde60a3c4562981ea03c..a2d2b02b34187f92a28957b5d1c466e9e31d1a37 100644 (file)
@@ -2194,12 +2194,12 @@ static int lpfc_debugfs_ras_log_data(struct lpfc_hba *phba,
 
        memset(buffer, 0, size);
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (phba->ras_fwlog.state != ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                return -EINVAL;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        list_for_each_entry_safe(dmabuf, next,
                                 &phba->ras_fwlog.fwlog_buff_list, list) {
@@ -2250,13 +2250,13 @@ lpfc_debugfs_ras_log_open(struct inode *inode, struct file *file)
        int size;
        int rc = -ENOMEM;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        if (phba->ras_fwlog.state != ACTIVE) {
-               spin_unlock_irq(&phba->hbalock);
+               spin_unlock_irq(&phba->ras_fwlog_lock);
                rc = -EINVAL;
                goto out;
        }
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        if (check_mul_overflow(LPFC_RAS_MIN_BUFF_POST_SIZE,
                               phba->cfg_ras_fwlog_buffsize, &size))
index 28e56542e0720e30d1221c3a24e38e68a5aedd08..f7c28dc73bf67d86ea87098c1cc7cf8b53cc6604 100644 (file)
@@ -4437,23 +4437,23 @@ lpfc_els_retry_delay(struct timer_list *t)
        unsigned long flags;
        struct lpfc_work_evt  *evtp = &ndlp->els_retry_evt;
 
+       /* Hold a node reference for outstanding queued work */
+       if (!lpfc_nlp_get(ndlp))
+               return;
+
        spin_lock_irqsave(&phba->hbalock, flags);
        if (!list_empty(&evtp->evt_listp)) {
                spin_unlock_irqrestore(&phba->hbalock, flags);
+               lpfc_nlp_put(ndlp);
                return;
        }
 
-       /* We need to hold the node by incrementing the reference
-        * count until the queued work is done
-        */
-       evtp->evt_arg1  = lpfc_nlp_get(ndlp);
-       if (evtp->evt_arg1) {
-               evtp->evt = LPFC_EVT_ELS_RETRY;
-               list_add_tail(&evtp->evt_listp, &phba->work_list);
-               lpfc_worker_wake_up(phba);
-       }
+       evtp->evt_arg1 = ndlp;
+       evtp->evt = LPFC_EVT_ELS_RETRY;
+       list_add_tail(&evtp->evt_listp, &phba->work_list);
        spin_unlock_irqrestore(&phba->hbalock, flags);
-       return;
+
+       lpfc_worker_wake_up(phba);
 }
 
 /**
@@ -7238,7 +7238,7 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
                goto rdp_fail;
        mbox->vport = rdp_context->ndlp->vport;
        mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
-       mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
+       mbox->ctx_u.rdp = rdp_context;
        rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
        if (rc == MBX_NOT_FINISHED) {
                lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
@@ -7290,7 +7290,7 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
                mbox->in_ext_byte_len = DMP_SFF_PAGE_A0_SIZE;
                mbox->out_ext_byte_len = DMP_SFF_PAGE_A0_SIZE;
                mbox->mbox_offset_word = 5;
-               mbox->ctx_buf = virt;
+               mbox->ext_buf = virt;
        } else {
                bf_set(lpfc_mbx_memory_dump_type3_length,
                       &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE);
@@ -7298,7 +7298,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
                mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
        }
        mbox->vport = phba->pport;
-       mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
 
        rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
        if (rc == MBX_NOT_FINISHED) {
@@ -7307,7 +7306,7 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
        }
 
        if (phba->sli_rev == LPFC_SLI_REV4)
-               mp = (struct lpfc_dmabuf *)(mbox->ctx_buf);
+               mp = mbox->ctx_buf;
        else
                mp = mpsave;
 
@@ -7350,7 +7349,7 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
                mbox->in_ext_byte_len = DMP_SFF_PAGE_A2_SIZE;
                mbox->out_ext_byte_len = DMP_SFF_PAGE_A2_SIZE;
                mbox->mbox_offset_word = 5;
-               mbox->ctx_buf = virt;
+               mbox->ext_buf = virt;
        } else {
                bf_set(lpfc_mbx_memory_dump_type3_length,
                       &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A2_SIZE);
@@ -7358,7 +7357,6 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
                mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
        }
 
-       mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
        rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
        if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) {
                rc = 1;
@@ -7500,9 +7498,9 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        int rc;
 
        mb = &pmb->u.mb;
-       lcb_context = (struct lpfc_lcb_context *)pmb->ctx_ndlp;
+       lcb_context = pmb->ctx_u.lcb;
        ndlp = lcb_context->ndlp;
-       pmb->ctx_ndlp = NULL;
+       memset(&pmb->ctx_u, 0, sizeof(pmb->ctx_u));
        pmb->ctx_buf = NULL;
 
        shdr = (union lpfc_sli4_cfg_shdr *)
@@ -7642,7 +7640,7 @@ lpfc_sli4_set_beacon(struct lpfc_vport *vport,
        lpfc_sli4_config(phba, mbox, LPFC_MBOX_SUBSYSTEM_COMMON,
                         LPFC_MBOX_OPCODE_SET_BEACON_CONFIG, len,
                         LPFC_SLI4_MBX_EMBED);
-       mbox->ctx_ndlp = (void *)lcb_context;
+       mbox->ctx_u.lcb = lcb_context;
        mbox->vport = phba->pport;
        mbox->mbox_cmpl = lpfc_els_lcb_rsp;
        bf_set(lpfc_mbx_set_beacon_port_num, &mbox->u.mqe.un.beacon_config,
@@ -8639,9 +8637,9 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        mb = &pmb->u.mb;
 
        ndlp = pmb->ctx_ndlp;
-       rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff);
-       oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff);
-       pmb->ctx_buf = NULL;
+       rxid = (uint16_t)(pmb->ctx_u.ox_rx_id & 0xffff);
+       oxid = (uint16_t)((pmb->ctx_u.ox_rx_id >> 16) & 0xffff);
+       memset(&pmb->ctx_u, 0, sizeof(pmb->ctx_u));
        pmb->ctx_ndlp = NULL;
 
        if (mb->mbxStatus) {
@@ -8745,8 +8743,7 @@ lpfc_els_rcv_rls(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
        mbox = mempool_alloc(phba->mbox_mem_pool, GFP_ATOMIC);
        if (mbox) {
                lpfc_read_lnk_stat(phba, mbox);
-               mbox->ctx_buf = (void *)((unsigned long)
-                                        (ox_id << 16 | ctx));
+               mbox->ctx_u.ox_rx_id = ox_id << 16 | ctx;
                mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
                if (!mbox->ctx_ndlp)
                        goto node_err;
index a7a2309a629fafa16f20814f434e38e0a324b334..e42fa9c822b50235a9421570a5816599f6463e8b 100644 (file)
@@ -257,7 +257,9 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
                if (evtp->evt_arg1) {
                        evtp->evt = LPFC_EVT_DEV_LOSS;
                        list_add_tail(&evtp->evt_listp, &phba->work_list);
+                       spin_unlock_irqrestore(&phba->hbalock, iflags);
                        lpfc_worker_wake_up(phba);
+                       return;
                }
                spin_unlock_irqrestore(&phba->hbalock, iflags);
        } else {
@@ -275,10 +277,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
                        lpfc_disc_state_machine(vport, ndlp, NULL,
                                                NLP_EVT_DEVICE_RM);
                }
-
        }
-
-       return;
 }
 
 /**
@@ -3429,7 +3428,7 @@ static void
 lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+       struct lpfc_dmabuf *mp = pmb->ctx_buf;
        struct lpfc_vport  *vport = pmb->vport;
        struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
        struct serv_parm *sp = &vport->fc_sparam;
@@ -3737,7 +3736,7 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        struct lpfc_mbx_read_top *la;
        struct lpfc_sli_ring *pring;
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
+       struct lpfc_dmabuf *mp = pmb->ctx_buf;
        uint8_t attn_type;
 
        /* Unblock ELS traffic */
@@ -3851,8 +3850,8 @@ void
 lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        struct lpfc_vport  *vport = pmb->vport;
-       struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+       struct lpfc_dmabuf *mp = pmb->ctx_buf;
+       struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
 
        /* The driver calls the state machine with the pmb pointer
         * but wants to make sure a stale ctx_buf isn't acted on.
@@ -4066,7 +4065,7 @@ lpfc_create_static_vport(struct lpfc_hba *phba)
                 * the dump routine is a single-use construct.
                 */
                if (pmb->ctx_buf) {
-                       mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+                       mp = pmb->ctx_buf;
                        lpfc_mbuf_free(phba, mp->virt, mp->phys);
                        kfree(mp);
                        pmb->ctx_buf = NULL;
@@ -4089,7 +4088,7 @@ lpfc_create_static_vport(struct lpfc_hba *phba)
 
                if (phba->sli_rev == LPFC_SLI_REV4) {
                        byte_count = pmb->u.mqe.un.mb_words[5];
-                       mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+                       mp = pmb->ctx_buf;
                        if (byte_count > sizeof(struct static_vport_info) -
                                        offset)
                                byte_count = sizeof(struct static_vport_info)
@@ -4169,7 +4168,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        struct lpfc_vport *vport = pmb->vport;
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+       struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
 
        pmb->ctx_ndlp = NULL;
 
@@ -4307,7 +4306,7 @@ void
 lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+       struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
        struct lpfc_vport *vport = pmb->vport;
        int rc;
 
@@ -4431,7 +4430,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        struct lpfc_vport *vport = pmb->vport;
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+       struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
 
        pmb->ctx_ndlp = NULL;
        if (mb->mbxStatus) {
@@ -5174,7 +5173,7 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        struct lpfc_vport  *vport = pmb->vport;
        struct lpfc_nodelist *ndlp;
 
-       ndlp = (struct lpfc_nodelist *)(pmb->ctx_ndlp);
+       ndlp = pmb->ctx_ndlp;
        if (!ndlp)
                return;
        lpfc_issue_els_logo(vport, ndlp, 0);
@@ -5496,7 +5495,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
        if ((mb = phba->sli.mbox_active)) {
                if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
                   !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
-                  (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
+                  (ndlp == mb->ctx_ndlp)) {
                        mb->ctx_ndlp = NULL;
                        mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
                }
@@ -5507,7 +5506,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
        list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) {
                if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) ||
                        (mb->mbox_flag & LPFC_MBX_IMED_UNREG) ||
-                       (ndlp != (struct lpfc_nodelist *)mb->ctx_ndlp))
+                       (ndlp != mb->ctx_ndlp))
                        continue;
 
                mb->ctx_ndlp = NULL;
@@ -5517,7 +5516,7 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
        list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
                if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
                   !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
-                   (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
+                   (ndlp == mb->ctx_ndlp)) {
                        list_del(&mb->list);
                        lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
 
@@ -6357,7 +6356,7 @@ void
 lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        MAILBOX_t *mb = &pmb->u.mb;
-       struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+       struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
        struct lpfc_vport    *vport = pmb->vport;
 
        pmb->ctx_ndlp = NULL;
index 88b2e57d90c2e3a671ab2907318bf7a9f6f7144c..f7a0aa3625f4e1b63d0254a925b0cc00f7bf40ad 100644 (file)
@@ -460,7 +460,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
                return -EIO;
        }
 
-       mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+       mp = pmb->ctx_buf;
 
        /* This dmabuf was allocated by lpfc_read_sparam. The dmabuf is no
         * longer needed.  Prevent unintended ctx_buf access as the mbox is
@@ -2217,7 +2217,7 @@ lpfc_handle_latt(struct lpfc_hba *phba)
        /* Cleanup any outstanding ELS commands */
        lpfc_els_flush_all_cmd(phba);
        psli->slistat.link_event++;
-       lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
+       lpfc_read_topology(phba, pmb, pmb->ctx_buf);
        pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
        pmb->vport = vport;
        /* Block ELS IOCBs until we have processed this mbox command */
@@ -5454,7 +5454,7 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba,
        phba->sli.slistat.link_event++;
 
        /* Create lpfc_handle_latt mailbox command from link ACQE */
-       lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
+       lpfc_read_topology(phba, pmb, pmb->ctx_buf);
        pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
        pmb->vport = phba->pport;
 
@@ -6347,7 +6347,7 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)
        phba->sli.slistat.link_event++;
 
        /* Create lpfc_handle_latt mailbox command from link ACQE */
-       lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
+       lpfc_read_topology(phba, pmb, pmb->ctx_buf);
        pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
        pmb->vport = phba->pport;
 
@@ -7705,6 +7705,9 @@ lpfc_setup_driver_resource_phase1(struct lpfc_hba *phba)
                                "NVME" : " "),
                        (phba->nvmet_support ? "NVMET" : " "));
 
+       /* ras_fwlog state */
+       spin_lock_init(&phba->ras_fwlog_lock);
+
        /* Initialize the IO buffer list used by driver for SLI3 SCSI */
        spin_lock_init(&phba->scsi_buf_list_get_lock);
        INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get);
@@ -13055,7 +13058,7 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)
                rc = request_threaded_irq(eqhdl->irq,
                                          &lpfc_sli4_hba_intr_handler,
                                          &lpfc_sli4_hba_intr_handler_th,
-                                         IRQF_ONESHOT, name, eqhdl);
+                                         0, name, eqhdl);
                if (rc) {
                        lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
                                        "0486 MSI-X fast-path (%d) "
index f7c41958036bb7c40c01a22eca8571f4443fe206..e98f1c2b22202e9e104c8efee3a5b4cd0be364e8 100644 (file)
@@ -102,7 +102,7 @@ lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
 {
        struct lpfc_dmabuf *mp;
 
-       mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
+       mp = mbox->ctx_buf;
        mbox->ctx_buf = NULL;
 
        /* Release the generic BPL buffer memory.  */
@@ -204,10 +204,8 @@ lpfc_dump_mem(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, uint16_t offset,
                uint16_t region_id)
 {
        MAILBOX_t *mb;
-       void *ctx;
 
        mb = &pmb->u.mb;
-       ctx = pmb->ctx_buf;
 
        /* Setup to dump VPD region */
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
@@ -219,7 +217,6 @@ lpfc_dump_mem(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, uint16_t offset,
        mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t));
        mb->un.varDmp.co = 0;
        mb->un.varDmp.resp_offset = 0;
-       pmb->ctx_buf = ctx;
        mb->mbxOwner = OWN_HOST;
        return;
 }
@@ -236,11 +233,8 @@ void
 lpfc_dump_wakeup_param(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        MAILBOX_t *mb;
-       void *ctx;
 
        mb = &pmb->u.mb;
-       /* Save context so that we can restore after memset */
-       ctx = pmb->ctx_buf;
 
        /* Setup to dump VPD region */
        memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
@@ -254,7 +248,6 @@ lpfc_dump_wakeup_param(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        mb->un.varDmp.word_cnt = WAKE_UP_PARMS_WORD_SIZE;
        mb->un.varDmp.co = 0;
        mb->un.varDmp.resp_offset = 0;
-       pmb->ctx_buf = ctx;
        return;
 }
 
@@ -372,7 +365,7 @@ lpfc_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb,
        /* Save address for later completion and set the owner to host so that
         * the FW knows this mailbox is available for processing.
         */
-       pmb->ctx_buf = (uint8_t *)mp;
+       pmb->ctx_buf = mp;
        mb->mbxOwner = OWN_HOST;
        return (0);
 }
@@ -1816,7 +1809,7 @@ lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
        }
        /* Reinitialize the context pointers to avoid stale usage. */
        mbox->ctx_buf = NULL;
-       mbox->context3 = NULL;
+       memset(&mbox->ctx_u, 0, sizeof(mbox->ctx_u));
        kfree(mbox->sge_array);
        /* Finally, free the mailbox command itself */
        mempool_free(mbox, phba->mbox_mem_pool);
@@ -2366,8 +2359,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 {
        MAILBOX_t *mb;
        int rc = FAILURE;
-       struct lpfc_rdp_context *rdp_context =
-                       (struct lpfc_rdp_context *)(mboxq->ctx_ndlp);
+       struct lpfc_rdp_context *rdp_context = mboxq->ctx_u.rdp;
 
        mb = &mboxq->u.mb;
        if (mb->mbxStatus)
@@ -2385,9 +2377,8 @@ mbx_failed:
 static void
 lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
 {
-       struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
-       struct lpfc_rdp_context *rdp_context =
-                       (struct lpfc_rdp_context *)(mbox->ctx_ndlp);
+       struct lpfc_dmabuf *mp = mbox->ctx_buf;
+       struct lpfc_rdp_context *rdp_context = mbox->ctx_u.rdp;
 
        if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
                goto error_mbox_free;
@@ -2401,7 +2392,7 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
        /* Save the dma buffer for cleanup in the final completion. */
        mbox->ctx_buf = mp;
        mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;
-       mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
+       mbox->ctx_u.rdp = rdp_context;
        if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)
                goto error_mbox_free;
 
@@ -2416,9 +2407,8 @@ void
 lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
 {
        int rc;
-       struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(mbox->ctx_buf);
-       struct lpfc_rdp_context *rdp_context =
-                       (struct lpfc_rdp_context *)(mbox->ctx_ndlp);
+       struct lpfc_dmabuf *mp = mbox->ctx_buf;
+       struct lpfc_rdp_context *rdp_context = mbox->ctx_u.rdp;
 
        if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
                goto error;
@@ -2448,7 +2438,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
        mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
 
        mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a2;
-       mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
+       mbox->ctx_u.rdp = rdp_context;
        rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
        if (rc == MBX_NOT_FINISHED)
                goto error;
index 8e425be7c7c99c05b8f899043e15cac7a937665e..c4172791c267511742a1e68a152abe00d2dfd7cc 100644 (file)
@@ -300,7 +300,7 @@ lpfc_defer_plogi_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *login_mbox)
        int rc;
 
        ndlp = login_mbox->ctx_ndlp;
-       save_iocb = login_mbox->context3;
+       save_iocb = login_mbox->ctx_u.save_iocb;
 
        if (mb->mbxStatus == MBX_SUCCESS) {
                /* Now that REG_RPI completed successfully,
@@ -640,7 +640,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
        if (!login_mbox->ctx_ndlp)
                goto out;
 
-       login_mbox->context3 = save_iocb; /* For PLOGI ACC */
+       login_mbox->ctx_u.save_iocb = save_iocb; /* For PLOGI ACC */
 
        spin_lock_irq(&ndlp->lock);
        ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
@@ -682,8 +682,8 @@ lpfc_mbx_cmpl_resume_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
        struct lpfc_nodelist *ndlp;
        uint32_t cmd;
 
-       elsiocb = (struct lpfc_iocbq *)mboxq->ctx_buf;
-       ndlp = (struct lpfc_nodelist *)mboxq->ctx_ndlp;
+       elsiocb = mboxq->ctx_u.save_iocb;
+       ndlp = mboxq->ctx_ndlp;
        vport = mboxq->vport;
        cmd = elsiocb->drvrTimeout;
 
@@ -1875,7 +1875,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
        /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
        if ((mb = phba->sli.mbox_active)) {
                if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
-                  (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
+                  (ndlp == mb->ctx_ndlp)) {
                        ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
                        lpfc_nlp_put(ndlp);
                        mb->ctx_ndlp = NULL;
@@ -1886,7 +1886,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport,
        spin_lock_irq(&phba->hbalock);
        list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
                if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
-                  (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
+                  (ndlp == mb->ctx_ndlp)) {
                        ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
                        lpfc_nlp_put(ndlp);
                        list_del(&mb->list);
index 09c53b85bcb8d6a11128f0cb2c1545afa5cab800..c5792eaf3f64cbd750c43e3dded87b29168c8fac 100644 (file)
@@ -2616,9 +2616,9 @@ lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
                /* No concern about the role change on the nvme remoteport.
                 * The transport will update it.
                 */
-               spin_lock_irq(&vport->phba->hbalock);
+               spin_lock_irq(&ndlp->lock);
                ndlp->fc4_xpt_flags |= NVME_XPT_UNREG_WAIT;
-               spin_unlock_irq(&vport->phba->hbalock);
+               spin_unlock_irq(&ndlp->lock);
 
                /* Don't let the host nvme transport keep sending keep-alives
                 * on this remoteport. Vport is unloading, no recovery. The
index 8258b771bd009e2fe4dbc610db2b56971e3a6f4e..561ced5503c6341e35ca696628f033c419f768f4 100644 (file)
@@ -1586,7 +1586,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba)
                wqe = &nvmewqe->wqe;
 
                /* Initialize WQE */
-               memset(wqe, 0, sizeof(union lpfc_wqe));
+               memset(wqe, 0, sizeof(*wqe));
 
                ctx_buf->iocbq->cmd_dmabuf = NULL;
                spin_lock(&phba->sli4_hba.sgl_list_lock);
index c0038eaae7b0ae9e40d945c9d99708897c97382e..4a6e5223a22418a9f10c07c104003187b3b727cb 100644 (file)
@@ -167,11 +167,10 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
        struct Scsi_Host  *shost;
        struct scsi_device *sdev;
        unsigned long new_queue_depth;
-       unsigned long num_rsrc_err, num_cmd_success;
+       unsigned long num_rsrc_err;
        int i;
 
        num_rsrc_err = atomic_read(&phba->num_rsrc_err);
-       num_cmd_success = atomic_read(&phba->num_cmd_success);
 
        /*
         * The error and success command counters are global per
@@ -186,20 +185,16 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
                for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
                        shost = lpfc_shost_from_vport(vports[i]);
                        shost_for_each_device(sdev, shost) {
-                               new_queue_depth =
-                                       sdev->queue_depth * num_rsrc_err /
-                                       (num_rsrc_err + num_cmd_success);
-                               if (!new_queue_depth)
-                                       new_queue_depth = sdev->queue_depth - 1;
+                               if (num_rsrc_err >= sdev->queue_depth)
+                                       new_queue_depth = 1;
                                else
                                        new_queue_depth = sdev->queue_depth -
-                                                               new_queue_depth;
+                                               num_rsrc_err;
                                scsi_change_queue_depth(sdev, new_queue_depth);
                        }
                }
        lpfc_destroy_vport_work_array(phba, vports);
        atomic_set(&phba->num_rsrc_err, 0);
-       atomic_set(&phba->num_cmd_success, 0);
 }
 
 /**
@@ -5336,16 +5331,6 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
                }
                err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
        } else {
-               if (vport->phba->cfg_enable_bg) {
-                       lpfc_printf_vlog(vport,
-                                        KERN_INFO, LOG_SCSI_CMD,
-                                        "9038 BLKGRD: rcvd PROT_NORMAL cmd: "
-                                        "x%x reftag x%x cnt %u pt %x\n",
-                                        cmnd->cmnd[0],
-                                        scsi_prot_ref_tag(cmnd),
-                                        scsi_logical_block_count(cmnd),
-                                        (cmnd->cmnd[1]>>5));
-               }
                err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
        }
 
index 1f8a9b5945cbae71a32172b4eb0d61e7924e4f0a..a028e008dd1ee8937e448b13db3394be2d562d41 100644 (file)
@@ -1217,9 +1217,9 @@ lpfc_set_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
        empty = list_empty(&phba->active_rrq_list);
        list_add_tail(&rrq->list, &phba->active_rrq_list);
        phba->hba_flag |= HBA_RRQ_ACTIVE;
+       spin_unlock_irqrestore(&phba->hbalock, iflags);
        if (empty)
                lpfc_worker_wake_up(phba);
-       spin_unlock_irqrestore(&phba->hbalock, iflags);
        return 0;
 out:
        spin_unlock_irqrestore(&phba->hbalock, iflags);
@@ -2830,7 +2830,7 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
         */
        pmboxq->mbox_flag |= LPFC_MBX_WAKE;
        spin_lock_irqsave(&phba->hbalock, drvr_flag);
-       pmbox_done = (struct completion *)pmboxq->context3;
+       pmbox_done = pmboxq->ctx_u.mbox_wait;
        if (pmbox_done)
                complete(pmbox_done);
        spin_unlock_irqrestore(&phba->hbalock, drvr_flag);
@@ -2885,7 +2885,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) &&
            pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 &&
            !pmb->u.mb.mbxStatus) {
-               mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+               mp = pmb->ctx_buf;
                if (mp) {
                        pmb->ctx_buf = NULL;
                        lpfc_mbuf_free(phba, mp->virt, mp->phys);
@@ -2914,12 +2914,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        }
 
        if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
-               ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+               ndlp = pmb->ctx_ndlp;
                lpfc_nlp_put(ndlp);
        }
 
        if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {
-               ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+               ndlp = pmb->ctx_ndlp;
 
                /* Check to see if there are any deferred events to process */
                if (ndlp) {
@@ -2952,7 +2952,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 
        /* This nlp_put pairs with lpfc_sli4_resume_rpi */
        if (pmb->u.mb.mbxCommand == MBX_RESUME_RPI) {
-               ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+               ndlp = pmb->ctx_ndlp;
                lpfc_nlp_put(ndlp);
        }
 
@@ -5819,7 +5819,7 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba)
                goto out_free_mboxq;
        }
 
-       mp = (struct lpfc_dmabuf *)mboxq->ctx_buf;
+       mp = mboxq->ctx_buf;
        rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
 
        lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
@@ -6849,9 +6849,9 @@ lpfc_ras_stop_fwlog(struct lpfc_hba *phba)
 {
        struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        /* Disable FW logging to host memory */
        writel(LPFC_CTL_PDEV_CTL_DDL_RAS,
@@ -6894,9 +6894,9 @@ lpfc_sli4_ras_dma_free(struct lpfc_hba *phba)
                ras_fwlog->lwpd.virt = NULL;
        }
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 }
 
 /**
@@ -6998,9 +6998,9 @@ lpfc_sli4_ras_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
                goto disable_ras;
        }
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = ACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
        mempool_free(pmb, phba->mbox_mem_pool);
 
        return;
@@ -7032,9 +7032,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
        uint32_t len = 0, fwlog_buffsize, fwlog_entry_count;
        int rc = 0;
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = INACTIVE;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
 
        fwlog_buffsize = (LPFC_RAS_MIN_BUFF_POST_SIZE *
                          phba->cfg_ras_fwlog_buffsize);
@@ -7095,9 +7095,9 @@ lpfc_sli4_ras_fwlog_init(struct lpfc_hba *phba,
        mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys);
        mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys);
 
-       spin_lock_irq(&phba->hbalock);
+       spin_lock_irq(&phba->ras_fwlog_lock);
        ras_fwlog->state = REG_INPROGRESS;
-       spin_unlock_irq(&phba->hbalock);
+       spin_unlock_irq(&phba->ras_fwlog_lock);
        mbox->vport = phba->pport;
        mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl;
 
@@ -8766,7 +8766,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
 
        mboxq->vport = vport;
        rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
-       mp = (struct lpfc_dmabuf *)mboxq->ctx_buf;
+       mp = mboxq->ctx_buf;
        if (rc == MBX_SUCCESS) {
                memcpy(&vport->fc_sparam, mp->virt, sizeof(struct serv_parm));
                rc = 0;
@@ -9548,8 +9548,8 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
                }
 
                /* Copy the mailbox extension data */
-               if (pmbox->in_ext_byte_len && pmbox->ctx_buf) {
-                       lpfc_sli_pcimem_bcopy(pmbox->ctx_buf,
+               if (pmbox->in_ext_byte_len && pmbox->ext_buf) {
+                       lpfc_sli_pcimem_bcopy(pmbox->ext_buf,
                                              (uint8_t *)phba->mbox_ext,
                                              pmbox->in_ext_byte_len);
                }
@@ -9562,10 +9562,10 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
                                = MAILBOX_HBA_EXT_OFFSET;
 
                /* Copy the mailbox extension data */
-               if (pmbox->in_ext_byte_len && pmbox->ctx_buf)
+               if (pmbox->in_ext_byte_len && pmbox->ext_buf)
                        lpfc_memcpy_to_slim(phba->MBslimaddr +
                                MAILBOX_HBA_EXT_OFFSET,
-                               pmbox->ctx_buf, pmbox->in_ext_byte_len);
+                               pmbox->ext_buf, pmbox->in_ext_byte_len);
 
                if (mbx->mbxCommand == MBX_CONFIG_PORT)
                        /* copy command data into host mbox for cmpl */
@@ -9688,9 +9688,9 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
                        lpfc_sli_pcimem_bcopy(phba->mbox, mbx,
                                                MAILBOX_CMD_SIZE);
                        /* Copy the mailbox extension data */
-                       if (pmbox->out_ext_byte_len && pmbox->ctx_buf) {
+                       if (pmbox->out_ext_byte_len && pmbox->ext_buf) {
                                lpfc_sli_pcimem_bcopy(phba->mbox_ext,
-                                                     pmbox->ctx_buf,
+                                                     pmbox->ext_buf,
                                                      pmbox->out_ext_byte_len);
                        }
                } else {
@@ -9698,9 +9698,9 @@ lpfc_sli_issue_mbox_s3(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox,
                        lpfc_memcpy_from_slim(mbx, phba->MBslimaddr,
                                                MAILBOX_CMD_SIZE);
                        /* Copy the mailbox extension data */
-                       if (pmbox->out_ext_byte_len && pmbox->ctx_buf) {
+                       if (pmbox->out_ext_byte_len && pmbox->ext_buf) {
                                lpfc_memcpy_from_slim(
-                                       pmbox->ctx_buf,
+                                       pmbox->ext_buf,
                                        phba->MBslimaddr +
                                        MAILBOX_HBA_EXT_OFFSET,
                                        pmbox->out_ext_byte_len);
@@ -11373,18 +11373,18 @@ lpfc_sli_post_recovery_event(struct lpfc_hba *phba,
        unsigned long iflags;
        struct lpfc_work_evt  *evtp = &ndlp->recovery_evt;
 
+       /* Hold a node reference for outstanding queued work */
+       if (!lpfc_nlp_get(ndlp))
+               return;
+
        spin_lock_irqsave(&phba->hbalock, iflags);
        if (!list_empty(&evtp->evt_listp)) {
                spin_unlock_irqrestore(&phba->hbalock, iflags);
+               lpfc_nlp_put(ndlp);
                return;
        }
 
-       /* Incrementing the reference count until the queued work is done. */
-       evtp->evt_arg1  = lpfc_nlp_get(ndlp);
-       if (!evtp->evt_arg1) {
-               spin_unlock_irqrestore(&phba->hbalock, iflags);
-               return;
-       }
+       evtp->evt_arg1 = ndlp;
        evtp->evt = LPFC_EVT_RECOVER_PORT;
        list_add_tail(&evtp->evt_listp, &phba->work_list);
        spin_unlock_irqrestore(&phba->hbalock, iflags);
@@ -13262,9 +13262,9 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
        /* setup wake call as IOCB callback */
        pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait;
 
-       /* setup context3 field to pass wait_queue pointer to wake function  */
+       /* setup ctx_u field to pass wait_queue pointer to wake function  */
        init_completion(&mbox_done);
-       pmboxq->context3 = &mbox_done;
+       pmboxq->ctx_u.mbox_wait = &mbox_done;
        /* now issue the command */
        retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
        if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
@@ -13272,7 +13272,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq,
                                            msecs_to_jiffies(timeout * 1000));
 
                spin_lock_irqsave(&phba->hbalock, flag);
-               pmboxq->context3 = NULL;
+               pmboxq->ctx_u.mbox_wait = NULL;
                /*
                 * if LPFC_MBX_WAKE flag is set the mailbox is completed
                 * else do not free the resources.
@@ -13813,10 +13813,10 @@ lpfc_sli_sp_intr_handler(int irq, void *dev_id)
                                        lpfc_sli_pcimem_bcopy(mbox, pmbox,
                                                        MAILBOX_CMD_SIZE);
                                        if (pmb->out_ext_byte_len &&
-                                               pmb->ctx_buf)
+                                               pmb->ext_buf)
                                                lpfc_sli_pcimem_bcopy(
                                                phba->mbox_ext,
-                                               pmb->ctx_buf,
+                                               pmb->ext_buf,
                                                pmb->out_ext_byte_len);
                                }
                                if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) {
@@ -13830,10 +13830,8 @@ lpfc_sli_sp_intr_handler(int irq, void *dev_id)
                                                pmbox->un.varWords[0], 0);
 
                                        if (!pmbox->mbxStatus) {
-                                               mp = (struct lpfc_dmabuf *)
-                                                       (pmb->ctx_buf);
-                                               ndlp = (struct lpfc_nodelist *)
-                                                       pmb->ctx_ndlp;
+                                               mp = pmb->ctx_buf;
+                                               ndlp = pmb->ctx_ndlp;
 
                                                /* Reg_LOGIN of dflt RPI was
                                                 * successful. new lets get
@@ -14340,8 +14338,8 @@ lpfc_sli4_sp_handle_mbox_event(struct lpfc_hba *phba, struct lpfc_mcqe *mcqe)
                                      mcqe_status,
                                      pmbox->un.varWords[0], 0);
                if (mcqe_status == MB_CQE_STATUS_SUCCESS) {
-                       mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
-                       ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
+                       mp = pmb->ctx_buf;
+                       ndlp = pmb->ctx_ndlp;
 
                        /* Reg_LOGIN of dflt RPI was successful. Mark the
                         * node as having an UNREG_LOGIN in progress to stop
@@ -19823,14 +19821,15 @@ lpfc_sli4_remove_rpis(struct lpfc_hba *phba)
  * lpfc_sli4_resume_rpi - Remove the rpi bitmask region
  * @ndlp: pointer to lpfc nodelist data structure.
  * @cmpl: completion call-back.
- * @arg: data to load as MBox 'caller buffer information'
+ * @iocbq: data to load as mbox ctx_u information
  *
  * This routine is invoked to remove the memory region that
  * provided rpi via a bitmask.
  **/
 int
 lpfc_sli4_resume_rpi(struct lpfc_nodelist *ndlp,
-       void (*cmpl)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *arg)
+                    void (*cmpl)(struct lpfc_hba *, LPFC_MBOXQ_t *),
+                    struct lpfc_iocbq *iocbq)
 {
        LPFC_MBOXQ_t *mboxq;
        struct lpfc_hba *phba = ndlp->phba;
@@ -19859,7 +19858,7 @@ lpfc_sli4_resume_rpi(struct lpfc_nodelist *ndlp,
        lpfc_resume_rpi(mboxq, ndlp);
        if (cmpl) {
                mboxq->mbox_cmpl = cmpl;
-               mboxq->ctx_buf = arg;
+               mboxq->ctx_u.save_iocb = iocbq;
        } else
                mboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
        mboxq->ctx_ndlp = ndlp;
@@ -20676,7 +20675,7 @@ lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data)
        if (lpfc_sli4_dump_cfg_rg23(phba, mboxq))
                goto out;
        mqe = &mboxq->u.mqe;
-       mp = (struct lpfc_dmabuf *)mboxq->ctx_buf;
+       mp = mboxq->ctx_buf;
        rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
        if (rc)
                goto out;
@@ -21035,7 +21034,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
                        (mb->u.mb.mbxCommand == MBX_REG_VPI))
                        mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
                if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
-                       act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
+                       act_mbx_ndlp = mb->ctx_ndlp;
 
                        /* This reference is local to this routine.  The
                         * reference is removed at routine exit.
@@ -21064,7 +21063,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
 
                        mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
                        if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
-                               ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
+                               ndlp = mb->ctx_ndlp;
                                /* Unregister the RPI when mailbox complete */
                                mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
                                restart_loop = 1;
@@ -21084,7 +21083,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport)
        while (!list_empty(&mbox_cmd_list)) {
                list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);
                if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
-                       ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
+                       ndlp = mb->ctx_ndlp;
                        mb->ctx_ndlp = NULL;
                        if (ndlp) {
                                spin_lock(&ndlp->lock);
index c911a39cb46b8cf00ef95f176c4c8b3503b0d80a..cf7c42ec03067992bf8d658c2575741d2c659f68 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
@@ -182,11 +182,29 @@ typedef struct lpfcMboxq {
                struct lpfc_mqe mqe;
        } u;
        struct lpfc_vport *vport; /* virtual port pointer */
-       void *ctx_ndlp;           /* an lpfc_nodelist pointer */
-       void *ctx_buf;            /* an lpfc_dmabuf pointer */
-       void *context3;           /* a generic pointer.  Code must
-                                  * accommodate the actual datatype.
-                                  */
+       struct lpfc_nodelist *ctx_ndlp; /* caller ndlp pointer */
+       struct lpfc_dmabuf *ctx_buf;    /* caller buffer information */
+       void *ext_buf;                  /* extended buffer for extended mbox
+                                        * cmds.  Not a generic pointer.
+                                        * Use for storing virtual address.
+                                        */
+
+       /* Pointers that are seldom used during mbox execution, but require
+        * a saved context.
+        */
+       union {
+               unsigned long ox_rx_id;         /* Used in els_rsp_rls_acc */
+               struct lpfc_rdp_context *rdp;   /* Used in get_rdp_info */
+               struct lpfc_lcb_context *lcb;   /* Used in set_beacon */
+               struct completion *mbox_wait;   /* Used in issue_mbox_wait */
+               struct bsg_job_data *dd_data;   /* Used in bsg_issue_mbox_cmpl
+                                                * and
+                                                * bsg_issue_mbox_ext_handle_job
+                                                */
+               struct lpfc_iocbq *save_iocb;   /* Used in defer_plogi_acc and
+                                                * lpfc_mbx_cmpl_resume_rpi
+                                                */
+       } ctx_u;
 
        void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *);
        uint8_t mbox_flag;
index 2541a8fba093fa0e0263b211fa7cd29c183d8f65..c1e9ec0243bacbf89ff8c1e938b7923feb8c16fd 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2023 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2024 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2009-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
@@ -1118,8 +1118,9 @@ void lpfc_sli4_free_rpi(struct lpfc_hba *, int);
 void lpfc_sli4_remove_rpis(struct lpfc_hba *);
 void lpfc_sli4_async_event_proc(struct lpfc_hba *);
 void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *);
-int lpfc_sli4_resume_rpi(struct lpfc_nodelist *,
-                       void (*)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *);
+int lpfc_sli4_resume_rpi(struct lpfc_nodelist *ndlp,
+                        void (*cmpl)(struct lpfc_hba *, LPFC_MBOXQ_t *),
+                        struct lpfc_iocbq *iocbq);
 void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *phba);
 void lpfc_sli4_nvme_pci_offline_aborted(struct lpfc_hba *phba,
                                        struct lpfc_io_buf *lpfc_ncmd);
index 56f5889dbaf9347cae12a7ab4a6f3f70ee2c58a7..915f2f11fb5585794d59d7947f12a269fed9cf9e 100644 (file)
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "14.4.0.0"
+#define LPFC_DRIVER_VERSION "14.4.0.1"
 #define LPFC_DRIVER_NAME               "lpfc"
 
 /* Used for SLI 2/3 */
index 0f79840b94986146478e61fa4e5ab1cd6eeaa99e..4439167a51882dedf10de9ade9c30c12bca8dfb1 100644 (file)
@@ -166,7 +166,7 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport)
                }
        }
 
-       mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+       mp = pmb->ctx_buf;
        memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));
        memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName,
               sizeof (struct lpfc_name));
@@ -674,10 +674,6 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
        lpfc_free_sysfs_attr(vport);
        lpfc_debugfs_terminate(vport);
 
-       /* Remove FC host to break driver binding. */
-       fc_remove_host(shost);
-       scsi_remove_host(shost);
-
        /* Send the DA_ID and Fabric LOGO to cleanup Nameserver entries. */
        ndlp = lpfc_findnode_did(vport, Fabric_DID);
        if (!ndlp)
@@ -721,6 +717,10 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
 
 skip_logo:
 
+       /* Remove FC host to break driver binding. */
+       fc_remove_host(shost);
+       scsi_remove_host(shost);
+
        lpfc_cleanup(vport);
 
        /* Remove scsi host now.  The nodes are cleaned up. */
index 181f16899fdc239d527d7823a16f1a8bbaaaa229..a402c4dc4645d3ac894b39469837d9524a9ba6bb 100644 (file)
@@ -534,7 +534,13 @@ static void __exit mac_scsi_remove(struct platform_device *pdev)
        scsi_host_put(instance);
 }
 
-static struct platform_driver mac_scsi_driver = {
+/*
+ * mac_scsi_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver mac_scsi_driver __refdata = {
        .remove_new = __exit_p(mac_scsi_remove),
        .driver = {
                .name   = DRV_MODULE_NAME,
index 3f2ce1eb081c4ebab3c9a5eca15648b3a1a788dc..56b76d73895ba1fb70c1e9ebb81f78efc7d8f61b 100644 (file)
@@ -3,85 +3,84 @@ config MEGARAID_NEWGEN
        bool "LSI Logic New Generation RAID Device Drivers"
        depends on PCI && HAS_IOPORT && SCSI
        help
-       LSI Logic RAID Device Drivers
+         LSI Logic RAID Device Drivers
 
 config MEGARAID_MM
        tristate "LSI Logic Management Module (New Driver)"
        depends on PCI && HAS_IOPORT && SCSI && MEGARAID_NEWGEN
        help
-       Management Module provides ioctl, sysfs support for LSI Logic
-       RAID controllers.
-       To compile this driver as a module, choose M here: the
-       module will be called megaraid_mm
+         Management Module provides ioctl, sysfs support for LSI Logic
+         RAID controllers.
+         To compile this driver as a module, choose M here: the
+         module will be called megaraid_mm
 
 
 config MEGARAID_MAILBOX
        tristate "LSI Logic MegaRAID Driver (New Driver)"
        depends on PCI && SCSI && MEGARAID_MM
        help
-       List of supported controllers
+         List of supported controllers
 
-       OEM     Product Name            VID :DID :SVID:SSID
-       ---     ------------            ---- ---- ---- ----
-       Dell PERC3/QC                   101E:1960:1028:0471
-       Dell PERC3/DC                   101E:1960:1028:0493
-       Dell PERC3/SC                   101E:1960:1028:0475
-       Dell PERC3/Di                   1028:000E:1028:0123
-       Dell PERC4/SC                   1000:1960:1028:0520
-       Dell PERC4/DC                   1000:1960:1028:0518
-       Dell PERC4/QC                   1000:0407:1028:0531
-       Dell PERC4/Di                   1028:000F:1028:014A
-       Dell PERC 4e/Si                 1028:0013:1028:016c
-       Dell PERC 4e/Di                 1028:0013:1028:016d
-       Dell PERC 4e/Di                 1028:0013:1028:016e
-       Dell PERC 4e/Di                 1028:0013:1028:016f
-       Dell PERC 4e/Di                 1028:0013:1028:0170
-       Dell PERC 4e/DC                 1000:0408:1028:0002
-       Dell PERC 4e/SC                 1000:0408:1028:0001
-       LSI MegaRAID SCSI 320-0         1000:1960:1000:A520
-       LSI MegaRAID SCSI 320-1         1000:1960:1000:0520
-       LSI MegaRAID SCSI 320-2         1000:1960:1000:0518
-       LSI MegaRAID SCSI 320-0X        1000:0407:1000:0530
-       LSI MegaRAID SCSI 320-2X        1000:0407:1000:0532
-       LSI MegaRAID SCSI 320-4X        1000:0407:1000:0531
-       LSI MegaRAID SCSI 320-1E        1000:0408:1000:0001
-       LSI MegaRAID SCSI 320-2E        1000:0408:1000:0002
-       LSI MegaRAID SATA 150-4         1000:1960:1000:4523
-       LSI MegaRAID SATA 150-6         1000:1960:1000:0523
-       LSI MegaRAID SATA 300-4X        1000:0409:1000:3004
-       LSI MegaRAID SATA 300-8X        1000:0409:1000:3008
-       INTEL RAID Controller SRCU42X   1000:0407:8086:0532
-       INTEL RAID Controller SRCS16    1000:1960:8086:0523
-       INTEL RAID Controller SRCU42E   1000:0408:8086:0002
-       INTEL RAID Controller SRCZCRX   1000:0407:8086:0530
-       INTEL RAID Controller SRCS28X   1000:0409:8086:3008
-       INTEL RAID Controller SROMBU42E 1000:0408:8086:3431
-       INTEL RAID Controller SROMBU42E 1000:0408:8086:3499
-       INTEL RAID Controller SRCU51L   1000:1960:8086:0520
-       FSC MegaRAID PCI Express ROMB   1000:0408:1734:1065
-       ACER MegaRAID ROMB-2E           1000:0408:1025:004D
-       NEC MegaRAID PCI Express ROMB   1000:0408:1033:8287
+         OEM  Product Name               VID :DID :SVID:SSID
+         ---  ------------               ---- ---- ---- ----
+         Dell PERC3/QC                   101E:1960:1028:0471
+         Dell PERC3/DC                   101E:1960:1028:0493
+         Dell PERC3/SC                   101E:1960:1028:0475
+         Dell PERC3/Di                   1028:000E:1028:0123
+         Dell PERC4/SC                   1000:1960:1028:0520
+         Dell PERC4/DC                   1000:1960:1028:0518
+         Dell PERC4/QC                   1000:0407:1028:0531
+         Dell PERC4/Di                   1028:000F:1028:014A
+         Dell PERC 4e/Si                 1028:0013:1028:016c
+         Dell PERC 4e/Di                 1028:0013:1028:016d
+         Dell PERC 4e/Di                 1028:0013:1028:016e
+         Dell PERC 4e/Di                 1028:0013:1028:016f
+         Dell PERC 4e/Di                 1028:0013:1028:0170
+         Dell PERC 4e/DC                 1000:0408:1028:0002
+         Dell PERC 4e/SC                 1000:0408:1028:0001
+         LSI MegaRAID SCSI 320-0         1000:1960:1000:A520
+         LSI MegaRAID SCSI 320-1         1000:1960:1000:0520
+         LSI MegaRAID SCSI 320-2         1000:1960:1000:0518
+         LSI MegaRAID SCSI 320-0X        1000:0407:1000:0530
+         LSI MegaRAID SCSI 320-2X        1000:0407:1000:0532
+         LSI MegaRAID SCSI 320-4X        1000:0407:1000:0531
+         LSI MegaRAID SCSI 320-1E        1000:0408:1000:0001
+         LSI MegaRAID SCSI 320-2E        1000:0408:1000:0002
+         LSI MegaRAID SATA 150-4         1000:1960:1000:4523
+         LSI MegaRAID SATA 150-6         1000:1960:1000:0523
+         LSI MegaRAID SATA 300-4X        1000:0409:1000:3004
+         LSI MegaRAID SATA 300-8X        1000:0409:1000:3008
+         INTEL RAID Controller SRCU42X   1000:0407:8086:0532
+         INTEL RAID Controller SRCS16    1000:1960:8086:0523
+         INTEL RAID Controller SRCU42E   1000:0408:8086:0002
+         INTEL RAID Controller SRCZCRX   1000:0407:8086:0530
+         INTEL RAID Controller SRCS28X   1000:0409:8086:3008
+         INTEL RAID Controller SROMBU42E 1000:0408:8086:3431
+         INTEL RAID Controller SROMBU42E 1000:0408:8086:3499
+         INTEL RAID Controller SRCU51L   1000:1960:8086:0520
+         FSC MegaRAID PCI Express ROMB   1000:0408:1734:1065
+         ACER MegaRAID ROMB-2E           1000:0408:1025:004D
+         NEC MegaRAID PCI Express ROMB   1000:0408:1033:8287
 
-       To compile this driver as a module, choose M here: the
-       module will be called megaraid_mbox
+         To compile this driver as a module, choose M here: the
+         module will be called megaraid_mbox
 
 config MEGARAID_LEGACY
        tristate "LSI Logic Legacy MegaRAID Driver"
        depends on PCI && HAS_IOPORT && SCSI
        help
-       This driver supports the LSI MegaRAID 418, 428, 438, 466, 762, 490
-       and 467 SCSI host adapters. This driver also support the all U320
-       RAID controllers
+         This driver supports the LSI MegaRAID 418, 428, 438, 466, 762, 490
+         and 467 SCSI host adapters. This driver also support the all U320
+         RAID controllers
 
-       To compile this driver as a module, choose M here: the
-       module will be called megaraid
+         To compile this driver as a module, choose M here: the
+         module will be called megaraid
 
 config MEGARAID_SAS
        tristate "LSI Logic MegaRAID SAS RAID Module"
        depends on PCI && SCSI
        select IRQ_POLL
        help
-       Module for LSI Logic's SAS based RAID controllers.
-       To compile this driver as a module, choose 'm' here.
-       Module will be called megaraid_sas
-
+         Module for LSI Logic's SAS based RAID controllers.
+         To compile this driver as a module, choose 'm' here.
+         Module will be called megaraid_sas
index 35f81af40f5118eb59862ea7b90a90c451360f55..6a19e17eb1a70c783c86f2f6288d9103988bfb2f 100644 (file)
@@ -309,6 +309,7 @@ struct mpi3_man6_gpio_entry {
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_GENERIC                     (0x00)
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_CABLE_MGMT                  (0x10)
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_ACTIVE_CABLE_OVERCURRENT    (0x20)
+#define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_ACK_REQUIRED                       (0x02)
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_TRIGGER_MASK                       (0x01)
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_TRIGGER_EDGE                       (0x00)
 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_TRIGGER_LEVEL                      (0x01)
@@ -1315,6 +1316,8 @@ struct mpi3_driver_page0 {
        __le32                             reserved18;
 };
 #define MPI3_DRIVER0_PAGEVERSION               (0x00)
+#define MPI3_DRIVER0_BSDOPTS_DEVICEEXPOSURE_DISABLE        (0x00000020)
+#define MPI3_DRIVER0_BSDOPTS_WRITECACHE_DISABLE                    (0x00000010)
 #define MPI3_DRIVER0_BSDOPTS_HEADLESS_MODE_ENABLE           (0x00000008)
 #define MPI3_DRIVER0_BSDOPTS_DIS_HII_CONFIG_UTIL            (0x00000004)
 #define MPI3_DRIVER0_BSDOPTS_REGISTRATION_MASK              (0x00000003)
index 47035b811902d15b7cd408995ae7e18b52e5901f..7df2421901357bb9a24753d0ed53dc496a06c410 100644 (file)
@@ -198,16 +198,17 @@ struct mpi3_supported_devices_data {
        struct mpi3_supported_device   supported_device[MPI3_SUPPORTED_DEVICE_MAX];
 };
 
-#ifndef MPI3_ENCRYPTED_HASH_MAX
-#define MPI3_ENCRYPTED_HASH_MAX                      (1)
+#ifndef MPI3_PUBLIC_KEY_MAX
+#define MPI3_PUBLIC_KEY_MAX                      (1)
 #endif
 struct mpi3_encrypted_hash_entry {
        u8                         hash_image_type;
        u8                         hash_algorithm;
        u8                         encryption_algorithm;
        u8                         reserved03;
-       __le32                     reserved04;
-       __le32                     encrypted_hash[MPI3_ENCRYPTED_HASH_MAX];
+       __le16                     public_key_size;
+       __le16                     signature_size;
+       __le32                     public_key[MPI3_PUBLIC_KEY_MAX];
 };
 
 #define MPI3_HASH_IMAGE_TYPE_KEY_WITH_SIGNATURE      (0x03)
@@ -228,17 +229,6 @@ struct mpi3_encrypted_hash_entry {
 #define MPI3_ENCRYPTION_ALGORITHM_RSA2048            (0x04)
 #define MPI3_ENCRYPTION_ALGORITHM_RSA4096            (0x05)
 #define MPI3_ENCRYPTION_ALGORITHM_RSA3072            (0x06)
-#ifndef MPI3_PUBLIC_KEY_MAX
-#define MPI3_PUBLIC_KEY_MAX                          (1)
-#endif
-struct mpi3_encrypted_key_with_hash_entry {
-       u8                         hash_image_type;
-       u8                         hash_algorithm;
-       u8                         encryption_algorithm;
-       u8                         reserved03;
-       __le32                     reserved04;
-       __le32                     public_key[MPI3_PUBLIC_KEY_MAX];
-};
 
 #ifndef MPI3_ENCRYPTED_HASH_ENTRY_MAX
 #define MPI3_ENCRYPTED_HASH_ENTRY_MAX               (1)
index 0cb24fc03620058cf1f760e3e451cab0422cc899..02878494987311b59e6363d63e6c2a263f1c9d2d 100644 (file)
@@ -27,7 +27,7 @@ struct mpi3_ioc_init_request {
        __le64                   sense_buffer_free_queue_address;
        __le64                   driver_information_address;
 };
-
+#define MPI3_IOCINIT_MSGFLAGS_WRITESAMEDIVERT_SUPPORTED                (0x08)
 #define MPI3_IOCINIT_MSGFLAGS_SCSIIOSTATUSREPLY_SUPPORTED      (0x04)
 #define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_MASK          (0x03)
 #define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_NOT_USED      (0x00)
@@ -101,6 +101,8 @@ struct mpi3_ioc_facts_data {
        __le16                     max_io_throttle_group;
        __le16                     io_throttle_low;
        __le16                     io_throttle_high;
+       __le32                     diag_fdl_size;
+       __le32                     diag_tty_size;
 };
 #define MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_MASK          (0x80000000)
 #define MPI3_IOCFACTS_CAPABILITY_SUPERVISOR_IOC               (0x00000000)
@@ -108,13 +110,13 @@ struct mpi3_ioc_facts_data {
 #define MPI3_IOCFACTS_CAPABILITY_INT_COALESCE_MASK            (0x00000600)
 #define MPI3_IOCFACTS_CAPABILITY_INT_COALESCE_FIXED_THRESHOLD (0x00000000)
 #define MPI3_IOCFACTS_CAPABILITY_INT_COALESCE_OUTSTANDING_IO  (0x00000200)
-#define MPI3_IOCFACTS_CAPABILITY_COMPLETE_RESET_CAPABLE       (0x00000100)
-#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_TRACE_ENABLED       (0x00000080)
-#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_FW_ENABLED          (0x00000040)
-#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_DRIVER_ENABLED      (0x00000020)
-#define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD_ENABLED     (0x00000010)
-#define MPI3_IOCFACTS_CAPABILITY_RAID_CAPABLE                 (0x00000008)
-#define MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED            (0x00000002)
+#define MPI3_IOCFACTS_CAPABILITY_COMPLETE_RESET_SUPPORTED     (0x00000100)
+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_TRACE_SUPPORTED     (0x00000080)
+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_FW_SUPPORTED        (0x00000040)
+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_DRIVER_SUPPORTED    (0x00000020)
+#define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD_SUPPORTED   (0x00000010)
+#define MPI3_IOCFACTS_CAPABILITY_RAID_SUPPORTED               (0x00000008)
+#define MPI3_IOCFACTS_CAPABILITY_MULTIPATH_SUPPORTED          (0x00000002)
 #define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_SUPPORTED      (0x00000001)
 #define MPI3_IOCFACTS_PID_TYPE_MASK                           (0xf000)
 #define MPI3_IOCFACTS_PID_TYPE_SHIFT                          (12)
@@ -159,6 +161,8 @@ struct mpi3_ioc_facts_data {
 #define MPI3_IOCFACTS_FLAGS_PERSONALITY_RAID_DDR              (0x00000002)
 #define MPI3_IOCFACTS_IO_THROTTLE_DATA_LENGTH_NOT_REQUIRED    (0x0000)
 #define MPI3_IOCFACTS_MAX_IO_THROTTLE_GROUP_NOT_REQUIRED      (0x0000)
+#define MPI3_IOCFACTS_DIAGFDLSIZE_NOT_SUPPORTED                      (0x00000000)
+#define MPI3_IOCFACTS_DIAGTTYSIZE_NOT_SUPPORTED               (0x00000000)
 struct mpi3_mgmt_passthrough_request {
        __le16                 host_tag;
        u8                     ioc_use_only02;
index 1e0a3dcaf723220c709ecf162fcc77ef4cfec342..fdc3d1968e4300a8e1e735b56116d837664e6e3b 100644 (file)
@@ -18,7 +18,7 @@ union mpi3_version_union {
 
 #define MPI3_VERSION_MAJOR                                              (3)
 #define MPI3_VERSION_MINOR                                              (0)
-#define MPI3_VERSION_UNIT                                               (28)
+#define MPI3_VERSION_UNIT                                               (31)
 #define MPI3_VERSION_DEV                                                (0)
 #define MPI3_DEVHANDLE_INVALID                                          (0xffff)
 struct mpi3_sysif_oper_queue_indexes {
index 3de1ee05c44e4cfb3663acf13c98e2e8ff44bdbd..d1c93978f28a5855dcc73501817d6d253092376f 100644 (file)
@@ -55,15 +55,15 @@ extern struct list_head mrioc_list;
 extern int prot_mask;
 extern atomic64_t event_counter;
 
-#define MPI3MR_DRIVER_VERSION  "8.5.1.0.0"
-#define MPI3MR_DRIVER_RELDATE  "5-December-2023"
+#define MPI3MR_DRIVER_VERSION  "8.8.1.0.50"
+#define MPI3MR_DRIVER_RELDATE  "5-March-2024"
 
 #define MPI3MR_DRIVER_NAME     "mpi3mr"
 #define MPI3MR_DRIVER_LICENSE  "GPL"
 #define MPI3MR_DRIVER_AUTHOR   "Broadcom Inc. <mpi3mr-linuxdrv.pdl@broadcom.com>"
 #define MPI3MR_DRIVER_DESC     "MPI3 Storage Controller Device Driver"
 
-#define MPI3MR_NAME_LENGTH     32
+#define MPI3MR_NAME_LENGTH     64
 #define IOCNAME                        "%s: "
 
 #define MPI3MR_DEFAULT_MAX_IO_SIZE     (1 * 1024 * 1024)
@@ -294,6 +294,10 @@ enum mpi3mr_reset_reason {
        MPI3MR_RESET_FROM_SAS_TRANSPORT_TIMEOUT = 30,
 };
 
+#define MPI3MR_RESET_REASON_OSTYPE_LINUX       1
+#define MPI3MR_RESET_REASON_OSTYPE_SHIFT       28
+#define MPI3MR_RESET_REASON_IOCNUM_SHIFT       20
+
 /* Queue type definitions */
 enum queue_type {
        MPI3MR_DEFAULT_QUEUE = 0,
@@ -1142,7 +1146,7 @@ struct mpi3mr_ioc {
        spinlock_t fwevt_lock;
        struct list_head fwevt_list;
 
-       char watchdog_work_q_name[20];
+       char watchdog_work_q_name[50];
        struct workqueue_struct *watchdog_work_q;
        struct delayed_work watchdog_work;
        spinlock_t watchdog_lock;
@@ -1336,7 +1340,7 @@ void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc);
 void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc);
 
 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
-                             u32 reset_reason, u8 snapdump);
+                             u16 reset_reason, u8 snapdump);
 void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
 void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc);
 
@@ -1348,7 +1352,7 @@ void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout);
 void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc);
 void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc);
 void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc);
-void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc);
+void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc);
 void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc);
 void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
 void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc);
index 0380996b5ad27aee4740f03431b4157b3526f6bf..38f63bc7ef3bf12d61a792e845eaba52071e75a4 100644 (file)
@@ -1598,26 +1598,33 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)
                rval = -EAGAIN;
                if (mrioc->bsg_cmds.state & MPI3MR_CMD_RESET)
                        goto out_unlock;
-               dprint_bsg_err(mrioc,
-                   "%s: bsg request timedout after %d seconds\n", __func__,
-                   karg->timeout);
-               if (mrioc->logging_level & MPI3_DEBUG_BSG_ERROR) {
-                       dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
+               if (((mpi_header->function != MPI3_FUNCTION_SCSI_IO) &&
+                   (mpi_header->function != MPI3_FUNCTION_NVME_ENCAPSULATED))
+                   || (mrioc->logging_level & MPI3_DEBUG_BSG_ERROR)) {
+                       ioc_info(mrioc, "%s: bsg request timedout after %d seconds\n",
+                           __func__, karg->timeout);
+                       if (!(mrioc->logging_level & MPI3_DEBUG_BSG_INFO)) {
+                               dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
                            "bsg_mpi3_req");
                        if (mpi_header->function ==
-                           MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) {
+                           MPI3_FUNCTION_MGMT_PASSTHROUGH) {
                                drv_buf_iter = &drv_bufs[0];
                                dprint_dump(drv_buf_iter->kern_buf,
                                    rmc_size, "mpi3_mgmt_req");
+                               }
                        }
                }
                if ((mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) ||
-                   (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO))
+                       (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO)) {
+                       dprint_bsg_err(mrioc, "%s: bsg request timedout after %d seconds,\n"
+                               "issuing target reset to (0x%04x)\n", __func__,
+                               karg->timeout, mpi_header->function_dependent);
                        mpi3mr_issue_tm(mrioc,
                            MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
                            mpi_header->function_dependent, 0,
                            MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT,
                            &mrioc->host_tm_cmds, &resp_code, NULL);
+               }
                if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE) &&
                    !(mrioc->bsg_cmds.state & MPI3MR_CMD_RESET))
                        mpi3mr_soft_reset_handler(mrioc,
index 528f19f782f2156d956a618eddb80e00f1faf728..c2a22e96f7b7e7058123aa185f1b3cfb55c8490b 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/io-64-nonatomic-lo-hi.h>
 
 static int
-mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u32 reset_reason);
+mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u16 reset_reason);
 static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc);
 static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
        struct mpi3_ioc_facts_data *facts_data);
@@ -1195,7 +1195,7 @@ static inline void mpi3mr_clear_reset_history(struct mpi3mr_ioc *mrioc)
 static int mpi3mr_issue_and_process_mur(struct mpi3mr_ioc *mrioc,
        u32 reset_reason)
 {
-       u32 ioc_config, timeout, ioc_status;
+       u32 ioc_config, timeout, ioc_status, scratch_pad0;
        int retval = -1;
 
        ioc_info(mrioc, "Issuing Message unit Reset(MUR)\n");
@@ -1204,7 +1204,11 @@ static int mpi3mr_issue_and_process_mur(struct mpi3mr_ioc *mrioc,
                return retval;
        }
        mpi3mr_clear_reset_history(mrioc);
-       writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]);
+       scratch_pad0 = ((MPI3MR_RESET_REASON_OSTYPE_LINUX <<
+                        MPI3MR_RESET_REASON_OSTYPE_SHIFT) |
+                       (mrioc->facts.ioc_num <<
+                        MPI3MR_RESET_REASON_IOCNUM_SHIFT) | reset_reason);
+       writel(scratch_pad0, &mrioc->sysif_regs->scratchpad[0]);
        ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
        ioc_config &= ~MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC;
        writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
@@ -1276,7 +1280,7 @@ mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc)
                            mrioc->shost->max_sectors * 512, mrioc->facts.max_data_length);
 
        if ((mrioc->sas_transport_enabled) && (mrioc->facts.ioc_capabilities &
-           MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED))
+           MPI3_IOCFACTS_CAPABILITY_MULTIPATH_SUPPORTED))
                ioc_err(mrioc,
                    "critical error: multipath capability is enabled at the\n"
                    "\tcontroller while sas transport support is enabled at the\n"
@@ -1520,11 +1524,11 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
  * Return: 0 on success, non-zero on failure.
  */
 static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
-       u32 reset_reason)
+       u16 reset_reason)
 {
        int retval = -1;
        u8 unlock_retry_count = 0;
-       u32 host_diagnostic, ioc_status, ioc_config;
+       u32 host_diagnostic, ioc_status, ioc_config, scratch_pad0;
        u32 timeout = MPI3MR_RESET_ACK_TIMEOUT * 10;
 
        if ((reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET) &&
@@ -1576,6 +1580,9 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
                    unlock_retry_count, host_diagnostic);
        } while (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_DIAG_WRITE_ENABLE));
 
+       scratch_pad0 = ((MPI3MR_RESET_REASON_OSTYPE_LINUX <<
+           MPI3MR_RESET_REASON_OSTYPE_SHIFT) | (mrioc->facts.ioc_num <<
+           MPI3MR_RESET_REASON_IOCNUM_SHIFT) | reset_reason);
        writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]);
        writel(host_diagnostic | reset_type,
            &mrioc->sysif_regs->host_diagnostic);
@@ -2581,7 +2588,7 @@ static void mpi3mr_watchdog_work(struct work_struct *work)
        unsigned long flags;
        enum mpi3mr_iocstate ioc_state;
        u32 fault, host_diagnostic, ioc_status;
-       u32 reset_reason = MPI3MR_RESET_FROM_FAULT_WATCH;
+       u16 reset_reason = MPI3MR_RESET_FROM_FAULT_WATCH;
 
        if (mrioc->reset_in_progress)
                return;
@@ -3302,6 +3309,8 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc)
 
        iocinit_req.msg_flags |=
            MPI3_IOCINIT_MSGFLAGS_SCSIIOSTATUSREPLY_SUPPORTED;
+       iocinit_req.msg_flags |=
+               MPI3_IOCINIT_MSGFLAGS_WRITESAMEDIVERT_SUPPORTED;
 
        init_completion(&mrioc->init_cmds.done);
        retval = mpi3mr_admin_request_post(mrioc, &iocinit_req,
@@ -3668,15 +3677,15 @@ static const struct {
        u32 capability;
        char *name;
 } mpi3mr_capabilities[] = {
-       { MPI3_IOCFACTS_CAPABILITY_RAID_CAPABLE, "RAID" },
-       { MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED, "MultiPath" },
+       { MPI3_IOCFACTS_CAPABILITY_RAID_SUPPORTED, "RAID" },
+       { MPI3_IOCFACTS_CAPABILITY_MULTIPATH_SUPPORTED, "MultiPath" },
 };
 
 /**
  * mpi3mr_print_ioc_info - Display controller information
  * @mrioc: Adapter instance reference
  *
- * Display controller personalit, capability, supported
+ * Display controller personality, capability, supported
  * protocols etc.
  *
  * Return: Nothing
@@ -3685,20 +3694,20 @@ static void
 mpi3mr_print_ioc_info(struct mpi3mr_ioc *mrioc)
 {
        int i = 0, bytes_written = 0;
-       char personality[16];
+       const char *personality;
        char protocol[50] = {0};
        char capabilities[100] = {0};
        struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver;
 
        switch (mrioc->facts.personality) {
        case MPI3_IOCFACTS_FLAGS_PERSONALITY_EHBA:
-               strncpy(personality, "Enhanced HBA", sizeof(personality));
+               personality = "Enhanced HBA";
                break;
        case MPI3_IOCFACTS_FLAGS_PERSONALITY_RAID_DDR:
-               strncpy(personality, "RAID", sizeof(personality));
+               personality = "RAID";
                break;
        default:
-               strncpy(personality, "Unknown", sizeof(personality));
+               personality = "Unknown";
                break;
        }
 
@@ -3951,7 +3960,7 @@ retry_init:
                    MPI3MR_HOST_IOS_KDUMP);
 
        if (!(mrioc->facts.ioc_capabilities &
-           MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED)) {
+           MPI3_IOCFACTS_CAPABILITY_MULTIPATH_SUPPORTED)) {
                mrioc->sas_transport_enabled = 1;
                mrioc->scsi_device_channel = 1;
                mrioc->shost->max_channel = 1;
@@ -4966,7 +4975,7 @@ cleanup_drv_cmd:
  * Return: 0 on success, non-zero on failure.
  */
 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
-       u32 reset_reason, u8 snapdump)
+       u16 reset_reason, u8 snapdump)
 {
        int retval = 0, i;
        unsigned long flags;
@@ -5102,6 +5111,7 @@ out:
                mrioc->device_refresh_on = 0;
                mrioc->unrecoverable = 1;
                mrioc->reset_in_progress = 0;
+               mrioc->stop_bsgs = 0;
                retval = -1;
                mpi3mr_flush_cmds_for_unrecovered_controller(mrioc);
        }
index 73c831a97d276a6f446ad22986cbc0e463fa4e9d..5f975e0db38831328e48798c265318def3d0b6bc 100644 (file)
@@ -1029,7 +1029,7 @@ mpi3mr_update_sdev(struct scsi_device *sdev, void *data)
 }
 
 /**
- * mpi3mr_rfresh_tgtdevs - Refresh target device exposure
+ * mpi3mr_refresh_tgtdevs - Refresh target device exposure
  * @mrioc: Adapter instance reference
  *
  * This is executed post controller reset to identify any
@@ -1039,7 +1039,7 @@ mpi3mr_update_sdev(struct scsi_device *sdev, void *data)
  * Return: Nothing.
  */
 
-void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc)
+void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc)
 {
        struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
        struct mpi3mr_stgt_priv_data *tgt_priv;
@@ -1047,8 +1047,8 @@ void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc)
        dprint_reset(mrioc, "refresh target devices: check for removals\n");
        list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,
            list) {
-               if ((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) &&
-                    tgtdev->is_hidden &&
+               if (((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) ||
+                    tgtdev->is_hidden) &&
                     tgtdev->host_exposed && tgtdev->starget &&
                     tgtdev->starget->hostdata) {
                        tgt_priv = tgtdev->starget->hostdata;
@@ -2010,7 +2010,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,
                        mpi3mr_refresh_sas_ports(mrioc);
                        mpi3mr_refresh_expanders(mrioc);
                }
-               mpi3mr_rfresh_tgtdevs(mrioc);
+               mpi3mr_refresh_tgtdevs(mrioc);
                ioc_info(mrioc,
                    "scan for non responding and newly added devices after soft reset completed\n");
                break;
@@ -4895,7 +4895,7 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost,
                    MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE;
                scsiio_flags |= MPI3_SCSIIO_FLAGS_DIVERT_REASON_IO_THROTTLING;
        }
-       scsiio_req->flags = cpu_to_le32(scsiio_flags);
+       scsiio_req->flags |= cpu_to_le32(scsiio_flags);
 
        if (mpi3mr_op_request_post(mrioc, op_req_q,
            scmd_priv_data->mpi3mr_scsiio_req)) {
index 1b492e9a3e55ea2650fa4185ea3fa55187816b5d..105917ea70ffa6b38526d8b6771d22603419e75d 100644 (file)
@@ -4774,7 +4774,7 @@ _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc)
        char desc[17] = {0};
        u32 iounit_pg1_flags;
 
-       strncpy(desc, ioc->manu_pg0.ChipName, 16);
+       strscpy(desc, ioc->manu_pg0.ChipName, sizeof(desc));
        ioc_info(ioc, "%s: FWVersion(%02d.%02d.%02d.%02d), ChipRevision(0x%02x)\n",
                 desc,
                 (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
index 421ea511b66421193fe1ed2778c89d578e4653c0..76f9a91771985baed3ede562c19c5df830696608 100644 (file)
@@ -458,17 +458,17 @@ _transport_expander_report_manufacture(struct MPT3SAS_ADAPTER *ioc,
                        goto out;
 
                manufacture_reply = data_out + sizeof(struct rep_manu_request);
-               strncpy(edev->vendor_id, manufacture_reply->vendor_id,
-                    SAS_EXPANDER_VENDOR_ID_LEN);
-               strncpy(edev->product_id, manufacture_reply->product_id,
-                    SAS_EXPANDER_PRODUCT_ID_LEN);
-               strncpy(edev->product_rev, manufacture_reply->product_rev,
-                    SAS_EXPANDER_PRODUCT_REV_LEN);
+               strscpy(edev->vendor_id, manufacture_reply->vendor_id,
+                       sizeof(edev->vendor_id));
+               strscpy(edev->product_id, manufacture_reply->product_id,
+                       sizeof(edev->product_id));
+               strscpy(edev->product_rev, manufacture_reply->product_rev,
+                       sizeof(edev->product_rev));
                edev->level = manufacture_reply->sas_format & 1;
                if (edev->level) {
-                       strncpy(edev->component_vendor_id,
-                           manufacture_reply->component_vendor_id,
-                            SAS_EXPANDER_COMPONENT_VENDOR_ID_LEN);
+                       strscpy(edev->component_vendor_id,
+                               manufacture_reply->component_vendor_id,
+                               sizeof(edev->component_vendor_id));
                        tmp = (u8 *)&manufacture_reply->component_id;
                        edev->component_id = tmp[0] << 8 | tmp[1];
                        edev->component_revision_id =
index 43ebb331e21673b68acee5b3824c0ae35e0b8500..c792e4486e54dfa145ea16bef44a3608f540fb47 100644 (file)
@@ -26,33 +26,18 @@ static const struct mvs_chip_info mvs_chips[] = {
 };
 
 static const struct attribute_group *mvst_host_groups[];
+static const struct attribute_group *mvst_sdev_groups[];
 
 #define SOC_SAS_NUM 2
 
 static const struct scsi_host_template mvs_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
-       .slave_configure        = sas_slave_configure,
+       LIBSAS_SHT_BASE
        .scan_finished          = mvs_scan_finished,
        .scan_start             = mvs_scan_start,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
        .can_queue              = 1,
-       .this_id                = -1,
        .sg_tablesize           = SG_ALL,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler = sas_eh_device_reset_handler,
-       .eh_target_reset_handler = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .shost_groups           = mvst_host_groups,
+       .sdev_groups            = mvst_sdev_groups,
        .track_queue_depth      = 1,
 };
 
@@ -779,6 +764,11 @@ static struct attribute *mvst_host_attrs[] = {
 
 ATTRIBUTE_GROUPS(mvst_host);
 
+static const struct attribute_group *mvst_sdev_groups[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
+
 module_init(mvs_init);
 module_exit(mvs_exit);
 
index 7b27618fd7b2e82dcb3e4ef5299c8a2fd94a4a6f..85ff95c6543a57161903dfda1abbd5d4f6a9fc11 100644 (file)
@@ -1039,3 +1039,8 @@ const struct attribute_group *pm8001_host_groups[] = {
        &pm8001_host_attr_group,
        NULL
 };
+
+const struct attribute_group *pm8001_sdev_groups[] = {
+       &sas_ata_sdev_attr_group,
+       NULL
+};
index ed6b7d954dda879a1d070586cdbe90ea2653ee87..1e63cb6cd8e327b265ae389a2df79aa4c7751e43 100644 (file)
@@ -110,30 +110,13 @@ static void pm8001_map_queues(struct Scsi_Host *shost)
  * The main structure which LLDD must register for scsi core.
  */
 static const struct scsi_host_template pm8001_sht = {
-       .module                 = THIS_MODULE,
-       .name                   = DRV_NAME,
-       .proc_name              = DRV_NAME,
-       .queuecommand           = sas_queuecommand,
-       .dma_need_drain         = ata_scsi_dma_need_drain,
-       .target_alloc           = sas_target_alloc,
-       .slave_configure        = sas_slave_configure,
+       LIBSAS_SHT_BASE
        .scan_finished          = pm8001_scan_finished,
        .scan_start             = pm8001_scan_start,
-       .change_queue_depth     = sas_change_queue_depth,
-       .bios_param             = sas_bios_param,
        .can_queue              = 1,
-       .this_id                = -1,
        .sg_tablesize           = PM8001_MAX_DMA_SG,
-       .max_sectors            = SCSI_DEFAULT_MAX_SECTORS,
-       .eh_device_reset_handler = sas_eh_device_reset_handler,
-       .eh_target_reset_handler = sas_eh_target_reset_handler,
-       .slave_alloc            = sas_slave_alloc,
-       .target_destroy         = sas_target_destroy,
-       .ioctl                  = sas_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl           = sas_ioctl,
-#endif
        .shost_groups           = pm8001_host_groups,
+       .sdev_groups            = pm8001_sdev_groups,
        .track_queue_depth      = 1,
        .cmd_per_lun            = 32,
        .map_queues             = pm8001_map_queues,
index 3ccb7371902f84cb573ef2b95e69380c8505d0de..ced6721380a85345a74a87ebd2facdaa513f8768 100644 (file)
@@ -717,6 +717,7 @@ int pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha);
 void pm8001_free_dev(struct pm8001_device *pm8001_dev);
 /* ctl shared API */
 extern const struct attribute_group *pm8001_host_groups[];
+extern const struct attribute_group *pm8001_sdev_groups[];
 
 #define PM8001_INVALID_TAG     ((u32)-1)
 
index e8bcc3a88732a1009d08b2d731289a38736c64ec..0614b7e366b77643f4bb9d879e819b62405e169e 100644 (file)
@@ -61,7 +61,9 @@ static atomic_t pmcraid_adapter_count = ATOMIC_INIT(0);
  * pmcraid_minor - minor number(s) to use
  */
 static unsigned int pmcraid_major;
-static struct class *pmcraid_class;
+static const struct class pmcraid_class = {
+       .name = PMCRAID_DEVFILE,
+};
 static DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
 
 /*
@@ -4723,7 +4725,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
        if (error)
                pmcraid_release_minor(minor);
        else
-               device_create(pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
+               device_create(&pmcraid_class, NULL, MKDEV(pmcraid_major, minor),
                              NULL, "%s%u", PMCRAID_DEVFILE, minor);
        return error;
 }
@@ -4739,7 +4741,7 @@ static int pmcraid_setup_chrdev(struct pmcraid_instance *pinstance)
 static void pmcraid_release_chrdev(struct pmcraid_instance *pinstance)
 {
        pmcraid_release_minor(MINOR(pinstance->cdev.dev));
-       device_destroy(pmcraid_class,
+       device_destroy(&pmcraid_class,
                       MKDEV(pmcraid_major, MINOR(pinstance->cdev.dev)));
        cdev_del(&pinstance->cdev);
 }
@@ -5390,10 +5392,10 @@ static int __init pmcraid_init(void)
        }
 
        pmcraid_major = MAJOR(dev);
-       pmcraid_class = class_create(PMCRAID_DEVFILE);
 
-       if (IS_ERR(pmcraid_class)) {
-               error = PTR_ERR(pmcraid_class);
+       error = class_register(&pmcraid_class);
+
+       if (error) {
                pmcraid_err("failed to register with sysfs, error = %x\n",
                            error);
                goto out_unreg_chrdev;
@@ -5402,7 +5404,7 @@ static int __init pmcraid_init(void)
        error = pmcraid_netlink_init();
 
        if (error) {
-               class_destroy(pmcraid_class);
+               class_unregister(&pmcraid_class);
                goto out_unreg_chrdev;
        }
 
@@ -5413,7 +5415,7 @@ static int __init pmcraid_init(void)
 
        pmcraid_err("failed to register pmcraid driver, error = %x\n",
                     error);
-       class_destroy(pmcraid_class);
+       class_unregister(&pmcraid_class);
        pmcraid_netlink_release();
 
 out_unreg_chrdev:
@@ -5432,7 +5434,7 @@ static void __exit pmcraid_exit(void)
        unregister_chrdev_region(MKDEV(pmcraid_major, 0),
                                 PMCRAID_MAX_ADAPTERS);
        pci_unregister_driver(&pmcraid_driver);
-       class_destroy(pmcraid_class);
+       class_unregister(&pmcraid_class);
 }
 
 module_init(pmcraid_init);
index a58353b7b4e8bad1430581b09cb0c08a8b85125c..fd12439cbaab6bf6df58d2bc76e1b282b0392ad0 100644 (file)
@@ -3468,7 +3468,7 @@ retry_probe:
        slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
        slowpath_params.drv_rev = QEDF_DRIVER_REV_VER;
        slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER;
-       strncpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
+       strscpy(slowpath_params.name, "qedf", sizeof(slowpath_params.name));
        rc = qed_ops->common->slowpath_start(qedf->cdev, &slowpath_params);
        if (rc) {
                QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n");
index a584708d3056f5ec9589d816440f5ee06a347676..a8b4314bfd6e210dbe8a40199ef35fe8d01fdef6 100644 (file)
@@ -7,29 +7,29 @@ config SCSI_QLA_FC
        select FW_LOADER
        select BTREE
        help
-       This qla2xxx driver supports all QLogic Fibre Channel
-       PCI and PCIe host adapters.
+         This qla2xxx driver supports all QLogic Fibre Channel
+         PCI and PCIe host adapters.
 
-       By default, firmware for the ISP parts will be loaded
-       via the Firmware Loader interface.
+         By default, firmware for the ISP parts will be loaded
+         via the Firmware Loader interface.
 
-       ISP               Firmware Filename
-       ----------        -----------------
-       21xx              ql2100_fw.bin
-       22xx              ql2200_fw.bin
-       2300, 2312, 6312  ql2300_fw.bin
-       2322, 6322        ql2322_fw.bin
-       24xx, 54xx        ql2400_fw.bin
-       25xx              ql2500_fw.bin
+         ISP               Firmware Filename
+         ----------        -----------------
+         21xx              ql2100_fw.bin
+         22xx              ql2200_fw.bin
+         2300, 2312, 6312  ql2300_fw.bin
+         2322, 6322        ql2322_fw.bin
+         24xx, 54xx        ql2400_fw.bin
+         25xx              ql2500_fw.bin
 
-       Upon request, the driver caches the firmware image until
-       the driver is unloaded.
+         Upon request, the driver caches the firmware image until
+         the driver is unloaded.
 
-       Firmware images can be retrieved from:
+         Firmware images can be retrieved from:
 
-               http://ldriver.qlogic.com/firmware/
+               http://ldriver.qlogic.com/firmware/
 
-       They are also included in the linux-firmware tree as well.
+         They are also included in the linux-firmware tree as well.
 
 config TCM_QLA2XXX
        tristate "TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs"
@@ -38,13 +38,15 @@ config TCM_QLA2XXX
        select BTREE
        default n
        help
-       Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs
+         Say Y here to enable the TCM_QLA2XXX fabric module for QLogic 24xx+
+         series target mode HBAs.
 
 if TCM_QLA2XXX
 config TCM_QLA2XXX_DEBUG
        bool "TCM_QLA2XXX fabric module DEBUG mode for QLogic 24xx+ series target mode HBAs"
        default n
        help
-       Say Y here to enable the TCM_QLA2XXX fabric module DEBUG for QLogic 24xx+ series target mode HBAs
-       This will include code to enable the SCSI command jammer
+         Say Y here to enable the TCM_QLA2XXX fabric module DEBUG for
+         QLogic 24xx+ series target mode HBAs.
+         This will include code to enable the SCSI command jammer.
 endif
index 44449c70a375f34feff9c97df33044831bb7bbc8..76eeba435fd0469f4f32cfbbda1720fad2a44255 100644 (file)
@@ -2741,7 +2741,13 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
                return;
 
        if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
-               qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
+               /* Will wait for wind down of adapter */
+               ql_dbg(ql_dbg_aer, fcport->vha, 0x900c,
+                   "%s pci offline detected (id %06x)\n", __func__,
+                   fcport->d_id.b24);
+               qla_pci_set_eeh_busy(fcport->vha);
+               qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24,
+                   0, WAIT_TARGET);
                return;
        }
 }
@@ -2763,7 +2769,11 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
        vha = fcport->vha;
 
        if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
-               qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
+               /* Will wait for wind down of adapter */
+               ql_dbg(ql_dbg_aer, fcport->vha, 0x900b,
+                   "%s pci offline detected (id %06x)\n", __func__,
+                   fcport->d_id.b24);
+               qla_pci_set_eeh_busy(vha);
                qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24,
                        0, WAIT_TARGET);
                return;
index deb642607deb6f6d3c0eead3e7688e9381af2e12..2f49baf131e26f3453f580bf4ceeb4c14d9321f7 100644 (file)
@@ -82,7 +82,7 @@ typedef union {
 #include "qla_nvme.h"
 #define QLA2XXX_DRIVER_NAME    "qla2xxx"
 #define QLA2XXX_APIDEV         "ql2xapidev"
-#define QLA2XXX_MANUFACTURER   "Marvell Semiconductor, Inc."
+#define QLA2XXX_MANUFACTURER   "Marvell"
 
 /*
  * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
index 09cb9413670a5e4034ea13792d8806fdab6cbc73..7309310d2ab94368fcda24f5fc9812aeaafa9397 100644 (file)
@@ -44,7 +44,7 @@ extern int qla2x00_fabric_login(scsi_qla_host_t *, fc_port_t *, uint16_t *);
 extern int qla2x00_local_device_login(scsi_qla_host_t *, fc_port_t *);
 
 extern int qla24xx_els_dcmd_iocb(scsi_qla_host_t *, int, port_id_t);
-extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *, bool);
+extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *);
 extern void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha,
                                   struct els_plogi *els_plogi);
 
index a314cfc5b263f223e4548c4647e1d645208db69f..8377624d76c98ebab3f2127ab0d0d15a19097f62 100644 (file)
@@ -1193,8 +1193,12 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
        return rval;
 
 done_free_sp:
-       /* ref: INIT */
-       kref_put(&sp->cmd_kref, qla2x00_sp_release);
+       /*
+        * use qla24xx_async_gnl_sp_done to purge all pending gnl request.
+        * kref_put is call behind the scene.
+        */
+       sp->u.iocb_cmd.u.mbx.in_mb[0] = MBS_COMMAND_ERROR;
+       qla24xx_async_gnl_sp_done(sp, QLA_COMMAND_ERROR);
        fcport->flags &= ~(FCF_ASYNC_SENT);
 done:
        fcport->flags &= ~(FCF_ASYNC_ACTIVE);
@@ -2665,6 +2669,40 @@ exit:
        return rval;
 }
 
+static void qla_enable_fce_trace(scsi_qla_host_t *vha)
+{
+       int rval;
+       struct qla_hw_data *ha = vha->hw;
+
+       if (ha->fce) {
+               ha->flags.fce_enabled = 1;
+               memset(ha->fce, 0, fce_calc_size(ha->fce_bufs));
+               rval = qla2x00_enable_fce_trace(vha,
+                   ha->fce_dma, ha->fce_bufs, ha->fce_mb, &ha->fce_bufs);
+
+               if (rval) {
+                       ql_log(ql_log_warn, vha, 0x8033,
+                           "Unable to reinitialize FCE (%d).\n", rval);
+                       ha->flags.fce_enabled = 0;
+               }
+       }
+}
+
+static void qla_enable_eft_trace(scsi_qla_host_t *vha)
+{
+       int rval;
+       struct qla_hw_data *ha = vha->hw;
+
+       if (ha->eft) {
+               memset(ha->eft, 0, EFT_SIZE);
+               rval = qla2x00_enable_eft_trace(vha, ha->eft_dma, EFT_NUM_BUFFERS);
+
+               if (rval) {
+                       ql_log(ql_log_warn, vha, 0x8034,
+                           "Unable to reinitialize EFT (%d).\n", rval);
+               }
+       }
+}
 /*
 * qla2x00_initialize_adapter
 *      Initialize board.
@@ -3668,9 +3706,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha)
 }
 
 static void
-qla2x00_init_fce_trace(scsi_qla_host_t *vha)
+qla2x00_alloc_fce_trace(scsi_qla_host_t *vha)
 {
-       int rval;
        dma_addr_t tc_dma;
        void *tc;
        struct qla_hw_data *ha = vha->hw;
@@ -3699,27 +3736,17 @@ qla2x00_init_fce_trace(scsi_qla_host_t *vha)
                return;
        }
 
-       rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS,
-                                       ha->fce_mb, &ha->fce_bufs);
-       if (rval) {
-               ql_log(ql_log_warn, vha, 0x00bf,
-                      "Unable to initialize FCE (%d).\n", rval);
-               dma_free_coherent(&ha->pdev->dev, FCE_SIZE, tc, tc_dma);
-               return;
-       }
-
        ql_dbg(ql_dbg_init, vha, 0x00c0,
               "Allocated (%d KB) for FCE...\n", FCE_SIZE / 1024);
 
-       ha->flags.fce_enabled = 1;
        ha->fce_dma = tc_dma;
        ha->fce = tc;
+       ha->fce_bufs = FCE_NUM_BUFFERS;
 }
 
 static void
-qla2x00_init_eft_trace(scsi_qla_host_t *vha)
+qla2x00_alloc_eft_trace(scsi_qla_host_t *vha)
 {
-       int rval;
        dma_addr_t tc_dma;
        void *tc;
        struct qla_hw_data *ha = vha->hw;
@@ -3744,14 +3771,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *vha)
                return;
        }
 
-       rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS);
-       if (rval) {
-               ql_log(ql_log_warn, vha, 0x00c2,
-                      "Unable to initialize EFT (%d).\n", rval);
-               dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma);
-               return;
-       }
-
        ql_dbg(ql_dbg_init, vha, 0x00c3,
               "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024);
 
@@ -3759,13 +3778,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *vha)
        ha->eft = tc;
 }
 
-static void
-qla2x00_alloc_offload_mem(scsi_qla_host_t *vha)
-{
-       qla2x00_init_fce_trace(vha);
-       qla2x00_init_eft_trace(vha);
-}
-
 void
 qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
 {
@@ -3820,10 +3832,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
                if (ha->tgt.atio_ring)
                        mq_size += ha->tgt.atio_q_length * sizeof(request_t);
 
-               qla2x00_init_fce_trace(vha);
+               qla2x00_alloc_fce_trace(vha);
                if (ha->fce)
                        fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE;
-               qla2x00_init_eft_trace(vha);
+               qla2x00_alloc_eft_trace(vha);
                if (ha->eft)
                        eft_size = EFT_SIZE;
        }
@@ -4253,7 +4265,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
        unsigned long flags;
-       uint16_t fw_major_version;
        int done_once = 0;
 
        if (IS_P3P_TYPE(ha)) {
@@ -4320,7 +4331,6 @@ execute_fw_with_lr:
                                        goto failed;
 
 enable_82xx_npiv:
-                               fw_major_version = ha->fw_major_version;
                                if (IS_P3P_TYPE(ha))
                                        qla82xx_check_md_needed(vha);
                                else
@@ -4349,12 +4359,11 @@ enable_82xx_npiv:
                                if (rval != QLA_SUCCESS)
                                        goto failed;
 
-                               if (!fw_major_version && !(IS_P3P_TYPE(ha)))
-                                       qla2x00_alloc_offload_mem(vha);
-
                                if (ql2xallocfwdump && !(IS_P3P_TYPE(ha)))
                                        qla2x00_alloc_fw_dump(vha);
 
+                               qla_enable_fce_trace(vha);
+                               qla_enable_eft_trace(vha);
                        } else {
                                goto failed;
                        }
@@ -7487,12 +7496,12 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
 int
 qla2x00_abort_isp(scsi_qla_host_t *vha)
 {
-       int rval;
        uint8_t        status = 0;
        struct qla_hw_data *ha = vha->hw;
        struct scsi_qla_host *vp, *tvp;
        struct req_que *req = ha->req_q_map[0];
        unsigned long flags;
+       fc_port_t *fcport;
 
        if (vha->flags.online) {
                qla2x00_abort_isp_cleanup(vha);
@@ -7561,6 +7570,15 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                               "ISP Abort - ISP reg disconnect post nvmram config, exiting.\n");
                        return status;
                }
+
+               /* User may have updated [fcp|nvme] prefer in flash */
+               list_for_each_entry(fcport, &vha->vp_fcports, list) {
+                       if (NVME_PRIORITY(ha, fcport))
+                               fcport->do_prli_nvme = 1;
+                       else
+                               fcport->do_prli_nvme = 0;
+               }
+
                if (!qla2x00_restart_isp(vha)) {
                        clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
 
@@ -7581,31 +7599,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
 
                        if (IS_QLA81XX(ha) || IS_QLA8031(ha))
                                qla2x00_get_fw_version(vha);
-                       if (ha->fce) {
-                               ha->flags.fce_enabled = 1;
-                               memset(ha->fce, 0,
-                                   fce_calc_size(ha->fce_bufs));
-                               rval = qla2x00_enable_fce_trace(vha,
-                                   ha->fce_dma, ha->fce_bufs, ha->fce_mb,
-                                   &ha->fce_bufs);
-                               if (rval) {
-                                       ql_log(ql_log_warn, vha, 0x8033,
-                                           "Unable to reinitialize FCE "
-                                           "(%d).\n", rval);
-                                       ha->flags.fce_enabled = 0;
-                               }
-                       }
 
-                       if (ha->eft) {
-                               memset(ha->eft, 0, EFT_SIZE);
-                               rval = qla2x00_enable_eft_trace(vha,
-                                   ha->eft_dma, EFT_NUM_BUFFERS);
-                               if (rval) {
-                                       ql_log(ql_log_warn, vha, 0x8034,
-                                           "Unable to reinitialize EFT "
-                                           "(%d).\n", rval);
-                               }
-                       }
                } else {        /* failed the ISP abort */
                        vha->flags.online = 1;
                        if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) {
@@ -7655,6 +7649,14 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
                                atomic_inc(&vp->vref_count);
                                spin_unlock_irqrestore(&ha->vport_slock, flags);
 
+                               /* User may have updated [fcp|nvme] prefer in flash */
+                               list_for_each_entry(fcport, &vp->vp_fcports, list) {
+                                       if (NVME_PRIORITY(ha, fcport))
+                                               fcport->do_prli_nvme = 1;
+                                       else
+                                               fcport->do_prli_nvme = 0;
+                               }
+
                                qla2x00_vp_abort_isp(vp);
 
                                spin_lock_irqsave(&ha->vport_slock, flags);
index df90169f82440a3f665164e55153d9b560231b4b..0b41e8a0660262106e67e781d9327d29d6661b40 100644 (file)
@@ -2587,6 +2587,33 @@ void
 qla2x00_sp_release(struct kref *kref)
 {
        struct srb *sp = container_of(kref, struct srb, cmd_kref);
+       struct scsi_qla_host *vha = sp->vha;
+
+       switch (sp->type) {
+       case SRB_CT_PTHRU_CMD:
+               /* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */
+               if (sp->u.iocb_cmd.u.ctarg.req &&
+                       (!sp->fcport ||
+                        sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) {
+                       dma_free_coherent(&vha->hw->pdev->dev,
+                           sp->u.iocb_cmd.u.ctarg.req_allocated_size,
+                           sp->u.iocb_cmd.u.ctarg.req,
+                           sp->u.iocb_cmd.u.ctarg.req_dma);
+                       sp->u.iocb_cmd.u.ctarg.req = NULL;
+               }
+               if (sp->u.iocb_cmd.u.ctarg.rsp &&
+                       (!sp->fcport ||
+                        sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) {
+                       dma_free_coherent(&vha->hw->pdev->dev,
+                           sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
+                           sp->u.iocb_cmd.u.ctarg.rsp,
+                           sp->u.iocb_cmd.u.ctarg.rsp_dma);
+                       sp->u.iocb_cmd.u.ctarg.rsp = NULL;
+               }
+               break;
+       default:
+               break;
+       }
 
        sp->free(sp);
 }
@@ -2610,7 +2637,8 @@ static void qla2x00_els_dcmd_sp_free(srb_t *sp)
 {
        struct srb_iocb *elsio = &sp->u.iocb_cmd;
 
-       kfree(sp->fcport);
+       if (sp->fcport)
+               qla2x00_free_fcport(sp->fcport);
 
        if (elsio->u.els_logo.els_logo_pyld)
                dma_free_coherent(&sp->vha->hw->pdev->dev, DMA_POOL_SIZE,
@@ -2692,7 +2720,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
         */
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
        if (!sp) {
-               kfree(fcport);
+               qla2x00_free_fcport(fcport);
                ql_log(ql_log_info, vha, 0x70e6,
                 "SRB allocation failed\n");
                return -ENOMEM;
@@ -2723,6 +2751,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
        if (!elsio->u.els_logo.els_logo_pyld) {
                /* ref: INIT */
                kref_put(&sp->cmd_kref, qla2x00_sp_release);
+               qla2x00_free_fcport(fcport);
                return QLA_FUNCTION_FAILED;
        }
 
@@ -2747,6 +2776,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
        if (rval != QLA_SUCCESS) {
                /* ref: INIT */
                kref_put(&sp->cmd_kref, qla2x00_sp_release);
+               qla2x00_free_fcport(fcport);
                return QLA_FUNCTION_FAILED;
        }
 
@@ -3012,7 +3042,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)
 
 int
 qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
-    fc_port_t *fcport, bool wait)
+                       fc_port_t *fcport)
 {
        srb_t *sp;
        struct srb_iocb *elsio = NULL;
@@ -3027,8 +3057,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
        if (!sp) {
                ql_log(ql_log_info, vha, 0x70e6,
                 "SRB allocation failed\n");
-               fcport->flags &= ~FCF_ASYNC_ACTIVE;
-               return -ENOMEM;
+               goto done;
        }
 
        fcport->flags |= FCF_ASYNC_SENT;
@@ -3037,9 +3066,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
        ql_dbg(ql_dbg_io, vha, 0x3073,
               "%s Enter: PLOGI portid=%06x\n", __func__, fcport->d_id.b24);
 
-       if (wait)
-               sp->flags = SRB_WAKEUP_ON_COMP;
-
        sp->type = SRB_ELS_DCMD;
        sp->name = "ELS_DCMD";
        sp->fcport = fcport;
@@ -3055,7 +3081,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
 
        if (!elsio->u.els_plogi.els_plogi_pyld) {
                rval = QLA_FUNCTION_FAILED;
-               goto out;
+               goto done_free_sp;
        }
 
        resp_ptr = elsio->u.els_plogi.els_resp_pyld =
@@ -3064,7 +3090,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
 
        if (!elsio->u.els_plogi.els_resp_pyld) {
                rval = QLA_FUNCTION_FAILED;
-               goto out;
+               goto done_free_sp;
        }
 
        ql_dbg(ql_dbg_io, vha, 0x3073, "PLOGI %p %p\n", ptr, resp_ptr);
@@ -3080,7 +3106,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
 
        if (els_opcode == ELS_DCMD_PLOGI && DBELL_ACTIVE(vha)) {
                struct fc_els_flogi *p = ptr;
-
                p->fl_csp.sp_features |= cpu_to_be16(FC_SP_FT_SEC);
        }
 
@@ -3089,10 +3114,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
            (uint8_t *)elsio->u.els_plogi.els_plogi_pyld,
            sizeof(*elsio->u.els_plogi.els_plogi_pyld));
 
-       init_completion(&elsio->u.els_plogi.comp);
        rval = qla2x00_start_sp(sp);
        if (rval != QLA_SUCCESS) {
-               rval = QLA_FUNCTION_FAILED;
+               fcport->flags |= FCF_LOGIN_NEEDED;
+               set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+               goto done_free_sp;
        } else {
                ql_dbg(ql_dbg_disc, vha, 0x3074,
                    "%s PLOGI sent, hdl=%x, loopid=%x, to port_id %06x from port_id %06x\n",
@@ -3100,21 +3126,15 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
                    fcport->d_id.b24, vha->d_id.b24);
        }
 
-       if (wait) {
-               wait_for_completion(&elsio->u.els_plogi.comp);
-
-               if (elsio->u.els_plogi.comp_status != CS_COMPLETE)
-                       rval = QLA_FUNCTION_FAILED;
-       } else {
-               goto done;
-       }
+       return rval;
 
-out:
-       fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
+done_free_sp:
        qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi);
        /* ref: INIT */
        kref_put(&sp->cmd_kref, qla2x00_sp_release);
 done:
+       fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
+       qla2x00_set_fcport_disc_state(fcport, DSC_DELETED);
        return rval;
 }
 
@@ -3918,7 +3938,7 @@ qla2x00_start_sp(srb_t *sp)
                return -EAGAIN;
        }
 
-       pkt = __qla2x00_alloc_iocbs(sp->qpair, sp);
+       pkt = qla2x00_alloc_iocbs_ready(sp->qpair, sp);
        if (!pkt) {
                rval = -EAGAIN;
                ql_log(ql_log_warn, vha, 0x700c,
index 21ec32b4fb2809321ee6498255e63662cc094fb0..0cd6f3e1488249b4a744ed08b81aeb84b888203f 100644 (file)
@@ -194,7 +194,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
        if (ha->flags.purge_mbox || chip_reset != ha->chip_reset ||
            ha->flags.eeh_busy) {
                ql_log(ql_log_warn, vha, 0xd035,
-                      "Error detected: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n",
+                      "Purge mbox: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n",
                       ha->flags.purge_mbox, ha->flags.eeh_busy, mcp->mb[0]);
                rval = QLA_ABORTED;
                goto premature_exit;
index dd674378f2f392216334f7adb90129f2753e8c2a..6a1900e96a5a5fec529208cdbba5c4f3ee628a84 100644 (file)
@@ -4602,6 +4602,7 @@ fail_free_init_cb:
        ha->init_cb_dma = 0;
 fail_free_vp_map:
        kfree(ha->vp_map);
+       ha->vp_map = NULL;
 fail:
        ql_log(ql_log_fatal, NULL, 0x0030,
            "Memory allocation failure.\n");
@@ -5583,7 +5584,7 @@ qla2x00_do_work(struct scsi_qla_host *vha)
                        break;
                case QLA_EVT_ELS_PLOGI:
                        qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI,
-                           e->u.fcport.fcport, false);
+                           e->u.fcport.fcport);
                        break;
                case QLA_EVT_SA_REPLACE:
                        rc = qla24xx_issue_sa_replace_iocb(vha, e);
@@ -8155,9 +8156,6 @@ MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
 
 static struct pci_driver qla2xxx_pci_driver = {
        .name           = QLA2XXX_DRIVER_NAME,
-       .driver         = {
-               .owner          = THIS_MODULE,
-       },
        .id_table       = qla2xxx_pci_tbl,
        .probe          = qla2x00_probe_one,
        .remove         = qla2x00_remove_one,
index 2ef2dbac0db2739d82c590f4afd987e893230931..d7551b1443e4a7538df5d45beb003a11b0c29b9f 100644 (file)
@@ -1062,6 +1062,16 @@ void qlt_free_session_done(struct work_struct *work)
                    "%s: sess %p logout completed\n", __func__, sess);
        }
 
+       /* check for any straggling io left behind */
+       if (!(sess->flags & FCF_FCP2_DEVICE) &&
+           qla2x00_eh_wait_for_pending_commands(sess->vha, sess->d_id.b24, 0, WAIT_TARGET)) {
+               ql_log(ql_log_warn, vha, 0x3027,
+                   "IO not return. Resetting.\n");
+               set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+               qla2xxx_wake_dpc(vha);
+               qla2x00_wait_for_chip_reset(vha);
+       }
+
        if (sess->logo_ack_needed) {
                sess->logo_ack_needed = 0;
                qla24xx_async_notify_ack(vha, sess,
index d903563e969eb32a0a079f3ea8c3504678afc65a..7627fd807bc3ede71b8bdbc707bed0a476d4c082 100644 (file)
@@ -6,9 +6,9 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION      "10.02.09.100-k"
+#define QLA2XXX_VERSION      "10.02.09.200-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   2
 #define QLA_DRIVER_PATCH_VER   9
-#define QLA_DRIVER_BETA_VER    100
+#define QLA_DRIVER_BETA_VER    200
index 249f1d7021d49ea0a9f64230318b1567a845d899..75125d2021f5f635ebabe783a3b4a8a9c7e63040 100644 (file)
@@ -1641,6 +1641,7 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
        struct ql4_chap_table *chap_table;
        uint32_t chap_size = 0;
        dma_addr_t chap_dma;
+       ssize_t secret_len;
 
        chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
        if (chap_table == NULL) {
@@ -1652,9 +1653,13 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
                chap_table->flags |= BIT_6; /* peer */
        else
                chap_table->flags |= BIT_7; /* local */
-       chap_table->secret_len = strlen(password);
-       strncpy(chap_table->secret, password, MAX_CHAP_SECRET_LEN - 1);
-       strncpy(chap_table->name, username, MAX_CHAP_NAME_LEN - 1);
+
+       secret_len = strscpy(chap_table->secret, password,
+                            sizeof(chap_table->secret));
+       if (secret_len < MIN_CHAP_SECRET_LEN)
+               goto cleanup_chap_table;
+       chap_table->secret_len = (uint8_t)secret_len;
+       strscpy(chap_table->name, username, sizeof(chap_table->name));
        chap_table->cookie = cpu_to_le16(CHAP_VALID_COOKIE);
 
        if (is_qla40XX(ha)) {
@@ -1679,6 +1684,8 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
                memcpy((struct ql4_chap_table *)ha->chap_list + idx,
                       chap_table, sizeof(struct ql4_chap_table));
        }
+
+cleanup_chap_table:
        dma_pool_free(ha->chap_dma_pool, chap_table, chap_dma);
        if (rval != QLA_SUCCESS)
                ret =  -EINVAL;
@@ -2281,8 +2288,8 @@ int qla4_8xxx_set_param(struct scsi_qla_host *ha, int param)
        mbox_cmd[0] = MBOX_CMD_SET_PARAM;
        if (param == SET_DRVR_VERSION) {
                mbox_cmd[1] = SET_DRVR_VERSION;
-               strncpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION,
-                       MAX_DRVR_VER_LEN - 1);
+               strscpy((char *)&mbox_cmd[2], QLA4XXX_DRIVER_VERSION,
+                       MAX_DRVR_VER_LEN);
        } else {
                ql4_printk(KERN_ERR, ha, "%s: invalid parameter 0x%x\n",
                           __func__, param);
index 675332e49a7b063c54c3d265e5f56006f59ffa8a..17cccd14765f8d78e806e5b420bf37b47cea8c73 100644 (file)
@@ -799,10 +799,10 @@ static int qla4xxx_get_chap_list(struct Scsi_Host *shost, uint16_t chap_tbl_idx,
 
                chap_rec->chap_tbl_idx = i;
                strscpy(chap_rec->username, chap_table->name,
-                       ISCSI_CHAP_AUTH_NAME_MAX_LEN);
-               strscpy(chap_rec->password, chap_table->secret,
-                       QL4_CHAP_MAX_SECRET_LEN);
-               chap_rec->password_length = chap_table->secret_len;
+                       sizeof(chap_rec->username));
+               chap_rec->password_length = strscpy(chap_rec->password,
+                                                   chap_table->secret,
+                                                   sizeof(chap_rec->password));
 
                if (chap_table->flags & BIT_7) /* local */
                        chap_rec->chap_type = CHAP_TYPE_OUT;
@@ -6291,8 +6291,8 @@ static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry,
 
        tddb->tpgt = sess->tpgt;
        tddb->port = conn->persistent_port;
-       strscpy(tddb->iscsi_name, sess->targetname, ISCSI_NAME_SIZE);
-       strscpy(tddb->ip_addr, conn->persistent_address, DDB_IPADDR_LEN);
+       strscpy(tddb->iscsi_name, sess->targetname, sizeof(tddb->iscsi_name));
+       strscpy(tddb->ip_addr, conn->persistent_address, sizeof(tddb->ip_addr));
 }
 
 static void qla4xxx_convert_param_ddb(struct dev_db_entry *fw_ddb_entry,
@@ -7792,7 +7792,7 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
        }
 
        strscpy(flash_tddb->iscsi_name, fnode_sess->targetname,
-               ISCSI_NAME_SIZE);
+               sizeof(flash_tddb->iscsi_name));
 
        if (!strncmp(fnode_sess->portal_type, PORTAL_TYPE_IPV6, 4))
                sprintf(flash_tddb->ip_addr, "%pI6", fnode_conn->ipaddress);
index ba7237e838633c95528c742db4efc94d209ecc0f..a7071e71389e0533ab367910b74b75ba1b452f58 100644 (file)
@@ -293,14 +293,16 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
        size_t from_length;
 
        from_length = strlen(from);
-       /* This zero-pads the destination */
-       strncpy(to, from, to_length);
-       if (from_length < to_length && !compatible) {
-               /*
-                * space pad the string if it is short.
-                */
-               memset(&to[from_length], ' ', to_length - from_length);
-       }
+
+       /*
+        * null pad and null terminate if compatible
+        * otherwise space pad
+        */
+       if (compatible)
+               strscpy_pad(to, from, to_length);
+       else
+               memcpy_and_pad(to, to_length, from, from_length, ' ');
+
        if (from_length > to_length)
                 printk(KERN_WARNING "%s: %s string '%s' is too long\n",
                        __func__, name, from);
index 775df00021e4d5591044d8e3272bb435a11cfa6a..b5aae4e8ae33f7316007dcde580d80db792bba58 100644 (file)
@@ -1609,13 +1609,14 @@ restart:
 }
 EXPORT_SYMBOL(scsi_remove_target);
 
-int scsi_register_driver(struct device_driver *drv)
+int __scsi_register_driver(struct device_driver *drv, struct module *owner)
 {
        drv->bus = &scsi_bus_type;
+       drv->owner = owner;
 
        return driver_register(drv);
 }
-EXPORT_SYMBOL(scsi_register_driver);
+EXPORT_SYMBOL(__scsi_register_driver);
 
 int scsi_register_interface(struct class_interface *intf)
 {
index ccff8f2e2e75bd4b0286f04c96cb41d588205941..0b447f1bc1a97a9ce7aaddd9ec18ca48cb8d2dcb 100644 (file)
@@ -4185,7 +4185,6 @@ static const struct dev_pm_ops sd_pm_ops = {
 static struct scsi_driver sd_template = {
        .gendrv = {
                .name           = "sd",
-               .owner          = THIS_MODULE,
                .probe          = sd_probe,
                .probe_type     = PROBE_PREFER_ASYNCHRONOUS,
                .remove         = sd_remove,
index 0f2c87cc95e6297da3c57645e3d1893ece273bc1..e22c7f5e652bd9f9bd6f989113ac7303a90a8c11 100644 (file)
@@ -908,7 +908,6 @@ static struct class_interface ses_interface = {
 static struct scsi_driver ses_template = {
        .gendrv = {
                .name           = "ses",
-               .owner          = THIS_MODULE,
                .probe          = ses_probe,
                .remove         = ses_remove,
        },
index 86210e4dd0d3530c65302723664b9ea5e9a6fc08..6ef6256246dfafb5a1084abaa5918cadffe069a7 100644 (file)
@@ -1424,7 +1424,9 @@ static const struct file_operations sg_fops = {
        .llseek = no_llseek,
 };
 
-static struct class *sg_sysfs_class;
+static const struct class sg_sysfs_class = {
+       .name = "scsi_generic"
+};
 
 static int sg_sysfs_valid = 0;
 
@@ -1526,7 +1528,7 @@ sg_add_device(struct device *cl_dev)
        if (sg_sysfs_valid) {
                struct device *sg_class_member;
 
-               sg_class_member = device_create(sg_sysfs_class, cl_dev->parent,
+               sg_class_member = device_create(&sg_sysfs_class, cl_dev->parent,
                                                MKDEV(SCSI_GENERIC_MAJOR,
                                                      sdp->index),
                                                sdp, "%s", sdp->name);
@@ -1616,7 +1618,7 @@ sg_remove_device(struct device *cl_dev)
        read_unlock_irqrestore(&sdp->sfd_lock, iflags);
 
        sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic");
-       device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index));
+       device_destroy(&sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, sdp->index));
        cdev_del(sdp->cdev);
        sdp->cdev = NULL;
 
@@ -1687,11 +1689,9 @@ init_sg(void)
                                    SG_MAX_DEVS, "sg");
        if (rc)
                return rc;
-        sg_sysfs_class = class_create("scsi_generic");
-        if ( IS_ERR(sg_sysfs_class) ) {
-               rc = PTR_ERR(sg_sysfs_class);
+       rc = class_register(&sg_sysfs_class);
+       if (rc)
                goto err_out;
-        }
        sg_sysfs_valid = 1;
        rc = scsi_register_interface(&sg_interface);
        if (0 == rc) {
@@ -1700,7 +1700,7 @@ init_sg(void)
 #endif                         /* CONFIG_SCSI_PROC_FS */
                return 0;
        }
-       class_destroy(sg_sysfs_class);
+       class_unregister(&sg_sysfs_class);
        register_sg_sysctls();
 err_out:
        unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS);
@@ -1715,7 +1715,7 @@ exit_sg(void)
        remove_proc_subtree("scsi/sg", NULL);
 #endif                         /* CONFIG_SCSI_PROC_FS */
        scsi_unregister_interface(&sg_interface);
-       class_destroy(sg_sysfs_class);
+       class_unregister(&sg_sysfs_class);
        sg_sysfs_valid = 0;
        unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
                                 SG_MAX_DEVS);
index 385180c98be496989dbf469926f52c974609a013..bb15e0ac8fe46ef3ccb67c118eb29959ac3fe484 100644 (file)
@@ -1041,9 +1041,8 @@ static int pqi_write_driver_version_to_host_wellness(
        buffer->driver_version_tag[1] = 'V';
        put_unaligned_le16(sizeof(buffer->driver_version),
                &buffer->driver_version_length);
-       strncpy(buffer->driver_version, "Linux " DRIVER_VERSION,
-               sizeof(buffer->driver_version) - 1);
-       buffer->driver_version[sizeof(buffer->driver_version) - 1] = '\0';
+       strscpy(buffer->driver_version, "Linux " DRIVER_VERSION,
+               sizeof(buffer->driver_version));
        buffer->dont_write_tag[0] = 'D';
        buffer->dont_write_tag[1] = 'W';
        buffer->end_tag[0] = 'Z';
index 3ddbdbc3ded1aa1841285913e7429f82586dbed7..48bf82d042b435924cf777a8ba2bb5463909e32b 100644 (file)
@@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev,
 {
        struct snic *snic = shost_priv(class_to_shost(dev));
 
-       return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
+       return sysfs_emit(buf, "%s\n", snic->name);
 }
 
 static ssize_t
@@ -23,8 +23,7 @@ snic_show_state(struct device *dev,
 {
        struct snic *snic = shost_priv(class_to_shost(dev));
 
-       return snprintf(buf, PAGE_SIZE, "%s\n",
-                       snic_state_str[snic_get_state(snic)]);
+       return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);
 }
 
 static ssize_t
@@ -32,7 +31,7 @@ snic_show_drv_version(struct device *dev,
                      struct device_attribute *attr,
                      char *buf)
 {
-       return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
+       return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
 }
 
 static ssize_t
@@ -45,8 +44,8 @@ snic_show_link_state(struct device *dev,
        if (snic->config.xpt_type == SNIC_DAS)
                snic->link_status = svnic_dev_link_status(snic->vdev);
 
-       return snprintf(buf, PAGE_SIZE, "%s\n",
-                       (snic->link_status) ? "Link Up" : "Link Down");
+       return sysfs_emit(buf, "%s\n",
+                         (snic->link_status) ? "Link Up" : "Link Down");
 }
 
 static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
index 268b3a40891edb65c59243fca24263b27a6aa114..7ab000942b97fcc858dac388b2b5cdcb7fa5e7ca 100644 (file)
@@ -95,7 +95,6 @@ static const struct dev_pm_ops sr_pm_ops = {
 static struct scsi_driver sr_template = {
        .gendrv = {
                .name           = "sr",
-               .owner          = THIS_MODULE,
                .probe          = sr_probe,
                .remove         = sr_remove,
                .pm             = &sr_pm_ops,
index 338aa8c429682ce2dd58c45b342228efadb81783..0d8ce1a92168c41ea0c9e7cf9a3cb25f161343d6 100644 (file)
@@ -87,7 +87,7 @@ static int try_rdio = 1;
 static int try_wdio = 1;
 static int debug_flag;
 
-static struct class st_sysfs_class;
+static const struct class st_sysfs_class;
 static const struct attribute_group *st_dev_groups[];
 static const struct attribute_group *st_drv_groups[];
 
@@ -206,7 +206,6 @@ static int st_remove(struct device *);
 static struct scsi_driver st_template = {
        .gendrv = {
                .name           = "st",
-               .owner          = THIS_MODULE,
                .probe          = st_probe,
                .remove         = st_remove,
                .groups         = st_drv_groups,
@@ -4438,7 +4437,7 @@ static void scsi_tape_release(struct kref *kref)
        return;
 }
 
-static struct class st_sysfs_class = {
+static const struct class st_sysfs_class = {
        .name = "scsi_tape",
        .dev_groups = st_dev_groups,
 };
index e4fafc77bd2010d6221e10932676312a1d1930a9..a44b60c9004ab0a5e01abbb05c4095e90ddaba2a 100644 (file)
@@ -1721,9 +1721,7 @@ wd33c93_setup(char *str)
        p1 = setup_buffer;
        *p1 = '\0';
        if (str)
-               strncpy(p1, str, SETUP_BUFFER_SIZE - strlen(setup_buffer));
-       setup_buffer[SETUP_BUFFER_SIZE - 1] = '\0';
-       p1 = setup_buffer;
+               strscpy(p1, str, SETUP_BUFFER_SIZE);
        i = 0;
        while (*p1 && (i < MAX_SETUP_ARGS)) {
                p2 = strchr(p1, ',');
index 6797200211836d5966027f236fd7f7d06c53821f..d9a6242264b787b1bda4e546a4a16bd7650abab3 100644 (file)
@@ -583,7 +583,7 @@ int iscsit_dataout_datapduinorder_no_fbit(
        struct iscsi_pdu *pdu)
 {
        int i, send_recovery_r2t = 0, recovery = 0;
-       u32 length = 0, offset = 0, pdu_count = 0, xfer_len = 0;
+       u32 length = 0, offset = 0, pdu_count = 0;
        struct iscsit_conn *conn = cmd->conn;
        struct iscsi_pdu *first_pdu = NULL;
 
@@ -596,7 +596,6 @@ int iscsit_dataout_datapduinorder_no_fbit(
                        if (cmd->pdu_list[i].seq_no == pdu->seq_no) {
                                if (!first_pdu)
                                        first_pdu = &cmd->pdu_list[i];
-                               xfer_len += cmd->pdu_list[i].length;
                                pdu_count++;
                        } else if (pdu_count)
                                break;
index 8db81f1a12d5fc8f39ac7a1010d6a0d1b55a16c9..768bf87cd80d3fe288eeba826ba3db46b4591dd3 100644 (file)
@@ -94,7 +94,7 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds)
 
        val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
        val &= ~MCQ_CFG_MAC_MASK;
-       val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds);
+       val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds - 1);
        ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
 }
 EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);
index e30fd125988d7a8ca521d6fb30e97c671f269732..62c8575f2c67ed12b2a419d7eb36c84062a616f0 100644 (file)
@@ -2710,18 +2710,27 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
 /**
  * ufshcd_prepare_req_desc_hdr - Fill UTP Transfer request descriptor header according to request
  * descriptor according to request
+ * @hba: per adapter instance
  * @lrbp: pointer to local reference block
  * @upiu_flags: flags required in the header
  * @cmd_dir: requests data direction
  * @ehs_length: Total EHS Length (in 32‐bytes units of all Extra Header Segments)
+ * @legacy_type: UTP_CMD_TYPE_SCSI or UTP_CMD_TYPE_DEV_MANAGE
  */
-static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp, u8 *upiu_flags,
-                                       enum dma_data_direction cmd_dir, int ehs_length)
+static void
+ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
+                           u8 *upiu_flags, enum dma_data_direction cmd_dir,
+                           int ehs_length, enum utp_cmd_type legacy_type)
 {
        struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
        struct request_desc_header *h = &req_desc->header;
        enum utp_data_direction data_direction;
 
+       if (hba->ufs_version <= ufshci_version(1, 1))
+               lrbp->command_type = legacy_type;
+       else
+               lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+
        *h = (typeof(*h)){ };
 
        if (cmd_dir == DMA_FROM_DEVICE) {
@@ -2854,12 +2863,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
        u8 upiu_flags;
        int ret = 0;
 
-       if (hba->ufs_version <= ufshci_version(1, 1))
-               lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
-       else
-               lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+       ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0, UTP_CMD_TYPE_DEV_MANAGE);
 
-       ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE, 0);
        if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
                ufshcd_prepare_utp_query_req_upiu(hba, lrbp, upiu_flags);
        else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
@@ -2882,13 +2887,8 @@ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
        unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
        u8 upiu_flags;
 
-       if (hba->ufs_version <= ufshci_version(1, 1))
-               lrbp->command_type = UTP_CMD_TYPE_SCSI;
-       else
-               lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
-
-       ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
-                                   lrbp->cmd->sc_data_direction, 0);
+       ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
+                                   lrbp->cmd->sc_data_direction, 0, UTP_CMD_TYPE_SCSI);
        if (ioprio_class == IOPRIO_CLASS_RT)
                upiu_flags |= UPIU_CMD_FLAGS_CP;
        ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
@@ -3061,15 +3061,21 @@ out:
        return err;
 }
 
-static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
-               struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
+static void ufshcd_setup_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
+                            enum dev_cmd_type cmd_type, u8 lun, int tag)
 {
        lrbp->cmd = NULL;
        lrbp->task_tag = tag;
-       lrbp->lun = 0; /* device management cmd is not specific to any LUN */
+       lrbp->lun = lun;
        lrbp->intr_cmd = true; /* No interrupt aggregation */
        ufshcd_prepare_lrbp_crypto(NULL, lrbp);
        hba->dev_cmd.type = cmd_type;
+}
+
+static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
+               struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
+{
+       ufshcd_setup_dev_cmd(hba, lrbp, cmd_type, 0, tag);
 
        return ufshcd_compose_devman_upiu(hba, lrbp);
 }
@@ -3274,6 +3280,39 @@ retry:
        return err;
 }
 
+static void ufshcd_dev_man_lock(struct ufs_hba *hba)
+{
+       ufshcd_hold(hba);
+       mutex_lock(&hba->dev_cmd.lock);
+       down_read(&hba->clk_scaling_lock);
+}
+
+static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
+{
+       up_read(&hba->clk_scaling_lock);
+       mutex_unlock(&hba->dev_cmd.lock);
+       ufshcd_release(hba);
+}
+
+static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
+                         const u32 tag, int timeout)
+{
+       DECLARE_COMPLETION_ONSTACK(wait);
+       int err;
+
+       hba->dev_cmd.complete = &wait;
+
+       ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
+
+       ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
+       err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
+
+       ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
+                                   (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
+
+       return err;
+}
+
 /**
  * ufshcd_exec_dev_cmd - API for sending device management requests
  * @hba: UFS hba
@@ -3288,34 +3327,18 @@ retry:
 static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
                enum dev_cmd_type cmd_type, int timeout)
 {
-       DECLARE_COMPLETION_ONSTACK(wait);
        const u32 tag = hba->reserved_slot;
-       struct ufshcd_lrb *lrbp;
+       struct ufshcd_lrb *lrbp = &hba->lrb[tag];
        int err;
 
        /* Protects use of hba->reserved_slot. */
        lockdep_assert_held(&hba->dev_cmd.lock);
 
-       down_read(&hba->clk_scaling_lock);
-
-       lrbp = &hba->lrb[tag];
-       lrbp->cmd = NULL;
        err = ufshcd_compose_dev_cmd(hba, lrbp, cmd_type, tag);
        if (unlikely(err))
-               goto out;
-
-       hba->dev_cmd.complete = &wait;
-
-       ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
-
-       ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
-       err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
-       ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
-                                   (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
+               return err;
 
-out:
-       up_read(&hba->clk_scaling_lock);
-       return err;
+       return ufshcd_issue_dev_cmd(hba, lrbp, tag, timeout);
 }
 
 /**
@@ -3385,8 +3408,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
 
        BUG_ON(!hba);
 
-       ufshcd_hold(hba);
-       mutex_lock(&hba->dev_cmd.lock);
+       ufshcd_dev_man_lock(hba);
+
        ufshcd_init_query(hba, &request, &response, opcode, idn, index,
                        selector);
 
@@ -3428,8 +3451,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
                                MASK_QUERY_UPIU_FLAG_LOC) & 0x1;
 
 out_unlock:
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+       ufshcd_dev_man_unlock(hba);
        return err;
 }
 
@@ -3459,9 +3481,8 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
                return -EINVAL;
        }
 
-       ufshcd_hold(hba);
+       ufshcd_dev_man_lock(hba);
 
-       mutex_lock(&hba->dev_cmd.lock);
        ufshcd_init_query(hba, &request, &response, opcode, idn, index,
                        selector);
 
@@ -3491,8 +3512,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
        *attr_val = be32_to_cpu(response->upiu_res.value);
 
 out_unlock:
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+       ufshcd_dev_man_unlock(hba);
        return err;
 }
 
@@ -3555,9 +3575,8 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
                return -EINVAL;
        }
 
-       ufshcd_hold(hba);
+       ufshcd_dev_man_lock(hba);
 
-       mutex_lock(&hba->dev_cmd.lock);
        ufshcd_init_query(hba, &request, &response, opcode, idn, index,
                        selector);
        hba->dev_cmd.query.descriptor = desc_buf;
@@ -3590,8 +3609,7 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
 
 out_unlock:
        hba->dev_cmd.query.descriptor = NULL;
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+       ufshcd_dev_man_unlock(hba);
        return err;
 }
 
@@ -4287,7 +4305,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
                 * Make sure UIC command completion interrupt is disabled before
                 * issuing UIC command.
                 */
-               wmb();
+               ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
                reenable_intr = true;
        }
        spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -4769,12 +4787,6 @@ int ufshcd_make_hba_operational(struct ufs_hba *hba)
        ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr),
                        REG_UTP_TASK_REQ_LIST_BASE_H);
 
-       /*
-        * Make sure base address and interrupt setup are updated before
-        * enabling the run/stop registers below.
-        */
-       wmb();
-
        /*
         * UCRDY, UTMRLDY and UTRLRDY bits must be 1
         */
@@ -5072,8 +5084,8 @@ static int ufshcd_verify_dev_init(struct ufs_hba *hba)
        int err = 0;
        int retries;
 
-       ufshcd_hold(hba);
-       mutex_lock(&hba->dev_cmd.lock);
+       ufshcd_dev_man_lock(hba);
+
        for (retries = NOP_OUT_RETRIES; retries > 0; retries--) {
                err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_NOP,
                                          hba->nop_out_timeout);
@@ -5083,8 +5095,8 @@ static int ufshcd_verify_dev_init(struct ufs_hba *hba)
 
                dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
        }
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+
+       ufshcd_dev_man_unlock(hba);
 
        if (err)
                dev_err(hba->dev, "%s: NOP OUT failed %d\n", __func__, err);
@@ -7090,10 +7102,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
 
        /* send command to the controller */
        __set_bit(task_tag, &hba->outstanding_tasks);
-
        ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL);
-       /* Make sure that doorbell is committed immediately */
-       wmb();
 
        spin_unlock_irqrestore(host->host_lock, flags);
 
@@ -7201,35 +7210,21 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
                                        enum dev_cmd_type cmd_type,
                                        enum query_opcode desc_op)
 {
-       DECLARE_COMPLETION_ONSTACK(wait);
        const u32 tag = hba->reserved_slot;
-       struct ufshcd_lrb *lrbp;
+       struct ufshcd_lrb *lrbp = &hba->lrb[tag];
        int err = 0;
        u8 upiu_flags;
 
        /* Protects use of hba->reserved_slot. */
        lockdep_assert_held(&hba->dev_cmd.lock);
 
-       down_read(&hba->clk_scaling_lock);
-
-       lrbp = &hba->lrb[tag];
-       lrbp->cmd = NULL;
-       lrbp->task_tag = tag;
-       lrbp->lun = 0;
-       lrbp->intr_cmd = true;
-       ufshcd_prepare_lrbp_crypto(NULL, lrbp);
-       hba->dev_cmd.type = cmd_type;
+       ufshcd_setup_dev_cmd(hba, lrbp, cmd_type, 0, tag);
 
-       if (hba->ufs_version <= ufshci_version(1, 1))
-               lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
-       else
-               lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+       ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0, UTP_CMD_TYPE_DEV_MANAGE);
 
        /* update the task tag in the request upiu */
        req_upiu->header.task_tag = tag;
 
-       ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE, 0);
-
        /* just copy the upiu request as it is */
        memcpy(lrbp->ucd_req_ptr, req_upiu, sizeof(*lrbp->ucd_req_ptr));
        if (desc_buff && desc_op == UPIU_QUERY_OPCODE_WRITE_DESC) {
@@ -7243,17 +7238,12 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
 
        memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
 
-       hba->dev_cmd.complete = &wait;
-
-       ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
-
-       ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
        /*
         * ignore the returning value here - ufshcd_check_query_response is
         * bound to fail since dev_cmd.query and dev_cmd.type were left empty.
         * read the response directly ignoring all errors.
         */
-       ufshcd_wait_for_dev_cmd(hba, lrbp, QUERY_REQ_TIMEOUT);
+       ufshcd_issue_dev_cmd(hba, lrbp, tag, QUERY_REQ_TIMEOUT);
 
        /* just copy the upiu response as it is */
        memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));
@@ -7276,7 +7266,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
        ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
                                    (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
 
-       up_read(&hba->clk_scaling_lock);
        return err;
 }
 
@@ -7315,13 +7304,11 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
                cmd_type = DEV_CMD_TYPE_NOP;
                fallthrough;
        case UPIU_TRANSACTION_QUERY_REQ:
-               ufshcd_hold(hba);
-               mutex_lock(&hba->dev_cmd.lock);
+               ufshcd_dev_man_lock(hba);
                err = ufshcd_issue_devman_upiu_cmd(hba, req_upiu, rsp_upiu,
                                                   desc_buff, buff_len,
                                                   cmd_type, desc_op);
-               mutex_unlock(&hba->dev_cmd.lock);
-               ufshcd_release(hba);
+               ufshcd_dev_man_unlock(hba);
 
                break;
        case UPIU_TRANSACTION_TASK_REQ:
@@ -7371,41 +7358,21 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
                         struct ufs_ehs *rsp_ehs, int sg_cnt, struct scatterlist *sg_list,
                         enum dma_data_direction dir)
 {
-       DECLARE_COMPLETION_ONSTACK(wait);
        const u32 tag = hba->reserved_slot;
-       struct ufshcd_lrb *lrbp;
+       struct ufshcd_lrb *lrbp = &hba->lrb[tag];
        int err = 0;
        int result;
        u8 upiu_flags;
        u8 *ehs_data;
        u16 ehs_len;
+       int ehs = (hba->capabilities & MASK_EHSLUTRD_SUPPORTED) ? 2 : 0;
 
        /* Protects use of hba->reserved_slot. */
-       ufshcd_hold(hba);
-       mutex_lock(&hba->dev_cmd.lock);
-       down_read(&hba->clk_scaling_lock);
+       ufshcd_dev_man_lock(hba);
 
-       lrbp = &hba->lrb[tag];
-       lrbp->cmd = NULL;
-       lrbp->task_tag = tag;
-       lrbp->lun = UFS_UPIU_RPMB_WLUN;
-
-       lrbp->intr_cmd = true;
-       ufshcd_prepare_lrbp_crypto(NULL, lrbp);
-       hba->dev_cmd.type = DEV_CMD_TYPE_RPMB;
+       ufshcd_setup_dev_cmd(hba, lrbp, DEV_CMD_TYPE_RPMB, UFS_UPIU_RPMB_WLUN, tag);
 
-       /* Advanced RPMB starts from UFS 4.0, so its command type is UTP_CMD_TYPE_UFS_STORAGE */
-       lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
-
-       /*
-        * According to UFSHCI 4.0 specification page 24, if EHSLUTRDS is 0, host controller takes
-        * EHS length from CMD UPIU, and SW driver use EHS Length field in CMD UPIU. if it is 1,
-        * HW controller takes EHS length from UTRD.
-        */
-       if (hba->capabilities & MASK_EHSLUTRD_SUPPORTED)
-               ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2);
-       else
-               ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 0);
+       ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, ehs, UTP_CMD_TYPE_DEV_MANAGE);
 
        /* update the task tag */
        req_upiu->header.task_tag = tag;
@@ -7420,11 +7387,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
 
        memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
 
-       hba->dev_cmd.complete = &wait;
-
-       ufshcd_send_command(hba, tag, hba->dev_cmd_queue);
-
-       err = ufshcd_wait_for_dev_cmd(hba, lrbp, ADVANCED_RPMB_REQ_TIMEOUT);
+       err = ufshcd_issue_dev_cmd(hba, lrbp, tag, ADVANCED_RPMB_REQ_TIMEOUT);
 
        if (!err) {
                /* Just copy the upiu response as it is */
@@ -7449,9 +7412,8 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
                }
        }
 
-       up_read(&hba->clk_scaling_lock);
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+       ufshcd_dev_man_unlock(hba);
+
        return err ? : result;
 }
 
@@ -8714,9 +8676,7 @@ static void ufshcd_set_timestamp_attr(struct ufs_hba *hba)
        if (dev_info->wspecversion < 0x400)
                return;
 
-       ufshcd_hold(hba);
-
-       mutex_lock(&hba->dev_cmd.lock);
+       ufshcd_dev_man_lock(hba);
 
        ufshcd_init_query(hba, &request, &response,
                          UPIU_QUERY_OPCODE_WRITE_ATTR,
@@ -8734,8 +8694,7 @@ static void ufshcd_set_timestamp_attr(struct ufs_hba *hba)
                dev_err(hba->dev, "%s: failed to set timestamp %d\n",
                        __func__, err);
 
-       mutex_unlock(&hba->dev_cmd.lock);
-       ufshcd_release(hba);
+       ufshcd_dev_man_unlock(hba);
 }
 
 /**
@@ -10395,7 +10354,7 @@ int ufshcd_system_restore(struct device *dev)
         * are updated with the latest queue addresses. Only after
         * updating these addresses, we can queue the new commands.
         */
-       mb();
+       ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H);
 
        /* Resuming from hibernate, assume that link was OFF */
        ufshcd_set_link_off(hba);
@@ -10616,7 +10575,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
         * Make sure that UFS interrupts are disabled and any pending interrupt
         * status is cleared before registering UFS interrupt handler.
         */
-       mb();
+       ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
 
        /* IRQ registration */
        err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);
@@ -10896,7 +10855,6 @@ static void ufshcd_check_header_layout(void)
 static struct scsi_driver ufs_dev_wlun_template = {
        .gendrv = {
                .name = "ufs_device_wlun",
-               .owner = THIS_MODULE,
                .probe = ufshcd_wl_probe,
                .remove = ufshcd_wl_remove,
                .pm = &ufshcd_wl_pm_ops,
index bb30267da4711e345ee4b5aa19d510ca8ac0c9d6..66811d8d1929c135aa43d5cda482464cf37854b4 100644 (file)
@@ -136,7 +136,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba)
         * Make sure the register was updated,
         * UniPro layer will not work with an incorrect value.
         */
-       mb();
+       ufshcd_readl(hba, CDNS_UFS_REG_HCLKDIV);
 
        return 0;
 }
diff --git a/drivers/ufs/host/ufs-mediatek-sip.h b/drivers/ufs/host/ufs-mediatek-sip.h
new file mode 100644 (file)
index 0000000..7d17aed
--- /dev/null
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#ifndef _UFS_MEDIATEK_SIP_H
+#define _UFS_MEDIATEK_SIP_H
+
+#include <linux/soc/mediatek/mtk_sip_svc.h>
+
+/*
+ * SiP (Slicon Partner) commands
+ */
+#define MTK_SIP_UFS_CONTROL               MTK_SIP_SMC_CMD(0x276)
+#define UFS_MTK_SIP_VA09_PWR_CTRL         BIT(0)
+#define UFS_MTK_SIP_DEVICE_RESET          BIT(1)
+#define UFS_MTK_SIP_CRYPTO_CTRL           BIT(2)
+#define UFS_MTK_SIP_REF_CLK_NOTIFICATION  BIT(3)
+#define UFS_MTK_SIP_SRAM_PWR_CTRL         BIT(5)
+#define UFS_MTK_SIP_GET_VCC_NUM           BIT(6)
+#define UFS_MTK_SIP_DEVICE_PWR_CTRL       BIT(7)
+#define UFS_MTK_SIP_MPHY_CTRL             BIT(8)
+#define UFS_MTK_SIP_MTCMOS_CTRL           BIT(9)
+
+/*
+ * Multi-VCC by Numbering
+ */
+enum ufs_mtk_vcc_num {
+       UFS_VCC_NONE = 0,
+       UFS_VCC_1,
+       UFS_VCC_2,
+       UFS_VCC_MAX
+};
+
+enum ufs_mtk_mphy_op {
+       UFS_MPHY_BACKUP = 0,
+       UFS_MPHY_RESTORE
+};
+
+/*
+ * SMC call wrapper function
+ */
+struct ufs_mtk_smc_arg {
+       unsigned long cmd;
+       struct arm_smccc_res *res;
+       unsigned long v1;
+       unsigned long v2;
+       unsigned long v3;
+       unsigned long v4;
+       unsigned long v5;
+       unsigned long v6;
+       unsigned long v7;
+};
+
+
+static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
+{
+       arm_smccc_smc(MTK_SIP_UFS_CONTROL,
+               s.cmd,
+               s.v1, s.v2, s.v3, s.v4, s.v5, s.v6, s.res);
+}
+
+#define ufs_mtk_smc(...) \
+       _ufs_mtk_smc((struct ufs_mtk_smc_arg) {__VA_ARGS__})
+
+/* Sip kernel interface */
+#define ufs_mtk_va09_pwr_ctrl(res, on) \
+       ufs_mtk_smc(UFS_MTK_SIP_VA09_PWR_CTRL, &(res), on)
+
+#define ufs_mtk_crypto_ctrl(res, enable) \
+       ufs_mtk_smc(UFS_MTK_SIP_CRYPTO_CTRL, &(res), enable)
+
+#define ufs_mtk_ref_clk_notify(on, stage, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_REF_CLK_NOTIFICATION, &(res), on, stage)
+
+#define ufs_mtk_device_reset_ctrl(high, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, &(res), high)
+
+#define ufs_mtk_sram_pwr_ctrl(on, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_SRAM_PWR_CTRL, &(res), on)
+
+#define ufs_mtk_get_vcc_num(res) \
+       ufs_mtk_smc(UFS_MTK_SIP_GET_VCC_NUM, &(res))
+
+#define ufs_mtk_device_pwr_ctrl(on, ufs_version, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_DEVICE_PWR_CTRL, &(res), on, ufs_version)
+
+#define ufs_mtk_mphy_ctrl(op, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_MPHY_CTRL, &(res), op)
+
+#define ufs_mtk_mtcmos_ctrl(op, res) \
+       ufs_mtk_smc(UFS_MTK_SIP_MTCMOS_CTRL, &(res), op)
+
+#endif /* !_UFS_MEDIATEK_SIP_H */
index b8a8801322e2d928343d8669f0dd90e7f64b29cd..0b0c923b1d7b9b1b2560c80e8f5f2ecdf2705b83 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/reset.h>
-#include <linux/soc/mediatek/mtk_sip_svc.h>
 
 #include <ufs/ufshcd.h>
 #include "ufshcd-pltfrm.h"
 #include <ufs/ufs_quirks.h>
 #include <ufs/unipro.h>
+
 #include "ufs-mediatek.h"
+#include "ufs-mediatek-sip.h"
 
 static int  ufs_mtk_config_mcq(struct ufs_hba *hba, bool irq);
 
@@ -118,6 +119,27 @@ static bool ufs_mtk_is_pmc_via_fastauto(struct ufs_hba *hba)
        return !!(host->caps & UFS_MTK_CAP_PMC_VIA_FASTAUTO);
 }
 
+static bool ufs_mtk_is_tx_skew_fix(struct ufs_hba *hba)
+{
+       struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+       return (host->caps & UFS_MTK_CAP_TX_SKEW_FIX);
+}
+
+static bool ufs_mtk_is_rtff_mtcmos(struct ufs_hba *hba)
+{
+       struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+       return (host->caps & UFS_MTK_CAP_RTFF_MTCMOS);
+}
+
+static bool ufs_mtk_is_allow_vccqx_lpm(struct ufs_hba *hba)
+{
+       struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+       return (host->caps & UFS_MTK_CAP_ALLOW_VCCQX_LPM);
+}
+
 static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable)
 {
        u32 tmp;
@@ -169,16 +191,23 @@ static void ufs_mtk_crypto_enable(struct ufs_hba *hba)
 static void ufs_mtk_host_reset(struct ufs_hba *hba)
 {
        struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+       struct arm_smccc_res res;
 
        reset_control_assert(host->hci_reset);
        reset_control_assert(host->crypto_reset);
        reset_control_assert(host->unipro_reset);
+       reset_control_assert(host->mphy_reset);
 
        usleep_range(100, 110);
 
        reset_control_deassert(host->unipro_reset);
        reset_control_deassert(host->crypto_reset);
        reset_control_deassert(host->hci_reset);
+       reset_control_deassert(host->mphy_reset);
+
+       /* restore mphy setting aftre mphy reset */
+       if (host->mphy_reset)
+               ufs_mtk_mphy_ctrl(UFS_MPHY_RESTORE, res);
 }
 
 static void ufs_mtk_init_reset_control(struct ufs_hba *hba,
@@ -203,6 +232,8 @@ static void ufs_mtk_init_reset(struct ufs_hba *hba)
                                   "unipro_rst");
        ufs_mtk_init_reset_control(hba, &host->crypto_reset,
                                   "crypto_rst");
+       ufs_mtk_init_reset_control(hba, &host->mphy_reset,
+                                  "mphy_rst");
 }
 
 static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba,
@@ -622,6 +653,15 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
        if (of_property_read_bool(np, "mediatek,ufs-pmc-via-fastauto"))
                host->caps |= UFS_MTK_CAP_PMC_VIA_FASTAUTO;
 
+       if (of_property_read_bool(np, "mediatek,ufs-tx-skew-fix"))
+               host->caps |= UFS_MTK_CAP_TX_SKEW_FIX;
+
+       if (of_property_read_bool(np, "mediatek,ufs-disable-mcq"))
+               host->caps |= UFS_MTK_CAP_DISABLE_MCQ;
+
+       if (of_property_read_bool(np, "mediatek,ufs-rtff-mtcmos"))
+               host->caps |= UFS_MTK_CAP_RTFF_MTCMOS;
+
        dev_info(hba->dev, "caps: 0x%x", host->caps);
 }
 
@@ -885,6 +925,9 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba)
        host->mcq_nr_intr = UFSHCD_MAX_Q_NR;
        pdev = container_of(hba->dev, struct platform_device, dev);
 
+       if (host->caps & UFS_MTK_CAP_DISABLE_MCQ)
+               goto failed;
+
        for (i = 0; i < host->mcq_nr_intr; i++) {
                /* irq index 0 is legacy irq, sq/cq irq start from index 1 */
                irq = platform_get_irq(pdev, i + 1);
@@ -923,6 +966,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
        struct ufs_mtk_host *host;
        struct Scsi_Host *shost = hba->host;
        int err = 0;
+       struct arm_smccc_res res;
 
        host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
        if (!host) {
@@ -951,6 +995,10 @@ static int ufs_mtk_init(struct ufs_hba *hba)
 
        ufs_mtk_init_reset(hba);
 
+       /* backup mphy setting if mphy can reset */
+       if (host->mphy_reset)
+               ufs_mtk_mphy_ctrl(UFS_MPHY_BACKUP, res);
+
        /* Enable runtime autosuspend */
        hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND;
 
@@ -987,6 +1035,15 @@ static int ufs_mtk_init(struct ufs_hba *hba)
         * Enable phy clocks specifically here.
         */
        ufs_mtk_mphy_power_on(hba, true);
+
+       if (ufs_mtk_is_rtff_mtcmos(hba)) {
+               /* First Restore here, to avoid backup unexpected value */
+               ufs_mtk_mtcmos_ctrl(false, res);
+
+               /* Power on to init */
+               ufs_mtk_mtcmos_ctrl(true, res);
+       }
+
        ufs_mtk_setup_clocks(hba, true, POST_CHANGE);
 
        host->ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER);
@@ -1303,27 +1360,37 @@ static void ufs_mtk_vsx_set_lpm(struct ufs_hba *hba, bool lpm)
 
 static void ufs_mtk_dev_vreg_set_lpm(struct ufs_hba *hba, bool lpm)
 {
-       if (!hba->vreg_info.vccq && !hba->vreg_info.vccq2)
-               return;
+       bool skip_vccqx = false;
 
-       /* Skip if VCC is assumed always-on */
-       if (!hba->vreg_info.vcc)
-               return;
-
-       /* Bypass LPM when device is still active */
+       /* Prevent entering LPM when device is still active */
        if (lpm && ufshcd_is_ufs_dev_active(hba))
                return;
 
-       /* Bypass LPM if VCC is enabled */
-       if (lpm && hba->vreg_info.vcc->enabled)
-               return;
+       /* Skip vccqx lpm control and control vsx only */
+       if (!hba->vreg_info.vccq && !hba->vreg_info.vccq2)
+               skip_vccqx = true;
+
+       /* VCC is always-on, control vsx only */
+       if (!hba->vreg_info.vcc)
+               skip_vccqx = true;
+
+       /* Broken vcc keep vcc always on, most case control vsx only */
+       if (lpm && hba->vreg_info.vcc && hba->vreg_info.vcc->enabled) {
+               /* Some device vccqx/vsx can enter lpm */
+               if (ufs_mtk_is_allow_vccqx_lpm(hba))
+                       skip_vccqx = false;
+               else /* control vsx only */
+                       skip_vccqx = true;
+       }
 
        if (lpm) {
-               ufs_mtk_vccqx_set_lpm(hba, lpm);
+               if (!skip_vccqx)
+                       ufs_mtk_vccqx_set_lpm(hba, lpm);
                ufs_mtk_vsx_set_lpm(hba, lpm);
        } else {
                ufs_mtk_vsx_set_lpm(hba, lpm);
-               ufs_mtk_vccqx_set_lpm(hba, lpm);
+               if (!skip_vccqx)
+                       ufs_mtk_vccqx_set_lpm(hba, lpm);
        }
 }
 
@@ -1374,7 +1441,7 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
        if (ufshcd_is_link_off(hba))
                ufs_mtk_device_reset_ctrl(0, res);
 
-       ufs_mtk_host_pwr_ctrl(HOST_PWR_HCI, false, res);
+       ufs_mtk_sram_pwr_ctrl(false, res);
 
        return 0;
 fail:
@@ -1395,7 +1462,7 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
        if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
                ufs_mtk_dev_vreg_set_lpm(hba, false);
 
-       ufs_mtk_host_pwr_ctrl(HOST_PWR_HCI, true, res);
+       ufs_mtk_sram_pwr_ctrl(true, res);
 
        err = ufs_mtk_mphy_power_on(hba, true);
        if (err)
@@ -1438,6 +1505,17 @@ static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba)
        if (mid == UFS_VENDOR_SAMSUNG) {
                ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6);
                ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME), 10);
+       } else if (mid == UFS_VENDOR_MICRON) {
+               /* Only for the host which have TX skew issue */
+               if (ufs_mtk_is_tx_skew_fix(hba) &&
+                       (STR_PRFX_EQUAL("MT128GBCAV2U31", dev_info->model) ||
+                       STR_PRFX_EQUAL("MT256GBCAV4U31", dev_info->model) ||
+                       STR_PRFX_EQUAL("MT512GBCAV8U31", dev_info->model) ||
+                       STR_PRFX_EQUAL("MT256GBEAX4U40", dev_info->model) ||
+                       STR_PRFX_EQUAL("MT512GAYAX4U40", dev_info->model) ||
+                       STR_PRFX_EQUAL("MT001TAYAX8U40", dev_info->model))) {
+                       ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 8);
+               }
        }
 
        /*
@@ -1579,6 +1657,12 @@ static int ufs_mtk_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
 
 static int ufs_mtk_get_hba_mac(struct ufs_hba *hba)
 {
+       struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+       /* MCQ operation not permitted */
+       if (host->caps & UFS_MTK_CAP_DISABLE_MCQ)
+               return -EPERM;
+
        return MAX_SUPP_MAC;
 }
 
@@ -1790,6 +1874,7 @@ static void ufs_mtk_remove(struct platform_device *pdev)
 static int ufs_mtk_system_suspend(struct device *dev)
 {
        struct ufs_hba *hba = dev_get_drvdata(dev);
+       struct arm_smccc_res res;
        int ret;
 
        ret = ufshcd_system_suspend(dev);
@@ -1798,15 +1883,22 @@ static int ufs_mtk_system_suspend(struct device *dev)
 
        ufs_mtk_dev_vreg_set_lpm(hba, true);
 
+       if (ufs_mtk_is_rtff_mtcmos(hba))
+               ufs_mtk_mtcmos_ctrl(false, res);
+
        return 0;
 }
 
 static int ufs_mtk_system_resume(struct device *dev)
 {
        struct ufs_hba *hba = dev_get_drvdata(dev);
+       struct arm_smccc_res res;
 
        ufs_mtk_dev_vreg_set_lpm(hba, false);
 
+       if (ufs_mtk_is_rtff_mtcmos(hba))
+               ufs_mtk_mtcmos_ctrl(true, res);
+
        return ufshcd_system_resume(dev);
 }
 #endif
@@ -1815,6 +1907,7 @@ static int ufs_mtk_system_resume(struct device *dev)
 static int ufs_mtk_runtime_suspend(struct device *dev)
 {
        struct ufs_hba *hba = dev_get_drvdata(dev);
+       struct arm_smccc_res res;
        int ret = 0;
 
        ret = ufshcd_runtime_suspend(dev);
@@ -1823,12 +1916,19 @@ static int ufs_mtk_runtime_suspend(struct device *dev)
 
        ufs_mtk_dev_vreg_set_lpm(hba, true);
 
+       if (ufs_mtk_is_rtff_mtcmos(hba))
+               ufs_mtk_mtcmos_ctrl(false, res);
+
        return 0;
 }
 
 static int ufs_mtk_runtime_resume(struct device *dev)
 {
        struct ufs_hba *hba = dev_get_drvdata(dev);
+       struct arm_smccc_res res;
+
+       if (ufs_mtk_is_rtff_mtcmos(hba))
+               ufs_mtk_mtcmos_ctrl(true, res);
 
        ufs_mtk_dev_vreg_set_lpm(hba, false);
 
index fb53882f42ca888c16192e9f91374ae57bbd0069..3ff17e95afab31569ec21408b19087e01d86c4d8 100644 (file)
@@ -7,7 +7,6 @@
 #define _UFS_MEDIATEK_H
 
 #include <linux/bitops.h>
-#include <linux/soc/mediatek/mtk_sip_svc.h>
 
 /*
  * MCQ define and struct
@@ -99,18 +98,6 @@ enum {
        VS_HIB_EXIT                 = 13,
 };
 
-/*
- * SiP commands
- */
-#define MTK_SIP_UFS_CONTROL               MTK_SIP_SMC_CMD(0x276)
-#define UFS_MTK_SIP_VA09_PWR_CTRL         BIT(0)
-#define UFS_MTK_SIP_DEVICE_RESET          BIT(1)
-#define UFS_MTK_SIP_CRYPTO_CTRL           BIT(2)
-#define UFS_MTK_SIP_REF_CLK_NOTIFICATION  BIT(3)
-#define UFS_MTK_SIP_HOST_PWR_CTRL         BIT(5)
-#define UFS_MTK_SIP_GET_VCC_NUM           BIT(6)
-#define UFS_MTK_SIP_DEVICE_PWR_CTRL       BIT(7)
-
 /*
  * VS_DEBUGCLOCKENABLE
  */
@@ -135,7 +122,17 @@ enum ufs_mtk_host_caps {
        UFS_MTK_CAP_VA09_PWR_CTRL              = 1 << 1,
        UFS_MTK_CAP_DISABLE_AH8                = 1 << 2,
        UFS_MTK_CAP_BROKEN_VCC                 = 1 << 3,
+
+       /*
+        * Override UFS_MTK_CAP_BROKEN_VCC's behavior to
+        * allow vccqx upstream to enter LPM
+        */
+       UFS_MTK_CAP_ALLOW_VCCQX_LPM            = 1 << 5,
        UFS_MTK_CAP_PMC_VIA_FASTAUTO           = 1 << 6,
+       UFS_MTK_CAP_TX_SKEW_FIX                = 1 << 7,
+       UFS_MTK_CAP_DISABLE_MCQ                = 1 << 8,
+       /* Control MTCMOS with RTFF */
+       UFS_MTK_CAP_RTFF_MTCMOS                = 1 << 9,
 };
 
 struct ufs_mtk_crypt_cfg {
@@ -170,6 +167,7 @@ struct ufs_mtk_host {
        struct reset_control *hci_reset;
        struct reset_control *unipro_reset;
        struct reset_control *crypto_reset;
+       struct reset_control *mphy_reset;
        struct ufs_hba *hba;
        struct ufs_mtk_crypt_cfg *crypt;
        struct ufs_mtk_clk mclk;
@@ -191,70 +189,4 @@ struct ufs_mtk_host {
 /* MTK delay of autosuspend: 500 ms */
 #define MTK_RPM_AUTOSUSPEND_DELAY_MS 500
 
-/*
- * Multi-VCC by Numbering
- */
-enum ufs_mtk_vcc_num {
-       UFS_VCC_NONE = 0,
-       UFS_VCC_1,
-       UFS_VCC_2,
-       UFS_VCC_MAX
-};
-
-/*
- * Host Power Control options
- */
-enum {
-       HOST_PWR_HCI = 0,
-       HOST_PWR_MPHY
-};
-
-/*
- * SMC call wrapper function
- */
-struct ufs_mtk_smc_arg {
-       unsigned long cmd;
-       struct arm_smccc_res *res;
-       unsigned long v1;
-       unsigned long v2;
-       unsigned long v3;
-       unsigned long v4;
-       unsigned long v5;
-       unsigned long v6;
-       unsigned long v7;
-};
-
-static void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
-{
-       arm_smccc_smc(MTK_SIP_UFS_CONTROL,
-                     s.cmd, s.v1, s.v2, s.v3, s.v4, s.v5, s.v6, s.res);
-}
-
-#define ufs_mtk_smc(...) \
-       _ufs_mtk_smc((struct ufs_mtk_smc_arg) {__VA_ARGS__})
-
-/*
- * SMC call interface
- */
-#define ufs_mtk_va09_pwr_ctrl(res, on) \
-       ufs_mtk_smc(UFS_MTK_SIP_VA09_PWR_CTRL, &(res), on)
-
-#define ufs_mtk_crypto_ctrl(res, enable) \
-       ufs_mtk_smc(UFS_MTK_SIP_CRYPTO_CTRL, &(res), enable)
-
-#define ufs_mtk_ref_clk_notify(on, stage, res) \
-       ufs_mtk_smc(UFS_MTK_SIP_REF_CLK_NOTIFICATION, &(res), on, stage)
-
-#define ufs_mtk_device_reset_ctrl(high, res) \
-       ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, &(res), high)
-
-#define ufs_mtk_host_pwr_ctrl(opt, on, res) \
-       ufs_mtk_smc(UFS_MTK_SIP_HOST_PWR_CTRL, &(res), opt, on)
-
-#define ufs_mtk_get_vcc_num(res) \
-       ufs_mtk_smc(UFS_MTK_SIP_GET_VCC_NUM, &(res))
-
-#define ufs_mtk_device_pwr_ctrl(on, ufs_ver, res) \
-       ufs_mtk_smc(UFS_MTK_SIP_DEVICE_PWR_CTRL, &(res), on, ufs_ver)
-
 #endif /* !_UFS_MEDIATEK_H */
index 8d68bd21ae7332409198b06d7c99d2f7e6faaafe..3a91255036ddd0766c65644d824a891dde18f014 100644 (file)
@@ -278,9 +278,6 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host)
 
        if (host->hw_ver.major >= 0x05)
                ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0);
-
-       /* make sure above configuration is applied before we return */
-       mb();
 }
 
 /*
@@ -409,7 +406,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba)
                    REG_UFS_CFG2);
 
        /* Ensure that HW clock gating is enabled before next operations */
-       mb();
+       ufshcd_readl(hba, REG_UFS_CFG2);
 }
 
 static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,
@@ -501,7 +498,7 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear,
                 * make sure above write gets applied before we return from
                 * this function.
                 */
-               mb();
+               ufshcd_readl(hba, REG_UFS_SYS1CLK_1US);
        }
 
        return 0;
@@ -690,6 +687,16 @@ static struct __ufs_qcom_bw_table ufs_qcom_get_bw_table(struct ufs_qcom_host *ho
        int gear = max_t(u32, p->gear_rx, p->gear_tx);
        int lane = max_t(u32, p->lane_rx, p->lane_tx);
 
+       if (WARN_ONCE(gear > QCOM_UFS_MAX_GEAR,
+                     "ICC scaling for UFS Gear (%d) not supported. Using Gear (%d) bandwidth\n",
+                     gear, QCOM_UFS_MAX_GEAR))
+               gear = QCOM_UFS_MAX_GEAR;
+
+       if (WARN_ONCE(lane > QCOM_UFS_MAX_LANE,
+                     "ICC scaling for UFS Lane (%d) not supported. Using Lane (%d) bandwidth\n",
+                     lane, QCOM_UFS_MAX_LANE))
+               lane = QCOM_UFS_MAX_LANE;
+
        if (ufshcd_is_hs_mode(p)) {
                if (p->hs_rate == PA_HS_MODE_B)
                        return ufs_qcom_bw_table[MODE_HS_RB][gear][lane];
@@ -1210,8 +1217,10 @@ static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
 
        list_for_each_entry(clki, head, list) {
                if (!IS_ERR_OR_NULL(clki->clk) &&
-                       !strcmp(clki->name, "core_clk_unipro")) {
-                       if (is_scale_up)
+                   !strcmp(clki->name, "core_clk_unipro")) {
+                       if (!clki->max_freq)
+                               cycles_in_1us = 150; /* default for backwards compatibility */
+                       else if (is_scale_up)
                                cycles_in_1us = ceil(clki->max_freq, (1000 * 1000));
                        else
                                cycles_in_1us = ceil(clk_get_rate(clki->clk), (1000 * 1000));
@@ -1443,11 +1452,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
                    (u32)host->testbus.select_minor << offset,
                    reg);
        ufs_qcom_enable_test_bus(host);
-       /*
-        * Make sure the test bus configuration is
-        * committed before returning.
-        */
-       mb();
 
        return 0;
 }
index 9dd9a391ebb76273f9e51afcc848ee7a36426e5a..b9de170983c9e13e9687de46cb5bd30331d96eb5 100644 (file)
@@ -151,10 +151,10 @@ static inline void ufs_qcom_assert_reset(struct ufs_hba *hba)
        ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1);
 
        /*
-        * Make sure assertion of ufs phy reset is written to
-        * register before returning
+        * Dummy read to ensure the write takes effect before doing any sort
+        * of delay
         */
-       mb();
+       ufshcd_readl(hba, REG_UFS_CFG1);
 }
 
 static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba)
@@ -162,10 +162,10 @@ static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba)
        ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, 0, REG_UFS_CFG1);
 
        /*
-        * Make sure de-assertion of ufs phy reset is written to
-        * register before returning
+        * Dummy read to ensure the write takes effect before doing any sort
+        * of delay
         */
-       mb();
+       ufshcd_readl(hba, REG_UFS_CFG1);
 }
 
 /* Host controller hardware version: major.minor.step */
index 26d68115afb826b65a9fd11ce329635161e39cca..6dd9a4f9ca7cb5a5d313d18b66807b8a90931180 100644 (file)
@@ -1157,6 +1157,12 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
                                       int queue_depth);
 extern int ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev,
                                  int queue_depth);
+extern int ata_ncq_prio_supported(struct ata_port *ap, struct scsi_device *sdev,
+                                 bool *supported);
+extern int ata_ncq_prio_enabled(struct ata_port *ap, struct scsi_device *sdev,
+                               bool *enabled);
+extern int ata_ncq_prio_enable(struct ata_port *ap, struct scsi_device *sdev,
+                              bool enable);
 extern struct ata_device *ata_dev_pair(struct ata_device *adev);
 extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
 extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
index f5257103fdb6d8e4bfa007f7acebf84b4f58d353..d06a0570f4c530a45ffafe04a57566e01538863b 100644 (file)
@@ -726,4 +726,33 @@ void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
 void sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event,
                           gfp_t gfp_flags);
 
+#define __LIBSAS_SHT_BASE                                              \
+       .module                         = THIS_MODULE,                  \
+       .name                           = DRV_NAME,                     \
+       .proc_name                      = DRV_NAME,                     \
+       .queuecommand                   = sas_queuecommand,             \
+       .dma_need_drain                 = ata_scsi_dma_need_drain,      \
+       .target_alloc                   = sas_target_alloc,             \
+       .change_queue_depth             = sas_change_queue_depth,       \
+       .bios_param                     = sas_bios_param,               \
+       .this_id                        = -1,                           \
+       .eh_device_reset_handler        = sas_eh_device_reset_handler,  \
+       .eh_target_reset_handler        = sas_eh_target_reset_handler,  \
+       .target_destroy                 = sas_target_destroy,           \
+       .ioctl                          = sas_ioctl,                    \
+
+#ifdef CONFIG_COMPAT
+#define _LIBSAS_SHT_BASE               __LIBSAS_SHT_BASE               \
+       .compat_ioctl                   = sas_ioctl,
+#else
+#define _LIBSAS_SHT_BASE               __LIBSAS_SHT_BASE
+#endif
+
+#define LIBSAS_SHT_BASE                        _LIBSAS_SHT_BASE                \
+       .slave_configure                = sas_slave_configure,          \
+       .slave_alloc                    = sas_slave_alloc,              \
+
+#define LIBSAS_SHT_BASE_NO_SLAVE_INIT  _LIBSAS_SHT_BASE
+
+
 #endif /* _SASLIB_H_ */
index 2f8c719840a6e742cc5d9bbc6d21f2fd79e66975..92e27e7bf08819d739f2e42f1bb0884d473f8b01 100644 (file)
@@ -39,6 +39,9 @@ int smp_ata_check_ready_type(struct ata_link *link);
 int sas_discover_sata(struct domain_device *dev);
 int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy,
                    struct domain_device *child, int phy_id);
+
+extern const struct attribute_group sas_ata_sdev_attr_group;
+
 #else
 
 static inline void sas_ata_disabled_notice(void)
@@ -123,6 +126,9 @@ static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *p
        sas_ata_disabled_notice();
        return -ENODEV;
 }
+
+#define sas_ata_sdev_attr_group ((struct attribute_group) {})
+
 #endif
 
 #endif /* _SAS_ATA_H_ */
index 4ce1988b2ba01c6a92a09f998346ea4c0ea29b19..5c6724322112ab3f2124ba9b396561e6d6ce5e59 100644 (file)
@@ -22,7 +22,9 @@ struct scsi_driver {
 #define to_scsi_driver(drv) \
        container_of((drv), struct scsi_driver, gendrv)
 
-extern int scsi_register_driver(struct device_driver *);
+#define scsi_register_driver(drv) \
+       __scsi_register_driver(drv, THIS_MODULE)
+int __scsi_register_driver(struct device_driver *, struct module *);
 #define scsi_unregister_driver(drv) \
        driver_unregister(drv);
 
index cb2afcebbdf5147c9f5f6c36f25f13084d3102a9..a35e12f8e68baa8b1baf45d5234dff62af91813e 100644 (file)
@@ -328,6 +328,7 @@ struct ufs_pwr_mode_info {
  * @op_runtime_config: called to config Operation and runtime regs Pointers
  * @get_outstanding_cqs: called to get outstanding completion queues
  * @config_esi: called to config Event Specific Interrupt
+ * @config_scsi_dev: called to configure SCSI device parameters
  */
 struct ufs_hba_variant_ops {
        const char *name;
index a196e1c4c3bb0596b6d3d5070d32aa9e84c3b870..88193f5540e5c6fc56beeb49746544827d4364c4 100644 (file)
@@ -426,7 +426,7 @@ union ufs_crypto_cfg_entry {
  */
 
 /* Transfer request command type */
-enum {
+enum utp_cmd_type {
        UTP_CMD_TYPE_SCSI               = 0x0,
        UTP_CMD_TYPE_UFS                = 0x1,
        UTP_CMD_TYPE_DEV_MANAGE         = 0x2,