Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4273464ybl; Mon, 13 Jan 2020 10:47:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyZXy3uK4D28g82r0l8sMqBz/Y8KqPMGiavYS61T4S5e/FVwnpuFFyRMToo0AyGJrdj/t8e X-Received: by 2002:a9d:6f82:: with SMTP id h2mr13829994otq.69.1578941220878; Mon, 13 Jan 2020 10:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578941220; cv=none; d=google.com; s=arc-20160816; b=iSLFpEZ1KojvayZAtUi5AiRf4x08EdsNwq5sY0cz9A3mfjdHunNeKhGoKYd/OUF6YY Db4Scroqg3H7YjtYo9PC9KCAQ/EvKYoI58USOxaDJi4a4S86jJegbJZOPseeRzUdpq5F qy6rl53qcLBWdwYh05YJ5jabrJZ9s0TBUm7De+AojvOTrq12Tn1JIvH3dVzwtILGg7+K 76iF2IW7JVD/I5ugssu4n10Wb+9JXAjBhRBTurDucqN8f1M9YazdSfALkHeQ71BhBsCw mRHc59r+1MOOOsyT47tNEGPok3hqdSLqHBqT2wj/bTy5GNqtUAnVGHvaW4/fbdNrH2ZQ APcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=BE7Ii/+ZSj3amZRXFjwOsrUKK4ov1l85oSUE5ZJn4jU=; b=rCWiXDOYJpBH5mi4RKfnb/pRGBenfis914tRWrkAQRbGrywg4sFLESb31sXuJ011kf WAp5yIo3z85wYJgY6z9TJ2xbMG01pq0cuzQexcJ9E+usFoY9c22i0M78xpv7e/3/RFNV PaqnW/untLjALEaEvO8fTzDjSmsVpdB4KRW/nUrIYi+JmM3RQRjoL4rU/vdnXumsFU3M 2LvRX/HIIWuVHrAarDiGW4adXTlUajvFlYtSQdYzEXYDwJ0lLVEgii++vtLtki3TdfFE pkYCxIifMNTaWpocpc9CQCuGgX2lgcQcUbSWyL4gvLqJ1dQFpiRqIFxfqFsfHaKde1c/ sPOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=IhzqKftg; 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 k13si6256219oij.118.2020.01.13.10.46.48; Mon, 13 Jan 2020 10:47:00 -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=IhzqKftg; 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 S1728766AbgAMSpf (ORCPT + 99 others); Mon, 13 Jan 2020 13:45:35 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:39048 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728664AbgAMSpf (ORCPT ); Mon, 13 Jan 2020 13:45:35 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1578941134; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=BE7Ii/+ZSj3amZRXFjwOsrUKK4ov1l85oSUE5ZJn4jU=; b=IhzqKftglfyFwbRsyWAJomJC0KroiV7xkRrzHyHFRHdS6YBSQ3OHHDhbmuz/kqBE7S0ZwU+x JtY5DOiRt0OkCzHL1R1/lqvPtCEd0PoCbJlV2/YhPLiQsYEVOsgTEFwVp/OMZgcj5eXpg9QZ MsnZFLRCJsHAOgN26rvx6XScB3I= 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 5e1cbaca.7fc7eb66f2d0-smtp-out-n01; Mon, 13 Jan 2020 18:45:30 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C44C9C447A1; Mon, 13 Jan 2020 18:45:29 +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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id 93683C43383; Mon, 13 Jan 2020 18:45:28 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 13 Jan 2020 10:45:28 -0800 From: asutoshd@codeaurora.org To: Bean Huo Cc: alim.akhtar@samsung.com, avri.altman@wdc.com, pedrom.sousa@synopsys.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH 3/3] scsi: ufs: use UFS device indicated maximum LU number In-Reply-To: <20200110183606.10102-4-huobean@gmail.com> References: <20200110183606.10102-1-huobean@gmail.com> <20200110183606.10102-4-huobean@gmail.com> Message-ID: <3c6080a44d2943f86d6991d48cd2dd28@codeaurora.org> X-Sender: asutoshd@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-01-10 10:36, Bean Huo wrote: > From: Bean Huo > > According to Jedec standard UFS 3.0 and UFS 2.1 Spec, Maximum number of > logical > units supported by the UFS device is indicated by parameter > bMaxNumberLU in > Geometry Descriptor. This patch is to delete current hard code macro > definition > of UFS_UPIU_MAX_GENERAL_LUN, and switch to use device indicated number > instead. > > Signed-off-by: Bean Huo > --- > drivers/scsi/ufs/ufs-sysfs.c | 2 +- > drivers/scsi/ufs/ufs.h | 12 +++++++++--- > drivers/scsi/ufs/ufshcd.c | 4 ++-- > 3 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/drivers/scsi/ufs/ufs-sysfs.c > b/drivers/scsi/ufs/ufs-sysfs.c > index 720be3f64be7..dbdf8b01abed 100644 > --- a/drivers/scsi/ufs/ufs-sysfs.c > +++ b/drivers/scsi/ufs/ufs-sysfs.c > @@ -713,7 +713,7 @@ static ssize_t _pname##_show(struct device > *dev, \ > struct scsi_device *sdev = to_scsi_device(dev); \ > struct ufs_hba *hba = shost_priv(sdev->host); \ > u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \ > - if (!ufs_is_valid_unit_desc_lun(lun)) \ > + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) \ > return -EINVAL; \ > return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \ > lun, _duname##_DESC_PARAM##_puname, buf, _size); \ > diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h > index 5ca7ea4f223e..810eeca0de63 100644 > --- a/drivers/scsi/ufs/ufs.h > +++ b/drivers/scsi/ufs/ufs.h > @@ -63,7 +63,6 @@ > #define UFS_UPIU_MAX_UNIT_NUM_ID 0x7F > #define UFS_MAX_LUNS (SCSI_W_LUN_BASE + UFS_UPIU_MAX_UNIT_NUM_ID) > #define UFS_UPIU_WLUN_ID (1 << 7) > -#define UFS_UPIU_MAX_GENERAL_LUN 8 > > /* Well known logical unit id in LUN field of UPIU */ > enum { > @@ -548,12 +547,19 @@ struct ufs_dev_desc { > > /** > * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit > descriptor > + * @dev_info: pointer of instance of struct ufs_dev_info > * @lun: LU number to check > * @return: true if the lun has a matching unit descriptor, false > otherwise > */ > -static inline bool ufs_is_valid_unit_desc_lun(u8 lun) > +static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info > *dev_info, > + u8 lun) > { > - return lun == UFS_UPIU_RPMB_WLUN || (lun < UFS_UPIU_MAX_GENERAL_LUN); > + if (!dev_info || !dev_info->max_lu_supported) { > + pr_err("Max General LU supported by UFS isn't initilized\n"); > + return false; > + } > + > + return lun == UFS_UPIU_RPMB_WLUN || (lun < > dev_info->max_lu_supported); > } > > #endif /* End of Header */ > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index a297fe55e36a..c6ea5d88222d 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -3286,7 +3286,7 @@ static inline int > ufshcd_read_unit_desc_param(struct ufs_hba *hba, > * Unit descriptors are only available for general purpose LUs (LUN > id > * from 0 to 7) and RPMB Well known LU. > */ > - if (!ufs_is_valid_unit_desc_lun(lun)) > + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) > return -EOPNOTSUPP; > > return ufshcd_read_desc_param(hba, QUERY_DESC_IDN_UNIT, lun, > @@ -4540,7 +4540,7 @@ static int ufshcd_get_lu_wp(struct ufs_hba *hba, > * protected so skip reading bLUWriteProtect parameter for > * it. For other W-LUs, UNIT DESCRIPTOR is not available. > */ > - else if (lun >= UFS_UPIU_MAX_GENERAL_LUN) > + else if (lun >= hba->dev_info.max_lu_supported) > ret = -ENOTSUPP; > else > ret = ufshcd_read_unit_desc_param(hba, Looks good to me. Reviewed-by: Asutosh Das