Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2310895rdb; Fri, 8 Dec 2023 04:49:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEq6bx6I5Tewsz8lvG3zR6NxTp68IftkHcg2RLf+TRGm/ZhiiKNQcuhcUjntqv7JBa2LfhF X-Received: by 2002:a17:902:8d85:b0:1d0:6ffd:e2d8 with SMTP id v5-20020a1709028d8500b001d06ffde2d8mr4236654plo.114.1702039741210; Fri, 08 Dec 2023 04:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702039741; cv=none; d=google.com; s=arc-20160816; b=zsT+MSoSb3aoh5LAOHKTyq+FRge4pU3qrrFgoAyCNj6CeUBlBNaJ6FTkJ3pRQyi8me QRdXJbf7N+zmhaxtkILHEQ2Zk/ARJqn4GnQNCwZLW5Axn5kj02undzErfKTNzbQeorRB MrP/oRoFD/Pk7lfpYEHKZauhRr1uaV5x0TY/Q22/FGibq7bEQLd/Pe0N/diDQ9jT2iVw AeGQyy0oVBbiXKE7R+god7ZVy3I9cBIdJ1JOy+X0HXsF7cSrwl4wWSlEbQanS3H6pMH8 5IB7fWlgALCFIyhhj+vv3EkIIHSM7oX5IUTipGxCryz6FZnz9iynkTZvoQkRjyZYc/VH x7GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/WYvsRi6HlrxNYC2c+ZrPbzwacSXT0VrMqRRp80rFUs=; fh=D0zHzE0rSeaV5xnFPtatb+q+bG5HGveof5GzyGf4cew=; b=Y0Zg1kmrTYuWQimAM16nlrhHEGQGg+kWrr12qT7Q98CkpEdVBND95M+EHklY3kiVld SIinMeR5XzNvkgC0ghfFv5i+GME1QrQWrLYxTbDDk/apGDkF9IAKZf4cdzcuQFdEUeqK GIRC0RHN6QfKSxX3oE8BNk3H7IH/KTcK+d5b/y5JrS9zJMdbs7KEo89H92P/O6Jo7/HN yWNXA4UWFmUEQMI+Jq4Q+Q/ub+kvfn1PfK0oay7bkOaxhrONP3LE7Gm1soLb++XLvbOy B5cjjoLQomfYj7SFAc3fvl5vMXfM+3WiPoDrkih2N8PmgMKR+CwikoOx5Ud4Zo9D2jH+ th9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cUr7UsSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x2-20020a170902ea8200b001d0be32b0d1si1525212plb.386.2023.12.08.04.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 04:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cUr7UsSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C808480FCE7C; Fri, 8 Dec 2023 04:48:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573736AbjLHMsp (ORCPT + 99 others); Fri, 8 Dec 2023 07:48:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232504AbjLHMso (ORCPT ); Fri, 8 Dec 2023 07:48:44 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7678211C for ; Fri, 8 Dec 2023 04:48:51 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38120C433C8; Fri, 8 Dec 2023 12:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702039731; bh=vLThQTwl+IH3G3R9f1dHTk2ydKuwPB5ETojX8rQGxDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cUr7UsShhnUneWThZk3aObq/YSqB0oQQVo1qKpT4PFaXdBLQSGttqnQUkEutMBmE3 4p0OqjCxmDbKZ6Z13oeqDssnJK4EUx7ksPahHJmd4fkbX1kn6mgZpcRNwmyoJod69U p/oTNCzTU1bqp2C+mnseohOA36Hws7niwY/oikrHnsxTNJQ11i/5pvNvMH1LnuLOnU 8RoRIXUZuFjCUb0FAwOISYH2Ozu1K/zBkSCIFUvNm5uQNGN9LdSEVw/jGKxTOBduB+ Cm7f0Jb4JnMBykYNWeM7Hkg67bOsVtFjA51SGQNci2y7zeAuAg+qdgsLMJRMAiR8ML hrmVof53G0CtA== Date: Fri, 8 Dec 2023 18:18:35 +0530 From: Manivannan Sadhasivam To: Bean Huo Cc: avri.altman@wdc.com, bvanassche@acm.org, alim.akhtar@samsung.com, jejb@linux.ibm.com, martin.petersen@oracle.com, quic_cang@quicinc.com, quic_asutoshd@quicinc.com, beanhuo@micron.com, thomas@t-8ch.de, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, mikebi@micron.com, lporzio@micron.com Subject: Re: [PATCH v4 1/3] scsi: ufs: core: Add ufshcd_is_ufs_dev_busy() Message-ID: <20231208124835.GB15552@thinkpad> References: <20231208103940.153734-1-beanhuo@iokpp.de> <20231208103940.153734-2-beanhuo@iokpp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231208103940.153734-2-beanhuo@iokpp.de> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 08 Dec 2023 04:48:58 -0800 (PST) On Fri, Dec 08, 2023 at 11:39:38AM +0100, Bean Huo wrote: > From: Bean Huo > > Add helper inline for retrieving whether UFS device is busy or not. > > Signed-off-by: Bean Huo > Reviewed-by: Avri Altman > --- > drivers/ufs/core/ufshcd.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index f0b837cb0c2b..32cfcba66d60 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -235,6 +235,13 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, > return UFS_PM_LVL_0; > } > > +static inline bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba) No need to use 'inline' keyword in '.c' files. Compiler has its own decisions. > +{ > + return (hba->clk_gating.active_reqs || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL || I feel like checking the ufshcd state inside ufshcd_is_ufs_dev_busy() is somewhat confusing. Because, if "ufshcd_state != UFSHCD_STATE_OPERATIONAL" returns true, then it means that the ufshc is in non-operational state. But, non-operational state doesn't mean that the ufs is busy doing some work. So I propose to move this check outside of ufshcd_is_ufs_dev_busy(). Like, if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL || ufshcd_is_ufs_dev_busy(hba)) - Mani > + hba->outstanding_reqs || hba->outstanding_tasks || hba->active_uic_cmd || > + hba->uic_async_done); > +} > + > static const struct ufs_dev_quirk ufs_fixups[] = { > /* UFS cards deviations table */ > { .wmanufacturerid = UFS_VENDOR_MICRON, > @@ -1917,10 +1924,7 @@ static void ufshcd_gate_work(struct work_struct *work) > goto rel_lock; > } > > - if (hba->clk_gating.active_reqs > - || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL > - || hba->outstanding_reqs || hba->outstanding_tasks > - || hba->active_uic_cmd || hba->uic_async_done) > + if (ufshcd_is_ufs_dev_busy(hba)) > goto rel_lock; > > spin_unlock_irqrestore(hba->host->host_lock, flags); > -- > 2.34.1 > -- மணிவண்ணன் சதாசிவம்