Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1204610lqo; Thu, 9 May 2024 07:33:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnl3D89rpsghbEp6HnbzZCUgmz9jl5N511/P1Rx9fjYelwei7O31hRdvMEQNP3SCrrPqEZDjY0w0njIaoeHt4+9o2RP/Kn8aemZMUNlw== X-Google-Smtp-Source: AGHT+IGdaqvZcoroNFTBdSxaBKGbTMyQkURgQJx6ouvhexZ/suP3sYxabDphwrA7dQBqdkoxi0P0 X-Received: by 2002:a05:620a:1aa5:b0:792:9232:c93f with SMTP id af79cd13be357-792b288608bmr714108585a.77.1715265218689; Thu, 09 May 2024 07:33:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715265218; cv=pass; d=google.com; s=arc-20160816; b=VDfXU7ivEUwZvdj6SNE0QzShMPFibWcMbz8XnNlpUNy2xPJfX93hiDzIVGu1u3FPeF jMO+4MiS+x3hNKcfoJK8JMbF0/cMR5i/BiTuUfdStfFmV8ABEB6ZQgONimdaAtaENnkr VK1VgbN1GlLv9QtecMqXnugaMzQ5KzRIm+COdIx2O/rN+kDoBcv+G0m/RF1mKndtLY2C bhc+G34FrT3d4VAgLExvOv33g/RprrWYmJdQhr+mIbrRgXxMnuVMyBouMP9EKfuuTkw8 VsNt19wfL8xTeMuCylVGWS3XK0tYeNhoQFvXCaXdlx7a/U4yxJiTIXm3tHfUlERQt6Et mhGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=CbAg3n36R4TagJoMqF81lAiMOZPOh5xy+nXTdZBqVkA=; fh=J2cBX+OycjQe7KBcFemMRTpVh5qeCMPKH9Fp3lXtaE0=; b=eP9y8hEgxMAQ6hgrAwRDX4oixBR3zD1cETp8d17wODoticOXEfvNZxayldRmEZPI6F 1BwpEhY+ZnA4WfyPfdQX/U783adZaTPZ95dtnaSFeO7iG2WK9nLFDgvhTc83Axo0Jxat 31EdFGQaUqKPn7Zoo7B/I3WA6Co7bf8Flmi/qTyGUbQ1RVfM1+oKPzw7C7VDjB9I2qjQ cwPURANIIPTZlroRMBOBnuT8jXZmj4786zXEvm4dohrSjxGZgTmo30ae2zXFyRcrdO6C 1SjDDNV7vWlzFhcNU3dWCOC3Z3AwG6LSclnmOhjX19vjOuHigF0QVWX5/JaASUV/iK9q C3iA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174592-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174592-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf278d77si135517785a.134.2024.05.09.07.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 07:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174592-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174592-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174592-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 97DD11C21EDB for ; Thu, 9 May 2024 14:33:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CA66134CCC; Thu, 9 May 2024 14:33:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B37D41B5AA; Thu, 9 May 2024 14:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715265198; cv=none; b=d/Do7dCkD4WL+VRtuQf8Oyqia8z1ZtjMGCkIg44UkPuN1go0arSJp9Sb6D5ck8Qo0xJts2kdQgMovGwK5WSbTMQgs8fu3gwXzLwCBxqGKUaPH+9KuQC3/xdiSjqdCXeHCV9x69KqQ+3qYVl/H3n+LVEPeeDjfBfPe+aSjW7kSjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715265198; c=relaxed/simple; bh=x+Uf/gt/MrLRVLMFBjjZ3+jQZpEm03831m9IVETeVCc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qMKZuhHeQkLJT00GIYU6CrMWIPXA270Zs2+Ch2C2fBKY157ayYcda5ZCWK5ZCP4rhP4F6ctZRnnDZVe52KcwDnNORQtcoBoHdFHHTdpAtyy7aBOI5cbD8wWTOmtaDioODLOPUPqcolPMdQWEmVuKH2vE32wqpidljtlPatPUtJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 97890106F; Thu, 9 May 2024 07:33:41 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 695983F641; Thu, 9 May 2024 07:33:14 -0700 (PDT) Message-ID: <5d6a26f5-5acb-4c5d-aa11-724399d1348b@arm.com> Date: Thu, 9 May 2024 15:33:13 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/7] dma: avoid redundant calls for sync operations To: Steven Price , Alexander Lobakin , Christoph Hellwig Cc: Eric Dumazet , Jakub Kicinski , Marek Szyprowski , Joerg Roedel , Will Deacon , "Rafael J. Wysocki" , Magnus Karlsson , nex.sw.ncis.osdt.itp.upstreaming@intel.com, bpf@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240507112026.1803778-1-aleksander.lobakin@intel.com> <20240507112026.1803778-3-aleksander.lobakin@intel.com> <010686f5-3049-46a1-8230-7752a1b433ff@arm.com> From: Robin Murphy Content-Language: en-GB In-Reply-To: <010686f5-3049-46a1-8230-7752a1b433ff@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 09/05/2024 2:43 pm, Steven Price wrote: > On 07/05/2024 12:20, Alexander Lobakin wrote: >> Quite often, devices do not need dma_sync operations on x86_64 at least. >> Indeed, when dev_is_dma_coherent(dev) is true and >> dev_use_swiotlb(dev) is false, iommu_dma_sync_single_for_cpu() >> and friends do nothing. >> >> However, indirectly calling them when CONFIG_RETPOLINE=y consumes about >> 10% of cycles on a cpu receiving packets from softirq at ~100Gbit rate. >> Even if/when CONFIG_RETPOLINE is not set, there is a cost of about 3%. >> >> Add dev->need_dma_sync boolean and turn it off during the device >> initialization (dma_set_mask()) depending on the setup: >> dev_is_dma_coherent() for the direct DMA, !(sync_single_for_device || >> sync_single_for_cpu) or the new dma_map_ops flag, %DMA_F_CAN_SKIP_SYNC, >> advertised for non-NULL DMA ops. >> Then later, if/when swiotlb is used for the first time, the flag >> is reset back to on, from swiotlb_tbl_map_single(). >> >> On iavf, the UDP trafficgen with XDP_DROP in skb mode test shows >> +3-5% increase for direct DMA. >> >> Suggested-by: Christoph Hellwig # direct DMA shortcut >> Co-developed-by: Eric Dumazet >> Signed-off-by: Eric Dumazet >> Signed-off-by: Alexander Lobakin > > I've bisected a boot failure (on a Firefly RK3288) to this commit. > AFAICT the problem is that I have (at least) two drivers which don't > call dma_set_mask() and therefore never initialise the new dma_need_sync > variable. > > The specific drivers are "rockchip-drm" and "rk_gmac-dwmac". Is it a > requirement that all drivers engaging in DMA should call dma_set_mask() > - and therefore this has uncovered a bug in those drivers. Or is the > assumption that all drivers call dma_set_mask() faulty? Historically it's long been documented (at least in DMA-API-HOWTO) that a 32-bit DMA mask is assumed by default, so as much as we would prefer to shift expectations, there are still going to be a great many drivers relying on that :( Perhaps its time for dma-debug to start warning about implicit mask usage, maybe that might help push the agenda a bit? Thanks, Robin.