From patchwork Thu Jan 23 07:25:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11346895 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F11014B4 for ; Thu, 23 Jan 2020 07:26:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CC672467B for ; Thu, 23 Jan 2020 07:26:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="eRDStNtK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbgAWH0U (ORCPT ); Thu, 23 Jan 2020 02:26:20 -0500 Received: from mail26.static.mailgun.info ([104.130.122.26]:34825 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727022AbgAWH0S (ORCPT ); Thu, 23 Jan 2020 02:26:18 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1579764377; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=vopNcEOmawSU+YQpd3himSwf1BKi0OwKP5XpBNewJUQ=; b=eRDStNtKWfuxTMtbKF+lmwkY+W4MaKbfoEVlVQKn6GsFcccC0o1UDoXgUmuxby6c3zbMU8Wl MxNplpsjJp040Zp6GFK4CL4GFyWoUhv21lInOoC4RrjixFSKI/3Zzd/m+PPzsMZ5xStFeDkG WmWEuDrlZdw9HAovPeDf9wi9MTQ= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJlNmU5NiIsICJsaW51eC1zY3NpQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e294a97.7f878ebf50a0-smtp-out-n02; Thu, 23 Jan 2020 07:26:15 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B8D6AC447A5; Thu, 23 Jan 2020 07:26:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 513B8C4479C; Thu, 23 Jan 2020 07:26:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 513B8C4479C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , Pedro Sousa , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Venkat Gopalakrishnan , Tomas Winkler , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/8] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic Date: Wed, 22 Jan 2020 23:25:46 -0800 Message-Id: <1579764349-15578-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1579764349-15578-1-git-send-email-cang@codeaurora.org> References: <1579764349-15578-1-git-send-email-cang@codeaurora.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The async version of ufshcd_hold(async == true), which is only called in queuecommand path as for now, is expected to work in atomic context, thus it should not sleep or schedule out. When it runs into the condition that clocks are ON but link is still in hibern8 state, it should bail out without flushing the clock ungate work. Signed-off-by: Can Guo Reviewed-by: Hongwu Su Reviewed-by: Asutosh Das --- drivers/scsi/ufs/ufshcd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4dfd705..c316a07 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1542,6 +1542,11 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) */ if (ufshcd_can_hibern8_during_gating(hba) && ufshcd_is_link_hibern8(hba)) { + if (async) { + rc = -EAGAIN; + hba->clk_gating.active_reqs--; + break; + } spin_unlock_irqrestore(hba->host->host_lock, flags); flush_work(&hba->clk_gating.ungate_work); spin_lock_irqsave(hba->host->host_lock, flags);