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 807DFEE4993 for ; Wed, 11 Sep 2024 23:53:02 +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-Transfer-Encoding: Content-Type: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=SJv3nyxVqjh5lB3KO3mH1O5Sj7uRV0DVaGHm7B4yrqI=; b=rvKNSfbi2KqEeL7ywu3mfK1qSn NdZSscVZWw/yypHBmXSoNYLQCwYeXvfRllVG7vRYQKqa8tkqhdaoawrM/O/zN8T/y9fDloUKnP+rj 2SVRkh8zx9aZUvjJHz37bDwusujshuVG116moUleZG5siMMpgRpWdvzosQ3rU9enfqnaPJ01r5yGQ kWhUexoOy24+aiaDt8pStKPEiRu2DoqHT05zq0QY50D5GSk1loefzuxijiJbey588xBBFDLkLPGPo XiJYVkomC63sc67+41LGD3aovlakOZODZCObMciqXOphUzqGnqDqnejJTNnOOKJYdJ2zFEGvsV08W LgUSibog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soX8i-0000000BNS2-1IOh; Wed, 11 Sep 2024 23:52:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soX7f-0000000BNKo-0GGk for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 23:51:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A49F95C0773; Wed, 11 Sep 2024 23:51:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50AE2C4CEC0; Wed, 11 Sep 2024 23:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726098701; bh=Y6kf4Wi6KDs88Xo6Q2D9THZIQ/bLuNqar2amyrJ7IBE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=f+ZcnKWyi/9UeOBLlF/Z3b+5pgzmUkwOiy10JBnuRxQTfqc4Hosspr/wpoDJIXVtI kk0Li2BICh2E/3SN852se+VptdvCM2DHcgLnkE0ORU+Y5ST9cfAITgQLxSLvpZtB8l cP7ALk2w2e5Qos/NuLD9CdmEP0Ect8bsLcdMpfJ8b1+b2HAIht0Sp/fZ2cd7GyPmJy 9bLOKQqMIKNXXxWOnOx+r8fPJc/IqtLrGWUeo4yJE6I75CJiYJahEgze1GP1U7y7fn Ix/Lxos3H3MZngCNdicv+J6H7X8MkOpu7NQwIqH8EH1F754GbaaG0nel0DeqXjyNbk 87ebwq7P0sF9A== Date: Wed, 11 Sep 2024 16:51:40 -0700 From: Jakub Kicinski To: Suraj Jaiswal Cc: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Paolo Abeni , Maxime Coquelin , , , , , Prasad Sodagudi , Andrew Halaney , Rob Herring , Subject: Re: [PATCH v2] net: stmmac: allocate separate page for buffer Message-ID: <20240911165140.566d9fdb@kernel.org> In-Reply-To: <20240910124841.2205629-2-quic_jsuraj@quicinc.com> References: <20240910124841.2205629-1-quic_jsuraj@quicinc.com> <20240910124841.2205629-2-quic_jsuraj@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_165143_187244_80B7C63F X-CRM114-Status: GOOD ( 15.33 ) 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 On Tue, 10 Sep 2024 18:18:41 +0530 Suraj Jaiswal wrote: > Currently for TSO page is mapped with dma_map_single() > and then resulting dma address is referenced (and offset) > by multiple descriptors until the whole region is > programmed into the descriptors. > This makes it possible for stmmac_tx_clean() to dma_unmap() > the first of the already processed descriptors, while the > rest are still being processed by the DMA engine. This leads > to an iommu fault due to the DMA engine using unmapped memory > as seen below: > > arm-smmu 15000000.iommu: Unhandled context fault: fsr=0x402, > iova=0xfc401000, fsynr=0x60003, cbfrsynra=0x121, cb=38 > > Descriptor content: > TDES0 TDES1 TDES2 TDES3 > 317: 0xfc400800 0x0 0x36 0xa02c0b68 > 318: 0xfc400836 0x0 0xb68 0x90000000 > > As we can see above descriptor 317 holding a page address > and 318 holding the buffer address by adding offset to page > addess. Now if 317 descritor is cleaned as part of tx_clean() > then we will get SMMU fault if 318 descriptor is getting accessed. The device is completing earlier chunks of the payload before the entire payload is sent? That's very unusual, is there a manual you can quote on this? > To fix this, let's map each descriptor's memory reference individually. > This way there's no risk of unmapping a region that's still being > referenced by the DMA engine in a later descriptor. This adds overhead. Why not wait with unmapping until the full skb is done? Presumably you can't free half an skb, anyway. Please added Fixes tag and use "PATCH net" as the subject tag/prefix. -- pw-bot: cr