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 74EB5C433F5 for ; Mon, 3 Oct 2022 15:26:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vmzx/5SWlqaBpEgF+kxhaOHPTY7jTXUmCD+fR8kvxbc=; b=yHwerqFdbr6JvXRZgmjpVYZSj7 v0Vh15jU+JH13qxt3jXGR4EATQiQ+4WH6MGIH7p207pRaDkaw/eg1lcZ4eRPS817H9u888tbsC7yt A7EnQrukDZEa2fVLrn1HE8e59l8i/99OZesQOdnxuccI7KazLgCmmGYvzGnZnB/RlkK1pz9VE8rjm 6vAejUhP1e7rv8jbG2AogIcQOLB46n+U8To0dPgMia7eJJfdObgYYxyRQdI7QQVhCmreb7V1EBGuG QUCVqoRx/DjcSZubiZ9ZY3mOObdkSelx6I5GLePtJ4jFVhswnftxBw+NBB9yVlSCjRz3ecUNxw9UA P++unIAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofNKC-006RmQ-UI; Mon, 03 Oct 2022 15:25:45 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofNK9-006RlX-NA for linux-arm-kernel@lists.infradead.org; Mon, 03 Oct 2022 15:25:43 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AB174B8117A; Mon, 3 Oct 2022 15:25:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E000EC433D6; Mon, 3 Oct 2022 15:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664810738; bh=x/6Lgc2u9XXeIc/A8kaBJ4+/SykIRy75X7N+3tp1hSA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GBuB48kwZJ98WpuzwwPc+jLcT26jRE7uXkFePrrKE4nCPbE0maMClTcPCwPnyru2g ZQZdU/VQTi7q6fVZ2NFDPCOQcmbBRyguWW2d070q11PpcjJlRg0Des7S7QE2IgmZeW 62BfE4IR8WeNzUCLF8MacUyHKgE05YcxXZgLZ1X+tS9zjw8DtdY+DN/DC6UqW9thWp zS6dcKfCPxulQEZNjUahUIkqqP761PJj8lacAM7lEoCbSsL+mDY5bBaDAdeEISo7rU 4YH4Pjdx4IefCZOBrg4NpWsL/giqob84znnAvj3kMmqELRbSVSfH0KT7En99gRnkp3 4oRREW4IYlrdg== Date: Mon, 3 Oct 2022 17:25:33 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: "Russell King (Oracle)" , pali@kernel.org Cc: Christoph Hellwig , Robin Murphy , Arnd Bergmann , Andre Przywara , Marc Zyngier , Linus Torvalds , Andrew Lunn , Gregory Clement , Greg Kroah-Hartman , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org Subject: Re: REGRESSION in 6.0-rc7 caused by patch "ARM/dma-mapping: use dma-direct unconditionally" Message-ID: <20221003172533.6dc87184@dellmb> In-Reply-To: References: <20220930151028.0e518421@dellmb> <630be11f-09ef-02d4-69f7-c7880ae5674c@arm.com> <20220930165234.729ad68c@dellmb> <20220930170205.490f1a6b@dellmb> <20221003073037.GB2108@lst.de> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/8Tl/Qn22i5Il+yB1M0vqija" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221003_082542_096280_3495283A X-CRM114-Status: GOOD ( 31.53 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --MP_/8Tl/Qn22i5Il+yB1M0vqija Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Mon, 3 Oct 2022 15:11:44 +0100 "Russell King (Oracle)" wrote: > On Mon, Oct 03, 2022 at 09:30:37AM +0200, Christoph Hellwig wrote: > > On Fri, Sep 30, 2022 at 05:02:05PM +0200, Marek Beh=C3=BAn wrote: =20 > > > It seems that the null pointer dereference comes from the data variab= le > > > having zero value. We assign > > > data =3D (u8 *)(uintptr_t)rx_desc->buf_cookie; =20 > >=20 > > I never see any assignment to ->buf_cookie in the driver, what am > > I missing? =20 >=20 > I think Marek's setup (like my setups) use the hardware buffer manager, > and it's hardware that fills in the "buf_cookie", which is supposed to > be the virtual address of the buffer. >=20 > Each buffer supplied to the hardware buffer manager is supposed to > contain the virtual address in the first 32-bit word in that buffer. >=20 > This is done by mvneta_bm_construct(): >=20 > /* In order to update buf_cookie field of RX descriptor properly, > * BM hardware expects buf virtual address to be placed in the > * first four bytes of mapped buffer. > */ > *(u32 *)buf =3D (u32)buf; >=20 > immediately prior to dma_map_single(..., DMA_FROM_DEVICE) is called. >=20 > If I had to guess, I would suggest that this write is being lost via > cache invalidation, and given that the hardware BM both reads and > writes this buffer, DMA_FROM_DEVICE is not correct, it should be > DMA_BIDIRECTIONAL. >=20 > Changing that is probably going to need DMA_FROM_DEVICE also changed > elsewhere in the mvneta_bm and mvneta driver. >=20 > I'm not in a position where I could test that out. Marek? >=20 Hello Russell, thanks for your suggestion! Adding Pali, since he has some information (see at the end of this message). The attached patch seems to solve the null-pointer dereference. I booted into single user mode and enabled eth2. Before it caused the NULL pointer dereference after link got up, not it does not happen. But I am still encountering the freeze after booting into system. Maybe these are different bugs? I am thinking whether we don't need something similar like 7bea67a99430 ("ARM: dts integrator: Fix DMA ranges") also for mvebu. I seem to remember Pali talking about how the ranges defined in some upstream mvebu-tree, using MBUS_ID() macros, are incorrect. Pali, what do you remember about this? Marek --MP_/8Tl/Qn22i5Il+yB1M0vqija Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=mvneta-dma-bidir.patch diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index ff3e361e06e7..28eeba9bece2 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -2587,7 +2587,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi, rx_desc->buf_phys_addr, MVNETA_MH_SIZE + NET_SKB_PAD, rx_bytes, - DMA_FROM_DEVICE); + DMA_BIDIRECTIONAL); skb_put_data(skb, data + MVNETA_MH_SIZE + NET_SKB_PAD, rx_bytes); @@ -2629,7 +2629,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi, * the skb is successfully built or not. */ dma_unmap_single(&pp->bm_priv->pdev->dev, phys_addr, - bm_pool->buf_size, DMA_FROM_DEVICE); + bm_pool->buf_size, DMA_BIDIRECTIONAL); if (!skb) goto err_drop_frame; diff --git a/drivers/net/ethernet/marvell/mvneta_bm.c b/drivers/net/ethernet/marvell/mvneta_bm.c index 46c942ef2287..7b93538078df 100644 --- a/drivers/net/ethernet/marvell/mvneta_bm.c +++ b/drivers/net/ethernet/marvell/mvneta_bm.c @@ -103,7 +103,7 @@ int mvneta_bm_construct(struct hwbm_pool *hwbm_pool, void *buf) */ *(u32 *)buf = (u32)buf; phys_addr = dma_map_single(&priv->pdev->dev, buf, bm_pool->buf_size, - DMA_FROM_DEVICE); + DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(&priv->pdev->dev, phys_addr))) return -ENOMEM; @@ -243,7 +243,7 @@ void mvneta_bm_bufs_free(struct mvneta_bm *priv, struct mvneta_bm_pool *bm_pool, break; dma_unmap_single(&priv->pdev->dev, buf_phys_addr, - bm_pool->buf_size, DMA_FROM_DEVICE); + bm_pool->buf_size, DMA_BIDIRECTIONAL); hwbm_buf_free(&bm_pool->hwbm_pool, vaddr); } --MP_/8Tl/Qn22i5Il+yB1M0vqija Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --MP_/8Tl/Qn22i5Il+yB1M0vqija--