From patchwork Fri Dec 3 23:19:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 150B5C433FE for ; Fri, 3 Dec 2021 23:20:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376688AbhLCXX1 (ORCPT ); Fri, 3 Dec 2021 18:23:27 -0500 Received: from mail-pj1-f54.google.com ([209.85.216.54]:42715 "EHLO mail-pj1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233523AbhLCXX0 (ORCPT ); Fri, 3 Dec 2021 18:23:26 -0500 Received: by mail-pj1-f54.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so3742633pjb.1 for ; Fri, 03 Dec 2021 15:20:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qY/e1tYjy/CX5akbZhb3KBBMMKjYLigNzjhchVjN1r4=; b=ZdWoZeNOhQBO2cW4avhUu4oy45W2275XwMOn7QKAyL84rF759fz0Gc9Hb9M1B4HeVf KPzk1XDPSAVwzza83pciYqcr418i5TzfB6GS9UDBMR8EjxSc9WewfKBhIUCoed3Y3lak JkcFhR+2vGVfPXAwvU6UQCcV/qlSx3l+M8CGb8eidY2VmHVl+7ngbrkTaUEBhOI0mcLR aNZnwK1+JV/NbzxmjocOKsfYc+SlOqmYjOXBi3akGuz+QFbhoyXnfQKd41rRvo7+/JbG cWVix7VJt1ich4HL5Oz1x2priVCwz7BkNslOV0ZhTBOiuvA173wVDzJkkh+SNfUi/xtf 2ggw== X-Gm-Message-State: AOAM530t3zqJzMaMFMF8qtP9QAokcJoFM/dHZJjMATQwqeinjjFMTo9u 8lOnpHCi/7hWW3MwANatcVo= X-Google-Smtp-Source: ABdhPJxhH0yXNMxn/yFbNZYtvylTM8n1NLBVT8fVPuIYUfX+OKLRvng9qOh/bFV37v9dIa9NKBFS9w== X-Received: by 2002:a17:90a:fe0b:: with SMTP id ck11mr17425845pjb.15.1638573601674; Fri, 03 Dec 2021 15:20:01 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:01 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Ming Lei , Bean Huo , Hannes Reinecke , Sumanesh Samanta , "James E.J. Bottomley" Subject: [PATCH v4 01/17] scsi: core: Fix scsi_device_max_queue_depth() Date: Fri, 3 Dec 2021 15:19:34 -0800 Message-Id: <20211203231950.193369-2-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The comment above scsi_device_max_queue_depth() and also the description of commit ca4453213951 ("scsi: core: Make sure sdev->queue_depth is <= max(shost->can_queue, 1024)") contradict the implementation of the function scsi_device_max_queue_depth(). Additionally, the maximum queue depth of a SCSI LUN never exceeds host->can_queue. Fix scsi_device_max_queue_depth() by changing max_t() into min_t(). Reviewed-by: Ming Lei Reviewed-by: Bean Huo Tested-by: Bean Huo Cc: Hannes Reinecke Cc: Sumanesh Samanta Fixes: ca4453213951 ("scsi: core: Make sure sdev->queue_depth is <= max(shost->can_queue, 1024)") Signed-off-by: Bart Van Assche --- drivers/scsi/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index dee4d9c6046d..211aace69c22 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -200,11 +200,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) /* - * 1024 is big enough for saturating the fast scsi LUN now + * 1024 is big enough for saturating fast SCSI LUNs. */ int scsi_device_max_queue_depth(struct scsi_device *sdev) { - return max_t(int, sdev->host->can_queue, 1024); + return min_t(int, sdev->host->can_queue, 1024); } /** From patchwork Fri Dec 3 23:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCFF9C433EF for ; Fri, 3 Dec 2021 23:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376710AbhLCXXj (ORCPT ); Fri, 3 Dec 2021 18:23:39 -0500 Received: from mail-pg1-f178.google.com ([209.85.215.178]:44847 "EHLO mail-pg1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXXj (ORCPT ); Fri, 3 Dec 2021 18:23:39 -0500 Received: by mail-pg1-f178.google.com with SMTP id m15so4495330pgu.11 for ; Fri, 03 Dec 2021 15:20:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s7O4xhTSYP8Q0bPg49nT0d3KMYnj5r7if8HK6Jcwzk0=; b=GyVfws0PIFFgUeagflUET83XuM/+sMgKXpN6/Dm1MoOy2WmsUkEoongPZse/O7eG9E b1vOyz/czsOhm7XqDc668LYw1ivtmd+6kHSy2/iKwFFn0Reg4sZWNGKfA/j/+DgveF4m 9pYBjQ1bPONoZe7ckb6jMrFWdw+ZYKS15kEsdsrS2m8G2Gvl3JZTULaWPDt43gSYqwfm WX+cJoe+Wg9eiPku/NBEbRlBYJetsyRypnszT1eEIqURr7WykMKSIbYIhuEt6xJSfvrC Zhd9Ueif5UOriKfmVTeoDF+l+xQBJw7Q7Y8tWMvl4Pd75mgnkKZ9ioyqJGTau0KLFgBG YxxA== X-Gm-Message-State: AOAM5328jaHyhPd3PTftwiCmldQXSpv8lbbEnXnKoA3BqKhHGfrRxw8/ kHW1ZFB9YF0e1bGnhwM8R2o= X-Google-Smtp-Source: ABdhPJzU31XJaiDx1DLcs3T2j20uScHa1rc2cLnkr2aUgH/vwlq0zHx9MiBktqirkHn6+Np64dAOSg== X-Received: by 2002:a63:2049:: with SMTP id r9mr6591875pgm.413.1638573614668; Fri, 03 Dec 2021 15:20:14 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:14 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Chanho Park , Alim Akhtar , Keoseong Park , Bean Huo , "James E.J. Bottomley" , Krzysztof Kozlowski , Kiwoong Kim , Yue Hu , Stanley Chu , Avri Altman , Can Guo , Asutosh Das Subject: [PATCH v4 02/17] scsi: ufs: Rename a function argument Date: Fri, 3 Dec 2021 15:19:35 -0800 Message-Id: <20211203231950.193369-3-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The new name makes it clear what the meaning of the function argument is. Reviewed-by: Chanho Park Acked-by: Alim Akhtar Reviewed-by: Keoseong Park Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufs-exynos.c | 4 ++-- drivers/scsi/ufs/ufshcd.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index cd26bc82462e..474a4a064a68 100644 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -853,14 +853,14 @@ static int exynos_ufs_post_pwr_mode(struct ufs_hba *hba, } static void exynos_ufs_specify_nexus_t_xfer_req(struct ufs_hba *hba, - int tag, bool op) + int tag, bool is_scsi_cmd) { struct exynos_ufs *ufs = ufshcd_get_variant(hba); u32 type; type = hci_readl(ufs, HCI_UTRL_NEXUS_TYPE); - if (op) + if (is_scsi_cmd) hci_writel(ufs, type | (1 << tag), HCI_UTRL_NEXUS_TYPE); else hci_writel(ufs, type & ~(1 << tag), HCI_UTRL_NEXUS_TYPE); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 6103e98e9a08..28c1bbe9fa7d 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -338,7 +338,8 @@ struct ufs_hba_variant_ops { enum ufs_notify_change_status status, struct ufs_pa_layer_attr *, struct ufs_pa_layer_attr *); - void (*setup_xfer_req)(struct ufs_hba *, int, bool); + void (*setup_xfer_req)(struct ufs_hba *hba, int tag, + bool is_scsi_cmd); void (*setup_task_mgmt)(struct ufs_hba *, int, u8); void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, enum ufs_notify_change_status); From patchwork Fri Dec 3 23:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C63DC433F5 for ; Fri, 3 Dec 2021 23:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376744AbhLCXXp (ORCPT ); Fri, 3 Dec 2021 18:23:45 -0500 Received: from mail-pg1-f175.google.com ([209.85.215.175]:40827 "EHLO mail-pg1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXXo (ORCPT ); Fri, 3 Dec 2021 18:23:44 -0500 Received: by mail-pg1-f175.google.com with SMTP id l190so4511617pge.7 for ; Fri, 03 Dec 2021 15:20:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXzSK3wHuMFAb4DWjfo8uFdYnqOpelZuA0THarlc7LM=; b=SWh7uRxr3AYvd/WnT3AUw5rKKAfqmTUVURHg1UKquoDT+ajAWSNsTPotFP0/bLLN2V ya+O4/D6nfZhukfR7XFlAEeRUw257JSzPM1sqJFFqgnef5S751CTXNeBJGRfnl99ZVcj JO/YGcCCeDT9f4ZA2OAOM71R4z2KnUwCEBRdSHvokLfZMJ8gWLRIQAdH9pHEkxWy5Gso wdmtXEq4WxZhwrGVvrcDXPWvhzR3pyAyW5GbEIKHdp0KU8IK3HAFkYrMq/WYKNJO/ccM J2G/jtGLfyOJoEcgA+ouRkcBGwMSIamdYCudiilCzwP5cn6FYuX3U6PMV6XXUqnVc8UM Wqzg== X-Gm-Message-State: AOAM530AcA6y5SaJodM77BoMW4K+gvV9W/reY308qQY1ZJq1dAYPSV19 s/BAAKuYbTpxM+ukQF5Mw84= X-Google-Smtp-Source: ABdhPJw03KOll3tGWsPzQFGC0BZtzeX9SvqC3RlngSGjuk/GuX8kMoea0ZWjv++huLi0+3osCc5UWg== X-Received: by 2002:a05:6a00:1514:b0:49f:b5ef:affb with SMTP id q20-20020a056a00151400b0049fb5efaffbmr21687514pfu.7.1638573619809; Fri, 03 Dec 2021 15:20:19 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:19 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Asutosh Das , Alim Akhtar , Bean Huo , kernel test robot , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu Subject: [PATCH v4 03/17] scsi: ufs: Remove is_rpmb_wlun() Date: Fri, 3 Dec 2021 15:19:36 -0800 Message-Id: <20211203231950.193369-4-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Commit edc0596cc04b ("scsi: ufs: core: Stop clearing UNIT ATTENTIONS") removed all callers of is_rpmb_wlun(). Hence also remove the function itself. Reviewed-by: Asutosh Das Reviewed-by: Alim Akhtar Reviewed-by: Bean Huo Tested-by: Bean Huo Reported-by: kernel test robot Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 024f6d958341..4821ad9912bb 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2650,11 +2650,6 @@ static inline u16 ufshcd_upiu_wlun_to_scsi_wlun(u8 upiu_wlun_id) return (upiu_wlun_id & ~UFS_UPIU_WLUN_ID) | SCSI_W_LUN_BASE; } -static inline bool is_rpmb_wlun(struct scsi_device *sdev) -{ - return sdev->lun == ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN); -} - static inline bool is_device_wlun(struct scsi_device *sdev) { return sdev->lun == From patchwork Fri Dec 3 23:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7561CC433F5 for ; Fri, 3 Dec 2021 23:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376761AbhLCXXx (ORCPT ); Fri, 3 Dec 2021 18:23:53 -0500 Received: from mail-pj1-f51.google.com ([209.85.216.51]:53086 "EHLO mail-pj1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXXw (ORCPT ); Fri, 3 Dec 2021 18:23:52 -0500 Received: by mail-pj1-f51.google.com with SMTP id h24so3446525pjq.2 for ; Fri, 03 Dec 2021 15:20:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rIFpmEaQVzQJF4yxUEcHb+hAveqBxGps251VVNl6QYs=; b=PUI4ExO3HLA1v5qnSqEdUxI54Ireq/vQzV9o9s7cipuZ/t+XxW8uDN1MgDEN5irQRv zZCiv+21rVslEGLVSqrrRxi2nc7uy4QhYaqgNO9Ndm/CyBdv5ghjobl+z7EbXoUbfMiE CGGzKFjvMbp4QTmNuVE2H7p5YSXCzWHEad/aazWaBtbs7A6xHEiqh2EgTkQOH2HGXKo/ g2Y5WOfbh+TA80YUoo2FlGyhs7rPxXEZTVpYiaWUEBc1KAaUE0GXhDn2OX9JcqHH3cL8 scwgAyBnSEIQwPy1atqn6KY1pbn+5JUwJrCh3kac16kg7zzzZIdcrRBqDhyHHqc75lIM AciA== X-Gm-Message-State: AOAM533P+5dWB/y4ugaurd+cNabRY7SiaoeiaioZmxLamhPHbqdT10th yNtcxTHSpUzHjK6l2GLhVanhcbrSLLw= X-Google-Smtp-Source: ABdhPJxQJDUTAO6F/8miXTrGs2Jp0x+kmgA3YnP38ZCpsIq91lujo3TT87kN8ty/YPtTiDdQWGXlBw== X-Received: by 2002:a17:902:c145:b0:142:50c3:c2a with SMTP id 5-20020a170902c14500b0014250c30c2amr26093887plj.32.1638573628194; Fri, 03 Dec 2021 15:20:28 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:27 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Asutosh Das , Alim Akhtar , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Keoseong Park Subject: [PATCH v4 04/17] scsi: ufs: Remove the sdev_rpmb member Date: Fri, 3 Dec 2021 15:19:37 -0800 Message-Id: <20211203231950.193369-5-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Since the sdev_rpmb member of struct ufs_hba is only used inside ufshcd_scsi_add_wlus(), convert it into a local variable. Reviewed-by: Asutosh Das Reviewed-by: Alim Akhtar Reviewed-by: Bean Huo Tested-by: Bean Huo Suggested-by: Jaegeuk Kim Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 12 ++++++------ drivers/scsi/ufs/ufshcd.h | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4821ad9912bb..973b7b083dbe 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7412,7 +7412,7 @@ static inline void ufshcd_blk_pm_runtime_init(struct scsi_device *sdev) static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) { int ret = 0; - struct scsi_device *sdev_boot; + struct scsi_device *sdev_boot, *sdev_rpmb; hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0, ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL); @@ -7423,14 +7423,14 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) } scsi_device_put(hba->sdev_ufs_device); - hba->sdev_rpmb = __scsi_add_device(hba->host, 0, 0, + sdev_rpmb = __scsi_add_device(hba->host, 0, 0, ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL); - if (IS_ERR(hba->sdev_rpmb)) { - ret = PTR_ERR(hba->sdev_rpmb); + if (IS_ERR(sdev_rpmb)) { + ret = PTR_ERR(sdev_rpmb); goto remove_sdev_ufs_device; } - ufshcd_blk_pm_runtime_init(hba->sdev_rpmb); - scsi_device_put(hba->sdev_rpmb); + ufshcd_blk_pm_runtime_init(sdev_rpmb); + scsi_device_put(sdev_rpmb); sdev_boot = __scsi_add_device(hba->host, 0, 0, ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 28c1bbe9fa7d..ecc6c545a19d 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -809,7 +809,6 @@ struct ufs_hba { * "UFS device" W-LU. */ struct scsi_device *sdev_ufs_device; - struct scsi_device *sdev_rpmb; #ifdef CONFIG_SCSI_UFS_HWMON struct device *hwmon_device; From patchwork Fri Dec 3 23:19:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62DB0C433F5 for ; Fri, 3 Dec 2021 23:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376773AbhLCXX6 (ORCPT ); Fri, 3 Dec 2021 18:23:58 -0500 Received: from mail-pf1-f172.google.com ([209.85.210.172]:42569 "EHLO mail-pf1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXX5 (ORCPT ); Fri, 3 Dec 2021 18:23:57 -0500 Received: by mail-pf1-f172.google.com with SMTP id u80so4266776pfc.9 for ; Fri, 03 Dec 2021 15:20:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XzOn4f/acWOzRXs1p+hJdHukOKqsYgZHwz6SxIy9I7U=; b=t+KABHF4zkQvN5Ar38ZChTp1Z/eqm0YLND10xiEO5sp2Noc7/6Bs3RIcrZfQjpr3CL R/0fWNJx8g85UNW8D/3bO0QOB8mx1XCiQLOJASiNADv0senxkSYVAbcqWsvx8s9/Hd5c +l7lQuK+X+q/P6OIsPEmTnqTDAqwO4R+ZSx2U57bZ1nNHf9mVsVrpDLsloilcE4gswxm aXirUAMZSO9Li9U+DGG+ZPtOtMWNh+Bx+0W6i9vJ+zhD5m0c/6XGWhfXylbodeq+/eL+ AVTOXpiL1hmOC15mImrao8TEWo2ytiB88fAPdwvTr1z1uvpXp0PcYljXJkR0j6BLc4kL FHgQ== X-Gm-Message-State: AOAM533zNCt8A1wmkzjFdil4dL4FbgG4CSlT5tEkoEpr3qQONKs7UN7s XUylNt85REue+nRrtJXHNns= X-Google-Smtp-Source: ABdhPJw8twbCrFh3aDVYKZoPxDR5Hh3sIYlQxMsvVdBZ7dZ8SUf5eF5m0PdCb7FUedzGSIneWNAtzg== X-Received: by 2002:a63:914c:: with SMTP id l73mr6911480pge.184.1638573633199; Fri, 03 Dec 2021 15:20:33 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:32 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Avri Altman , Bean Huo , "James E.J. Bottomley" , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 05/17] scsi: ufs: Remove dead code Date: Fri, 3 Dec 2021 15:19:38 -0800 Message-Id: <20211203231950.193369-6-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Commit 7252a3603015 ("scsi: ufs: Avoid busy-waiting by eliminating tag conflicts") guarantees that 'tag' is not in use by any SCSI command. Remove the check that returns early if a conflict occurs. Acked-by: Avri Altman Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 973b7b083dbe..d4996ada55b6 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6730,11 +6730,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, tag = req->tag; WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); - if (unlikely(test_bit(tag, &hba->outstanding_reqs))) { - err = -EBUSY; - goto out; - } - lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = NULL; @@ -6802,8 +6797,8 @@ 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); -out: blk_mq_free_request(req); + out_unlock: up_read(&hba->clk_scaling_lock); return err; From patchwork Fri Dec 3 23:19:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 048C1C433F5 for ; Fri, 3 Dec 2021 23:20:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376848AbhLCXYK (ORCPT ); Fri, 3 Dec 2021 18:24:10 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:43555 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXYJ (ORCPT ); Fri, 3 Dec 2021 18:24:09 -0500 Received: by mail-pl1-f177.google.com with SMTP id m24so3096964pls.10 for ; Fri, 03 Dec 2021 15:20:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=putL4xFG36SbL3f3NePHbD7K4DAwsBAAKE4Bav0mrJU=; b=8PFmGFudlY+3D31vmHkeyyz0ia63pojcrcwXCwK+OM5vaTN9yhqatCpLaIrWSEFx9O HO/JBbTq3b+yuUfCkGLZLgId9s2HI299DGMlsxLQJ8TDyL0eJKJ/3aNkJtQ49dpcsgWY rJwxcpWokGIMCjpRU/W18WwuZ9zeVbNdtiJGfk5D8lZcDOKzmwOuCFM9OjxgGYThQsuN 5ShfRtuf41aG4+A7mlO6HEq3uER1NUl6W32xdFuFkoDvTYQGUjB00JNVCn4qKGqdMXu1 fJQo6Mc6J2t3EJjYcQ/FQMzS79D4iVkQmlkSS6Nh86MizOMwL2yi5OhsQiHliEw5e71Y UJTQ== X-Gm-Message-State: AOAM532qkW1/qIrPOmB3ptRZNBgiCP+R3v6nb3sDrYDAS8hBvc1KPXca 34V2HsZztiFnVhXj6EmdSX4= X-Google-Smtp-Source: ABdhPJxwB9czl1wsGACRFx/F5EMfGQ+VoXxz5vQx5vnMEzCsux8F9wQ07Tik9e8UxVi5/fBg9KG/mg== X-Received: by 2002:a17:90b:4c8b:: with SMTP id my11mr18038150pjb.96.1638573644754; Fri, 03 Dec 2021 15:20:44 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:44 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , Alexey Dobriyan , "James E.J. Bottomley" , Avri Altman , Asutosh Das , Stanley Chu , Yue Hu , Sergey Shtylyov , Srinivas Kandagatla , Can Guo , Vinayak Holikatti , Santosh Yaraganavi , Namjae Jeon , Arnd Bergmann Subject: [PATCH v4 06/17] scsi: ufs: Fix race conditions related to driver data Date: Fri, 3 Dec 2021 15:19:39 -0800 Message-Id: <20211203231950.193369-7-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver data pointer must be set before any callbacks are registered that use that pointer. Hence move the initialization of that pointer from after the ufshcd_init() call to inside ufshcd_init(). Fixes: 3b1d05807a9a ("[SCSI] ufs: Segregate PCI Specific Code") Reviewed-by: Bean Huo Tested-by: Bean Huo Reported-by: Alexey Dobriyan Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/tc-dwc-g210-pci.c | 1 - drivers/scsi/ufs/ufshcd-pci.c | 2 -- drivers/scsi/ufs/ufshcd-pltfrm.c | 2 -- drivers/scsi/ufs/ufshcd.c | 7 +++++++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c b/drivers/scsi/ufs/tc-dwc-g210-pci.c index 679289e1a78e..7b08e2e07cc5 100644 --- a/drivers/scsi/ufs/tc-dwc-g210-pci.c +++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c @@ -110,7 +110,6 @@ tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return err; } - pci_set_drvdata(pdev, hba); pm_runtime_put_noidle(&pdev->dev); pm_runtime_allow(&pdev->dev); diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index 51424557810d..a673eedb2f05 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -522,8 +522,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return err; } - pci_set_drvdata(pdev, hba); - hba->vops = (struct ufs_hba_variant_ops *)id->driver_data; err = ufshcd_init(hba, mmio_base, pdev->irq); diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index eaeae83b999f..8b16bbbcb806 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -361,8 +361,6 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, goto dealloc_host; } - platform_set_drvdata(pdev, hba); - pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d4996ada55b6..04a19b826837 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9481,6 +9481,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) struct device *dev = hba->dev; char eh_wq_name[sizeof("ufs_eh_wq_00")]; + /* + * dev_set_drvdata() must be called before any callbacks are registered + * that use dev_get_drvdata() (frequency scaling, clock scaling, hwmon, + * sysfs). + */ + dev_set_drvdata(dev, hba); + if (!mmio_base) { dev_err(hba->dev, "Invalid memory reference for mmio_base is NULL\n"); From patchwork Fri Dec 3 23:19:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 647F6C433F5 for ; Fri, 3 Dec 2021 23:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383340AbhLCXYO (ORCPT ); Fri, 3 Dec 2021 18:24:14 -0500 Received: from mail-pj1-f45.google.com ([209.85.216.45]:55060 "EHLO mail-pj1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXYO (ORCPT ); Fri, 3 Dec 2021 18:24:14 -0500 Received: by mail-pj1-f45.google.com with SMTP id np3so3426473pjb.4 for ; Fri, 03 Dec 2021 15:20:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0/WF1cKS8jhYGebwL6h+RPxXoGzjOvzbqSF8ETpM3SU=; b=v1OpmG2UQbc3tQAizoXwuUlwLiPmI8GEzJn5zT5TmU3ANVLVLcl5S9fdjCuNuifTTm dPUKSE4VnHrkQDM0r4FRu4tR2QOisme1M3a2FzYKrpaFTk8qBBjcPSMQ9ogbmTJgNziP ArIjbpKrXVCcGffVAQJmKerjl9fLeSmjByT5hP1GKJNdKm8dwOSRMbNGKJuyG4x1h90p Q5jVMqAykPxyvYm8zBeB7i4IwMCLU2mjQ6SnqyYZlQHNjZ/T4xbgPTSvJBRrLdgFAC+W +KlY4EUJdjnEaFSgMk0QQ6n+Uq5amRKlaVpqGQ+zIhi49ZR2fhE+M0/fixfiBTwhL6NF HGJQ== X-Gm-Message-State: AOAM530XM0jc+SSqwpagot48MrdWgkN+zc/CnqjaSsJld+xxCQruN+L/ Kav2RZPmKKJXvdZzb2osDAo= X-Google-Smtp-Source: ABdhPJwkw+vdayduepI3bT9gYPJj+40R76maxYNKBIy4yo0r3K4H1eJcqmO1nosYaGX12LuAQ2fJjQ== X-Received: by 2002:a17:90a:1b45:: with SMTP id q63mr17934696pjq.135.1638573649766; Fri, 03 Dec 2021 15:20:49 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:49 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 07/17] scsi: ufs: Remove ufshcd_any_tag_in_use() Date: Fri, 3 Dec 2021 15:19:40 -0800 Message-Id: <20211203231950.193369-8-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use hba->outstanding_reqs instead of ufshcd_any_tag_in_use(). This patch prepares for removal of the blk_mq_start_request() call from ufshcd_wait_for_dev_cmd(). blk_mq_tagset_busy_iter() only iterates over started requests. Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 04a19b826837..974bf47e733c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1352,25 +1352,6 @@ static int ufshcd_devfreq_target(struct device *dev, return ret; } -static bool ufshcd_is_busy(struct request *req, void *priv, bool reserved) -{ - int *busy = priv; - - WARN_ON_ONCE(reserved); - (*busy)++; - return false; -} - -/* Whether or not any tag is in use by a request that is in progress. */ -static bool ufshcd_any_tag_in_use(struct ufs_hba *hba) -{ - struct request_queue *q = hba->cmd_queue; - int busy = 0; - - blk_mq_tagset_busy_iter(q->tag_set, ufshcd_is_busy, &busy); - return busy; -} - static int ufshcd_devfreq_get_dev_status(struct device *dev, struct devfreq_dev_status *stat) { @@ -1769,7 +1750,7 @@ static void ufshcd_gate_work(struct work_struct *work) if (hba->clk_gating.active_reqs || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL - || ufshcd_any_tag_in_use(hba) || hba->outstanding_tasks + || hba->outstanding_reqs || hba->outstanding_tasks || hba->active_uic_cmd || hba->uic_async_done) goto rel_lock; From patchwork Fri Dec 3 23:19:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F13EAC433EF for ; Fri, 3 Dec 2021 23:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383417AbhLCXYU (ORCPT ); Fri, 3 Dec 2021 18:24:20 -0500 Received: from mail-pg1-f172.google.com ([209.85.215.172]:33674 "EHLO mail-pg1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376419AbhLCXYT (ORCPT ); Fri, 3 Dec 2021 18:24:19 -0500 Received: by mail-pg1-f172.google.com with SMTP id f125so4589586pgc.0 for ; Fri, 03 Dec 2021 15:20:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xnK/yQe9eicvD/7ZRJSIPZCIvlJeOYBgRPK+Xw3/s9Y=; b=akPd8cnm6FIY/VvZqS3u4LuIWMOl2cjQ1BOHH0khJh6Jr3KogblojRWoos877JppYG rYDQ/nH0NK4dG8MxgcnRx40c1kpVLyw3cT6m9lAuUPrenEg1X9x82vGNYyLOCzVD4jYi 8SIh75S7/CBgX2P+Bo3cE1jBs2uZDexgiNyhqmIUh9lOFI4uE+J4CwihvlKtAZIrA0pm zA0P8Udoj/5K4/FbCjW5FqHu3gkh/KoFCg7JM3vUXEpJAPOCNHphSCHXphx0ccqKpaMJ tPXUQXMI7YysC3bu7do6yTvx78I90fyjbPvzPAbILOgd81hfOo/XkKLF29TAf2+0jyJl ckUA== X-Gm-Message-State: AOAM531x0bz45gt713gDTJVAk4W18Msmro2+0zxazE3daGUbxwKc0FH2 9y01o1R4mpJ5LeWUFhXQdWI= X-Google-Smtp-Source: ABdhPJwI+sd5o5yu5cWFZN1FFfY+S2bN4qe8l42FkgT5hQQozVbqZ/JaXkoU6+SneRnmIR5t8fVgcQ== X-Received: by 2002:a63:155:: with SMTP id 82mr6905426pgb.485.1638573654773; Fri, 03 Dec 2021 15:20:54 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:20:54 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 08/17] scsi: ufs: Rework ufshcd_change_queue_depth() Date: Fri, 3 Dec 2021 15:19:41 -0800 Message-Id: <20211203231950.193369-9-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Prepare for making sdev->host->can_queue less than hba->nutrs. This patch does not change any functionality. Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 974bf47e733c..2d0f59424b00 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4936,11 +4936,7 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) */ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) { - struct ufs_hba *hba = shost_priv(sdev->host); - - if (depth > hba->nutrs) - depth = hba->nutrs; - return scsi_change_queue_depth(sdev, depth); + return scsi_change_queue_depth(sdev, min(depth, sdev->host->can_queue)); } static void ufshcd_hpb_destroy(struct ufs_hba *hba, struct scsi_device *sdev) From patchwork Fri Dec 3 23:19:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E98C433EF for ; Fri, 3 Dec 2021 23:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376419AbhLCXY2 (ORCPT ); Fri, 3 Dec 2021 18:24:28 -0500 Received: from mail-pl1-f169.google.com ([209.85.214.169]:35620 "EHLO mail-pl1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383427AbhLCXY1 (ORCPT ); Fri, 3 Dec 2021 18:24:27 -0500 Received: by mail-pl1-f169.google.com with SMTP id b13so3135599plg.2 for ; Fri, 03 Dec 2021 15:21:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k+z3aWmRALc/WpQMZQ99+JVqTGUzpli10NeNZx3r8HA=; b=KHfwocWyj7r6oQdDC1i4u/YdsbliERZN3TfISSRnGKHS164EjsvB902BewFmuvl6iN 0niKAxXJ8PhV3ojriBioJdoaY7pE5AcgglIHF/Iv7Q1pNcffvJTvKLB6cXNYGRVZ6CYD h9sXO1flISjs20sy2IeEGTGSVQaM9mlBQDbaOAqZIb/+fVLIJDD3gdU5U3MlvpClrOwr vP5zbf02uQrAhI4ud0kQF1NwvDovhljHEGrsIHrMgDhbHgUDNGUpsAWUmiPIpZ7pmkAM o9HqS89LgoMKHFruSBOhuTB/SO5LshpSvQsoHjTd2EST/2jFg37MS5iWJHvQgqUOzfE2 DyRg== X-Gm-Message-State: AOAM530aeoQ69enybwYvvLuQHQRw0FiGU59BeSPhKYBThDBdWRcyGBUR 2O6tt/9uogexwz5m8wPVDNg= X-Google-Smtp-Source: ABdhPJy9wUVZ4spM0cOAlRLn1//vqayxtfTV0DtvNuclExMW8N4Gzvj4pjuV2b07mnlxzXd4y/1URQ== X-Received: by 2002:a17:903:1109:b0:143:85f3:af29 with SMTP id n9-20020a170903110900b0014385f3af29mr26376663plh.47.1638573662974; Fri, 03 Dec 2021 15:21:02 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:02 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das , Keoseong Park Subject: [PATCH v4 09/17] scsi: ufs: Fix a deadlock in the error handler Date: Fri, 3 Dec 2021 15:19:42 -0800 Message-Id: <20211203231950.193369-10-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The following deadlock has been observed on a test setup: * All tags allocated. * The SCSI error handler calls ufshcd_eh_host_reset_handler() * ufshcd_eh_host_reset_handler() queues work that calls ufshcd_err_handler() * ufshcd_err_handler() locks up as follows: Workqueue: ufs_eh_wq_0 ufshcd_err_handler.cfi_jt Call trace: __switch_to+0x298/0x5d8 __schedule+0x6cc/0xa94 schedule+0x12c/0x298 blk_mq_get_tag+0x210/0x480 __blk_mq_alloc_request+0x1c8/0x284 blk_get_request+0x74/0x134 ufshcd_exec_dev_cmd+0x68/0x640 ufshcd_verify_dev_init+0x68/0x35c ufshcd_probe_hba+0x12c/0x1cb8 ufshcd_host_reset_and_restore+0x88/0x254 ufshcd_reset_and_restore+0xd0/0x354 ufshcd_err_handler+0x408/0xc58 process_one_work+0x24c/0x66c worker_thread+0x3e8/0xa4c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30 Fix this lockup by making ufshcd_exec_dev_cmd() allocate a reserved request. Reviewed-by: Adrian Hunter Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 53 +++++++++++---------------------------- drivers/scsi/ufs/ufshcd.h | 2 ++ 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2d0f59424b00..da4714aaa850 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -128,8 +128,9 @@ EXPORT_SYMBOL_GPL(ufshcd_dump_regs); enum { UFSHCD_MAX_CHANNEL = 0, UFSHCD_MAX_ID = 1, - UFSHCD_CMD_PER_LUN = 32, - UFSHCD_CAN_QUEUE = 32, + UFSHCD_NUM_RESERVED = 1, + UFSHCD_CMD_PER_LUN = 32 - UFSHCD_NUM_RESERVED, + UFSHCD_CAN_QUEUE = 32 - UFSHCD_NUM_RESERVED, }; static const char *const ufshcd_state_name[] = { @@ -2170,6 +2171,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS) + 1; hba->nutmrs = ((hba->capabilities & MASK_TASK_MANAGEMENT_REQUEST_SLOTS) >> 16) + 1; + hba->reserved_slot = hba->nutrs - 1; /* Read crypto capabilities */ err = ufshcd_hba_init_crypto_capabilities(hba); @@ -2912,30 +2914,15 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, enum dev_cmd_type cmd_type, int timeout) { - struct request_queue *q = hba->cmd_queue; DECLARE_COMPLETION_ONSTACK(wait); - struct request *req; + const u32 tag = hba->reserved_slot; struct ufshcd_lrb *lrbp; int err; - int tag; - down_read(&hba->clk_scaling_lock); + /* Protects use of hba->reserved_slot. */ + lockdep_assert_held(&hba->dev_cmd.lock); - /* - * Get free slot, sleep if slots are unavailable. - * Even though we use wait_event() which sleeps indefinitely, - * the maximum wait time is bounded by SCSI request timeout. - */ - req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); - if (IS_ERR(req)) { - err = PTR_ERR(req); - goto out_unlock; - } - tag = req->tag; - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); - /* Set the timeout such that the SCSI error handler is not activated. */ - req->timeout = msecs_to_jiffies(2 * timeout); - blk_mq_start_request(req); + down_read(&hba->clk_scaling_lock); lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); @@ -2953,8 +2940,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); out: - blk_mq_free_request(req); -out_unlock: up_read(&hba->clk_scaling_lock); return err; } @@ -6689,23 +6674,16 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, enum dev_cmd_type cmd_type, enum query_opcode desc_op) { - struct request_queue *q = hba->cmd_queue; DECLARE_COMPLETION_ONSTACK(wait); - struct request *req; + const u32 tag = hba->reserved_slot; struct ufshcd_lrb *lrbp; int err = 0; - int tag; u8 upiu_flags; - down_read(&hba->clk_scaling_lock); + /* Protects use of hba->reserved_slot. */ + lockdep_assert_held(&hba->dev_cmd.lock); - req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); - if (IS_ERR(req)) { - err = PTR_ERR(req); - goto out_unlock; - } - tag = req->tag; - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); + down_read(&hba->clk_scaling_lock); lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); @@ -6774,9 +6752,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); - blk_mq_free_request(req); - -out_unlock: up_read(&hba->clk_scaling_lock); return err; } @@ -9507,8 +9482,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) /* Configure LRB */ ufshcd_host_memory_configure(hba); - host->can_queue = hba->nutrs; - host->cmd_per_lun = hba->nutrs; + host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; + host->cmd_per_lun = hba->nutrs - UFSHCD_NUM_RESERVED; host->max_id = UFSHCD_MAX_ID; host->max_lun = UFS_MAX_LUNS; host->max_channel = UFSHCD_MAX_CHANNEL; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index ecc6c545a19d..c3c2792f309f 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -745,6 +745,7 @@ struct ufs_hba_monitor { * @capabilities: UFS Controller Capabilities * @nutrs: Transfer Request Queue depth supported by controller * @nutmrs: Task Management Queue depth supported by controller + * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock. * @ufs_version: UFS Version to which controller complies * @vops: pointer to variant specific operations * @priv: pointer to variant specific private data @@ -836,6 +837,7 @@ struct ufs_hba { u32 capabilities; int nutrs; int nutmrs; + u32 reserved_slot; u32 ufs_version; const struct ufs_hba_variant_ops *vops; struct ufs_hba_variant_params *vps; From patchwork Fri Dec 3 23:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B955EC433F5 for ; Fri, 3 Dec 2021 23:21:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383428AbhLCXYg (ORCPT ); Fri, 3 Dec 2021 18:24:36 -0500 Received: from mail-pl1-f174.google.com ([209.85.214.174]:40889 "EHLO mail-pl1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383421AbhLCXYg (ORCPT ); Fri, 3 Dec 2021 18:24:36 -0500 Received: by mail-pl1-f174.google.com with SMTP id v19so3118213plo.7 for ; Fri, 03 Dec 2021 15:21:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QO87TjjZHhEnTm5wG2q7sGnYRMn1FImZKprz4Ef5To4=; b=O/6i9Ao38ZzyqSaBQbBnYVZLCeCxWirJdi2VZyrVf+zMn4FW7OBZhkwrm8KNpdAQtJ CSxsNwa26yGxVsGBv2UddS357LHzg74UYCkiHd6iCnXfCuIHhiuurVJbtzc+iUa5x14R Z3v/cBurTGLVfuCtjBgp0A5BFgdy0Z4lWPfM9nGOgPjsAYqKFYU0Jcxb0jidQBfv7yiN MwvuFVAeD508PTrKO4hIYr+JVosjIcOL+kiGO3WgMEh1irZ9hTS7AQFT8gSM5PHkYILG Glcw3uL302lK5j8WYcnJzucFyugfVKM6VDG3DqiZx9x+73lcL7GXr25cZlWxJJR3qSRH h8zQ== X-Gm-Message-State: AOAM531tbVvQyvyT6bsJF00mHEJkUZHJAk7aFnQw+Dw9kRGJGMXdIt1W QyuwVuUllFnydD0oEV5Jx5Y= X-Google-Smtp-Source: ABdhPJzAHNmWybilw3Sj6/muUWyXfeI5I/Zb5w10pzvK6xN7Z+3BP6alPJl6OoD5xvPExtv342UcyQ== X-Received: by 2002:a17:90a:fe0b:: with SMTP id ck11mr17432009pjb.15.1638573671472; Fri, 03 Dec 2021 15:21:11 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:10 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das , Keoseong Park Subject: [PATCH v4 10/17] scsi: ufs: Remove hba->cmd_queue Date: Fri, 3 Dec 2021 15:19:43 -0800 Message-Id: <20211203231950.193369-11-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The previous patch removed all code that uses hba->cmd_queue. Hence also remove hba->cmd_queue itself. Reviewed-by: Adrian Hunter Reviewed-by: Bean Huo Tested-by: Bean Huo Suggested-by: Adrian Hunter Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 11 +---------- drivers/scsi/ufs/ufshcd.h | 2 -- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index da4714aaa850..2cd777d92c7b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9331,7 +9331,6 @@ void ufshcd_remove(struct ufs_hba *hba) ufs_sysfs_remove_nodes(hba->dev); blk_cleanup_queue(hba->tmf_queue); blk_mq_free_tag_set(&hba->tmf_tag_set); - blk_cleanup_queue(hba->cmd_queue); scsi_remove_host(hba->host); /* disable interrupts */ ufshcd_disable_intr(hba, hba->intr_mask); @@ -9551,12 +9550,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) goto out_disable; } - hba->cmd_queue = blk_mq_init_queue(&hba->host->tag_set); - if (IS_ERR(hba->cmd_queue)) { - err = PTR_ERR(hba->cmd_queue); - goto out_remove_scsi_host; - } - hba->tmf_tag_set = (struct blk_mq_tag_set) { .nr_hw_queues = 1, .queue_depth = hba->nutmrs, @@ -9565,7 +9558,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) }; err = blk_mq_alloc_tag_set(&hba->tmf_tag_set); if (err < 0) - goto free_cmd_queue; + goto out_remove_scsi_host; hba->tmf_queue = blk_mq_init_queue(&hba->tmf_tag_set); if (IS_ERR(hba->tmf_queue)) { err = PTR_ERR(hba->tmf_queue); @@ -9634,8 +9627,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) blk_cleanup_queue(hba->tmf_queue); free_tmf_tag_set: blk_mq_free_tag_set(&hba->tmf_tag_set); -free_cmd_queue: - blk_cleanup_queue(hba->cmd_queue); out_remove_scsi_host: scsi_remove_host(hba->host); out_disable: diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index c3c2792f309f..8e942762e668 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -738,7 +738,6 @@ struct ufs_hba_monitor { * @host: Scsi_Host instance of the driver * @dev: device handle * @lrb: local reference block - * @cmd_queue: Used to allocate command tags from hba->host->tag_set. * @outstanding_tasks: Bits representing outstanding task requests * @outstanding_lock: Protects @outstanding_reqs. * @outstanding_reqs: Bits representing outstanding transfer requests @@ -804,7 +803,6 @@ struct ufs_hba { struct Scsi_Host *host; struct device *dev; - struct request_queue *cmd_queue; /* * This field is to keep a reference to "scsi_device" corresponding to * "UFS device" W-LU. From patchwork Fri Dec 3 23:19:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E186DC433F5 for ; Fri, 3 Dec 2021 23:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383430AbhLCXYl (ORCPT ); Fri, 3 Dec 2021 18:24:41 -0500 Received: from mail-pj1-f44.google.com ([209.85.216.44]:35357 "EHLO mail-pj1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383421AbhLCXYl (ORCPT ); Fri, 3 Dec 2021 18:24:41 -0500 Received: by mail-pj1-f44.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso6363937pji.0 for ; Fri, 03 Dec 2021 15:21:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=39KmaVXublhCNLRTgpUKfx7YNz4c3+aUjhGSuwczddg=; b=HI5IEuv+P9VPHo96cj0pEXB8BAluRlmuG2u4Aa7FebOorcwXipmSXyN8fVeeRiz4IH AI0R/fEIrNEAPODLjRDqmBlzZv+fLoA6p6YwPbHkUxyE2nd78a+ozQ5dz5b832BCY+z7 BtCktJ5E8XKreWLqjQxIfBDMazc1J4CJK6OoeDLhLHfftPHC4STrzfzGsMoVnPxEMuMr P4x4qqoAdegwKfHN7QKxR5SfOCJVIZabSe+u0m3rHRsTQeUJYAki91GYbWLO+qKLI/nT +ivFjnJ/pBu5mS9Gm9zx89KkIUalD7z8lzQ2nPP3aUJe8zqxEM6wv+S4W5kmCvoB5E/h o0xg== X-Gm-Message-State: AOAM531Z5eGMFS1RD0qKqsyZNectH0cl2EEguKBgAoMy4PYT7KGQRp4U 6ridm/wXaNiErj6sxbCxcso= X-Google-Smtp-Source: ABdhPJxBYQnoD9HdC7M2Y5tjvKzBkOEC2wqoxC7hF1anXnppjB2wOCDzDh0zTdlFUKddtRXABDskbg== X-Received: by 2002:a17:90b:3848:: with SMTP id nl8mr17505203pjb.221.1638573676686; Fri, 03 Dec 2021 15:21:16 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:16 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 11/17] scsi: ufs: Remove the 'update_scaling' local variable Date: Fri, 3 Dec 2021 15:19:44 -0800 Message-Id: <20211203231950.193369-12-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch does not change any functionality but makes the next patch in this series easier to read. Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2cd777d92c7b..27574aef5374 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5225,7 +5225,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, struct scsi_cmnd *cmd; int result; int index; - bool update_scaling = false; for_each_set_bit(index, &completed_reqs, hba->nutrs) { lrbp = &hba->lrb[index]; @@ -5243,18 +5242,16 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, /* Do not touch lrbp after scsi done */ scsi_done(cmd); ufshcd_release(hba); - update_scaling = true; + ufshcd_clk_scaling_update_busy(hba); } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { if (hba->dev_cmd.complete) { ufshcd_add_command_trace(hba, index, UFS_DEV_COMP); complete(hba->dev_cmd.complete); - update_scaling = true; + ufshcd_clk_scaling_update_busy(hba); } } - if (update_scaling) - ufshcd_clk_scaling_update_busy(hba); } } From patchwork Fri Dec 3 23:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01938C433F5 for ; Fri, 3 Dec 2021 23:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383433AbhLCXYr (ORCPT ); Fri, 3 Dec 2021 18:24:47 -0500 Received: from mail-pj1-f47.google.com ([209.85.216.47]:38757 "EHLO mail-pj1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383432AbhLCXYq (ORCPT ); Fri, 3 Dec 2021 18:24:46 -0500 Received: by mail-pj1-f47.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so6310584pju.3 for ; Fri, 03 Dec 2021 15:21:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OfYIjYMvSESmJftxJGkLriH/+C/5Xhx2gxHA+6duJzg=; b=NqstqAibXdm6rIVJ7M3MihwuVRAD4JYhg/q1Dh6F+0uf4j0LT3KEzElIuLHAg2vhI/ iwDg/nQrk8D4rp7OMCGPxjyLbxZRnLTViqFUIfHLQY+f2jDAe73T/yOyDpEwtt/1adja sGyAuLvpYe2lvyDIZDDfd8ElBC9xUsiS3WJKiPdwL6AOld4Pf4EkgwyIGfZtfc8puFvj xx5/8ljxWi9u4Bl4USSrOsdPltyhjoHAVy3ODlK3Ptjot3FydZ9F55h5FwC5tPB8g92T Jr8Xy+f2OGeIVzG9gHvFfwBUppnvZeqSqu9qw4NQ4ky19sLomH4RHCgerENdTpIECpl2 Lw8Q== X-Gm-Message-State: AOAM530IO8vOMs6EMkrVj+RDE+Z8afTHF7mEljdy1fqWIEdMMQdIjNhH zTncsjyWDBD+cuLsakXobKg= X-Google-Smtp-Source: ABdhPJxZ+Ij/AunIYHYd2SoWWZY71qCvwq/uKp2T7MRnxKlYpS1CkcELWfvAB6Q6mRaK06iPSYxdYA== X-Received: by 2002:a17:90a:1919:: with SMTP id 25mr18012540pjg.154.1638573681851; Fri, 03 Dec 2021 15:21:21 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:21 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 12/17] scsi: ufs: Introduce ufshcd_release_scsi_cmd() Date: Fri, 3 Dec 2021 15:19:45 -0800 Message-Id: <20211203231950.193369-13-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The only functional change in this patch is that scsi_done() is now called after ufshcd_release() and ufshcd_clk_scaling_update_busy() instead of before. The next patch in this series will introduce a call to ufshcd_release_scsi_cmd() in the abort handler. Reviewed-by: Adrian Hunter Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 27574aef5374..5a641610dd74 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5213,6 +5213,18 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) return retval; } +/* Release the resources allocated for processing a SCSI command. */ +static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, + struct ufshcd_lrb *lrbp) +{ + struct scsi_cmnd *cmd = lrbp->cmd; + + scsi_dma_unmap(cmd); + lrbp->cmd = NULL; /* Mark the command as completed. */ + ufshcd_release(hba); + ufshcd_clk_scaling_update_busy(hba); +} + /** * __ufshcd_transfer_req_compl - handle SCSI and query command completion * @hba: per adapter instance @@ -5223,7 +5235,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, { struct ufshcd_lrb *lrbp; struct scsi_cmnd *cmd; - int result; int index; for_each_set_bit(index, &completed_reqs, hba->nutrs) { @@ -5234,15 +5245,10 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) ufshcd_update_monitor(hba, lrbp); ufshcd_add_command_trace(hba, index, UFS_CMD_COMP); - result = ufshcd_transfer_rsp_status(hba, lrbp); - scsi_dma_unmap(cmd); - cmd->result = result; - /* Mark completed command as NULL in LRB */ - lrbp->cmd = NULL; + cmd->result = ufshcd_transfer_rsp_status(hba, lrbp); + ufshcd_release_scsi_cmd(hba, lrbp); /* Do not touch lrbp after scsi done */ scsi_done(cmd); - ufshcd_release(hba); - ufshcd_clk_scaling_update_busy(hba); } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { if (hba->dev_cmd.complete) { From patchwork Fri Dec 3 23:19:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BCC1C433EF for ; Fri, 3 Dec 2021 23:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383437AbhLCXYw (ORCPT ); Fri, 3 Dec 2021 18:24:52 -0500 Received: from mail-pg1-f174.google.com ([209.85.215.174]:41708 "EHLO mail-pg1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383434AbhLCXYw (ORCPT ); Fri, 3 Dec 2021 18:24:52 -0500 Received: by mail-pg1-f174.google.com with SMTP id k4so4502816pgb.8 for ; Fri, 03 Dec 2021 15:21:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZBecXUo6uc6jDRSeY7/hLNr5GsF+L2lRT9/DS17e4zc=; b=XW/KmmQqhthIAlilEillEw/GttkrVoXhtTTCxe+R4Db6bTOJUYFrHNpaQ4OPNT7mto sq3I8mtHRbhVxphvRyNHDDNGQ9g/UsVtSIWHIpNcB5y0THNaIHIrm5329a8uKVA5tFrS UCBALSMzgxpknkEP+YzWVJfzdGX5ptm9Z1yZL9ydxidKX3UPWwihmXjQ1fAEEPmY4I6O +rFKduDVW+jWhCmgbkNp5LUVQTGM2DXjHzXQ83TqB6zIhS4naUyodbGrYaqhZRkYFh+Y zxVZj8yggZ0bCw/yZDxTR8HztqSFy26sP/RsZ+KKxuUHJTk+xL2qznRkXv+cYeqwMRtk 9vyw== X-Gm-Message-State: AOAM531MIyfbTB5JFi19BpZi4JFLzMPrMa8GNcXvYE5DIOUE5Fm2WiC3 V00sWT+qmSe5RljVDoDciFw= X-Google-Smtp-Source: ABdhPJwxT6TMRZzQrGTnMIVZgiC1zgfyapan1z5CXfjNmeNXoOJSbA4KIJuo7DNyVm0r/M/JQE7GlQ== X-Received: by 2002:a05:6a00:24d2:b0:49f:bbce:7bc1 with SMTP id d18-20020a056a0024d200b0049fbbce7bc1mr22398990pfv.37.1638573687233; Fri, 03 Dec 2021 15:21:27 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:26 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das , James Bottomley , Vinayak Holikatti , Namjae Jeon , Santosh Yaraganavi Subject: [PATCH v4 13/17] scsi: ufs: Improve SCSI abort handling further Date: Fri, 3 Dec 2021 15:19:46 -0800 Message-Id: <20211203231950.193369-14-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Release resources when aborting a command. Make sure that aborted commands are completed once by clearing the corresponding tag bit from hba->outstanding_reqs. This patch is an improved version of commit 3ff1f6b6ba6f ("scsi: ufs: core: Improve SCSI abort handling"). Reviewed-by: Adrian Hunter Reviewed-by: Bean Huo Tested-by: Bean Huo Fixes: 7a3e97b0dc4b ("[SCSI] ufshcd: UFS Host controller driver") Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5a641610dd74..06954a6e9d5d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6984,6 +6984,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) struct ufshcd_lrb *lrbp = &hba->lrb[tag]; unsigned long flags; int err = FAILED; + bool outstanding; u32 reg; WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); @@ -7061,6 +7062,17 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } + /* + * Clear the corresponding bit from outstanding_reqs since the command + * has been aborted successfully. + */ + spin_lock_irqsave(&hba->outstanding_lock, flags); + outstanding = __test_and_clear_bit(tag, &hba->outstanding_reqs); + spin_unlock_irqrestore(&hba->outstanding_lock, flags); + + if (outstanding) + ufshcd_release_scsi_cmd(hba, lrbp); + err = SUCCESS; release: From patchwork Fri Dec 3 23:19:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE87BC433EF for ; Fri, 3 Dec 2021 23:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383441AbhLCXY5 (ORCPT ); Fri, 3 Dec 2021 18:24:57 -0500 Received: from mail-pj1-f51.google.com ([209.85.216.51]:44012 "EHLO mail-pj1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383434AbhLCXY5 (ORCPT ); Fri, 3 Dec 2021 18:24:57 -0500 Received: by mail-pj1-f51.google.com with SMTP id nh10-20020a17090b364a00b001a69adad5ebso3741451pjb.2 for ; Fri, 03 Dec 2021 15:21:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r5dKjNMEoD+YYSnRcW9rBk3RuQnWvccJRl67nvbgmks=; b=NMdrrqbkOhe1CpIkfbXSPqoUQZpxhX/5Bu31LZNYr+IbChVaV4E5sj8+8U52bTX0Tk sVpw4A+hpWC48z3Ur7rvR23D5oGrlGr7sGOaktEZ7+duEkAQIDq2W1/WD3nQyftPzonR CPITJ/zlDfvZJeym4hXaN6fqCMZ++0nQqYxxHHRpg6ApPl+2E/GyJ+RRa11FbVrIaHmh 7m8ze9AJd03OJ9G4M6iL56rY+IeclA9cbIupGxYBWGC9KgOo8TjZtVVoG2aynEngrbjq tenlU9kLzgyNhHKR4dKd4Va+84rXMVtueBnxliRe2/7V7uFTEmnn/xJDqgPBuAXaxE4P Hn9Q== X-Gm-Message-State: AOAM533Q9jnRr4g1r4CgkL5ruCaA1pqh14CBl8/XFFFxUewVZ74rQcST 1sQvIJHpOWnAKnBUQ0BfGzo= X-Google-Smtp-Source: ABdhPJxeUO80l+ENYdDAEAOhhPH2IES1DO/fa02XhHriRqgCXfwyoHEbYPGeoLiHQLuzoUi6Lnq0GQ== X-Received: by 2002:a17:90b:4c8b:: with SMTP id my11mr18042521pjb.96.1638573692270; Fri, 03 Dec 2021 15:21:32 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:31 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 14/17] scsi: ufs: Fix a kernel crash during shutdown Date: Fri, 3 Dec 2021 15:19:47 -0800 Message-Id: <20211203231950.193369-15-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Fix the following kernel crash: Unable to handle kernel paging request at virtual address ffffffc91e735000 Call trace: __queue_work+0x26c/0x624 queue_work_on+0x6c/0xf0 ufshcd_hold+0x12c/0x210 __ufshcd_wl_suspend+0xc0/0x400 ufshcd_wl_shutdown+0xb8/0xcc device_shutdown+0x184/0x224 kernel_restart+0x4c/0x124 __arm64_sys_reboot+0x194/0x264 el0_svc_common+0xc8/0x1d4 do_el0_svc+0x30/0x8c el0_svc+0x20/0x30 el0_sync_handler+0x84/0xe4 el0_sync+0x1bc/0x1c0 Fix this crash by ungating the clock before destroying the work queue on which clock gating work is queued. Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 06954a6e9d5d..d434d76aa657 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1648,7 +1648,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) bool flush_result; unsigned long flags; - if (!ufshcd_is_clkgating_allowed(hba)) + if (!ufshcd_is_clkgating_allowed(hba) || + !hba->clk_gating.is_initialized) goto out; spin_lock_irqsave(hba->host->host_lock, flags); hba->clk_gating.active_reqs++; @@ -1808,7 +1809,7 @@ static void __ufshcd_release(struct ufs_hba *hba) if (hba->clk_gating.active_reqs || hba->clk_gating.is_suspended || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL || - hba->outstanding_tasks || + hba->outstanding_tasks || !hba->clk_gating.is_initialized || hba->active_uic_cmd || hba->uic_async_done || hba->clk_gating.state == CLKS_OFF) return; @@ -1943,11 +1944,15 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba) { if (!hba->clk_gating.is_initialized) return; + ufshcd_remove_clk_gating_sysfs(hba); - cancel_work_sync(&hba->clk_gating.ungate_work); - cancel_delayed_work_sync(&hba->clk_gating.gate_work); - destroy_workqueue(hba->clk_gating.clk_gating_workq); + + /* Ungate the clock if necessary. */ + ufshcd_hold(hba, false); hba->clk_gating.is_initialized = false; + ufshcd_release(hba); + + destroy_workqueue(hba->clk_gating.clk_gating_workq); } /* Must be called with host lock acquired */ From patchwork Fri Dec 3 23:19:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1217C433F5 for ; Fri, 3 Dec 2021 23:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383440AbhLCXZC (ORCPT ); Fri, 3 Dec 2021 18:25:02 -0500 Received: from mail-pg1-f171.google.com ([209.85.215.171]:46771 "EHLO mail-pg1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383434AbhLCXZC (ORCPT ); Fri, 3 Dec 2021 18:25:02 -0500 Received: by mail-pg1-f171.google.com with SMTP id r138so4481204pgr.13 for ; Fri, 03 Dec 2021 15:21:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0VNtnzz9TknhCoqF8tEmp0xmaoEWRugruPGfbtRFwJc=; b=oZWuU4nmbsYEmKCyaKppowRsPt6eFZpKPDOTiUNJ/6VdOGdDENFfwYp8QKxL55s8jc TqY5O6oG2Dz57cLILqxrhzv3CTLv/mXOATopMoC5LaDmsJ6VxcFk5zXCr7Iz9Td0By0S RIX2hgAmzFl8ktEtV4Vka9M3iATuhE7iEsXpE7D03JiaBo0ha1FNxE33x0QuSjz8r+Uu zFjJfODuLOBPJbtQ1ON2CljzNJGVQkQC7BDpmBl7fIChTw2+BNRUBpwvWA6oqhGmT7eP VkWhYRRzlTGip5bY23JeigxhN70XkcJeGJVMP3d0xPenJAa8zi+gyUlBQfg/BbyjWz0R QKXg== X-Gm-Message-State: AOAM533/g2W0IApHm5HjkZRbrYiY2rbljvnI/NjxKLhF83nFOx9fDXM+ vjIl4hpkG3mh0ifZgeHwTpA= X-Google-Smtp-Source: ABdhPJz8Iwiy3p5qGkWLqHVaTrZiB+Rqe9elcngdJNQLwKvZr2/aALDMHgDo9LcsZKnMJXy5cVnz4g== X-Received: by 2002:a63:1b4b:: with SMTP id b11mr6886972pgm.322.1638573697417; Fri, 03 Dec 2021 15:21:37 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:36 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 15/17] scsi: ufs: Stop using the clock scaling lock in the error handler Date: Fri, 3 Dec 2021 15:19:48 -0800 Message-Id: <20211203231950.193369-16-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of locking and unlocking the clock scaling lock, surround the command queueing code with an RCU reader lock and call synchronize_rcu(). This patch prepares for removal of the clock scaling lock. Reviewed-by: Adrian Hunter Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d434d76aa657..9f0a1f637030 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2684,6 +2684,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) if (!down_read_trylock(&hba->clk_scaling_lock)) return SCSI_MLQUEUE_HOST_BUSY; + /* + * Allows the UFS error handler to wait for prior ufshcd_queuecommand() + * calls. + */ + rcu_read_lock(); + switch (hba->ufshcd_state) { case UFSHCD_STATE_OPERATIONAL: break; @@ -2762,7 +2768,10 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) } ufshcd_send_command(hba, tag); + out: + rcu_read_unlock(); + up_read(&hba->clk_scaling_lock); if (ufs_trigger_eh()) { @@ -5951,8 +5960,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) } ufshcd_scsi_block_requests(hba); /* Drain ufshcd_queuecommand() */ - down_write(&hba->clk_scaling_lock); - up_write(&hba->clk_scaling_lock); + synchronize_rcu(); cancel_work_sync(&hba->eeh_work); } From patchwork Fri Dec 3 23:19:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A7A4C433EF for ; Fri, 3 Dec 2021 23:21:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383446AbhLCXZL (ORCPT ); Fri, 3 Dec 2021 18:25:11 -0500 Received: from mail-pf1-f181.google.com ([209.85.210.181]:36658 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383434AbhLCXZK (ORCPT ); Fri, 3 Dec 2021 18:25:10 -0500 Received: by mail-pf1-f181.google.com with SMTP id n26so4290190pff.3 for ; Fri, 03 Dec 2021 15:21:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fQ0LbTq+9BDFFCnw0ZkvGkte2ZOCS6MD5p1A6DrPDvg=; b=i8OoaC33MCyS55XJfbAVMQXi5j4RPx2O+P81xLPizQaEoMy17ejt907atmLWGAwrhd np/5ci2oaiIYCp2y+ZhjhuOFaSY2rohnOKOJ1mf5hZVIOooAECgGZgHhrg1hy0X/HLH7 DNwl56I2UnWlTKAZAb6G1mA5gUebVakIqFRE+cX0eP4aBBLY5Ub9LdlSWnFlhCp3RsmM 9sF8YzlBFA9GUXRSpmnmh6KW9FNLhbR986wEdB7sodbkWqjwMMuka5O+HlJeLNId3LF4 TF2F6D4SNvSxYJhSw+5zWc64chwCQRcmEKU4t0SRohaCCpvr/SRC7BACSMc3jStSHALz e78g== X-Gm-Message-State: AOAM532p9g6O5TRjdf0yAln1DtQORuO44Ep9SUuvzx2m+zPTQSGc2TWd SFq1nTEFbQ3nBj8iwUWmiHk= X-Google-Smtp-Source: ABdhPJy+bj8iG9122p5mP0VJGh6eBHDk9JldnE2P4XZcLJRUW7T2KCTRrkMlfKa4Y0WHeGAipeGkEw== X-Received: by 2002:a05:6a00:2182:b0:4a7:ec46:29da with SMTP id h2-20020a056a00218200b004a7ec4629damr21586251pfi.68.1638573705717; Fri, 03 Dec 2021 15:21:45 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:45 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Asutosh Das , "James E.J. Bottomley" , Bean Huo , Avri Altman , Can Guo , Stanley Chu , Keoseong Park Subject: [PATCH v4 16/17] scsi: ufs: Optimize the command queueing code Date: Fri, 3 Dec 2021 15:19:49 -0800 Message-Id: <20211203231950.193369-17-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Remove the clock scaling lock from ufshcd_queuecommand() since it is a performance bottleneck. Instead check the SCSI device budget bitmaps in the code that waits for ongoing ufshcd_queuecommand() calls. A bit is set in sdev->budget_map just before scsi_queue_rq() is called and a bit is cleared from that bitmap if scsi_queue_rq() does not submit the request or after the request has finished. See also the blk_mq_{get,put}_dispatch_budget() calls in the block layer. There is no risk for a livelock since the block layer delays queue reruns if queueing a request fails because the SCSI host has been blocked. Cc: Asutosh Das (asd) Signed-off-by: Bart Van Assche Reviewed-by: Asutosh Das Tested-by: Bjorn Andersson Reviewed-by: Bjorn Andersson --- drivers/scsi/ufs/ufshcd.c | 33 +++++++++++++++++++++++---------- drivers/scsi/ufs/ufshcd.h | 1 + 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9f0a1f637030..650dddf960c2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1070,13 +1070,31 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba, return false; } +/* + * Determine the number of pending commands by counting the bits in the SCSI + * device budget maps. This approach has been selected because a bit is set in + * the budget map before scsi_host_queue_ready() checks the host_self_blocked + * flag. The host_self_blocked flag can be modified by calling + * scsi_block_requests() or scsi_unblock_requests(). + */ +static u32 ufshcd_pending_cmds(struct ufs_hba *hba) +{ + struct scsi_device *sdev; + u32 pending = 0; + + shost_for_each_device(sdev, hba->host) + pending += sbitmap_weight(&sdev->budget_map); + + return pending; +} + static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us) { unsigned long flags; int ret = 0; u32 tm_doorbell; - u32 tr_doorbell; + u32 tr_pending; bool timeout = false, do_last_check = false; ktime_t start; @@ -1094,8 +1112,8 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, } tm_doorbell = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); - tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); - if (!tm_doorbell && !tr_doorbell) { + tr_pending = ufshcd_pending_cmds(hba); + if (!tm_doorbell && !tr_pending) { timeout = false; break; } else if (do_last_check) { @@ -1115,12 +1133,12 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, do_last_check = true; } spin_lock_irqsave(hba->host->host_lock, flags); - } while (tm_doorbell || tr_doorbell); + } while (tm_doorbell || tr_pending); if (timeout) { dev_err(hba->dev, "%s: timedout waiting for doorbell to clear (tm=0x%x, tr=0x%x)\n", - __func__, tm_doorbell, tr_doorbell); + __func__, tm_doorbell, tr_pending); ret = -EBUSY; } out: @@ -2681,9 +2699,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); - if (!down_read_trylock(&hba->clk_scaling_lock)) - return SCSI_MLQUEUE_HOST_BUSY; - /* * Allows the UFS error handler to wait for prior ufshcd_queuecommand() * calls. @@ -2772,8 +2787,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) out: rcu_read_unlock(); - up_read(&hba->clk_scaling_lock); - if (ufs_trigger_eh()) { unsigned long flags; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 8e942762e668..88c20f3608c2 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -778,6 +778,7 @@ struct ufs_hba_monitor { * @clk_list_head: UFS host controller clocks list node head * @pwr_info: holds current power mode * @max_pwr_info: keeps the device max valid pwm + * @clk_scaling_lock: used to serialize device commands and clock scaling * @desc_size: descriptor sizes reported by device * @urgent_bkops_lvl: keeps track of urgent bkops level for device * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for From patchwork Fri Dec 3 23:19:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 520437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4855DC433F5 for ; Fri, 3 Dec 2021 23:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383450AbhLCXZQ (ORCPT ); Fri, 3 Dec 2021 18:25:16 -0500 Received: from mail-pj1-f43.google.com ([209.85.216.43]:52179 "EHLO mail-pj1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383447AbhLCXZP (ORCPT ); Fri, 3 Dec 2021 18:25:15 -0500 Received: by mail-pj1-f43.google.com with SMTP id gt5so3453632pjb.1 for ; Fri, 03 Dec 2021 15:21:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k1jEne7oix7Q/9/XlwRRas5CBY+bXhWVO6Uz2cxXRbg=; b=WUPciCN+IXD6GJfODsL5xXRJ/wXP2TRDpKEmImaFxXwx+2VP/776sj7kPCq439ph6a BVIoWAjucJco1BO5oW7UK59IhXHtjOVEHzggY3TWzDpGw8az+u8z8U6m44yjN1L07cuu Kq3DIkRpGtCTFJp14di753M0OoIPS2rNGq4fFPQjfKbcOY8rHnDNdIppRNulzmrIRTEE 9KsEWtauyP7huQjKHttDJkvhhdbLNe7E/lkreASMikY4axXuGiuE/d/4Ptan8TAbh2hN GGRLHxPKLc8uGuukg8wsTOXNnDPaM7Z87rIv8NpzYHf4ajhR+Xb//txytvgj9z40mkFw HXFA== X-Gm-Message-State: AOAM532jwH819FNyYPEEfiDfQWajrZyb0T/XYfZogBlLm/aBGljKJjRA TRLkF79OCYwnfX0FnA1goL4= X-Google-Smtp-Source: ABdhPJx+5ehgS5uFxrUGnGS9iGSeBiaUBiaDn4qgSFKMaROZSzwq9Ut45PPwsOte5euVZexmIJdd0Q== X-Received: by 2002:a17:90a:7e86:: with SMTP id j6mr18069675pjl.25.1638573710741; Fri, 03 Dec 2021 15:21:50 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f942:89a1:6ccd:130]) by smtp.gmail.com with ESMTPSA id k18sm3233849pgb.70.2021.12.03.15.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 15:21:50 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Bean Huo , "James E.J. Bottomley" , Avri Altman , Can Guo , Stanley Chu , Asutosh Das Subject: [PATCH v4 17/17] scsi: ufs: Implement polling support Date: Fri, 3 Dec 2021 15:19:50 -0800 Message-Id: <20211203231950.193369-18-bvanassche@acm.org> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org> References: <20211203231950.193369-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The time spent in io_schedule() and also the interrupt latency are significant when submitting direct I/O to a UFS device. Hence this patch that implements polling support. User space software can enable polling by passing the RWF_HIPRI flag to the preadv2() system call or the IORING_SETUP_IOPOLL flag to the io_uring interface. Although the block layer supports to partition the tag space for interrupt-based completions (HCTX_TYPE_DEFAULT) purposes and polling (HCTX_TYPE_POLL), the choice has been made to use the same hardware queue for both hctx types because partitioning the tag space would negatively affect performance. On my test setup this patch increases IOPS from 2736 to 22000 (8x) for the following test: for hipri in 0 1; do fio --ioengine=io_uring --iodepth=1 --rw=randread \ --runtime=60 --time_based=1 --direct=1 --name=qd1 \ --filename=/dev/block/sda --ioscheduler=none --gtod_reduce=1 \ --norandommap --hipri=$hipri done Reviewed-by: Bean Huo Tested-by: Bean Huo Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 85 ++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 650dddf960c2..6dd517267f1b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2662,6 +2662,36 @@ static inline bool is_device_wlun(struct scsi_device *sdev) ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN); } +/* + * Associate the UFS controller queue with the default and poll HCTX types. + * Initialize the mq_map[] arrays. + */ +static int ufshcd_map_queues(struct Scsi_Host *shost) +{ + int i, ret; + + for (i = 0; i < shost->nr_maps; i++) { + struct blk_mq_queue_map *map = &shost->tag_set.map[i]; + + switch (i) { + case HCTX_TYPE_DEFAULT: + case HCTX_TYPE_POLL: + map->nr_queues = 1; + break; + case HCTX_TYPE_READ: + map->nr_queues = 0; + break; + default: + WARN_ON_ONCE(true); + } + map->queue_offset = 0; + ret = blk_mq_map_queues(map); + WARN_ON_ONCE(ret); + } + + return 0; +} + static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i) { struct utp_transfer_cmd_desc *cmd_descp = hba->ucdl_base_addr; @@ -2697,7 +2727,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) struct ufshcd_lrb *lrbp; int err = 0; - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); + WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag); /* * Allows the UFS error handler to wait for prior ufshcd_queuecommand() @@ -5288,6 +5318,31 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, } } +/* + * Returns > 0 if one or more commands have been completed or 0 if no + * requests have been completed. + */ +static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num) +{ + struct ufs_hba *hba = shost_priv(shost); + unsigned long completed_reqs, flags; + u32 tr_doorbell; + + spin_lock_irqsave(&hba->outstanding_lock, flags); + tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); + completed_reqs = ~tr_doorbell & hba->outstanding_reqs; + WARN_ONCE(completed_reqs & ~hba->outstanding_reqs, + "completed: %#lx; outstanding: %#lx\n", completed_reqs, + hba->outstanding_reqs); + hba->outstanding_reqs &= ~completed_reqs; + spin_unlock_irqrestore(&hba->outstanding_lock, flags); + + if (completed_reqs) + __ufshcd_transfer_req_compl(hba, completed_reqs); + + return completed_reqs; +} + /** * ufshcd_transfer_req_compl - handle SCSI and query command completion * @hba: per adapter instance @@ -5298,9 +5353,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, */ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) { - unsigned long completed_reqs, flags; - u32 tr_doorbell; - /* Resetting interrupt aggregation counters first and reading the * DOOR_BELL afterward allows us to handle all the completed requests. * In order to prevent other interrupts starvation the DB is read once @@ -5315,21 +5367,13 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) if (ufs_fail_completion()) return IRQ_HANDLED; - spin_lock_irqsave(&hba->outstanding_lock, flags); - tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); - completed_reqs = ~tr_doorbell & hba->outstanding_reqs; - WARN_ONCE(completed_reqs & ~hba->outstanding_reqs, - "completed: %#lx; outstanding: %#lx\n", completed_reqs, - hba->outstanding_reqs); - hba->outstanding_reqs &= ~completed_reqs; - spin_unlock_irqrestore(&hba->outstanding_lock, flags); + /* + * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we + * do not want polling to trigger spurious interrupt complaints. + */ + ufshcd_poll(hba->host, 0); - if (completed_reqs) { - __ufshcd_transfer_req_compl(hba, completed_reqs); - return IRQ_HANDLED; - } else { - return IRQ_NONE; - } + return IRQ_HANDLED; } int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask) @@ -6581,6 +6625,8 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, spin_lock_irqsave(host->host_lock, flags); task_tag = req->tag; + WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n", + task_tag); hba->tmf_rqs[req->tag] = req; treq->upiu_req.req_header.dword_0 |= cpu_to_be32(task_tag); @@ -8144,7 +8190,9 @@ static struct scsi_host_template ufshcd_driver_template = { .module = THIS_MODULE, .name = UFSHCD, .proc_name = UFSHCD, + .map_queues = ufshcd_map_queues, .queuecommand = ufshcd_queuecommand, + .mq_poll = ufshcd_poll, .slave_alloc = ufshcd_slave_alloc, .slave_configure = ufshcd_slave_configure, .slave_destroy = ufshcd_slave_destroy, @@ -9432,6 +9480,7 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle) err = -ENOMEM; goto out_error; } + host->nr_maps = HCTX_TYPE_POLL + 1; hba = shost_priv(host); hba->host = host; hba->dev = dev;