Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A06F0C43381 for ; Fri, 15 Feb 2019 17:05:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F51721924 for ; Fri, 15 Feb 2019 17:05:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="DrXF73JE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbfBORFQ (ORCPT ); Fri, 15 Feb 2019 12:05:16 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:37172 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbfBORFP (ORCPT ); Fri, 15 Feb 2019 12:05:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References: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-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qOKOqJfoaTStW9JarKZ2A0AuwQtpxGdrZLIibxlHkHY=; b=DrXF73JEafUc7nOp4EiMjIuRA C0iRRDyxt0ptyh6W7gzTIKGtmvdW1fq7YPNzCnio4GcFnVJzpJublJe48muikf9R1XpX73YNAfP6A dWkqP9ZaS3PS5Hj6p6indBlZrlhaaXlIRKlKXdx3gM59zdzWbmr1/3Eo2pK2AFitCiu/6VgWah6Ji 4FVL2jJ7RVDQAP/G4/s286e0flIbH5UY0RpFJFaGsiwP4OV0L0sgzV1uI/VJmFD7YcsdmJsD8UbEr R86GYvkMfNrY/pfICG7h5E53lchONdmhk2ZJQWZPIti+YKKVVPdUmDp/CYxoMjQ4a9chu8sugy8i6 Ndq8lACXQ==; Received: from shell.armlinux.org.uk ([2002:4e20:1eda:1:5054:ff:fe00:4ec]:36790) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gugvF-0004Dv-SO; Fri, 15 Feb 2019 17:05:10 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1gugvD-0004jV-HU; Fri, 15 Feb 2019 17:05:07 +0000 Date: Fri, 15 Feb 2019 17:05:07 +0000 From: Russell King - ARM Linux admin To: Gregory CLEMENT Cc: Thomas Petazzoni , "David S. Miller" , netdev@vger.kernel.org Subject: Re: [PATCH] net: marvell: mvneta: fix DMA debug warning Message-ID: <20190215170507.p3kztk7okx4rvfko@shell.armlinux.org.uk> References: <87zhqx2ket.fsf@FE-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87zhqx2ket.fsf@FE-laptop> User-Agent: NeoMutt/20170113 (1.7.2) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Feb 15, 2019 at 03:31:06PM +0100, Gregory CLEMENT wrote: > Hi Russell, > > On ven., févr. 15 2019, Russell King wrote: > > > Booting 4.20 on SolidRun Clearfog issues this warning with DMA API > > debug enabled: > > > > WARNING: CPU: 0 PID: 555 at kernel/dma/debug.c:1230 check_sync+0x514/0x5bc > > mvneta f1070000.ethernet: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x000000002dd7dc00] [size=240 bytes] > > Modules linked in: ahci mv88e6xxx dsa_core xhci_plat_hcd xhci_hcd devlink armada_thermal marvell_cesa des_generic ehci_orion phy_armada38x_comphy mcp3021 spi_orion evbug sfp mdio_i2c ip_tables x_tables > > CPU: 0 PID: 555 Comm: bridge-network- Not tainted 4.20.0+ #291 > > Hardware name: Marvell Armada 380/385 (Device Tree) > > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > > [] (show_stack) from [] (dump_stack+0x9c/0xd4) > > [] (dump_stack) from [] (__warn+0xf8/0x124) > > [] (__warn) from [] (warn_slowpath_fmt+0x38/0x48) > > [] (warn_slowpath_fmt) from [] (check_sync+0x514/0x5bc) > > [] (check_sync) from [] (debug_dma_sync_single_range_for_cpu+0x6c/0x74) > > [] (debug_dma_sync_single_range_for_cpu) from [] (mvneta_poll+0x298/0xf58) > > [] (mvneta_poll) from [] (net_rx_action+0x128/0x424) > > [] (net_rx_action) from [] (__do_softirq+0xf0/0x540) > > [] (__do_softirq) from [] (irq_exit+0x124/0x144) > > [] (irq_exit) from [] (__handle_domain_irq+0x58/0xb0) > > [] (__handle_domain_irq) from [] (gic_handle_irq+0x48/0x98) > > [] (gic_handle_irq) from [] (__irq_svc+0x70/0x98) > > ... > > > > This appears to be caused by mvneta_rx_hwbm() calling > > dma_sync_single_range_for_cpu() with the wrong struct device pointer, > > as the buffer manager device pointer is used to map and unmap the > > buffer. Fix this. > > > > For me it makes sens to associate the DMA buffer to the HWBM, so this > fixes looks good for me. I'd still question which device is the one doing DMA to the buffer. The HWBM surely is just a management agent passing cookies that happen to be physical addresses to mvneta for it to then do DMA on the resulting buffer. If that's true, then the correct device to map/sync/unmap these buffers against is mvneta, not hwbm. > Reviwed-by: Gregory CLEMENT > > Thanks, > > Gregory > > > > Signed-off-by: Russell King > > --- > > Please check that this is the correct fix. > > > > drivers/net/ethernet/marvell/mvneta.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c > > index ef0a85bbc586..0e1f87fca952 100644 > > --- a/drivers/net/ethernet/marvell/mvneta.c > > +++ b/drivers/net/ethernet/marvell/mvneta.c > > @@ -2086,7 +2086,7 @@ static int mvneta_rx_hwbm(struct napi_struct *napi, > > if (unlikely(!skb)) > > goto err_drop_frame_ret_pool; > > > > - dma_sync_single_range_for_cpu(dev->dev.parent, > > + dma_sync_single_range_for_cpu(&pp->bm_priv->pdev->dev, > > rx_desc->buf_phys_addr, > > MVNETA_MH_SIZE + NET_SKB_PAD, > > rx_bytes, > > -- > > 2.7.4 > > > > -- > Gregory Clement, Bootlin > Embedded Linux and Kernel engineering > http://bootlin.com > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up