From patchwork Thu Nov 7 08:42:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Can Guo X-Patchwork-Id: 11232289 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 2B9611390 for ; Thu, 7 Nov 2019 08:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F25E221D7F for ; Thu, 7 Nov 2019 08:43:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="UFshVw57"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="dFubnSHn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387764AbfKGInL (ORCPT ); Thu, 7 Nov 2019 03:43:11 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34110 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbfKGInJ (ORCPT ); Thu, 7 Nov 2019 03:43:09 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9916A60B12; Thu, 7 Nov 2019 08:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573116188; bh=rNVWgNXpCmjzKl7+DgyZaXwpqUvs9j2dpx4wlh2Z2MQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFshVw575HfgLXUismyqqMfQjI9opEjoXB4FABby6JnujSFmJoXIsZdauSRArdyiB l8y3pVABGYqQcwJ7gdfGFa4N4FGKz0x6B61YNcQ/69yePiQPdU/XOmXzG6/wjnRTRN fS6LLaiKMfZ0pzGurQK/56cC1XJ0/+zb7IDGUg68= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no 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@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0940E60AD7; Thu, 7 Nov 2019 08:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573116186; bh=rNVWgNXpCmjzKl7+DgyZaXwpqUvs9j2dpx4wlh2Z2MQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFubnSHn/1hgvH8iYtRTUnr3NHcXy0uPFQwHOf6Z3SVXlbmsrOU1nY4ay+aGoy2FU gM0CG7rSXtizbecUB4M4BhBbATn70Z5WCcS06ZjwCKwCb62oFfqNhaUwv8PImZyig2 FIcmAsC3k85smovWKFGFe3fUHMcEyWnnr1zkKup0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0940E60AD7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@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 , Bean Huo , Tomas Winkler , Venkat Gopalakrishnan , Subhash Jadavani , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 6/6] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic Date: Thu, 7 Nov 2019 00:42:13 -0800 Message-Id: <1573116140-22408-7-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1573116140-22408-1-git-send-email-cang@codeaurora.org> References: <1573116140-22408-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 aysnc 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 9cf5da3..5e112ae8 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1545,6 +1545,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);