From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 288947E for ; Mon, 25 Apr 2022 11:03:42 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D0371FB; Mon, 25 Apr 2022 04:03:38 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECFB83F73B; Mon, 25 Apr 2022 04:03:36 -0700 (PDT) Date: Mon, 25 Apr 2022 12:03:34 +0100 From: Andre Przywara To: Samuel Holland Cc: Ulf Hansson , linux-mmc@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec , Maxime Ripard , Yangtao Li , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH] mmc: sunxi-mmc: Fix DMA descriptors allocated above 32 bits Message-ID: <20220425120334.62f60978@donnerap.cambridge.arm.com> In-Reply-To: <20220424231751.32053-1-samuel@sholland.org> References: <20220424231751.32053-1-samuel@sholland.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 24 Apr 2022 18:17:50 -0500 Samuel Holland wrote: Hi Samuel, thanks for sending this. > Newer variants of the MMC controller support a 34-bit physical address > space by using word addresses instead of byte addresses. However, the > code truncates the DMA descriptor address to 32 bits before applying the > shift. This breaks DMA for descriptors allocated above the 32-bit limit. > > Fixes: 3536b82e5853 ("mmc: sunxi: add support for A100 mmc controller") > Signed-off-by: Samuel Holland > --- > > drivers/mmc/host/sunxi-mmc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index c62afd212692..46f9e2923d86 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -377,8 +377,9 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host, > pdes[i].buf_addr_ptr1 = > cpu_to_le32(sg_dma_address(&data->sg[i]) >> > host->cfg->idma_des_shift); > - pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc >> > - host->cfg->idma_des_shift); > + pdes[i].buf_addr_ptr2 = > + cpu_to_le32(next_desc >> > + host->cfg->idma_des_shift); I had mentioned this problem on the original patch before[1] and had this fixed in my re-submission[2], so it looks good to me: Reviewed-by: Andre Przywara Cheers, Andre [1]https://lore.kernel.org/linux-arm-kernel/65401815-cb2e-58ec-7653-f09d6a25804c@arm.com/ [2]https://lore.kernel.org/linux-arm-kernel/20210118020848.11721-3-andre.przywara@arm.com/ > } > > pdes[0].config |= cpu_to_le32(SDXC_IDMAC_DES0_FD); 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9F38C433EF for ; Mon, 25 Apr 2022 11:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9KCG2sxze9no8me57qXBC8G9H/3UZqJY+KMa8nSH/UI=; b=24SWxxptSzpKLo POsk7l7gNli9Fp2hgpJR1unwSvJB7qUtxo6R7EauHNRG5n6prhiXYw+iuPFEyUAyLw1b0WRXK/Zcr J5TNP+wseHtrnSW3W26D2plM28l/lsgmzR8FvkLUwurwooLLcYO1PFNKjDe+2jw4Ayj0pphjKCrbZ 7gR0dDk+HWX1t3z0JDqNORP2SZ4B2xDXdS6AzkGjpIaPUG2RVH4mEAqSqlaIiKEf9jZe4QbCTAmVZ xBGsMY+dgyvU1iY/16zcWinsK/ltGt5t5PZjsRV21QIQ2nN9ena9kAU0WJ9c9GE7oOaeexLc5codO hkoeY+dyGbkRF30X2LYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1niwVQ-009Dhm-Sd; Mon, 25 Apr 2022 11:03:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1niwVK-009Dfa-Ek for linux-arm-kernel@lists.infradead.org; Mon, 25 Apr 2022 11:03:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D0371FB; Mon, 25 Apr 2022 04:03:38 -0700 (PDT) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECFB83F73B; Mon, 25 Apr 2022 04:03:36 -0700 (PDT) Date: Mon, 25 Apr 2022 12:03:34 +0100 From: Andre Przywara To: Samuel Holland Cc: Ulf Hansson , linux-mmc@vger.kernel.org, Chen-Yu Tsai , Jernej Skrabec , Maxime Ripard , Yangtao Li , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH] mmc: sunxi-mmc: Fix DMA descriptors allocated above 32 bits Message-ID: <20220425120334.62f60978@donnerap.cambridge.arm.com> In-Reply-To: <20220424231751.32053-1-samuel@sholland.org> References: <20220424231751.32053-1-samuel@sholland.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220425_040343_528493_3AC1C375 X-CRM114-Status: GOOD ( 18.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, 24 Apr 2022 18:17:50 -0500 Samuel Holland wrote: Hi Samuel, thanks for sending this. > Newer variants of the MMC controller support a 34-bit physical address > space by using word addresses instead of byte addresses. However, the > code truncates the DMA descriptor address to 32 bits before applying the > shift. This breaks DMA for descriptors allocated above the 32-bit limit. > > Fixes: 3536b82e5853 ("mmc: sunxi: add support for A100 mmc controller") > Signed-off-by: Samuel Holland > --- > > drivers/mmc/host/sunxi-mmc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index c62afd212692..46f9e2923d86 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -377,8 +377,9 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host, > pdes[i].buf_addr_ptr1 = > cpu_to_le32(sg_dma_address(&data->sg[i]) >> > host->cfg->idma_des_shift); > - pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc >> > - host->cfg->idma_des_shift); > + pdes[i].buf_addr_ptr2 = > + cpu_to_le32(next_desc >> > + host->cfg->idma_des_shift); I had mentioned this problem on the original patch before[1] and had this fixed in my re-submission[2], so it looks good to me: Reviewed-by: Andre Przywara Cheers, Andre [1]https://lore.kernel.org/linux-arm-kernel/65401815-cb2e-58ec-7653-f09d6a25804c@arm.com/ [2]https://lore.kernel.org/linux-arm-kernel/20210118020848.11721-3-andre.przywara@arm.com/ > } > > pdes[0].config |= cpu_to_le32(SDXC_IDMAC_DES0_FD); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel