Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp395435ybz; Tue, 21 Apr 2020 23:55:44 -0700 (PDT) X-Google-Smtp-Source: APiQypL73D1ze7k1+7/LKg6PA4f/Eewqg7wMnh9XLrSuJn/iI8uWw7DbhV+zJtsmjyNCLhsDbRgj X-Received: by 2002:a50:99c4:: with SMTP id n4mr22743711edb.187.1587538544110; Tue, 21 Apr 2020 23:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587538544; cv=none; d=google.com; s=arc-20160816; b=A5T26TlrdVTEIEHi5NoSMmEsCLpQitiAINaQ5pWPgLa8npxiVsp1ebaNANDVA3GNLv iaYCqT1TXilNkihCZoZM/NmrAdmUQLj1CGbjc6oyQQlF4Re0XKYexEdonlWusqN16FMf GVQsITLhaTUihLHrl7x61r9cAdYqmqqzSB6b1tJESL5srHPgCxH3KAUNR1TCfzPFcYQt RjOiasKOoePljcHZewjvq27mXhuayuGmxicJhcbm3p9jp5b10vqeDsCPMlNrhh3Ml8oa ATe/MehEGEeOfcl46E3+OHLNwPUfARDke/R/K23sFkAXhZUD1mS7jQIWpIRtQ+Coa2Ag N6xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=PPZ4h2g1T5oHvKPAYnNLCJiwA+6mBi/YDgQyauKaszE=; b=XWHODHYMKmxYDJYl5dpFUPOk0et2oyFPzpRCieuTuP5ELPKB3Bvk/ErhFN9lhhJ8An kaJC2U8FJktV2UlmVOhQO3TmzKjg9e9Qnpx5oj/HUPLLNWY9u3lU51zPpgQCHmUQBlf+ V21/hQc4O4U0eKlWzhL9gg56S0/Kqp0nIAymBP3mnlOY+iruX+vpzewwl4JaB9ckrUsg E0jkAFjE/7+AI4RDfnjYRPMJO/u7HlbK7IyZA6acYGRecffx8t8cooSIqITSL5OVmRUq OkvmDEqcAl0j4J7wDLaT/X1WRZY965fe6TZ9o2JgwYX9WhtsE0JSWBZJqDmEIso/FSAC Tjew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uA+B5OdC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq3si2787668edb.367.2020.04.21.23.55.21; Tue, 21 Apr 2020 23:55:44 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uA+B5OdC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726066AbgDVGyP (ORCPT + 99 others); Wed, 22 Apr 2020 02:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbgDVGyP (ORCPT ); Wed, 22 Apr 2020 02:54:15 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C985C03C1A6; Tue, 21 Apr 2020 23:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PPZ4h2g1T5oHvKPAYnNLCJiwA+6mBi/YDgQyauKaszE=; b=uA+B5OdCZI47BRrAhfT/13mIKQ tcepQX5mWIn1Y1cEAeGW+MeiXS3dc/+mQmnvDGpF3/MtB7lTDahF03J4+v1e9QCo5UVk+EVRbTw3S xsQkC2wUOAwqKEQn+LF3rYpjdi8CqpQ22CdGp28zJGe3BfiCAisIDCL9+eVulZmyXhH7ffc+xRREo wBdn5UWxKVS3lxdoTU+ggRZWXetaZZVUUBDGgOVan9WZ9hAR3GAk6Q+3PI275OtXqRSZJgbfUy2Q4 RhwdqKFLaI7rXULSE49yznfQH6iMjawCrlWwO3LHXhh+V9ln/XQyWZ6FLmViomNojEt+YuDPJUfDq cLPnmVfw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR9Gw-0004PS-1b; Wed, 22 Apr 2020 06:54:14 +0000 Date: Tue, 21 Apr 2020 23:54:14 -0700 From: Christoph Hellwig To: Alim Akhtar Cc: robh@kernel.org, devicetree@vger.kernel.org, linux-scsi@vger.kernel.org, krzk@kernel.org, avri.altman@wdc.com, martin.petersen@oracle.com, kwmad.kim@samsung.com, stanley.chu@mediatek.com, cang@codeaurora.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 04/10] scsi: ufs: introduce UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk Message-ID: <20200422065414.GK20318@infradead.org> References: <20200417175944.47189-1-alim.akhtar@samsung.com> <20200417175944.47189-5-alim.akhtar@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200417175944.47189-5-alim.akhtar@samsung.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 11:29:38PM +0530, Alim Akhtar wrote: > Some UFS host controllers may think granularities of PRDT length and > offset as bytes, not double words. > > Signed-off-by: Kiwoong Kim > Signed-off-by: Alim Akhtar > --- > drivers/scsi/ufs/ufshcd.c | 30 +++++++++++++++++++++++------- > drivers/scsi/ufs/ufshcd.h | 6 ++++++ > 2 files changed, 29 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index ee30ed6cc805..b32fcedcdcb9 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -2151,8 +2151,14 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) > return sg_segments; > > if (sg_segments) { > - lrbp->utr_descriptor_ptr->prd_table_length = > - cpu_to_le16((u16)sg_segments); > + > + if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN) > + lrbp->utr_descriptor_ptr->prd_table_length = > + cpu_to_le16((u16)(sg_segments * > + sizeof(struct ufshcd_sg_entry))); > + else > + lrbp->utr_descriptor_ptr->prd_table_length = > + cpu_to_le16((u16) (sg_segments)); No double words here. "Normal" UFS uses the actual segment count, while Samsumg uses bytes. Also no need fo the u16 count in either the old or new version.