From mboxrd@z Thu Jan 1 00:00:00 1970 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 A758FECAAA1 for ; Thu, 27 Oct 2022 21:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237120AbiJ0VwO (ORCPT ); Thu, 27 Oct 2022 17:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237127AbiJ0VwM (ORCPT ); Thu, 27 Oct 2022 17:52:12 -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 A8E88870B6; Thu, 27 Oct 2022 14:52:07 -0700 (PDT) Received: by mail-pj1-f53.google.com with SMTP id pb15so2923991pjb.5; Thu, 27 Oct 2022 14:52:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X93ycM+kLxHErIWtURA8L8exeaHt9regQ5pDIAbzkS0=; b=GXeMbffaMFuykrzvitrGEe2rO/secFaM5iEgWmx/dfZvy9pQCilLme3JkT08GdyxCB h9vuRbs7RKRHJx+kY0mPp6s93Z7AtwgZ9s6wjuYGUK0ma7OenSRcujnawJM3qxKr6Op0 z/rMWyCC8CUpxLoPKp60xEZW0VXrJpGTH5WRI75o8X0n9r0/eeR7WH7tqqRmh0PkTctI nFT+DFlPkEBsJxBp1jvwouEfjAx6h1cRkNOnN1EcL0XsQgzJ6zjGZaLAv16O03JbibzQ +X4KZQIzbxJBF0d8eJ6JqPTt6gK+hIkNY0NdZJVre8wXL7hMTxi4lsLQRz8NlXDL9a/N Edxw== X-Gm-Message-State: ACrzQf0oc4HgLyyPnTCgPYtr+29JGMMqfbEMZxllhdDoKyefquTQsPDO auUNJ2U+zrEimUfhMAIecL4= X-Google-Smtp-Source: AMsMyM4/J1Mgt0PgewEVAt/TRafibQip+YEIMiITVhdtcYAPhTb/TWZOSky5J8YGz+kUFDtm6qjb9A== X-Received: by 2002:a17:90b:4ac5:b0:20a:de32:366b with SMTP id mh5-20020a17090b4ac500b0020ade32366bmr12307796pjb.197.1666907526977; Thu, 27 Oct 2022 14:52:06 -0700 (PDT) Received: from ?IPV6:2620:15c:211:201:bc2b:ff19:1b02:257b? ([2620:15c:211:201:bc2b:ff19:1b02:257b]) by smtp.gmail.com with ESMTPSA id d18-20020a17090ab31200b002005fcd2cb4sm3133963pjr.2.2022.10.27.14.52.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Oct 2022 14:52:06 -0700 (PDT) Message-ID: <0fb3f8ae-5ed7-9057-0d2b-8866f36c2441@acm.org> Date: Thu, 27 Oct 2022 14:52:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH v3 07/17] ufs: core: mcq: Calculate queue depth Content-Language: en-US To: Asutosh Das , quic_cang@quicinc.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: quic_nguyenb@quicinc.com, quic_xiaosenh@quicinc.com, stanley.chu@mediatek.com, eddie.huang@mediatek.com, daejun7.park@samsung.com, avri.altman@wdc.com, mani@kernel.org, beanhuo@micron.com, quic_richardp@quicinc.com, linux-arm-msm@vger.kernel.org, Alim Akhtar , "James E.J. Bottomley" , Andy Gross , Bjorn Andersson , Krzysztof Kozlowski , Jinyoung Choi , Kiwoong Kim , open list References: <1987fbada1d33c04c9598614ef712e0a48fe065e.1666288432.git.quic_asutoshd@quicinc.com> From: Bart Van Assche In-Reply-To: <1987fbada1d33c04c9598614ef712e0a48fe065e.1666288432.git.quic_asutoshd@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 10/20/22 11:03, Asutosh Das wrote: > +u32 ufshcd_mcq_decide_queue_depth(struct ufs_hba *hba) > +{ > + u32 qd, val; > + int mac; > + > + mac = ufshcd_mcq_vops_get_hba_mac(hba); > + if (mac < 0) { > + val = ufshcd_readl(hba, REG_UFS_MCQ_CFG); > + mac = FIELD_GET(MCQ_CFG_MAC_MASK, val); > + } According to the UFSHCI 4.0 specification the MAC value is set by the host. Can the above code read the MAC value from the host controller before it has been set by the host? If so, how about leaving out the code that reads the MAC value from the controller and making it mandatory to implement the new get_hba_mac vop? > + > + /* MAC is a 0 based value. */ > + mac += 1; > + /* max. value of bqueuedepth = 256, mac is host dependent */ host dependent -> defined by the host controller? > + qd = min_t(u32, mac, hba->dev_info.bqueuedepth); > + if (!qd) > + qd = mac; How about using min_not_zero() instead of open-coding it? Thanks, Bart.