From 171b1d54e85474623aa863f1045d52eee3a07b90 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:43:47 +0000 Subject: [PATCH 1/6] scst_vdisk: Restore support for adding a block device with non-existent filename This patch is a fix for commit df4c250b8db5 ("scst_vdisk: Port to Linux kernel v5.11"). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9595 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index b2137e67a..ef0bec8ea 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1347,6 +1347,12 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only) virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, virt_dev->bdev_mode, (void *)__func__); res = IS_ERR(virt_dev->bdev) ? PTR_ERR(virt_dev->bdev) : 0; + if ((!virt_dev->dev_active) && (res == -ENOENT)) + { + TRACE_MGMT_DBG("Skip opening for not active dev %s", + virt_dev->dev->virt_name); + res = -EMEDIUMTYPE; + } } else { virt_dev->fd = vdev_open_fd(virt_dev, virt_dev->filename, read_only); From 47ba05f2a7e80408d78d7e4fcb917d5a4ec93521 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:44:44 +0000 Subject: [PATCH 2/6] scst_vdisk: Rework the most recent fix Instead of making vdev_open_fd() check the dev_active flag, let the callers of this function check that flag. This patch does not change the behavior of the scst_vdisk driver. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9596 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index ef0bec8ea..d7d757768 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -371,13 +371,6 @@ static struct file *vdev_open_fd(const struct scst_vdisk_dev *virt_dev, sBUG_ON(!name); - if (!virt_dev->dev_active) { - TRACE_MGMT_DBG("Skip opening for not active dev %s", - virt_dev->dev->virt_name); - fd = ERR_PTR(-EMEDIUMTYPE); - goto out; - } - if (read_only) open_flags |= O_RDONLY; else @@ -395,7 +388,6 @@ static struct file *vdev_open_fd(const struct scst_vdisk_dev *virt_dev, PRINT_ERROR("filp_open(%s) failed: %d", name, (int)PTR_ERR(fd)); } -out: TRACE_EXIT(); return fd; } @@ -1191,7 +1183,7 @@ next: } } - if (virt_dev->dif_filename != NULL) { + if (virt_dev->dev_active && virt_dev->dif_filename != NULL) { /* Check if it can be used */ struct file *dfd = vdev_open_fd(virt_dev, virt_dev->dif_filename, virt_dev->rd_only); @@ -1340,19 +1332,17 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only) sBUG_ON(!virt_dev->filename); sBUG_ON(vdisk_is_open(virt_dev)); - if (virt_dev->blockio) { + if (!virt_dev->dev_active) { + TRACE_MGMT_DBG("Skip opening for not active dev %s", + virt_dev->dev->virt_name); + res = -EMEDIUMTYPE; + } else if (virt_dev->blockio) { virt_dev->bdev_mode = FMODE_READ; if (!read_only) virt_dev->bdev_mode |= FMODE_WRITE; virt_dev->bdev = blkdev_get_by_path(virt_dev->filename, virt_dev->bdev_mode, (void *)__func__); res = IS_ERR(virt_dev->bdev) ? PTR_ERR(virt_dev->bdev) : 0; - if ((!virt_dev->dev_active) && (res == -ENOENT)) - { - TRACE_MGMT_DBG("Skip opening for not active dev %s", - virt_dev->dev->virt_name); - res = -EMEDIUMTYPE; - } } else { virt_dev->fd = vdev_open_fd(virt_dev, virt_dev->filename, read_only); From c8b3b06b2bae8bf5c1a1acb49e8622d03590ceac Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:47:29 +0000 Subject: [PATCH 3/6] scst: Backport the scsi_done() function The scsi_done() function is new in kernel v5.16. Backport it to older kernel versions. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9597 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index ea69927d2..809d22062 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -2267,6 +2267,16 @@ static inline u32 scsi_prot_ref_tag(struct scsi_cmnd *scmd) #endif #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +/* + * See also commit 11b68e36b167 ("scsi: core: Call scsi_done directly"; v5.16) + */ +static inline void scsi_done(struct scsi_cmnd *cmd) +{ + return cmd->scsi_done(cmd); +} +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) From 0f9f9eeb3a0c5b7c72a896d0d2739aa6dcb4a284 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:48:08 +0000 Subject: [PATCH 4/6] scst: Port to Linux kernel v5.16 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9598 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 16 +++++++- scst/src/scst_lib.c | 65 +++++++++++++++++++----------- scst/src/scst_pres.c | 4 ++ 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index d7d757768..fd87a774e 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -44,6 +44,9 @@ #else #include #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#include +#endif #include #include #include @@ -3188,7 +3191,11 @@ static bool vdisk_alloc_async_kvec(struct scst_cmd *cmd, return true; } -static void fileio_async_complete(struct kiocb *iocb, long ret, long ret2) +static void fileio_async_complete(struct kiocb *iocb, long ret +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) + , long ret2 +#endif + ) { struct vdisk_cmd_params *p = container_of(iocb, typeof(*p), async.iocb); struct scst_cmd *cmd = p->cmd; @@ -3290,8 +3297,13 @@ static enum compl_status_e fileio_exec_async(struct vdisk_cmd_params *p) } if (p->async.kvec != p->async.small_kvec) kfree(p->async.kvec); - if (ret != -EIOCBQUEUED) + if (ret != -EIOCBQUEUED) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) fileio_async_complete(iocb, ret, 0); +#else + fileio_async_complete(iocb, ret); +#endif + } /* * Return RUNNING_ASYNC even if fileio_async_complete() has been * called because that function calls cmd->scst_cmd_done(). diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 444ca46ef..ec22e0176 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8213,7 +8213,7 @@ static void bio_kmalloc_destructor(struct bio *bio) #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) -static blk_mq_req_flags_t gfp_mask_to_flags(gfp_t gfp_mask) +static blk_mq_req_flags_t scst_gfp_mask_to_flags(gfp_t gfp_mask) { switch (gfp_mask) { case GFP_KERNEL: @@ -8228,6 +8228,35 @@ static blk_mq_req_flags_t gfp_mask_to_flags(gfp_t gfp_mask) } #endif +/** + * scst_alloc_passthrough_request - Allocate a SCSI pass-through request. + * @q: Request queue. + * @rw: READ or WRITE. + * @gfp_mask: GFP_KERNEL, GFP_ATOMIC or GFP_NOIO. + * + * Returns + * A valid request pointer, NULL or an error pointer. The value NULL is only + * returned for the legacy block layer if allocation fails. The legacy block + * layer is only supported by kernel versions before v5.0. + */ +static inline struct request * +scst_alloc_passthrough_request(struct request_queue *q, int rw, gfp_t gfp_mask) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) + return blk_get_request(q, rw, gfp_mask); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) + return blk_get_request(q, rw == READ ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT, + gfp_mask); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) + return blk_get_request(q, rw == READ ? REQ_OP_SCSI_IN : REQ_OP_SCSI_OUT, + scst_gfp_mask_to_flags(gfp_mask)); +#else + return blk_mq_alloc_request(q, rw == READ ? REQ_OP_DRV_IN : + rw == READ ? REQ_OP_DRV_IN : REQ_OP_DRV_OUT, + scst_gfp_mask_to_flags(gfp_mask)); +#endif +} + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \ (defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) static struct request *blk_make_request(struct request_queue *q, @@ -8236,17 +8265,8 @@ static struct request *blk_make_request(struct request_queue *q, { struct request *rq; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) - rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) - rq = blk_get_request(q, bio_data_dir(bio) == READ ? REQ_OP_SCSI_IN : - REQ_OP_SCSI_OUT, gfp_mask); -#else - rq = blk_get_request(q, bio_data_dir(bio) == READ ? REQ_OP_SCSI_IN : - REQ_OP_SCSI_OUT, gfp_mask_to_flags(gfp_mask)); -#endif - - if (IS_ERR(rq)) + rq = scst_alloc_passthrough_request(q, bio_data_dir(bio), gfp_mask); + if (IS_ERR_OR_NULL(rq)) return rq; #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) @@ -8280,7 +8300,11 @@ static struct request *blk_make_request(struct request_queue *q, ret = blk_rq_append_bio(rq, bio); #endif if (unlikely(ret)) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) blk_put_request(rq); +#else + blk_mq_free_request(rq); +#endif return ERR_PTR(ret); } } @@ -8469,16 +8493,9 @@ static struct request *blk_map_kern_sg(struct request_queue *q, struct request *rq; if (!sgl) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) - rq = blk_get_request(q, reading ? READ : WRITE, gfp); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0) - rq = blk_get_request(q, reading ? REQ_OP_SCSI_IN : - REQ_OP_SCSI_OUT, gfp); -#else - rq = blk_get_request(q, reading ? REQ_OP_SCSI_IN : - REQ_OP_SCSI_OUT, gfp_mask_to_flags(gfp)); -#endif - if (unlikely(!rq)) + rq = scst_alloc_passthrough_request(q, reading ? READ : WRITE, + gfp); + if (unlikely(IS_ERR_OR_NULL(rq))) return ERR_PTR(-ENOMEM); #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) @@ -8728,8 +8745,10 @@ static void scsi_end_async(struct request *req, blk_status_t error) (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 8) /* See also commit 92bc5a24844a ("block: remove __blk_put_request()") */ __blk_put_request(req->q, req); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) blk_put_request(req); +#else + blk_mq_free_request(req); #endif return; } diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index f38b53cdc..d9404bb10 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -41,7 +41,11 @@ #endif #include #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) #include +#else +#include +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) #include From af579d68c35b7746b8aaa37455a35074f3bd0d02 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:48:38 +0000 Subject: [PATCH 5/6] scst_local: Port to Linux kernel v5.16 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9599 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst_local/scst_local.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index 2715d61aa..081150be8 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -925,7 +925,7 @@ static int scst_local_queuecommand_lck(struct scsi_cmnd *scmd, if (sess->unregistering) { scmd->result = DID_BAD_TARGET << 16; - scmd->scsi_done(scmd); + scsi_done(scmd); return 0; } @@ -1420,7 +1420,11 @@ static int scst_local_targ_xmit_response(struct scst_cmd *scst_cmd) done = tgt_specific->done; #else scmd = scst_cmd_get_tgt_priv(scst_cmd); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) done = scmd->scsi_done; +#else + done = scsi_done; +#endif #endif /* From 6b8b4a8004ca98d498a1f9d1969e2a7942d87c36 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 22 Nov 2021 03:49:47 +0000 Subject: [PATCH 6/6] qla2x00t: Port to Linux kernel v5.16 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9600 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_attr.c | 75 +++++++++++++++++++++++++++++++++++++- qla2x00t-32gbit/qla_gbl.h | 6 +++ qla2x00t-32gbit/qla_os.c | 14 +++++-- qla2x00t/qla_attr.c | 48 ++++++++++++++++++++++++ qla2x00t/qla_gbl.h | 4 ++ qla2x00t/qla_os.c | 18 ++++++++- 6 files changed, 158 insertions(+), 7 deletions(-) diff --git a/qla2x00t-32gbit/qla_attr.c b/qla2x00t-32gbit/qla_attr.c index d09776b77..020b52f3e 100644 --- a/qla2x00t-32gbit/qla_attr.c +++ b/qla2x00t-32gbit/qla_attr.c @@ -2461,7 +2461,7 @@ static DEVICE_ATTR(port_no, 0444, qla2x00_port_no_show, NULL); static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL); static DEVICE_ATTR_RO(edif_doorbell); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) struct device_attribute *qla2x00_host_attrs[] = { &dev_attr_driver_version, &dev_attr_fw_version, @@ -2527,6 +2527,79 @@ void qla_insert_tgt_attrs(void) attr++; *attr = &dev_attr_ql2xexchoffld; } +#else +static struct attribute *qla2x00_host_attrs[] = { + &dev_attr_driver_version.attr, + &dev_attr_fw_version.attr, + &dev_attr_serial_num.attr, + &dev_attr_isp_name.attr, + &dev_attr_isp_id.attr, + &dev_attr_model_name.attr, + &dev_attr_model_desc.attr, + &dev_attr_pci_info.attr, + &dev_attr_link_state.attr, + &dev_attr_zio.attr, + &dev_attr_zio_timer.attr, + &dev_attr_beacon.attr, + &dev_attr_beacon_config.attr, + &dev_attr_optrom_bios_version.attr, + &dev_attr_optrom_efi_version.attr, + &dev_attr_optrom_fcode_version.attr, + &dev_attr_optrom_fw_version.attr, + &dev_attr_84xx_fw_version.attr, + &dev_attr_total_isp_aborts.attr, + &dev_attr_serdes_version.attr, + &dev_attr_mpi_version.attr, + &dev_attr_phy_version.attr, + &dev_attr_flash_block_size.attr, + &dev_attr_vlan_id.attr, + &dev_attr_vn_port_mac_address.attr, + &dev_attr_fabric_param.attr, + &dev_attr_fw_state.attr, + &dev_attr_optrom_gold_fw_version.attr, + &dev_attr_thermal_temp.attr, + &dev_attr_diag_requests.attr, + &dev_attr_diag_megabytes.attr, + &dev_attr_fw_dump_size.attr, + &dev_attr_allow_cna_fw_dump.attr, + &dev_attr_pep_version.attr, + &dev_attr_min_supported_speed.attr, + &dev_attr_max_supported_speed.attr, + &dev_attr_zio_threshold.attr, + &dev_attr_dif_bundle_statistics.attr, + &dev_attr_port_speed.attr, + &dev_attr_port_no.attr, + &dev_attr_fw_attr.attr, + &dev_attr_dport_diagnostics.attr, + &dev_attr_edif_doorbell.attr, + &dev_attr_mpi_pause.attr, + &dev_attr_qlini_mode.attr, + &dev_attr_ql2xiniexchg.attr, + &dev_attr_ql2xexchoffld.attr, + NULL, +}; + +static umode_t qla_host_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int i) +{ + if (ql2x_ini_mode != QLA2XXX_INI_MODE_DUAL && + (attr == &dev_attr_qlini_mode.attr || + attr == &dev_attr_ql2xiniexchg.attr || + attr == &dev_attr_ql2xexchoffld.attr)) + return 0; + return attr->mode; +} + +static const struct attribute_group qla2x00_host_attr_group = { + .is_visible = qla_host_attr_is_visible, + .attrs = qla2x00_host_attrs +}; + +const struct attribute_group *qla2x00_host_groups[] = { + &qla2x00_host_attr_group, + NULL +}; +#endif /* Host attributes. */ diff --git a/qla2x00t-32gbit/qla_gbl.h b/qla2x00t-32gbit/qla_gbl.h index 1faa817b6..8422573b8 100644 --- a/qla2x00t-32gbit/qla_gbl.h +++ b/qla2x00t-32gbit/qla_gbl.h @@ -742,7 +742,11 @@ uint qla25xx_fdmi_port_speed_currently(struct qla_hw_data *); * Global Function Prototypes in qla_attr.c source file. */ struct device_attribute; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) extern struct device_attribute *qla2x00_host_attrs[]; +#else +extern const struct attribute_group *qla2x00_host_groups[]; +#endif extern struct device_attribute *qla2x00_host_attrs_dm[]; struct fc_function_template; extern struct fc_function_template qla2xxx_transport_functions; @@ -757,7 +761,9 @@ extern int qla2x00_echo_test(scsi_qla_host_t *, extern int qla24xx_update_all_fcp_prio(scsi_qla_host_t *); extern int qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t *, struct qla_fcp_prio_cfg *, uint8_t); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) void qla_insert_tgt_attrs(void); +#endif /* * Global Function Prototypes in qla_dfs.c source file. */ diff --git a/qla2x00t-32gbit/qla_os.c b/qla2x00t-32gbit/qla_os.c index 9fcb40c43..e7f04658c 100644 --- a/qla2x00t-32gbit/qla_os.c +++ b/qla2x00t-32gbit/qla_os.c @@ -757,7 +757,7 @@ void qla2x00_sp_compl(srb_t *sp, int res) sp->free(sp); cmd->result = res; CMD_SP(cmd) = NULL; - cmd->scsi_done(cmd); + scsi_done(cmd); if (comp) complete(comp); } @@ -848,7 +848,7 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, int res) sp->free(sp); cmd->result = res; CMD_SP(cmd) = NULL; - cmd->scsi_done(cmd); + scsi_done(cmd); if (comp) complete(comp); } @@ -987,7 +987,7 @@ qc24_target_busy: return SCSI_MLQUEUE_TARGET_BUSY; qc24_fail_command: - cmd->scsi_done(cmd); + scsi_done(cmd); return 0; } @@ -1075,7 +1075,7 @@ qc24_target_busy: return SCSI_MLQUEUE_TARGET_BUSY; qc24_fail_command: - cmd->scsi_done(cmd); + scsi_done(cmd); return 0; } @@ -8039,7 +8039,11 @@ struct scsi_host_template qla2xxx_driver_template = { .sg_tablesize = SG_ALL, .max_sectors = 0xFFFF, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) .shost_attrs = qla2x00_host_attrs, +#else + .shost_groups = qla2x00_host_groups, +#endif .supported_mode = MODE_INITIATOR, #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) @@ -8252,8 +8256,10 @@ qla2x00_module_init(void) if (ql2xextended_error_logging == 1) ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) if (ql2x_ini_mode == QLA2XXX_INI_MODE_DUAL) qla_insert_tgt_attrs(); +#endif qla2xxx_transport_template = fc_attach_transport(&qla2xxx_transport_functions); diff --git a/qla2x00t/qla_attr.c b/qla2x00t/qla_attr.c index 99ca9e2af..d6c2bef7c 100644 --- a/qla2x00t/qla_attr.c +++ b/qla2x00t/qla_attr.c @@ -1803,6 +1803,7 @@ static DEVICE_ATTR(fabric_param, S_IRUGO, qla2x00_fabric_param_show, NULL); static DEVICE_ATTR(fw_state, S_IRUGO, qla2x00_fw_state_show, NULL); static DEVICE_ATTR(thermal_temp, S_IRUGO, qla2x00_thermal_temp_show, NULL); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) struct device_attribute *qla2x00_host_attrs[] = { &dev_attr_driver_version, &dev_attr_fw_version, @@ -1839,6 +1840,53 @@ struct device_attribute *qla2x00_host_attrs[] = { &dev_attr_thermal_temp, NULL, }; +#else +static struct attribute *qla2x00_host_attrs[] = { + &dev_attr_driver_version.attr, + &dev_attr_fw_version.attr, + &dev_attr_serial_num.attr, + &dev_attr_isp_name.attr, + &dev_attr_isp_id.attr, + &dev_attr_model_name.attr, + &dev_attr_model_desc.attr, + &dev_attr_pci_info.attr, + &dev_attr_link_state.attr, + &dev_attr_zio.attr, + &dev_attr_zio_timer.attr, + &dev_attr_beacon.attr, + &dev_attr_optrom_bios_version.attr, + &dev_attr_optrom_efi_version.attr, + &dev_attr_optrom_fcode_version.attr, + &dev_attr_optrom_fw_version.attr, + &dev_attr_84xx_fw_version.attr, + &dev_attr_class2_enabled.attr, +#ifdef CONFIG_SCSI_QLA2XXX_TARGET + &dev_attr_ini_mode_force_reverse.attr, + &dev_attr_resource_counts.attr, + &dev_attr_port_database.attr, +#endif + &dev_attr_total_isp_aborts.attr, + &dev_attr_mpi_version.attr, + &dev_attr_phy_version.attr, + &dev_attr_flash_block_size.attr, + &dev_attr_vlan_id.attr, + &dev_attr_vn_port_mac_address.attr, + &dev_attr_fabric_param.attr, + &dev_attr_fw_state.attr, + &dev_attr_optrom_gold_fw_version.attr, + &dev_attr_thermal_temp.attr, + NULL, +}; + +static const struct attribute_group qla2x00_host_attr_group = { + .attrs = qla2x00_host_attrs +}; + +const struct attribute_group *qla2x00_host_groups[] = { + &qla2x00_host_attr_group, + NULL +}; +#endif /* Host attributes. */ diff --git a/qla2x00t/qla_gbl.h b/qla2x00t/qla_gbl.h index 0bd4d3360..936bc2dab 100644 --- a/qla2x00t/qla_gbl.h +++ b/qla2x00t/qla_gbl.h @@ -496,7 +496,11 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *); * Global Function Prototypes in qla_attr.c source file. */ struct device_attribute; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) extern struct device_attribute *qla2x00_host_attrs[]; +#else +extern const struct attribute_group *qla2x00_host_groups[]; +#endif struct fc_function_template; extern struct fc_function_template qla2xxx_transport_functions; extern struct fc_function_template qla2xxx_transport_vport_functions; diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index 0e86d1df5..62df19e61 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -249,8 +249,12 @@ static int qla2xxx_slave_alloc(struct scsi_device *); static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); static void qla2xxx_scan_start(struct Scsi_Host *); static void qla2xxx_slave_destroy(struct scsi_device *); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) static int qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)); +#else +static int qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd); +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) static DEF_SCSI_QCMD(qla2xxx_queuecommand); #endif @@ -306,7 +310,11 @@ struct scsi_host_template qla2xxx_driver_template = { .sg_tablesize = SG_ALL, .max_sectors = 0xFFFF, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) .shost_attrs = qla2x00_host_attrs, +#else + .shost_groups = qla2x00_host_groups, +#endif #ifdef CONFIG_SCSI_QLA2XXX_TARGET .supported_mode = MODE_INITIATOR | MODE_TARGET, #endif /* CONFIG_SCSI_QLA2XXX_TARGET */ @@ -674,11 +682,15 @@ qla2x00_sp_compl(void *data, void *ptr, int res) return; qla2x00_sp_free_dma(ha, sp); - cmd->scsi_done(cmd); + scsi_done(cmd); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) static int qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) +#else +static int qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd) +#endif { scsi_qla_host_t *vha = shost_priv(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; @@ -757,7 +769,9 @@ qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *) sp->type = SRB_SCSI_CMD; atomic_set(&sp->ref_count, 1); CMD_SP(cmd) = (void *)sp; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) cmd->scsi_done = done; +#endif sp->free = qla2x00_sp_free_dma; sp->done = qla2x00_sp_compl; @@ -785,7 +799,7 @@ qc24_target_busy: qc24_fail_command: spin_lock_irq(vha->host->host_lock); - done(cmd); + scsi_done(cmd); return 0; }