Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1412142rbb; Mon, 26 Feb 2024 08:27:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVGadASUhL2pPhKKnYuUwJ5I9m4dsXIH0tzKl+RCsNDRXwnq3nCTg5I7zeHWhIH45sOaW1WDJtcDaUi2jK66ndeurRcU0dfo+HwRnK25g== X-Google-Smtp-Source: AGHT+IHf9lD/b2Cjnwa2iPJOlud80R+2jQ8bx/8AbQ7NJobKwWSdkJxP+jrSmKpeB/I345kBUHWq X-Received: by 2002:a17:906:f116:b0:a3f:52dc:786b with SMTP id gv22-20020a170906f11600b00a3f52dc786bmr6542084ejb.23.1708964875141; Mon, 26 Feb 2024 08:27:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708964875; cv=pass; d=google.com; s=arc-20160816; b=UpKdU+oo6GRGt2+UkrzWDaDT5oSUzflHY45+d7JAaYoCu2/3dhafNr2uUYPY3MmBOK m8hibzgjiXqDIwCRjInzIMn7yuCHH7uaY0fabVGbt3l4YpipKAz7y704p6FReiHkLpQT TGmdiZgK6qNoyavpchkJOrimJyK7PDl0nrO37Zze8fdbvsi685u9dnRGpDbU63thLXJg 2uLQ9vDOlRriXiwTd0qFJt2sLFfQE7j5fRSr2cYuPLrkSplxywTRjQA6PpRafmVFcxIQ wSWq7MYW4kQGqx9eBBFUe2A/3eTNo3ETn0FnBRjVOODBt0w5uJ7N2v9jhZDglLtqxUWM bXdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=M1E62GOl8ygZip/OS74ui0vmDjeHeqdU+o27AGQEar8=; fh=jzJr8VuOb3bE13WBKPtcmSGx28ADPF+UIYQ4KJd4Rn0=; b=zYLRLYAhtTOCDSGFzcnKao+uFuGHNnF5okVfgxlRwfM4nA9FSsSUFsadpOJbcgKIVf 8n+qoEXZ+LSVisAFfeHJ3xYjlqOzBBNfDZhRP+N73ZJtbzQZSouDgrtz3g762xKq0Pdb gumGdiF5xbqAtn7uDDxzcn73D7ASluWrzF4ttf/xoM5dcwQULzX7kMk68PLCu0GmPcOv kNtW9Yvt2A7C4JuqN9L5fwRhpfE1XRRynp/wTR6poli3REXsRSHmmY8PFmZhawvoC6uL kNyZriMvQMJCyED7Dn3hNFlbkpNM2E4iHYaNev6kt5eGvAs09v/Q4XGXn1jVPrnnkX/B 8OAQ==; 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-81908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gb34-20020a170907962200b00a3e57ae39e0si2314484ejc.474.2024.02.26.08.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:27:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-81908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81908-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B47311F2BCC0 for ; Mon, 26 Feb 2024 16:27:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA0CE12FB00; Mon, 26 Feb 2024 16:27:28 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ECEF12C810; Mon, 26 Feb 2024 16:27:25 +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=1708964848; cv=none; b=SfpLWc6J25GvPdTLI6IPQydbgSSAuWduHILjQmlwSxax2SVRV4ybwXIIFTQtYmeXPsrpYhNQMeu5Yz7NzQlrykWk/U3cdfp4V+MEkUKkeas4WyacP971kGjEGFgkU1V5mlj19BYhSiHKD3RcWyqr1bFbjnbWyX4m84NSJW+4YLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708964848; c=relaxed/simple; bh=mO9DSkJwDCEJi0Uvk9Pm5rQ7w+WPMSHOMnK//jgc+C8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rK+MfGUWUXkyvk/NX89qupKprsLy7tDdNLet1ny9EP3aY+idkzCLrvv6jJ5Q74Ox98x/aY0JA/ZiBxLzOu/7jEZDKEowOZYVxX/pROe5vZJnHNLQjc02oGjiLS1th649IjOym4kE+QJsM7VVRsHJlR2l7u3ndD4zrJUzgyClgOk= 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 4510EDA7; Mon, 26 Feb 2024 08:27:58 -0800 (PST) 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 965933F73F; Mon, 26 Feb 2024 08:27:17 -0800 (PST) Message-ID: <94043c84-0b03-491a-9dd4-2a792d33bca0@arm.com> Date: Mon, 26 Feb 2024 16:27:16 +0000 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 net-next v3 1/7] dma: compile-out DMA sync op calls when not used Content-Language: en-GB To: Alexander Lobakin Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christoph Hellwig , Marek Szyprowski , Joerg Roedel , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Magnus Karlsson , Maciej Fijalkowski , Alexander Duyck , bpf@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240214162201.4168778-1-aleksander.lobakin@intel.com> <20240214162201.4168778-2-aleksander.lobakin@intel.com> <893ad3a4-ba24-43cf-8200-b8cd7742622d@arm.com> <6b003271-cd83-4091-89c6-bb37da62afef@intel.com> From: Robin Murphy In-Reply-To: <6b003271-cd83-4091-89c6-bb37da62afef@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 19/02/2024 12:53 pm, Alexander Lobakin wrote: > From: Robin Murphy > Date: Wed, 14 Feb 2024 17:20:50 +0000 > >> On 2024-02-14 4:21 pm, Alexander Lobakin wrote: > > [...] > >>> -static inline void dma_sync_single_for_cpu(struct device *dev, >>> dma_addr_t addr, >>> -        size_t size, enum dma_data_direction dir) >>> +static inline void __dma_sync_single_for_cpu(struct device *dev, >>> +        dma_addr_t addr, size_t size, enum dma_data_direction dir) >> >> To me it would feel more logical to put all the wrappers inside the >> #ifdef CONFIG_HAS_DMA and not touch these stubs at all (what does it >> mean to skip an inline no-op?). Or in fact, if dma_skip_sync() is >> constant false for !HAS_DMA, then we could also just make the external >> function declarations unconditional and remove the stubs. Not a critical >> matter though, and I defer to whatever Christoph thinks is most >> maintainable. > > It's done like that due to that I'm adding a runtime check in the second > patch. I don't feel like touching this twice makes sense. Huh? Why would anything need touching twice? All I'm saying is that it's pretty pointless to add any invocations of dma_skip_sync() in !HAS_DMA paths where we already know the whole API is stubbed out anyway. The only cases which are worth differentiating here are HAS_DMA + DMA_NEED_SYNC vs. HAS_DMA + !DMA_NEED_SYNC (with the subsequent runtime check then just subdividing the former). > > [...] > >>> @@ -348,18 +348,72 @@ static inline void dma_unmap_single_attrs(struct >>> device *dev, dma_addr_t addr, >>>       return dma_unmap_page_attrs(dev, addr, size, dir, attrs); >>>   } >>>   +static inline void __dma_sync_single_range_for_cpu(struct device *dev, >>> +        dma_addr_t addr, unsigned long offset, size_t size, >>> +        enum dma_data_direction dir) >>> +{ >>> +    __dma_sync_single_for_cpu(dev, addr + offset, size, dir); >>> +} >>> + >>> +static inline void __dma_sync_single_range_for_device(struct device >>> *dev, >>> +        dma_addr_t addr, unsigned long offset, size_t size, >>> +        enum dma_data_direction dir) >>> +{ >>> +    __dma_sync_single_for_device(dev, addr + offset, size, dir); >>> +} >> >> There is no need to introduce these two. > > I already replied to this in the previous thread. Some subsys may want > to check for the shortcut earlier to avoid call ladders of their own > functions. See patch 6 for example where I use this one. Ugh, no. If the page pool code wants to be clever poking around and sidestepping parts of the documented API, it can flippin' well open-code a single addition to call __dma_sync_single_for_device() directly itself. I'm not at all keen on having to maintain "common" APIs for such niche trickery. Thanks, Robin.