Re: [PATCH 1/1] scsi/ufshcd: Fix NULL pointer dereference for in ufshcd_init
Hi Martin, On Wed, Aug 29, 2018 at 1:50 PM Vivek Gautam wrote: > > On Wed, Aug 29, 2018 at 1:13 AM Evan Green wrote: > > > > On Tue, Aug 7, 2018 at 10:48 AM Vivek Gautam > > wrote: > > > > > > Error paths in ufshcd_init() ufshcd_hba_exit() killed clk_scaling > > > workqueue when the workqueue is actually created quite late in > > > ufshcd_init(). > > > So, we end up getting NULL pointer dereference in such error paths. > > > Fix this by moving clk_scaling initialization and kill codes to > > > two separate methods, and call them at required places. > > > > > > Fixes: 401f1e4490ee ("scsi: ufs: don't suspend clock scaling during clock > > > gating") > > > > > > Signed-off-by: Vivek Gautam > > > Cc: Bjorn Andersson > > > Cc: Subhash Jadavani > > > Cc: Matthias Kaehlcke > > > Cc: Evan Green > > > Cc: Martin K. Petersen > > > --- > > > > > > Bjorn, Subhash, > > > I am not certain of some of these devfreq, and clk_scaling bits > > > that are moved as part of this patch. Please help in reviewing the > > > change in the light of these features, and related sequence should > > > be followed. > > > Thanks. > > > > > > > You're right, there is a lot of logic moving around here. I think this > > looks okay to me. > > > > Reviewed-by: Evan Green > > Thanks Evan. > > Best regards > Vivek Gentle ping. Will you please consider picking this patch for the merge? Thanks Vivek -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 2/3] scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls from host
Hi Martin, On Mon, Sep 24, 2018 at 10:51 PM Bjorn Andersson wrote: > > On Tue 04 Sep 03:17 PDT 2018, Vivek Gautam wrote: > > > The host makes direct calls into phy using ufs_qcom_phy_*() > > APIs. These APIs are only defined for 20nm qcom-ufs-qmp phy > > which is not being used by any architecture as yet. Future > > architectures too are not going to use 20nm ufs phy. > > So remove these ufs_qcom_phy_*() calls from host to let further > > change declare the 20nm phy as broken. > > Also remove couple of stale enum defines for ufs phy. > > > > Signed-off-by: Vivek Gautam > > Reviewed-by: Bjorn Andersson > > Regards, > Bjorn Kishon is looking to pick this series through linux-phy tree. Will you please consider giving your ack for this patch? Thanks. Best regards Vivek > > > --- > > drivers/phy/qualcomm/phy-qcom-ufs-i.h | 2 +- > > drivers/scsi/ufs/ufs-qcom.c | 28 +--- > > drivers/scsi/ufs/ufs-qcom.h | 5 - > > include/linux/phy/phy-qcom-ufs.h | 24 > > 4 files changed, 2 insertions(+), 57 deletions(-) > > delete mode 100644 include/linux/phy/phy-qcom-ufs.h > > > > diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-i.h > > b/drivers/phy/qualcomm/phy-qcom-ufs-i.h > > index 822c83b8efcd..681644e43248 100644 > > --- a/drivers/phy/qualcomm/phy-qcom-ufs-i.h > > +++ b/drivers/phy/qualcomm/phy-qcom-ufs-i.h > > @@ -17,9 +17,9 @@ > > > > #include > > #include > > +#include > > #include > > #include > > -#include > > #include > > #include > > #include > > diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c > > index 75ee5906b966..3dc4501c6945 100644 > > --- a/drivers/scsi/ufs/ufs-qcom.c > > +++ b/drivers/scsi/ufs/ufs-qcom.c > > @@ -16,7 +16,6 @@ > > #include > > #include > > #include > > -#include > > > > #include "ufshcd.h" > > #include "ufshcd-pltfrm.h" > > @@ -189,22 +188,9 @@ static int ufs_qcom_init_lane_clks(struct > > ufs_qcom_host *host) > > > > static int ufs_qcom_link_startup_post_change(struct ufs_hba *hba) > > { > > - struct ufs_qcom_host *host = ufshcd_get_variant(hba); > > - struct phy *phy = host->generic_phy; > > u32 tx_lanes; > > - int err = 0; > > - > > - err = ufs_qcom_get_connected_tx_lanes(hba, &tx_lanes); > > - if (err) > > - goto out; > > > > - err = ufs_qcom_phy_set_tx_lane_enable(phy, tx_lanes); > > - if (err) > > - dev_err(hba->dev, "%s: ufs_qcom_phy_set_tx_lane_enable > > failed\n", > > - __func__); > > - > > -out: > > - return err; > > + return ufs_qcom_get_connected_tx_lanes(hba, &tx_lanes); > > } > > > > static int ufs_qcom_check_hibern8(struct ufs_hba *hba) > > @@ -932,10 +918,8 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba > > *hba, > > { > > u32 val; > > struct ufs_qcom_host *host = ufshcd_get_variant(hba); > > - struct phy *phy = host->generic_phy; > > struct ufs_qcom_dev_params ufs_qcom_cap; > > int ret = 0; > > - int res = 0; > > > > if (!dev_req_params) { > > pr_err("%s: incoming dev_req_params is NULL\n", __func__); > > @@ -1002,12 +986,6 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba > > *hba, > > } > > > > val = ~(MAX_U32 << dev_req_params->lane_tx); > > - res = ufs_qcom_phy_set_tx_lane_enable(phy, val); > > - if (res) { > > - dev_err(hba->dev, "%s: > > ufs_qcom_phy_set_tx_lane_enable() failed res = %d\n", > > - __func__, res); > > - ret = res; > > - } > > > > /* cache the power mode parameters to use internally */ > > memcpy(&host->dev_req_params, > > @@ -1264,10 +1242,6 @@ static int ufs_qcom_init(struct ufs_hba *hba) > > } > > } > > > > - /* update phy revision information before calling phy_init() */ > > - ufs_qcom_phy_save_controller_version(host->generic_phy, > > - host->hw_ver.major, host->hw_ver.minor, host->hw_ver.step); > > - > > err = ufs_qcom_init_lane_clks(host); > > if (err) > > goto out_variant_clear; > > diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h > > index 295f4bef6a0e..c114826316eb 100644 > > --- a/drivers/scsi/ufs/ufs-qcom.h > > +++ b/drivers/scsi/ufs/ufs-qcom.h > > @@ -129,11 +129,6 @@ enum { > > MASK_CLK_NS_REG = 0xFFFC00, > > }; > > > > -enum ufs_qcom_phy_init_type { > > - UFS_PHY_INIT_FULL, > > - UFS_PHY_INIT_CFG_RESTORE, > > -}; > > - > > /* QCOM UFS debug print bit mask */ > > #define UFS_QCOM_DBG_PRINT_REGS_EN BIT(0) > > #define UFS_QCOM_DBG_PRINT_ICE_REGS_EN BIT(1) > > diff --git a/include/linux/phy/phy-qcom-ufs.h > > b/include/linux/phy/phy-qcom-ufs.h > > deleted file mode 100644 > > index 9dd85071bcce.. > > --- a/include/linux/phy/phy-qcom-ufs.h > > +++
Re: [PATCH v4 1/2] dt-bindings: ufs: Add bindings for Cadence UFS
On Thu, Sep 20, 2018 at 01:08:22PM +, Janek Kotas wrote: > This patch adds a DT binding documentation for > Cadence UFS Host Controller. > > Signed-off-by: Jan Kotas > --- > .../devicetree/bindings/ufs/cdns,ufshc.txt | 31 > ++ > 1 file changed, 31 insertions(+) > create mode 100644 Documentation/devicetree/bindings/ufs/cdns,ufshc.txt Reviewed-by: Rob Herring
[GIT PULL] SCSI fixes for 4.19-rc5
Nine obvious bug fixes mostly in individual drivers. The target fix is of particular importance because it's CVE related. The patch is available here: git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes The short changelog is: Adrian Hunter (1): scsi: ufs: Disable blk-mq for now James Smart (1): scsi: lpfc: Synchronize access to remoteport via rport Johannes Thumshirn (1): scsi: sd: don't crash the host on invalid commands Laura Abbott (2): scsi: ibmvscsis: Ensure partition name is properly NUL terminated scsi: ibmvscsis: Fix a stringop-overflow warning Vincent Pelletier (2): scsi: target: iscsi: Use bin2hex instead of a re-implementation scsi: target: iscsi: Use hex2bin instead of a re-implementation Wen Xiong (1): scsi: ipr: System hung while dlpar adding primary ipr adapter back Xuewei Zhang (1): scsi: sd: Contribute to randomness when running rotational device And the diffstat: drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 +- drivers/scsi/ipr.c | 106 ++- drivers/scsi/ipr.h | 1 + drivers/scsi/lpfc/lpfc_attr.c| 15 +++-- drivers/scsi/lpfc/lpfc_debugfs.c | 10 +-- drivers/scsi/lpfc/lpfc_nvme.c| 11 +++- drivers/scsi/sd.c| 6 +- drivers/scsi/ufs/ufshcd.c| 7 ++ drivers/target/iscsi/iscsi_target_auth.c | 45 + 9 files changed, 116 insertions(+), 90 deletions(-) With full diff below. James --- diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index fac377320158..f42a619198c4 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -3474,11 +3474,10 @@ static int ibmvscsis_probe(struct vio_dev *vdev, vscsi->dds.window[LOCAL].liobn, vscsi->dds.window[REMOTE].liobn); - strcpy(vscsi->eye, "VSCSI "); - strncat(vscsi->eye, vdev->name, MAX_EYE); + snprintf(vscsi->eye, sizeof(vscsi->eye), "VSCSI %s", vdev->name); vscsi->dds.unit_id = vdev->unit_address; - strncpy(vscsi->dds.partition_name, partition_name, + strscpy(vscsi->dds.partition_name, partition_name, sizeof(vscsi->dds.partition_name)); vscsi->dds.partition_num = partition_number; diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index f2ec80b0ffc0..271990bc065b 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -3335,6 +3335,65 @@ static void ipr_release_dump(struct kref *kref) LEAVE; } +static void ipr_add_remove_thread(struct work_struct *work) +{ + unsigned long lock_flags; + struct ipr_resource_entry *res; + struct scsi_device *sdev; + struct ipr_ioa_cfg *ioa_cfg = + container_of(work, struct ipr_ioa_cfg, scsi_add_work_q); + u8 bus, target, lun; + int did_work; + + ENTER; + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + +restart: + do { + did_work = 0; + if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds) { + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + return; + } + + list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { + if (res->del_from_ml && res->sdev) { + did_work = 1; + sdev = res->sdev; + if (!scsi_device_get(sdev)) { + if (!res->add_to_ml) + list_move_tail(&res->queue, &ioa_cfg->free_res_q); + else + res->del_from_ml = 0; + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + scsi_remove_device(sdev); + scsi_device_put(sdev); + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + } + break; + } + } + } while (did_work); + + list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { + if (res->add_to_ml) { + bus = res->bus; + target = res->target; + lun = res->lun; + res->add_to_ml = 0; + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + scsi_add_device(ioa_cfg->host, bus, target, lun); + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + goto restart; + } + } + + ioa_cfg->scan_done = 1; + spin_unl
Re: [GIT PULL] SCSI fixes for 4.19-rc5
On Tue, Sep 25, 2018 at 08:34:52AM -0700, James Bottomley wrote: > Nine obvious bug fixes mostly in individual drivers. The target fix is > of particular importance because it's CVE related. > > The patch is available here: > > git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes Now pulled, thanks. greg k-h
duplicate check for CAP_SYS_RAWIO
Kernel Version: 4.18.5 Problem Description: We found a path where duplicate capability checks are observed, the path is : scsi_ioctl<- require CAP_SYS_ADMIN and CAP_SYS_RAWIO `->sg_scsi_ioctl() `->blk_verify_command() <- require CAP_SYS_RAWIO CAP_SYS_RAWIO is checked twice. related file: block/scsi_ioctl.c:215 block/scsi_ioctl.c:471 drivers/scsi/scsi_ioctl.c:240 drivers/scsi/scsi_ioctl.c:242 - Tong
Re: [PATCH v4] scsi: ufs: Make sysfs attributes writable
Hi, On Tue, Sep 4, 2018 at 3:29 AM Adrian Hunter wrote: > > On 22/08/18 14:00, Adrian Hunter wrote: > > On 09/08/18 01:44, Evan Green wrote: > >> This change makes the UFS controller's sysfs attributes writable, which > >> will enable users to provision unprovisioned UFS devices, or > >> re-provision unlocked UFS devices. > >> > >> Signed-off-by: Evan Green > > > > Acked-by: Adrian Hunter > > > > This patch has my Ack and Reviewed-by: Stanislav Nijnikov, so can it be > queued for v4.20? There is also Evan's "[PATCH] scsi: ufs: Make sysfs flags > writable" Ping? I came across this patch and Evan's other one and noticed that they haven't been applied though a batch of other SCSI patches for 4.20 were applied about a week ago. Martin: is there something about these patches that needs to change before they can land? We're about to land the two patches into the Chrome OS kernel tree which will remove any built-in reminders we'll have to keep track of upstream progress, so this is probably the final ping from this end until the next major Chrome OS kernel rebase. ;-) -Doug
Re: [PATCH 2/3] scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls from host
Vivek, > Kishon is looking to pick this series through linux-phy tree. > Will you please consider giving your ack for this patch? Thanks. Looks fine. Acked-by: Martin K. Petersen -- Martin K. Petersen Oracle Linux Engineering
Re: [RESEND PATCH v2] scsi: Use vmemdup_user to replace the open code
zhong, > vmemdup_user is better than duplicating its implementation, So just > replace the open code. Applied to 4.20/scsi-queue, thanks! -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH] scsi: FlashPoint: Remove unnecessary parentheses
Nathan, > Clang warns when multiple pairs of parentheses are used for a single > conditional statement. Applied to 4.20/scsi-queue, thanks! -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH] scsi: advansys: Remove unnecessary parentheses
Hannes, > On 9/20/18 10:58 PM, Nathan Chancellor wrote: >> Clang warns when multiple pairs of parentheses are used for a single >> conditional statement. Applied to 4.20/scsi-queue, thanks! -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v2] scsi: sd: don't crash the host on invalid commands
Johannes, > When sd_init_command() get's a with a unknown req_op() it crashes the > system via BUG(). > > This makes debugging the actual reason for the broken request > cmd_flags pretty hard as the system is down before it's able to write > out debugging data on the serial console or the trace buffer. > > Change the BUG() to a WARN_ON() and return BLKPREP_KILL to fail > gracefully and return an I/O error to the producer of the request. Looks like a bunch of my merge mails didn't make it out last week. For the record, I did merge this into 4.19/scsi-fixes and it has made its way upstream. -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 1/1] scsi/ufshcd: Fix NULL pointer dereference for in ufshcd_init
Vivek, >> > > Bjorn, Subhash, >> > > I am not certain of some of these devfreq, and clk_scaling bits >> > > that are moved as part of this patch. Please help in reviewing the >> > > change in the light of these features, and related sequence should >> > > be followed. >> > > Thanks. >> > > >> > >> > You're right, there is a lot of logic moving around here. I think this >> > looks okay to me. >> > >> > Reviewed-by: Evan Green >> >> Thanks Evan. >> >> Best regards >> Vivek > > Gentle ping. Will you please consider picking this patch for the > merge? I was waiting for some feedback from Bjorn or Subhash. -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v4] scsi: ufs: Make sysfs attributes writable
Doug, > I came across this patch and Evan's other one and noticed that they > haven't been applied though a batch of other SCSI patches for 4.20 > were applied about a week ago. Martin: is there something about these > patches that needs to change before they can land? I have simply been awaiting some sort of consensus on the various competing approaches. Lots of patches posted with tiny incremental fixes but very little discussion about the merits of one over the other. -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v3 0/5] scsi: libsas: some code cleanups and bug fixes
Jason, > I split some code cleanups and bug fixes patches from my earlier series: > https://lkml.org/lkml/2018/5/28/2154 Applied to 4.20/scsi-queue, thank you! -- Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v4] scsi: ufs: Make sysfs attributes writable
Martin, On Tue, Sep 25, 2018 at 6:08 PM Martin K. Petersen wrote: > > Doug, > > > I came across this patch and Evan's other one and noticed that they > > haven't been applied though a batch of other SCSI patches for 4.20 > > were applied about a week ago. Martin: is there something about these > > patches that needs to change before they can land? > > I have simply been awaiting some sort of consensus on the various > competing approaches. Lots of patches posted with tiny incremental fixes > but very little discussion about the merits of one over the other. Ah, perfect information! Thank you! I was just confused because I didn't understand all the status and it just looked like silence here. Maybe someone on this thread can start a discussion with all the stakeholders (people who have been involved in competing patches or other tiny bits and pieces) and summarize their view of the current status? Maybe that would help get the ball rolling again? Thanks again! :) -Doug
Re: [PATCH] scsi: qla2xxx: Fix comment in MODULE_PARM_DESC in qla2xxx
> On Sep 11, 2018, at 2:48 AM, Masanari Iida wrote: > > External Email > > Default value of ql2xasynctmfenable for qla2xxx driver was > set to 1 in commit 043dc1d7e8501. > But comment in MODULE_PARAM_DESC was not modified. > > Signed-off-by: Masanari Iida > --- > drivers/scsi/qla2xxx/qla_os.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c > index 42b8f0d3e580..fe5404be73c5 100644 > --- a/drivers/scsi/qla2xxx/qla_os.c > +++ b/drivers/scsi/qla2xxx/qla_os.c > @@ -204,7 +204,7 @@ int ql2xasynctmfenable = 1; > module_param(ql2xasynctmfenable, int, S_IRUGO); > MODULE_PARM_DESC(ql2xasynctmfenable, >"Enables issue of TM IOCBs asynchronously via IOCB mechanism" > - "Default is 0 - Issue TM IOCBs via mailbox mechanism."); > + "Default is 1 - Issue TM IOCBs via mailbox mechanism."); > > int ql2xdontresethba; > module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); > -- > 2.19.0 > Thanks for the patch. Acked-by: Himanshu Madhani -Himanshu
[PATCH] scsi: bfa: Avoid implicit enum conversion in bfad_im_post_vendor_event
Clang warns when one enumerated type is implicitly converted to another. drivers/scsi/bfa/bfa_fcs_lport.c:379:26: warning: implicit conversion from enumeration type 'enum bfa_lport_aen_event' to different enumeration type 'enum bfa_ioc_aen_event' [-Wenum-conversion] BFA_AEN_CAT_LPORT, event); ^ The root cause of these warnings is the bfad_im_post_vendor_event function, which expects a value from enum bfa_ioc_aen_event but there are multiple instances of values from enums bfa_port_aen_event, bfa_audit_aen_event, and bfa_lport_aen_event being used in this function. Given that this doesn't appear to be a problem since cat helps with differentiating the events, just change evt's type to int so that no conversion needs to happen and Clang won't warn. Link: https://github.com/ClangBuiltLinux/linux/issues/147 Signed-off-by: Nathan Chancellor --- The alternate way of fixing these warnings is to explicitly cast the conversion when calling the function but since there are about 8-10 of these warnings, it seems logical to just change the function definiton which is cleaner in my opinion. See commits 3eb95feac113 ("mm/zsmalloc.c: change stat type parameter to int") and 04fecbf51b3c ("mm: memcontrol: use int for event/state parameter in several functions") for similar fixes. drivers/scsi/bfa/bfad_im.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h index e61ed8dad0b4..bd4ac187fd8e 100644 --- a/drivers/scsi/bfa/bfad_im.h +++ b/drivers/scsi/bfa/bfad_im.h @@ -143,7 +143,7 @@ struct bfad_im_s { static inline void bfad_im_post_vendor_event(struct bfa_aen_entry_s *entry, struct bfad_s *drv, int cnt, enum bfa_aen_category cat, -enum bfa_ioc_aen_event evt) +int evt) { struct timespec64 ts; -- 2.19.0
Re: [PATCH 2/3] scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls from host
On Wed, Sep 26, 2018 at 5:59 AM Martin K. Petersen wrote: > > > Vivek, > > > Kishon is looking to pick this series through linux-phy tree. > > Will you please consider giving your ack for this patch? Thanks. > > Looks fine. > > Acked-by: Martin K. Petersen Thanks Martin. Best regards Vivek > > -- > Martin K. Petersen Oracle Linux Engineering -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 1/1] scsi/ufshcd: Fix NULL pointer dereference for in ufshcd_init
On Wed, Sep 26, 2018 at 6:36 AM Martin K. Petersen wrote: > > > Vivek, > > >> > > Bjorn, Subhash, > >> > > I am not certain of some of these devfreq, and clk_scaling bits > >> > > that are moved as part of this patch. Please help in reviewing the > >> > > change in the light of these features, and related sequence should > >> > > be followed. > >> > > Thanks. > >> > > > >> > > >> > You're right, there is a lot of logic moving around here. I think this > >> > looks okay to me. > >> > > >> > Reviewed-by: Evan Green > >> > >> Thanks Evan. > >> > >> Best regards > >> Vivek > > > > Gentle ping. Will you please consider picking this patch for the > > merge? > > I was waiting for some feedback from Bjorn or Subhash. Sure. Bjorn, Subhash, gentle ping. How does this change look to you? Would appreciate if you could please review this. Thanks. Best regards Vivek > > -- > Martin K. Petersen Oracle Linux Engineering -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH v2] scsi: sd: don't crash the host on invalid commands
On Tue, Sep 25, 2018 at 08:52:58PM -0400, Martin K. Petersen wrote: > Looks like a bunch of my merge mails didn't make it out last week. > > For the record, I did merge this into 4.19/scsi-fixes and it has made > its way upstream. Thanks for the info. Byte, Johannes -- Johannes Thumshirn Storage jthumsh...@suse.de+49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH v3 0/6] mpt3sas: Hot-Plug Surprise removal support on IOC.
On Mon, Sep 24, 2018 at 9:36 AM Suganath Prabu S wrote: > > Posting below set of patches to support PCIe Hot Plug surprise removal, > and few defect fixes. > > This is NOT the normal PCIe Hot Plug support, whereby the user informs the > OS that a hot removal is desired, the OS does an orderly shutdown of the > driver on the device, special hot plug circuitry removes power from the > PCIe slot, then the user can remove the device and replace it > (where orderly bring-up of the device is done). > > With a true surprise removal (just removing HBA from a slot) > there is a possibility to get all kinds of PCIe transaction errors, > Below patches addresses those issues and remove HBA without bringing > the system down. > > For surprise removal detection, driver does a PCI > read of IOC's vendor field in IOC's PCI configuration space. > If the read value is 0x this indicates that the device > might have hot removed and the device will be removed from driver. > AFAIR Lukas asked you to Cc new versions to Linux PCI mailing list and, if I'm not mistaken, to him. > V1 changes: > In Patch 0001 - unlock mutex, if active reset is in progress. > > V2 changes: > Replaced mpt3sas_base_pci_device_is_unplugged with > pci_device_is_present. > > V3 Change Set: > Simplified function "mpt3sas_base_pci_device_is_available" and > made inline > > Suganath Prabu S (6): > mpt3sas: Introduce mpt3sas_base_pci_device_is_available > mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational > mpt3sas: Introdude _scsih_get_shost_and_ioc. > mpt3sas: Fix Sync cache command failure during driver unload. > mpt3sas: Fix driver modifying NVRAM/persistent data. > mpt3sas: Bump driver version to 27.100.00.00. > > drivers/scsi/mpt3sas/mpt3sas_base.c | 135 +++--- > drivers/scsi/mpt3sas/mpt3sas_base.h | 11 +- > drivers/scsi/mpt3sas/mpt3sas_config.c| 32 +- > drivers/scsi/mpt3sas/mpt3sas_ctl.c | 26 + > drivers/scsi/mpt3sas/mpt3sas_scsih.c | 189 > +++ > drivers/scsi/mpt3sas/mpt3sas_transport.c | 82 +++--- > 6 files changed, 298 insertions(+), 177 deletions(-) > > -- > 1.8.3.1 > -- With Best Regards, Andy Shevchenko
Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
On Mon, Sep 24, 2018 at 9:36 AM Suganath Prabu S wrote: > > * Driver uses "pci_device_is_present" to check whether > If Hot unplugged: > the outstanding IOs with 'DID_NO_CONNECT' before removing the drives > attached to the HBA. > "DID_NO_CONNECT" status and free the smid, if driver detects that > HBA is hot unplugged. > > * In the hard reset flush out all the outstanding IOs even if diag reset > fails and also if driver detects that HBA is hot unplugged. > + if (!mpt3sas_base_pci_device_is_available(ioc)) { > + pr_err(MPT3SAS_FMT > + "%s: pci error recovery reset or" > + " pci device unplug occurred\n", This should be just one line. > + ioc->name, __func__); > + return; > + } -- With Best Regards, Andy Shevchenko
Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
Hi Andy, I forgot to add Lukas in last patch CC list, But i have sent a note regarding the updated patch to him. Also added linux-pci On Tue, Sep 25, 2018 at 2:10 PM Andy Shevchenko wrote: > > On Mon, Sep 24, 2018 at 9:36 AM Suganath Prabu S > wrote: > > > > * Driver uses "pci_device_is_present" to check whether > > If Hot unplugged: > > the outstanding IOs with 'DID_NO_CONNECT' before removing the drives > > attached to the HBA. > > "DID_NO_CONNECT" status and free the smid, if driver detects that > > HBA is hot unplugged. > > > > * In the hard reset flush out all the outstanding IOs even if diag reset > > fails and also if driver detects that HBA is hot unplugged. > > > + if (!mpt3sas_base_pci_device_is_available(ioc)) { > > > + pr_err(MPT3SAS_FMT > > + "%s: pci error recovery reset or" > > + " pci device unplug occurred\n", > > This should be just one line. Above line crosses over 80 characters, so it is in two lines. > > > + ioc->name, __func__); > > + return; > > + } > > -- > With Best Regards, > Andy Shevchenko
Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
On Tue, Sep 25, 2018 at 12:46 PM Suganath Prabu Subramani wrote: > > > + pr_err(MPT3SAS_FMT > > > + "%s: pci error recovery reset or" > > > + " pci device unplug occurred\n", > > > > This should be just one line. > Above line crosses over 80 characters, so it is in two lines. For years there is no such requirement for string literals. Please, don't split string literals in ugly way like this. -- With Best Regards, Andy Shevchenko
Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
On Tue, Sep 25, 2018 at 3:22 PM Andy Shevchenko wrote: > > On Tue, Sep 25, 2018 at 12:46 PM Suganath Prabu Subramani > wrote: > > > > > + pr_err(MPT3SAS_FMT > > > > + "%s: pci error recovery reset or" > > > > + " pci device unplug occurred\n", > > > > > > This should be just one line. > > Above line crosses over 80 characters, so it is in two lines. > > For years there is no such requirement for string literals. Below is the one i was mentioning, WARNING: line over 80 characters #30: FILE: drivers/scsi/mpt3sas/mpt3sas_base.c:6861: + pr_err(MPT3SAS_FMT "%s: pci error recovery reset or pci device unplug occurred\n", ioc->name, __func__); Warning comes for both characters over 80 chars and string split. Do you want us to ignore warning and repost like above in single line ? > Please, don't split string literals in ugly way like this. > > -- > With Best Regards, > Andy Shevchenko
Re: [PATCH v3 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
On Tue, Sep 25, 2018 at 1:29 PM Suganath Prabu Subramani wrote: > > On Tue, Sep 25, 2018 at 3:22 PM Andy Shevchenko > wrote: > > > > On Tue, Sep 25, 2018 at 12:46 PM Suganath Prabu Subramani > > wrote: > > > > > > > + pr_err(MPT3SAS_FMT > > > > > + "%s: pci error recovery reset or" > > > > > + " pci device unplug occurred\n", > > > > > > > > This should be just one line. > > > Above line crosses over 80 characters, so it is in two lines. > > > > For years there is no such requirement for string literals. > Below is the one i was mentioning, > WARNING: line over 80 characters > #30: FILE: drivers/scsi/mpt3sas/mpt3sas_base.c:6861: > + pr_err(MPT3SAS_FMT "%s: pci error recovery reset or pci device > unplug occurred\n", ioc->name, __func__); > > Warning comes for both characters over 80 chars and string split. > Do you want us to ignore warning and repost like above in single line ? > > Please, don't split string literals in ugly way like this. I didn't tell anything about other parameters to be on the same line. So, please, try again. -- With Best Regards, Andy Shevchenko
Re: [PATCH] scsi: sd: Use info prints if no write cache
Per, >>We have it at error level because many consumer devices lie about >>having caches and we would like the users to know that their data >>integrity may be at risk. > > There are users that get confused by these errors thinking something > is broken. Something is broken: Their hardware! > Would you consider to use warning level instead or do you still prefer > error? This question pops up every few months. I'm not particularly married to error level except it has been there for ages. But how many users actually know what their current log level is set to? And how to tweak it? So I don't think the log level issue is particularly interesting in itself. I think it would be more worthwhile to massage the message. -- Martin K. Petersen Oracle Linux Engineering
[PATCH v4 3/6] mpt3sas: Introdude _scsih_get_shost_and_ioc.
The code for getting shost and IOC is redundant so moved that to function "scsih_get_shost_and_ioc". Also checks for NULL are added to IOC and shost. Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 98 ++-- 1 file changed, 82 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 566a550..f6e92eb 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -9809,6 +9809,35 @@ _scsih_ir_shutdown(struct MPT3SAS_ADAPTER *ioc) } /** + * _scsih_get_shost_and_ioc - get shost and ioc + * and verify whether they are NULL or not + * @pdev: PCI device struct + * @shost: address of scsi host pointer + * @ioc: address of HBA adapter pointer + * + * Return zero if *shost and *ioc are not NULL otherwise return error number. + */ +static int +_scsih_get_shost_and_ioc(struct pci_dev *pdev, + struct Scsi_Host **shost, struct MPT3SAS_ADAPTER **ioc) +{ + *shost = pci_get_drvdata(pdev); + if (*shost == NULL) { + dev_err(&pdev->dev, "pdev's driver data is null\n"); + return -ENXIO; + } + + *ioc = shost_priv(*shost); + if (*ioc == NULL) { + dev_err(&pdev->dev, "shost's private data is null\n"); + return -ENXIO; + } + + return 0; +} + + +/** * scsih_remove - detach and remove add host * @pdev: PCI device struct * @@ -9816,8 +9845,8 @@ _scsih_ir_shutdown(struct MPT3SAS_ADAPTER *ioc) */ static void scsih_remove(struct pci_dev *pdev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + struct Scsi_Host *shost = NULL; + struct MPT3SAS_ADAPTER *ioc = NULL; struct _sas_port *mpt3sas_port, *next_port; struct _raid_device *raid_device, *next; struct MPT3SAS_TARGET *sas_target_priv_data; @@ -9825,6 +9854,10 @@ static void scsih_remove(struct pci_dev *pdev) struct workqueue_struct *wq; unsigned long flags; + if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc)) { + dev_err(&pdev->dev, "unable to remove device\n"); + return; + } ioc->remove_host = 1; mpt3sas_wait_for_commands_to_complete(ioc); @@ -9898,11 +9931,16 @@ static void scsih_remove(struct pci_dev *pdev) static void scsih_shutdown(struct pci_dev *pdev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + struct Scsi_Host *shost = NULL; + struct MPT3SAS_ADAPTER *ioc = NULL; struct workqueue_struct *wq; unsigned long flags; + if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc)) { + dev_err(&pdev->dev, "unable to shutdown device\n"); + return; + } + ioc->remove_host = 1; mpt3sas_wait_for_commands_to_complete(ioc); @@ -10727,10 +10765,16 @@ out_add_shost_fail: static int scsih_suspend(struct pci_dev *pdev, pm_message_t state) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + struct Scsi_Host *shost = NULL; + struct MPT3SAS_ADAPTER *ioc = NULL; pci_power_t device_state; + int rc; + rc = _scsih_get_shost_and_ioc(pdev, &shost, &ioc); + if (rc) { + dev_err(&pdev->dev, "unable to suspend device\n"); + return rc; + } mpt3sas_base_stop_watchdog(ioc); flush_scheduled_work(); scsi_block_requests(shost); @@ -10754,11 +10798,17 @@ scsih_suspend(struct pci_dev *pdev, pm_message_t state) static int scsih_resume(struct pci_dev *pdev) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + struct Scsi_Host *shost = NULL; + struct MPT3SAS_ADAPTER *ioc = NULL; pci_power_t device_state = pdev->current_state; int r; + r = _scsih_get_shost_and_ioc(pdev, &shost, &ioc); + if (r) { + dev_err(&pdev->dev, "unable to resume device\n"); + return r; + } + pr_info(MPT3SAS_FMT "pdev=0x%p, slot=%s, previous operating state [D%d]\n", ioc->name, pdev, pci_name(pdev), device_state); @@ -10790,9 +10840,13 @@ scsih_resume(struct pci_dev *pdev) static pci_ers_result_t scsih_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { - struct Scsi_Host *shost = pci_get_drvdata(pdev); - struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); + struct Scsi_Host *shost = NULL; + struct MPT3SAS_ADAPTER *ioc = NULL; + if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc)) { + dev_err(&pdev->dev, "device unavailable\n"); + return PCI_ERS_RESULT_DISCONNECT; + } pr_info(MPT3SAS_FMT "PCI err
[PATCH v4 6/6] mpt3sas: Bump driver version to 27.100.00.00.
Modify driver version to 27.100.00.00 (which is equivalent to PH8 OOB driver) Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index f0351a2..b880d79 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -74,8 +74,8 @@ #define MPT3SAS_DRIVER_NAME"mpt3sas" #define MPT3SAS_AUTHOR "Avago Technologies " #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "26.100.00.00" -#define MPT3SAS_MAJOR_VERSION 26 +#define MPT3SAS_DRIVER_VERSION "27.100.00.00" +#define MPT3SAS_MAJOR_VERSION 27 #define MPT3SAS_MINOR_VERSION 100 #define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION00 -- 1.8.3.1
[PATCH v4 5/6] mpt3sas: Fix driver modifying NVRAM/persistent data.
* If EEDPTagMode field in manufacturing page11 is set, unset it. This is needed to fix a hardware bug in SAS3/SAS2 cards, So, skipping EEDPTagMode changes in Manufacturing page11 for SAS35 controllers. * Fix driver modifying NVRAM/persistent data in Manufacturing page11 along with current copy. Driver should change only current copy of Manufacturing page11 Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_config.c | 4 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 9f1d8fb..a43579e 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4122,7 +4122,7 @@ _base_static_config_pages(struct MPT3SAS_ADAPTER *ioc) * flag unset in NVDATA. */ mpt3sas_config_get_manufacturing_pg11(ioc, &mpi_reply, &ioc->manu_pg11); - if (ioc->manu_pg11.EEDPTagMode == 0) { + if ((!ioc->is_gen35_ioc) && (ioc->manu_pg11.EEDPTagMode == 0)) { pr_err("%s: overriding NVDATA EEDPTagMode setting\n", ioc->name); ioc->manu_pg11.EEDPTagMode &= ~0x3; diff --git a/drivers/scsi/mpt3sas/mpt3sas_config.c b/drivers/scsi/mpt3sas/mpt3sas_config.c index 5713a2d..f2a326a 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_config.c +++ b/drivers/scsi/mpt3sas/mpt3sas_config.c @@ -676,10 +676,6 @@ mpt3sas_config_set_manufacturing_pg11(struct MPT3SAS_ADAPTER *ioc, r = _config_request(ioc, &mpi_request, mpi_reply, MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sizeof(*config_page)); - mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_WRITE_NVRAM; - r = _config_request(ioc, &mpi_request, mpi_reply, - MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, - sizeof(*config_page)); out: return r; } -- 1.8.3.1
[PATCH v4 4/6] mpt3sas: Fix Sync cache command failure during driver unload.
This is to fix Sync cache and start stop command failures with DID_NO_CONNECT during driver unload. 1) Release drives first from SML, then remove internally in driver. 2) And allow sync cache and Start stop commands to firmware, even when remove_host flag is set v2 Changeset: Replaced this function mpt3sas_base_pci_device_is_unplugged with pci_device_is_present Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 41 ++-- drivers/scsi/mpt3sas/mpt3sas_transport.c | 7 -- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index f6e92eb..5d15d06 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -3806,6 +3806,43 @@ _scsih_tm_tr_complete(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, return _scsih_check_for_pending_tm(ioc, smid); } +/** _scsih_allow_scmd_to_device - check whether scmd needs to + * issue to IOC or not. + * @ioc: per adapter object + * @scmd: pointer to scsi command object + * + * Returns true if scmd can be issued to IOC otherwise returns false. + */ +inline bool _scsih_allow_scmd_to_device(struct MPT3SAS_ADAPTER *ioc, + struct scsi_cmnd *scmd) +{ + + if (ioc->pci_error_recovery) + return false; + + if (ioc->hba_mpi_version_belonged == MPI2_VERSION) { + if (ioc->remove_host) + return false; + + return true; + } + + + if (ioc->remove_host) { + if (!pci_device_is_present(ioc->pdev)) + return false; + + switch (scmd->cmnd[0]) { + case SYNCHRONIZE_CACHE: + case START_STOP: + return true; + default: + return false; + } + } + + return true; +} /** * _scsih_sas_control_complete - completion routine @@ -4640,7 +4677,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) return 0; } - if (ioc->pci_error_recovery || ioc->remove_host) { + if (!(_scsih_allow_scmd_to_device(ioc, scmd))) { scmd->result = DID_NO_CONNECT << 16; scmd->scsi_done(scmd); return 0; @@ -9874,6 +9911,7 @@ static void scsih_remove(struct pci_dev *pdev) /* release all the volumes */ _scsih_ir_shutdown(ioc); + sas_remove_host(shost); list_for_each_entry_safe(raid_device, next, &ioc->raid_device_list, list) { if (raid_device->starget) { @@ -9916,7 +9954,6 @@ static void scsih_remove(struct pci_dev *pdev) ioc->sas_hba.num_phys = 0; } - sas_remove_host(shost); mpt3sas_base_detach(ioc); spin_lock(&gioc_lock); list_del(&ioc->list); diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index b10d73e..742da74 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -817,10 +817,13 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address, mpt3sas_port->remote_identify.sas_address, mpt3sas_phy->phy_id); mpt3sas_phy->phy_belongs_to_port = 0; - sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy); + if (!ioc->remove_host) + sas_port_delete_phy(mpt3sas_port->port, + mpt3sas_phy->phy); list_del(&mpt3sas_phy->port_siblings); } - sas_port_delete(mpt3sas_port->port); + if (!ioc->remove_host) + sas_port_delete(mpt3sas_port->port); kfree(mpt3sas_port); } -- 1.8.3.1
[PATCH v4 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
* Driver uses "pci_device_is_present" to check whether If Hot unplugged: the outstanding IOs with 'DID_NO_CONNECT' before removing the drives attached to the HBA. "DID_NO_CONNECT" status and free the smid, if driver detects that HBA is hot unplugged. * In the hard reset flush out all the outstanding IOs even if diag reset fails and also if driver detects that HBA is hot unplugged. v1 change set: == unlock mutex before goto "out_unlocked", if active reset is in progress. v2 change set: == 1) Use pci_device_is_present instead of mpt3sas_base_pci_device_is_unplugged. 2) As suggested by Lukas, removed using watchdog thread for checking hba hot unplug(Patch 02 of V1). Added Hot unplug checks in scan finish and reset paths. v3 Change Set: = Simplified function "mpt3sas_base_pci_device_is_available" and made inline. v4 Changes: === Dont split strings in print statement. Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 39 drivers/scsi/mpt3sas/mpt3sas_base.h | 3 ++- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 50 3 files changed, 86 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 59d7844..c880e72 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -543,6 +543,20 @@ static int mpt3sas_remove_dead_ioc_func(void *arg) } /** + * mpt3sas_base_pci_device_is_available - check whether pci device is + * available for any transactions with FW + * + * @ioc: per adapter object + * + * Return 1 if pci device state is up and running else return 0. + */ +inline bool +mpt3sas_base_pci_device_is_available(struct MPT3SAS_ADAPTER *ioc) +{ + return !ioc->pci_error_recovery && pci_device_is_present(ioc->pdev); +} + +/** * _base_fault_reset_work - workq handling ioc fault conditions * @work: input argument, used to derive ioc * @@ -6122,6 +6136,11 @@ _base_diag_reset(struct MPT3SAS_ADAPTER *ioc) count = 0; do { + if (!pci_device_is_present(ioc->pdev)) { + ioc->remove_host = 1; + pr_err(MPT3SAS_FMT "Hba Hot unplugged\n", ioc->name); + goto out; + } /* Write magic sequence to WriteSequence register * Loop until in diagnostic mode */ @@ -6853,6 +6872,13 @@ mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) ioc->pending_io_count = 0; + if (!mpt3sas_base_pci_device_is_available(ioc)) { + pr_err(MPT3SAS_FMT + "%s: pci error recovery reset or pci device unplug occurred\n", + ioc->name, __func__); + return; + } + ioc_state = mpt3sas_base_get_iocstate(ioc, 0); if ((ioc_state & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) return; @@ -6899,6 +6925,19 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, /* wait for an active reset in progress to complete */ mutex_lock(&ioc->reset_in_progress_mutex); + if (!mpt3sas_base_pci_device_is_available(ioc)) { + pr_err(MPT3SAS_FMT + "%s: pci error recovery reset or pci device unplug occurred\n", + ioc->name, __func__); + if (!pci_device_is_present(ioc->pdev)) + ioc->schedule_dead_ioc_flush_running_cmds(ioc); + r = 0; + mutex_unlock(&ioc->reset_in_progress_mutex); + goto out_unlocked; + } + + mpt3sas_halt_firmware(ioc); + spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); ioc->shost_recovery = 1; spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 96dc15e..a802ad4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1474,7 +1474,8 @@ void mpt3sas_base_update_missing_delay(struct MPT3SAS_ADAPTER *ioc, u16 device_missing_delay, u8 io_missing_delay); int mpt3sas_port_enable(struct MPT3SAS_ADAPTER *ioc); - +inline bool mpt3sas_base_pci_device_is_available( + struct MPT3SAS_ADAPTER *ioc); void mpt3sas_wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 53133cf..566a550 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2846,9 +2846,19 @@ scsih_abort(struct scsi_cmnd *scmd) "attempting task abort! scmd(%p)\n", scmd); _scsih_tm_display_info(ioc, scmd); + if (!pci_device_is_present(ioc->pdev) || ioc->remove_host) { + sdev_printk(KERN_INFO, scmd->device, "%s
[PATCH v4 2/6] mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational
Introduce mpt3sas_wait_for_ioc_to_operational. This section of code "wait for IOC to be operational" is used in many places across the driver, and hence moved this section of code in to the function "mpt3sas_wait_for_ioc_to_operational". Also added HBA hot unplug checks, and this returns with error code EFAULT, if it detects HBA is hot unplugged or IOC is not in operational state. V2 change set: used pci_device_is_present instead of mpt3sas_base_pci_device_is_unplugged v4 Change set: Dont split strings in print statement Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 92 +++- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++ drivers/scsi/mpt3sas/mpt3sas_config.c| 28 +++--- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 26 ++--- drivers/scsi/mpt3sas/mpt3sas_transport.c | 75 +- 5 files changed, 81 insertions(+), 144 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index c880e72..9f1d8fb 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -5176,6 +5176,53 @@ _base_send_ioc_reset(struct MPT3SAS_ADAPTER *ioc, u8 reset_type, int timeout) } /** + * mpt3sas_wait_for_ioc_to_operational - IOC's operational + * state and HBA hot unplug status are checked here. + * @ioc: per adapter object + * @wait_count: timeout in seconds + * + * Return: Returns EFAULT, if HBA is hot unplugged or IOC is + * not in operational state, within the wait_count. + * And returns 0, If not hot unplugged Or ioc is in + * operational state. + */ + +int +mpt3sas_wait_for_ioc_to_operational(struct MPT3SAS_ADAPTER *ioc, + int wait_count) +{ + int wait_state_count = 0; + u32 ioc_state; + + if (!pci_device_is_present(ioc->pdev)) + return -EFAULT; + + ioc_state = mpt3sas_base_get_iocstate(ioc, 1); + while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { + + if (!pci_device_is_present(ioc->pdev)) + return -EFAULT; + + if (wait_state_count++ == wait_count) { + pr_err(MPT3SAS_FMT + "%s: failed due to ioc not operational\n", + ioc->name, __func__); + return -EFAULT; + } + ssleep(1); + ioc_state = mpt3sas_base_get_iocstate(ioc, 1); + pr_info(MPT3SAS_FMT + "%s: waiting for operational state(count=%d)\n", +ioc->name, __func__, wait_state_count); + } + if (wait_state_count) + pr_info(MPT3SAS_FMT "%s: ioc is operational\n", + ioc->name, __func__); + + return 0; +} + +/** * _base_handshake_req_reply_wait - send request thru doorbell interface * @ioc: per adapter object * @request_bytes: request length @@ -5316,11 +5363,9 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, Mpi2SasIoUnitControlRequest_t *mpi_request) { u16 smid; - u32 ioc_state; u8 issue_reset = 0; int rc; void *request; - u16 wait_state_count; dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, __func__)); @@ -5334,22 +5379,10 @@ mpt3sas_base_sas_iounit_control(struct MPT3SAS_ADAPTER *ioc, goto out; } - wait_state_count = 0; - ioc_state = mpt3sas_base_get_iocstate(ioc, 1); - while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { - if (wait_state_count++ == 10) { - pr_err(MPT3SAS_FMT - "%s: failed due to ioc not operational\n", - ioc->name, __func__); - rc = -EFAULT; - goto out; - } - ssleep(1); - ioc_state = mpt3sas_base_get_iocstate(ioc, 1); - pr_info(MPT3SAS_FMT - "%s: waiting for operational state(count=%d)\n", - ioc->name, __func__, wait_state_count); - } + rc = mpt3sas_wait_for_ioc_to_operational(ioc, + IOC_OPERATIONAL_WAIT_COUNT); + if (rc) + goto out; smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx); if (!smid) { @@ -5416,11 +5449,9 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request) { u16 smid; - u32 ioc_state; u8 issue_reset = 0; int rc; void *request; - u16 wait_state_count; dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, __func__)); @@ -5434,23 +5465,10 @@ mpt3sas_base_scsi_enclosure_processor(struct MPT3SAS_ADAPTER *ioc, goto out; } - wait_state_count = 0; - ioc_state = mpt3sas_base_get_iocstat
[PATCH v4 0/6] mpt3sas: Hot-Plug Surprise removal support on IOC.
Posting below set of patches to support PCIe Hot Plug surprise removal, and few defect fixes. This is NOT the normal PCIe Hot Plug support, whereby the user informs the OS that a hot removal is desired, the OS does an orderly shutdown of the driver on the device, special hot plug circuitry removes power from the PCIe slot, then the user can remove the device and replace it (where orderly bring-up of the device is done). With a true surprise removal (just removing HBA from a slot) there is a possibility to get all kinds of PCIe transaction errors, Below patches addresses those issues and remove HBA without bringing the system down. For surprise removal detection, driver does a PCI read of IOC's vendor field in IOC's PCI configuration space. If the read value is 0x this indicates that the device might have hot removed and the device will be removed from driver. V1 changes: In Patch 0001 - unlock mutex, if active reset is in progress. V2 changes: Replaced mpt3sas_base_pci_device_is_unplugged with pci_device_is_present. V3 Change Set: Simplified function "mpt3sas_base_pci_device_is_available" and made inline V4 Change set: Reframe split strings in print statement, to avoid warning from checkpatch.pl. Suganath Prabu S (6): mpt3sas: Introduce mpt3sas_base_pci_device_is_available mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational mpt3sas: Introdude _scsih_get_shost_and_ioc. mpt3sas: Fix Sync cache command failure during driver unload. mpt3sas: Fix driver modifying NVRAM/persistent data. mpt3sas: Bump driver version to 27.100.00.00. drivers/scsi/mpt3sas/mpt3sas_base.c | 133 +++--- drivers/scsi/mpt3sas/mpt3sas_base.h | 11 +- drivers/scsi/mpt3sas/mpt3sas_config.c| 32 +- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 26 + drivers/scsi/mpt3sas/mpt3sas_scsih.c | 189 +++ drivers/scsi/mpt3sas/mpt3sas_transport.c | 82 +++--- 6 files changed, 296 insertions(+), 177 deletions(-) -- 1.8.3.1
[PATCH v2 5/5] qla2xxx: Update driver version to 11.00.00.00-k
Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index 12bafff71a1a..0d58aa629c08 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h @@ -7,9 +7,9 @@ /* * Driver version */ -#define QLA2XXX_VERSION "10.00.00.11-k" +#define QLA2XXX_VERSION "11.00.00.00-k" -#define QLA_DRIVER_MAJOR_VER 10 +#define QLA_DRIVER_MAJOR_VER 11 #define QLA_DRIVER_MINOR_VER 0 #define QLA_DRIVER_PATCH_VER 0 #define QLA_DRIVER_BETA_VER0 -- 2.12.0
[PATCH v2 0/5] qla2xxx: Add FC-NVMe Target support
Hi Martin, This series adds support for FC-NVMe Target. Patch #1 addes new qla_nvmet files for FC-NVMe Target support. Patch #2 adds Kconfig and Makefile changes to prepare code compile. Patch #3, #4 has bulk of changes to handle FC-NVMe Target LS4 processing via Purex pass through path. Patch #4 adds SysFS hook to enable NVMe Target for the port. Note: All the patches in this series must be applied before they can be compilable. Please apply them to 4.20/scsi-queue Changes from v1 -> v2 o Addressed all comments from Bart. o Consolidated Patch 1 and Patch 2 into single patch. o Fixed smatch warning reported by kbuild autommation. o NVMe Target mode is exclusive at the moment. Qlogic driver does not support both FCP Target and NVMe Target at the same time. This will be fixed in later updates. Thanks, Himanshu Anil Gurumurthy (4): qla2xxx_nvmet: Add files for FC-NVMe Target support qla2xxx_nvmet: Add FC-NVMe Target Link Service request handling qla2xxx_nvmet: Add FC-NVMe Target handling qla2xxx_nvmet: Add SysFS node for FC-NVMe Target Himanshu Madhani (1): qla2xxx: Update driver version to 11.00.00.00-k drivers/scsi/qla2xxx/Makefile | 3 +- drivers/scsi/qla2xxx/qla_attr.c| 33 ++ drivers/scsi/qla2xxx/qla_dbg.c | 1 + drivers/scsi/qla2xxx/qla_dbg.h | 2 + drivers/scsi/qla2xxx/qla_def.h | 35 +- drivers/scsi/qla2xxx/qla_fw.h | 263 ++ drivers/scsi/qla2xxx/qla_gbl.h | 17 +- drivers/scsi/qla2xxx/qla_gs.c | 16 +- drivers/scsi/qla2xxx/qla_init.c| 49 +- drivers/scsi/qla2xxx/qla_iocb.c| 42 +- drivers/scsi/qla2xxx/qla_isr.c | 112 - drivers/scsi/qla2xxx/qla_mbx.c | 101 +++- drivers/scsi/qla2xxx/qla_nvme.h| 33 -- drivers/scsi/qla2xxx/qla_nvmet.c | 798 ++ drivers/scsi/qla2xxx/qla_nvmet.h | 129 + drivers/scsi/qla2xxx/qla_os.c | 77 ++- drivers/scsi/qla2xxx/qla_target.c | 977 - drivers/scsi/qla2xxx/qla_target.h | 90 drivers/scsi/qla2xxx/qla_version.h | 4 +- 19 files changed, 2708 insertions(+), 74 deletions(-) create mode 100644 drivers/scsi/qla2xxx/qla_nvmet.c create mode 100644 drivers/scsi/qla2xxx/qla_nvmet.h -- 2.12.0
[PATCH v2 4/5] qla2xxx_nvmet: Add SysFS node for FC-NVMe Target
From: Anil Gurumurthy This patch adds SysFS node for NVMe Target configuration Signed-off-by: Anil Gurumurthy Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 33 + drivers/scsi/qla2xxx/qla_gs.c| 2 +- drivers/scsi/qla2xxx/qla_init.c | 3 ++- drivers/scsi/qla2xxx/qla_nvmet.c | 6 +++--- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index a31d23905753..0d2d4f33701b 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -13,6 +13,7 @@ #include static int qla24xx_vport_disable(struct fc_vport *, bool); +extern void qlt_set_mode(struct scsi_qla_host *vha); /* SYSFS attributes - */ @@ -631,6 +632,37 @@ static struct bin_attribute sysfs_sfp_attr = { }; static ssize_t +qla2x00_sysfs_write_nvmet(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj, + struct device, kobj))); + struct qla_hw_data *ha = vha->hw; + scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); + + ql_log(ql_log_info, vha, 0x706e, + "Bringing up target mode!! vha:%p\n", vha); + qlt_op_target_mode = 1; + qlt_set_mode(base_vha); + set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + qla2x00_wait_for_hba_online(vha); + + return count; +} + +static struct bin_attribute sysfs_nvmet_attr = { + .attr = { + .name = "nvmet", + .mode = 0200, + }, + .size = 0, + .write = qla2x00_sysfs_write_nvmet, +}; + + +static ssize_t qla2x00_sysfs_write_reset(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) @@ -943,6 +975,7 @@ static struct sysfs_entry { { "issue_logo", &sysfs_issue_logo_attr, }, { "xgmac_stats", &sysfs_xgmac_stats_attr, 3 }, { "dcbx_tlv", &sysfs_dcbx_tlv_attr, 3 }, + { "nvmet", &sysfs_nvmet_attr, }, { NULL }, }; diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 55dc11d91b35..ba58cfe7ff9b 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -698,7 +698,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha, u8 type) return (QLA_SUCCESS); return qla_async_rffid(vha, &vha->d_id, qlt_rff_id(vha), - FC4_TYPE_FCP_SCSI); + type); } static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id, diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 841541201671..01676345018f 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5523,7 +5523,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) * will be newer than discovery_gen. */ qlt_do_generation_tick(vha, &discovery_gen); - if (USE_ASYNC_SCAN(ha)) { + if (USE_ASYNC_SCAN(ha) && !(vha->flags.nvmet_enabled)) { + /* If NVME target mode is enabled, go through regular scan */ rval = qla24xx_async_gpnft(vha, FC4_TYPE_FCP_SCSI, NULL); if (rval) diff --git a/drivers/scsi/qla2xxx/qla_nvmet.c b/drivers/scsi/qla2xxx/qla_nvmet.c index 5335c0618f00..cc0fb83b8f69 100644 --- a/drivers/scsi/qla2xxx/qla_nvmet.c +++ b/drivers/scsi/qla2xxx/qla_nvmet.c @@ -546,7 +546,7 @@ static void qla_nvmet_send_resp_ctio(struct qla_qpair *qpair, case NVMET_FCOP_READDATA: case NVMET_FCOP_READDATA_RSP: /* Populate the CTIO resp with the SGL present in the rsp */ - ql_log(ql_log_info, vha, 0x1100c, + ql_dbg(ql_dbg_nvme, vha, 0x1100c, "op: %#x, ox_id=%x c_flags=%x transfer_length: %#x req_cnt: %#x, tot_dsds: %#x\n", rsp_buf->op, ctio->ox_id, c_flags, rsp_buf->transfer_length, req_cnt, tot_dsds); @@ -632,7 +632,7 @@ static void qla_nvmet_send_resp_ctio(struct qla_qpair *qpair, case NVMET_FCOP_WRITEDATA: /* Send transfer rdy */ - ql_log(ql_log_info, vha, 0x1100e, + ql_dbg(ql_dbg_nvme, vha, 0x1100e, "FCOP_WRITE: ox_id=%x c_flags=%x transfer_length: %#x req_cnt: %#x, tot_dsds: %#x\n", ctio->ox_id, c_flags, rsp_buf->transfer_length, req_cnt, tot_dsds); @@ -707,7 +707,7 @@ static void qla_nvmet_send_resp_ctio(struct qla_qpair *qpair, ctio->u.nvme_status_mode1.transfer_len = cpu_to_be32(ersp
[PATCH v2 3/5] qla2xxx_nvmet: Add FC-NVMe Target handling
From: Anil Gurumurthy This patch Adds following code in the driver to support FC-NVMe Target - Updated ql2xenablenvme to allow FC-NVMe Target operation - Added Link Serviccce Request handling for NVMe Target - Added passthru IOCB for LS4 request - Added CTIO for sending response to FW - Added FC4 Registration for FC-NVMe Target - Added PUREX IOCB support for login processing in FC-NVMe Target mode - Added Continuation IOCB for PUREX - Added Session creation with PUREX IOCB in FC-NVMe Target mode Signed-off-by: Anil Gurumurthy Signed-off-by: Giridhar Malavali Signed-off-by: Darren Trapp Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h| 35 +- drivers/scsi/qla2xxx/qla_fw.h | 263 ++ drivers/scsi/qla2xxx/qla_gbl.h| 17 +- drivers/scsi/qla2xxx/qla_gs.c | 14 +- drivers/scsi/qla2xxx/qla_init.c | 46 +- drivers/scsi/qla2xxx/qla_isr.c| 112 - drivers/scsi/qla2xxx/qla_mbx.c| 101 +++- drivers/scsi/qla2xxx/qla_nvme.h | 33 -- drivers/scsi/qla2xxx/qla_os.c | 77 ++- drivers/scsi/qla2xxx/qla_target.c | 977 +- drivers/scsi/qla2xxx/qla_target.h | 90 11 files changed, 1697 insertions(+), 68 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 26b93c563f92..feda0b90f62e 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -480,6 +480,10 @@ struct srb_iocb { uint32_t dl; uint32_t timeout_sec; struct list_head entry; + uint32_t exchange_address; + uint16_t nport_handle; + uint8_t vp_index; + void *cmd; } nvme; struct { u16 cmd; @@ -490,7 +494,11 @@ struct srb_iocb { struct timer_list timer; void (*timeout)(void *); }; - +struct srb_nvme_els_rsp { + dma_addr_t dma_addr; + void *dma_ptr; + void *ptr; +}; /* Values for srb_ctx type */ #define SRB_LOGIN_CMD 1 #define SRB_LOGOUT_CMD 2 @@ -515,6 +523,11 @@ struct srb_iocb { #define SRB_PRLI_CMD 21 #define SRB_CTRL_VP22 #define SRB_PRLO_CMD 23 +#define SRB_NVME_ELS_RSP 24 +#define SRB_NVMET_LS 25 +#define SRB_NVMET_FCP 26 +#define SRB_NVMET_ABTS 27 +#define SRB_NVMET_SEND_ABTS28 enum { TYPE_SRB, @@ -545,10 +558,13 @@ typedef struct srb { int rc; int retry_count; struct completion comp; + struct work_struct nvmet_comp_work; + uint16_t comp_status; union { struct srb_iocb iocb_cmd; struct bsg_job *bsg_job; struct srb_cmd scmd; + struct srb_nvme_els_rsp snvme_els; } u; void (*done)(void *, int); void (*free)(void *); @@ -2273,6 +2289,15 @@ struct qlt_plogi_ack_t { void*fcport; }; +/* NVMET */ +struct qlt_purex_plogi_ack_t { + struct list_headlist; + struct __fc_plogi rcvd_plogi; + port_id_t id; + int ref_count; + void*fcport; +}; + struct ct_sns_desc { struct ct_sns_pkt *ct_sns; dma_addr_t ct_sns_dma; @@ -3235,6 +3260,7 @@ enum qla_work_type { QLA_EVT_SP_RETRY, QLA_EVT_IIDMA, QLA_EVT_ELS_PLOGI, + QLA_EVT_NEW_NVMET_SESS, }; @@ -4229,6 +4255,7 @@ typedef struct scsi_qla_host { uint32_tqpairs_req_created:1; uint32_tqpairs_rsp_created:1; uint32_tnvme_enabled:1; + uint32_tnvmet_enabled:1; } flags; atomic_tloop_state; @@ -4274,6 +4301,7 @@ typedef struct scsi_qla_host { #define N2N_LOGIN_NEEDED 30 #define IOCB_WORK_ACTIVE 31 #define SET_ZIO_THRESHOLD_NEEDED 32 +#define NVMET_PUREX33 unsigned long pci_flags; #define PFLG_DISCONNECTED 0 /* PCI device removed */ @@ -4314,6 +4342,7 @@ typedef struct scsi_qla_host { uint8_t fabric_node_name[WWN_SIZE]; struct nvme_fc_local_port *nvme_local_port; + struct nvmet_fc_target_port *targetport; struct completion nvme_del_done; struct list_head nvme_rport_list; @@ -4394,6 +4423,9 @@ typedef struct scsi_qla_host { uint16_tn2n_id; struct list_head gpnid_list; struct fab_scan scan; + /*NVMET*/ + struct list_headpurex_atio_list; + struct completion purex_plogi_sess; } scsi_qla_host_t; struct qla27xx_image_status { @@ -4664,6 +4696,7 @@ struct sff_8247_a0 { !ha->current_topology) #include "qla_target.h" +#include "qla_nvmet.h" #include "qla_gbl.h" #include "qla_dbg.h" #include "qla_inline.h" diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/q
[PATCH v2 1/5] qla2xxx_nvmet: Add files for FC-NVMe Target support
From: Anil Gurumurthy This patch adds initial files to enable NVMe Target Support Signed-off-by: Anil Gurumurthy Signed-off-by: Giridhar Malavali Signed-off-by: Darren Trapp Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/Makefile| 3 +- drivers/scsi/qla2xxx/qla_nvmet.c | 798 +++ drivers/scsi/qla2xxx/qla_nvmet.h | 129 +++ 3 files changed, 929 insertions(+), 1 deletion(-) create mode 100644 drivers/scsi/qla2xxx/qla_nvmet.c create mode 100644 drivers/scsi/qla2xxx/qla_nvmet.h diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile index 17d5bc1cc56b..ec924733c10e 100644 --- a/drivers/scsi/qla2xxx/Makefile +++ b/drivers/scsi/qla2xxx/Makefile @@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ qla_dbg.o qla_sup.o qla_attr.o qla_mid.o qla_dfs.o qla_bsg.o \ - qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_nvme.o + qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_nvme.o \ + qla_nvmet.o obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o diff --git a/drivers/scsi/qla2xxx/qla_nvmet.c b/drivers/scsi/qla2xxx/qla_nvmet.c new file mode 100644 index ..5335c0618f00 --- /dev/null +++ b/drivers/scsi/qla2xxx/qla_nvmet.c @@ -0,0 +1,798 @@ +/* + * QLogic Fibre Channel HBA Driver + * Copyright (c) 2003-2017 QLogic Corporation + * + * See LICENSE.qla2xxx for copyright and licensing details. + */ + +#include +#include +#include +#include + +#include "qla_nvme.h" +#include "qla_nvmet.h" + +static void qla_nvmet_send_resp_ctio(struct qla_qpair *qpair, + struct qla_nvmet_cmd *cmd, struct nvmefc_tgt_fcp_req *rsp); +static void qla_nvmet_send_abts_ctio(struct scsi_qla_host *vha, + struct abts_recv_from_24xx *abts, bool flag); + +/* + * qla_nvmet_targetport_delete - + * Invoked by the nvmet to indicate that the target port has + * been deleted + */ +static void +qla_nvmet_targetport_delete(struct nvmet_fc_target_port *targetport) +{ + struct qla_nvmet_tgtport *tport = targetport->private; + + if (!IS_ENABLED(CONFIG_NVME_TARGET_FC)) + return; + + complete(&tport->tport_del); +} + +/* + * qlt_nvmet_ls_done - + * Invoked by the firmware interface to indicate the completion + * of an LS cmd + * Free all associated resources of the LS cmd + */ +static void qlt_nvmet_ls_done(void *ptr, int res) +{ + struct srb *sp = ptr; + struct srb_iocb *nvme = &sp->u.iocb_cmd; + struct nvmefc_tgt_ls_req *rsp = nvme->u.nvme.desc; + struct qla_nvmet_cmd *tgt_cmd = nvme->u.nvme.cmd; + + if (!IS_ENABLED(CONFIG_NVME_TARGET_FC)) + return; + + ql_log(ql_log_info, sp->vha, 0x11000, + "Done with NVME LS4 req\n"); + + ql_log(ql_log_info, sp->vha, 0x11001, + "sp: %p vha: %p, rsp: %p, cmd: %p\n", + sp, sp->vha, nvme->u.nvme.desc, nvme->u.nvme.cmd); + + rsp->done(rsp); + /* Free tgt_cmd */ + kfree(tgt_cmd->buf); + kfree(tgt_cmd); + qla2x00_rel_sp(sp); +} + +/* + * qla_nvmet_ls_rsp - + * Invoked by the nvme-t to complete the LS req. + * Prepare and send a response CTIO to the firmware. + */ +static int +qla_nvmet_ls_rsp(struct nvmet_fc_target_port *tgtport, + struct nvmefc_tgt_ls_req *rsp) +{ + struct qla_nvmet_cmd *tgt_cmd = + container_of(rsp, struct qla_nvmet_cmd, cmd.ls_req); + struct scsi_qla_host *vha = tgt_cmd->vha; + struct srb_iocb *nvme; + int rval = QLA_FUNCTION_FAILED; + srb_t *sp; + + ql_log(ql_log_info, vha, 0x11002, + "Dumping the NVMET-LS response buffer\n"); + ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, vha, 0x2075, + (uint8_t *)rsp->rspbuf, rsp->rsplen); + + /* Alloc SRB structure */ + sp = qla2x00_get_sp(vha, NULL, GFP_ATOMIC); + if (!sp) { + ql_log(ql_log_info, vha, 0x11003, "Failed to allocate SRB\n"); + return -ENOMEM; + } + + sp->type = SRB_NVMET_LS; + sp->done = qlt_nvmet_ls_done; + sp->vha = vha; + sp->fcport = tgt_cmd->fcport; + + nvme = &sp->u.iocb_cmd; + nvme->u.nvme.rsp_dma = rsp->rspdma; + nvme->u.nvme.rsp_len = rsp->rsplen; + nvme->u.nvme.exchange_address = tgt_cmd->atio.u.pt_ls4.exchange_address; + nvme->u.nvme.nport_handle = tgt_cmd->atio.u.pt_ls4.nport_handle; + nvme->u.nvme.vp_index = tgt_cmd->atio.u.pt_ls4.vp_index; + + nvme->u.nvme.cmd = tgt_cmd; /* To be freed */ + nvme->u.nvme.desc = rsp; /* Call back to nvmet */ + + rval = qla2x00_start_sp(sp); + if (rval != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x11004, + "qla2x00_start_sp failed = %d\n", rval); + return rval; + } +
[PATCH v2 2/5] qla2xxx_nvmet: Add FC-NVMe Target Link Service request handling
From: Anil Gurumurthy This patch provides link service pass through feature handling in the driver. This feature is implemented mainly by the firmware and the same implementation is handled in the driver via an IOCB interface. Signed-off-by: Anil Gurumurthy Signed-off-by: Giridhar Malavali Signed-off-by: Darren Trapp Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_dbg.c | 1 + drivers/scsi/qla2xxx/qla_dbg.h | 2 ++ drivers/scsi/qla2xxx/qla_iocb.c | 42 - 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index c7533fa7f46e..ed9c228f7d11 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -67,6 +67,7 @@ * | Target Mode Management | 0xf09b | 0xf002 | * | || 0xf046-0xf049 | * | Target Mode Task Management | 0x1000d || + * | NVME| 0x11000 || * -- */ diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h index 8877aa97d829..4ad97923e40b 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.h +++ b/drivers/scsi/qla2xxx/qla_dbg.h @@ -367,6 +367,8 @@ ql_log_qp(uint32_t, struct qla_qpair *, int32_t, const char *fmt, ...); #define ql_dbg_tgt_tmr 0x1000 /* Target mode task management */ #define ql_dbg_tgt_dif 0x0800 /* Target mode dif */ +#define ql_dbg_nvme 0x0400 /* NVME Target */ + extern int qla27xx_dump_mpi_ram(struct qla_hw_data *, uint32_t, uint32_t *, uint32_t, void **); extern int qla24xx_dump_ram(struct qla_hw_data *, uint32_t, uint32_t *, diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 4de910231ba6..cce32362cf21 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2113,7 +2113,7 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp) req_cnt = 1; handle = 0; - if (sp && (sp->type != SRB_SCSI_CMD)) { + if (sp && (sp->type != SRB_SCSI_CMD) && (sp->type != SRB_NVMET_FCP)) { /* Adjust entry-counts as needed. */ req_cnt = sp->iocbs; } @@ -3433,6 +3433,40 @@ qla24xx_prlo_iocb(srb_t *sp, struct logio_entry_24xx *logio) logio->vp_index = sp->fcport->vha->vp_idx; } +/* + * Build NVMET LS response + */ +static int +qla_nvmet_ls(srb_t *sp, struct pt_ls4_request *rsp_pkt) +{ + struct srb_iocb *nvme; + int rval = QLA_SUCCESS; + + nvme = &sp->u.iocb_cmd; + + rsp_pkt->entry_type = PT_LS4_REQUEST; + rsp_pkt->entry_count = 1; + rsp_pkt->control_flags = cpu_to_le16(CF_LS4_RESPONDER << CF_LS4_SHIFT); + rsp_pkt->handle = sp->handle; + + rsp_pkt->nport_handle = sp->fcport->loop_id; + rsp_pkt->vp_index = nvme->u.nvme.vp_index; + rsp_pkt->exchange_address = cpu_to_le32(nvme->u.nvme.exchange_address); + + rsp_pkt->tx_dseg_count = 1; + rsp_pkt->tx_byte_count = cpu_to_le16(nvme->u.nvme.rsp_len); + rsp_pkt->dseg0_len = cpu_to_le16(nvme->u.nvme.rsp_len); + rsp_pkt->dseg0_address[0] = cpu_to_le32(LSD(nvme->u.nvme.rsp_dma)); + rsp_pkt->dseg0_address[1] = cpu_to_le32(MSD(nvme->u.nvme.rsp_dma)); + + ql_log(ql_log_info, sp->vha, 0x, + "Dumping the NVME-LS response IOCB\n"); + ql_dump_buffer(ql_dbg_disc + ql_dbg_buffer, sp->vha, 0x2075, + (uint8_t *)rsp_pkt, sizeof(*rsp_pkt)); + + return rval; +} + int qla2x00_start_sp(srb_t *sp) { @@ -3493,6 +3527,9 @@ qla2x00_start_sp(srb_t *sp) case SRB_NVME_LS: qla_nvme_ls(sp, pkt); break; + case SRB_NVMET_LS: + qla_nvmet_ls(sp, pkt); + break; case SRB_ABT_CMD: IS_QLAFX00(ha) ? qlafx00_abort_iocb(sp, pkt) : @@ -3518,6 +3555,9 @@ qla2x00_start_sp(srb_t *sp) case SRB_PRLO_CMD: qla24xx_prlo_iocb(sp, pkt); break; + case SRB_NVME_ELS_RSP: + qlt_send_els_resp(sp, pkt); + break; default: break; } -- 2.12.0