From patchwork Wed Apr 27 23:38:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 567007 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 1E15FC433F5 for ; Wed, 27 Apr 2022 23:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbiD0Xmk (ORCPT ); Wed, 27 Apr 2022 19:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiD0Xmh (ORCPT ); Wed, 27 Apr 2022 19:42:37 -0400 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F4715F25F for ; Wed, 27 Apr 2022 16:39:25 -0700 (PDT) Received: by mail-pj1-f53.google.com with SMTP id t11-20020a17090ad50b00b001d95bf21996so6209722pju.2 for ; Wed, 27 Apr 2022 16:39:25 -0700 (PDT) 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=7Pb20ev5jB8nj0N8bVNVYGAJNTRZq9Y7U0EGQL8t0l4=; b=7W1Ps1oVJEsgSaVyQx1N0K1ls9qe9HbruEEaSapnVlygq6jwRIznrV84vE02MG50OX YZKSwbiCe9aYrzoA+IVzUxNIc/cOKy2RnjCMUZA2jNcKPY2HApKkOXbWt/PD20l3/+LF 9c1mA7mgaVV8060QWf2mIE9L9MjxMv+I2H5LHu81PgEcQD5GkUUi+Lkw19zsNrlaEvfx jkuzZDdqepKfaAlJJr9i3v/mDxfGV/nQl837fdVDR/yGLX2HIU4yfwb1ZM9KQ9skNP/3 7ZlxKsuxldW9qBEMV44hZ/V+5kqiKBMI/bXmpQhxytOj+ACazq94KqY9jDJmu7MruUyJ 1JCA== X-Gm-Message-State: AOAM5318VlwxBHYImmEIN0H4pjjGThjKF8haVYrsD6IBnV184KeFffFv kJL6xf8VSslQ6dP7V0LC7qA77um+AAfCAg== X-Google-Smtp-Source: ABdhPJzwJl7I6CMP6Ody6ZItv51jIEV+McI2f4m13wVfLA4JbtOiQIql9hIC00lOfPTgyYsk5OSEzA== X-Received: by 2002:a17:90b:1a8a:b0:1d2:e93e:6604 with SMTP id ng10-20020a17090b1a8a00b001d2e93e6604mr46408221pjb.233.1651102764903; Wed, 27 Apr 2022 16:39:24 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:6cbb:d78e:9b3:bb62]) by smtp.gmail.com with ESMTPSA id f16-20020aa78b10000000b0050a81508653sm19817580pfd.198.2022.04.27.16.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 16:39:24 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche Subject: [PATCH 1/4] scsi: ufs: Reduce the clock scaling latency Date: Wed, 27 Apr 2022 16:38:52 -0700 Message-Id: <20220427233855.2685505-2-bvanassche@acm.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog In-Reply-To: <20220427233855.2685505-1-bvanassche@acm.org> References: <20220427233855.2685505-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Wait at most 20 ms before rechecking the doorbells instead of waiting for a potentially long time between doorbell checks. Signed-off-by: Bart Van Assche Reviewed-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2b4390a1106e..a3fecbb403d3 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1141,7 +1141,7 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, } spin_unlock_irqrestore(hba->host->host_lock, flags); - schedule(); + io_schedule_timeout(msecs_to_jiffies(20)); if (ktime_to_us(ktime_sub(ktime_get(), start)) > wait_timeout_us) { timeout = true; From patchwork Wed Apr 27 23:38:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 568487 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 59A86C433EF for ; Wed, 27 Apr 2022 23:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbiD0Xml (ORCPT ); Wed, 27 Apr 2022 19:42:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbiD0Xmj (ORCPT ); Wed, 27 Apr 2022 19:42:39 -0400 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BEB5F266 for ; Wed, 27 Apr 2022 16:39:26 -0700 (PDT) Received: by mail-pj1-f52.google.com with SMTP id j8-20020a17090a060800b001cd4fb60dccso2937210pjj.2 for ; Wed, 27 Apr 2022 16:39:26 -0700 (PDT) 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=0scTl9jILL9mKGSNSrFA00jf2Zsqg7JYqUtzIar3uhc=; b=AhtZGqqJ0i1gfyVtSqRInVjK5JOM5Ui7HYp9CXzZDbbL1ZKBoEDwZDlX4ZTKWlPFqR nuIPXvFPFD2LzNq9v4funEJC1i4x9kF5PbzzvTq0aD+fJ4gdEDOTvQtEXiVQ0TKrlfgQ Db4MXaroeKfaTyW1pPtv+TB3JO/nrZcndc8V58QBXyX5Y2Tkl69FU2pwSMV4BpnFBezR qfz1VM3NGaH9FJpA8PlChNcKcbIMvxQgIlBBDsepTmBYo7J+znGM3nnv6nT1UoRb0FiO p3297SScQavt/1XENhUha+g4tbpG2F2c7Z9jyVSpm1sRPGYIEk+dmPLXetpnoj5Iva3u qBNw== X-Gm-Message-State: AOAM533uLp1tSiRFimM4WMj/vCDWEpG5O9lj7NVKPNIHObpRIQKsfmoW k25jVvH00xDpNf7spJ2SZl8= X-Google-Smtp-Source: ABdhPJwjDUsTRS6LlVw/t3Ryk8iKrtT4T6gPrkRe0il7JKLP967/1j4dBAF1T1I57dEKpwlLQzBtLQ== X-Received: by 2002:a17:90a:a82:b0:1da:3763:5cf5 with SMTP id 2-20020a17090a0a8200b001da37635cf5mr6381918pjw.55.1651102766387; Wed, 27 Apr 2022 16:39:26 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:6cbb:d78e:9b3:bb62]) by smtp.gmail.com with ESMTPSA id f16-20020aa78b10000000b0050a81508653sm19817580pfd.198.2022.04.27.16.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 16:39:25 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche Subject: [PATCH 2/4] scsi: ufs: Move a clock scaling check Date: Wed, 27 Apr 2022 16:38:53 -0700 Message-Id: <20220427233855.2685505-3-bvanassche@acm.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog In-Reply-To: <20220427233855.2685505-1-bvanassche@acm.org> References: <20220427233855.2685505-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move a check related to clock scaling into ufshcd_devfreq_scale(). This patch prepares for adding a second ufshcd_clock_scaling_prepare() caller. Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a3fecbb403d3..3c83f4049031 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1223,8 +1223,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba) ufshcd_scsi_block_requests(hba); down_write(&hba->clk_scaling_lock); - if (!hba->clk_scaling.is_allowed || - ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) { + if (ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) { ret = -EBUSY; up_write(&hba->clk_scaling_lock); ufshcd_scsi_unblock_requests(hba); @@ -1262,10 +1261,18 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up) int ret = 0; bool is_writelock = true; + if (!hba->clk_scaling.is_allowed) + return -EBUSY; + ret = ufshcd_clock_scaling_prepare(hba); if (ret) return ret; + if (!hba->clk_scaling.is_allowed) { + ret = -EBUSY; + goto out_unprepare; + } + /* scale down the gear before scaling down clocks */ if (!scale_up) { ret = ufshcd_scale_gear(hba, false); From patchwork Wed Apr 27 23:38:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 567006 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 46E78C433F5 for ; Wed, 27 Apr 2022 23:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbiD0Xmm (ORCPT ); Wed, 27 Apr 2022 19:42:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiD0Xmk (ORCPT ); Wed, 27 Apr 2022 19:42:40 -0400 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA0C5F25F for ; Wed, 27 Apr 2022 16:39:28 -0700 (PDT) Received: by mail-pl1-f181.google.com with SMTP id j8so2856943pll.11 for ; Wed, 27 Apr 2022 16:39:28 -0700 (PDT) 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=pys2NjB9kTY7mpqLXwuixnBV6CiqLHWCJ4i7tBt5VTM=; b=uA9OxPwd02jNzW9TrH1PxxPwTfun0yCaQksQJ9shX/an3XzbWt7h32h5XuGLDjR+ov xfzXfjNxz025wXFJdSL3McdxF/BjQGEEWYuObTp4MeUg1A3g1bpstquWABGNTHIrCWF+ K5Co3DfwzyYn+95OBNzf2MCg2R9C0d0ogdRCOdHlMjpxgLcWX2uSC0eG0Buw6r6fq+Cx eZ2bmXQxQBDl+TDw7XqifCGQTv/vqTfCuxIW76upEyA3WyJHtJdUHz+RuFcijvRggVFL bXTAmXCdX7EGebac8K1XAGYGi9xe6DobFL4DK9RZIJafnixlmXB5w3Lzi7Fwo7pxeDfT HuDg== X-Gm-Message-State: AOAM530O8O2sgeQb1/K5ffTaMuF8o+OQqRKqrqnl6WjCDfEhBzT0j+fs /ngyG52WfQgA9QoOznYXtAg= X-Google-Smtp-Source: ABdhPJz8NAbN9/KSmWUr2ajTpbmMemRQIL6LTdgLMRvyN7d8YJcjurrKGXJo2C0SIaKO7zXPKiX/8g== X-Received: by 2002:a17:90b:3a81:b0:1d9:54a0:9362 with SMTP id om1-20020a17090b3a8100b001d954a09362mr23533290pjb.144.1651102767900; Wed, 27 Apr 2022 16:39:27 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:6cbb:d78e:9b3:bb62]) by smtp.gmail.com with ESMTPSA id f16-20020aa78b10000000b0050a81508653sm19817580pfd.198.2022.04.27.16.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 16:39:27 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche Subject: [PATCH 3/4] scsi: ufs: Pass the clock scaling timeout as an argument Date: Wed, 27 Apr 2022 16:38:54 -0700 Message-Id: <20220427233855.2685505-4-bvanassche@acm.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog In-Reply-To: <20220427233855.2685505-1-bvanassche@acm.org> References: <20220427233855.2685505-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Prepare for adding an additional ufshcd_clock_scaling_prepare() call with a different timeout. Signed-off-by: Bart Van Assche Reviewed-by: Avri Altman --- drivers/scsi/ufs/ufshcd.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 3c83f4049031..60ba11b68735 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1108,6 +1108,12 @@ static u32 ufshcd_pending_cmds(struct ufs_hba *hba) return pending; } +/* + * Wait until all pending SCSI commands and TMFs have finished or the timeout + * has expired. + * + * Return: 0 upon success; -EBUSY upon timeout. + */ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, u64 wait_timeout_us) { @@ -1212,9 +1218,14 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) return ret; } -static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba) +/* + * Wait until all pending SCSI commands and TMFs have finished or the timeout + * has expired. + * + * Return: 0 upon success; -EBUSY upon timeout. + */ +static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us) { - #define DOORBELL_CLR_TOUT_US (1000 * 1000) /* 1 sec */ int ret = 0; /* * make sure that there are no outstanding requests when @@ -1223,7 +1234,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba) ufshcd_scsi_block_requests(hba); down_write(&hba->clk_scaling_lock); - if (ufshcd_wait_for_doorbell_clr(hba, DOORBELL_CLR_TOUT_US)) { + if (ufshcd_wait_for_doorbell_clr(hba, timeout_us)) { ret = -EBUSY; up_write(&hba->clk_scaling_lock); ufshcd_scsi_unblock_requests(hba); @@ -1264,7 +1275,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up) if (!hba->clk_scaling.is_allowed) return -EBUSY; - ret = ufshcd_clock_scaling_prepare(hba); + ret = ufshcd_clock_scaling_prepare(hba, 1 * USEC_PER_SEC); if (ret) return ret; From patchwork Wed Apr 27 23:38:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 568486 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 BFAC5C433F5 for ; Wed, 27 Apr 2022 23:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbiD0Xmo (ORCPT ); Wed, 27 Apr 2022 19:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbiD0Xmm (ORCPT ); Wed, 27 Apr 2022 19:42:42 -0400 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F855F260 for ; Wed, 27 Apr 2022 16:39:30 -0700 (PDT) Received: by mail-pl1-f171.google.com with SMTP id b12so2882036plg.4 for ; Wed, 27 Apr 2022 16:39:30 -0700 (PDT) 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=k23SKwJTDpyjcozrr8MpWutx8/NJPzXL4cAkJY4C2AI=; b=adsyl8BNYOLjbLeBteGUWr2wmQxH/Efit9PRj2wqa0H13TNLPHiRQmipo9e6xiD1P5 9ThRh2PggX889hMgTQrO4/CPc7CrhK4CUC6dtL+0XwmioT1pr36Z0G2Zrne2GOrkiEcl jtPs3Znceuadaak/r8IyUY7gfQgpZ24VR1x77s2yZcx4rkI8I31Vy+93tYMQPC6jkziF 9RdJmMuhvhNckgxt6R4GZzlnbV1SkLmX4EhimA5gG+ElWtqA8quqZVnxJ6S31Il4zxhN WH5wKLRK7y94/mQxXx5DiqQurJgPiPtaeujO+/FXE0TqarE5EoWe5KyIYLZckIIkjF61 2oJA== X-Gm-Message-State: AOAM531dmDrSTpT3e42sQO0NuMmRaCo46R0xUdeWuwA84684Ez63eYDa CWzt8wDUiqPoFPKIH11QulTj/mHBcjgcJg== X-Google-Smtp-Source: ABdhPJyr5mWEnbFmNXg18C62kQL7VEDsBEPZHUSl93jEKKPlFPJwJpzaorJkRvmO1Xlfn5UkaP4dGQ== X-Received: by 2002:a17:902:db10:b0:15c:e4d6:4b10 with SMTP id m16-20020a170902db1000b0015ce4d64b10mr24934250plx.44.1651102769448; Wed, 27 Apr 2022 16:39:29 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:6cbb:d78e:9b3:bb62]) by smtp.gmail.com with ESMTPSA id f16-20020aa78b10000000b0050a81508653sm19817580pfd.198.2022.04.27.16.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 16:39:28 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche Subject: [PATCH 4/4] scsi: ufs: Add suspend/resume SCSI command processing support Date: Wed, 27 Apr 2022 16:38:55 -0700 Message-Id: <20220427233855.2685505-5-bvanassche@acm.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog In-Reply-To: <20220427233855.2685505-1-bvanassche@acm.org> References: <20220427233855.2685505-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This functionality is needed by UFS drivers to e.g. suspend SCSI command processing while reprogramming encryption keys if the hardware does not support concurrent I/O and key reprogramming. Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 20 ++++++++++++++++++++ drivers/scsi/ufs/ufshcd.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 60ba11b68735..22447c4f16a2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1692,6 +1692,26 @@ static void ufshcd_ungate_work(struct work_struct *work) ufshcd_scsi_unblock_requests(hba); } +/* + * Block processing of new SCSI commands and wait until pending SCSI + * commands and TMFs have finished. ufshcd_exec_dev_cmd() and + * ufshcd_issue_devman_upiu_cmd() are not affected by this function. + * + * Return: 0 upon success; -EBUSY upon timeout. + */ +int ufshcd_freeze_scsi_devs(struct ufs_hba *hba, u64 timeout_us) +{ + return ufshcd_clock_scaling_prepare(hba, timeout_us); +} +EXPORT_SYMBOL_GPL(ufshcd_freeze_scsi_devs); + +/* Resume processing of SCSI commands. */ +void ufshcd_unfreeze_scsi_devs(struct ufs_hba *hba) +{ + ufshcd_clock_scaling_unprepare(hba, true); +} +EXPORT_SYMBOL_GPL(ufshcd_unfreeze_scsi_devs); + /** * ufshcd_hold - Enable clocks that were gated earlier due to ufshcd_release. * Also, exit from hibern8 mode and set the link as active. diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 2b0f3441b813..8954fcbdaf6f 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1181,6 +1181,9 @@ void ufshcd_release(struct ufs_hba *hba); void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value); +int ufshcd_freeze_scsi_devs(struct ufs_hba *hba, u64 timeout_us); +void ufshcd_unfreeze_scsi_devs(struct ufs_hba *hba); + void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, int *desc_length);