Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp311391ybl; Wed, 22 Jan 2020 22:14:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwMIeqQC3FzsXyPdF55tLrKIL3XLVUCazdRIangNgynbunB2L2dO1mmb4Jte5dFJfJ8vcQ9 X-Received: by 2002:a05:6808:191:: with SMTP id w17mr9354948oic.29.1579760059116; Wed, 22 Jan 2020 22:14:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579760059; cv=none; d=google.com; s=arc-20160816; b=HjQv7GNsWWG5/YwPlBbOSSjtI/1NmKkiZBQtBwouM8kXphFT0364SZapY2TQbp+2Ms USBE5DQo+A5CY48arFekb5Ql2xVzeMzmp7P+zq9srXZUEEzYUbBJwBN8qQRFNDrpKPgd rDtniyEdtC7IYxJfsNNc29Vcv4LL0s1ra4lIFYv/YQm5j4N8mUFMI+cQVab5e5XjDG8C up6z8fLp3w/HU79OxUCF/GHCNMzph9SbLvAneWNZ2tiz03bkO9/ouNozpiB6BzmuxCDJ hdssrHnOTmjHlYe74ye0WMYkQsqLSQPL6ZQWwCI6Mcc3EmTSwez2jHkWcikWaVmE7elY SxDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=ufnUZk2jyW5OcA0BLZcoL0R4/Lm2xEPoQrZqG5wkWXA=; b=uT7M73qvFaIFoPKhr+Lia0nQUAxUvKx17ipAlKE0SEdIEslhGuhZxAsP+gOjnEAjwm mKMRQ/mNNcE14GHLvD3mXQ0BuQKxdgWgy7RHnjD+uxXwFEwK0fpm3/wOSzR8qLjk1pEQ LQhGmpub313QqqNNVlV9Evmrafzx+fW6WidFAjsdIUYxaFckV712oSfTLS3pvZtIBZic 9p1gsPdOtkpYgzWO9pZHw4ynA/Weq7xJEo+CA0rQ38siODlifIm1xd3Oqgiu6gJZN/MY kl8ZpfiV9Z4jJJj2/MQhsQ6MmQK5yXbEA+i2Hi9Zvgrh1AANm5JpoA2ofxRvAk6YeRr4 cY/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=UJKIbIvS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si728311ota.71.2020.01.22.22.14.07; Wed, 22 Jan 2020 22:14:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=UJKIbIvS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728057AbgAWGNF (ORCPT + 99 others); Thu, 23 Jan 2020 01:13:05 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:42451 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgAWGNE (ORCPT ); Thu, 23 Jan 2020 01:13:04 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1579759984; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ufnUZk2jyW5OcA0BLZcoL0R4/Lm2xEPoQrZqG5wkWXA=; b=UJKIbIvSnNPi4r0DBa7Uk4Wm7gcH1FDVCiUgCDYCcaE/Dcoe/29tlZY9tAhncIQyeLPBRK6t BzSf5aGsWidgjv2xAFVniNLfCRLQ4Pau+qSda9MJCShVWqVpVZUGBiZAOhSJv9Li0gNoapbX dhnjEU76PXEtzhf5rrUoRvHuYJI= X-Mailgun-Sending-Ip: 104.130.122.25 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd 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 5e29396e.7fc8f2745960-smtp-out-n03; Thu, 23 Jan 2020 06:13:02 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C4687C447B4; Thu, 23 Jan 2020 06:13:00 +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 37505C447A4; Thu, 23 Jan 2020 06:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 37505C447A4 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 v3 5/8] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic Date: Wed, 22 Jan 2020 22:12:22 -0800 Message-Id: <1579759946-5448-6-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1579759946-5448-1-git-send-email-cang@codeaurora.org> References: <1579759946-5448-1-git-send-email-cang@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project