Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2087411ybm; Sun, 31 May 2020 08:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIbOTDwrxRItm1S4GmPS2+FmoELVita96P/9wPhhKlqCv0tjuQQ6aCbvWz7lP6GRyospip X-Received: by 2002:aa7:d042:: with SMTP id n2mr17879099edo.226.1590937877430; Sun, 31 May 2020 08:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590937877; cv=none; d=google.com; s=arc-20160816; b=UJkAecNBRQ08XGVRzSFqjBr7gFhpkG/rhApm2MpqUoChF70lfQJuVraMY/+XRT1IgN sqiF8mhZi0P396wqzefEW5fWveyjC6dwe/BYAVTlimjuhLhLeii2FcqxO7RpSyelRcqn rgECfA/l4jQLkjEw9mSgll0EozVCZIbOXrcxkIrp5LY4juJ92Dy3xejb3EVmykVNjaeO 2exnl31OaY88tD7PwEMZMSSnVgubQy8MpYEki9BtHtDWJtSElLA1fTZaiyWvs+dobcnV nT0EoTnBcasohy38brto/Cw+P6Z0KP7FYWAVdSIqt39ev/Tw37flssTUokbNGyP9aeeR tHpg== 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:dkim-signature; bh=MEIjMYiUChbqFAFH7gikTnN2cVqo8tkhFxOw2OxjyaU=; b=IyHNdX6WOZR+mtwTggu5Sr5PhIUpgghGwOsda82CQc7iNgkqiC65Iff0vYHb43FTj9 hu/mSgk2p4jtliimSU46ThV0xGErmoI0X22cZvq3cE6uzu8BVpQ/Ue+8yfPvsUtFG7vu jT2h8nzEv6pgeCehHPhHhfNmISQoTM13QfE0vZLjzNO7y8WtngWSQUqKh5607RunigsW 0bmS3Rj+WHAdSSA9Wv0WtzsQnj9C/J69MbEUUPgqpEy2+4whKZaAIC3oHtUHGwSyO1sP 7jwKDcgKKrUDQYNcC5a/KC78IUfSbKtKhHwWx24AlpJfuKD5Flstu3r968mfTkSqthNY ZKGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uPKWmbqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j93si9587648edb.327.2020.05.31.08.10.54; Sun, 31 May 2020 08:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uPKWmbqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbgEaPI5 (ORCPT + 99 others); Sun, 31 May 2020 11:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728252AbgEaPIu (ORCPT ); Sun, 31 May 2020 11:08:50 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08455C061A0E; Sun, 31 May 2020 08:08:50 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id z5so6826523ejb.3; Sun, 31 May 2020 08:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MEIjMYiUChbqFAFH7gikTnN2cVqo8tkhFxOw2OxjyaU=; b=uPKWmbquwWYeY5eW/cl9nAqdXzw/jh5U6svQPC4aapN5yV+zz9gi2aSPkFDSdngsqj qOS7wLyjCgd6tmm+o9JvjlEmadKDLNrK+R3+HtAh99a54pRSXn/iFb5sQmWme+LryTKJ GoKFIr5sNIfhChDRObuRtjT9SDL2/bQzDSmk8mMpgpfc0KXfJI26mIDlVfJC9nCSGpoB oJv+PuIceaRe/zSxkkEoZdXM/TKECYQBd+fwB97pPumDBniN7si8TM/uF5QWogGvtk7l qseS4dx91NabCA8ohoJTyOv9NRtgw8u4UWIAhBWkk9G30gz7I9LhKPZpIYg3mdUk+yA7 YogA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MEIjMYiUChbqFAFH7gikTnN2cVqo8tkhFxOw2OxjyaU=; b=myuU4pqUXHRV+qpwHuhla5Kfalujt99yMHqaDuihh/Zx/mb7HjybnCNyC2qn2VYf2e isk+6Sd36uN6KrQ+D/8nRBXsMb4srI4iDEeTA7CCXm6S27YS1HYQZdH6x/nJxWJeKcyx j1NsuNiQ3HDhrvD+DcGm9jddMjeYbJfPAbeggPdVQ21bfMHSkgweOWvwNW2jAW4WanIO HabPZik0zIgTZCChDSz5Ue9QvrrqDSWp7qM0CixQ020t+MKVSYvdF0FvjRSEDjkGoHpz yOFHhQKCO2XG7UclfBJIccLWmcV85ITLIBMQHVasSq/W7Lu/1n+Xc3rGDYh6aJ0Er0qT 5oCA== X-Gm-Message-State: AOAM5325j+2gP0cLbYIRJgniNL78rb+vPOGtBZTQ4TUwJwXh0Sj5kkY1 6uO7e1vL69jUv55OZTuO/tY= X-Received: by 2002:a17:906:6686:: with SMTP id z6mr10337247ejo.258.1590937728748; Sun, 31 May 2020 08:08:48 -0700 (PDT) Received: from localhost.localdomain (ip5f5bfcfd.dynamic.kabel-deutschland.de. [95.91.252.253]) by smtp.gmail.com with ESMTPSA id a62sm9564928edf.38.2020.05.31.08.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 08:08:48 -0700 (PDT) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, 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 Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/5] scsi: ufs: add compatibility with 3.1 UFS unit descriptor length Date: Sun, 31 May 2020 17:08:31 +0200 Message-Id: <20200531150831.9946-6-huobean@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200531150831.9946-1-huobean@gmail.com> References: <20200531150831.9946-1-huobean@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bean Huo For UFS 3.1, the normal unit descriptor is 10 bytes larger than the RPMB unit, however, both descriptors share the same desc_idn, to cover both unit descriptors with one length, we choose the normal unit descriptor length by desc_index. Signed-off-by: Bean Huo Reviewed-by: Avri Altman --- drivers/scsi/ufs/ufs.h | 1 + drivers/scsi/ufs/ufshcd.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 6548ef102eb9..332ae09e6238 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -63,6 +63,7 @@ #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_RPMB_UNIT 0xC4 /* WriteBooster buffer is available only for the logical unit from 0 to 7 */ #define UFS_UPIU_MAX_WB_LUN_ID 8 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 45d1fef982a9..a64718bfe2bc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3070,11 +3070,16 @@ void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, EXPORT_SYMBOL(ufshcd_map_desc_id_to_length); static void ufshcd_update_desc_length(struct ufs_hba *hba, - enum desc_idn desc_id, + enum desc_idn desc_id, int desc_index, unsigned char desc_len) { if (hba->desc_size[desc_id] == QUERY_DESC_MAX_SIZE && - desc_id != QUERY_DESC_IDN_STRING) + desc_id != QUERY_DESC_IDN_STRING && desc_index != UFS_RPMB_UNIT) + /* For UFS 3.1, the normal unit descriptor is 10 bytes larger + * than the RPMB unit, however, both descriptors share the same + * desc_idn, to cover both unit descriptors with one length, we + * choose the normal unit descriptor length by desc_index. + */ hba->desc_size[desc_id] = desc_len; } @@ -3143,7 +3148,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, /* Update descriptor length */ buff_len = desc_buf[QUERY_DESC_LENGTH_OFFSET]; - ufshcd_update_desc_length(hba, desc_id, buff_len); + ufshcd_update_desc_length(hba, desc_id, desc_index, buff_len); /* Check wherher we will not copy more data, than available */ if (is_kmalloc && param_size > buff_len) -- 2.17.1