Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp333547lqs; Tue, 5 Mar 2024 03:35:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvEn5jewFdUbOACsIan7JiY+jmQK61iN5LKTpxzIUn4pYAGcEdIMx1DMV0Ld2FF4UsxxWuCex2OOUH1cpM7SXDAWXlqEMzf1/jLa0E7Q== X-Google-Smtp-Source: AGHT+IF5NzZW/iKP3Zk6UpoNBNuRSSV6/ffOEDHVmCXSdfnDbOwrQEIv4wG9sOS6yy4EuE37Fx09 X-Received: by 2002:a05:622a:40a:b0:42e:da9f:c21a with SMTP id n10-20020a05622a040a00b0042eda9fc21amr1896600qtx.22.1709638548464; Tue, 05 Mar 2024 03:35:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709638548; cv=pass; d=google.com; s=arc-20160816; b=qfaVSY0tWlrOKNErR5FuD996/aGqkywnmYHjOgN3Wlawg09Jv+SgGEmUFdcphOVlqh GtadsBEmvNkcCO/NAmfgRJA+ulgTrgnDxB3rZAuxTmEq0zq1sik2X97D3Ww7XBF15Nh0 kyJWTHXG5iiP0Q998hMUi5BwgiWi7XuxytR9YcRMRYpDIkqtIO6DCsGw3UfqePSQ8NeX ZZPT0Q8zwD4LKWTsWZl3EHW5Oww5Y0yhuC4mFpSjByxUv84hWa1TWMyDewumBe2Gu+br j8bOI9x/zdGOHASPQmNJf803+/nEsjuDhC+knY5GHdRsKDT8WKsIURHU9oNwV3vgNbGm ZpSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=ekmA5RBZ+CvAhdFbvGw1i/0H90ih8Imy4vkxYH5RFbI=; fh=mGL+QDiLPsMFdIzG/6Lv8KDRNnXweMPK5miXynhYqv4=; b=tfWjB0S8cy84kxoAKSo9RVz7XoAjCoDyMqujPIGSKeJq0lGsa+QOxGVBv5TqcS7v/c TSH/NcZH1lj8ki+XjdLiUe8x5tS7UYWKD8RhM0dL5lvjZNwOY5SeG0kbikvKn9lHB4g3 ZPSeUO2M0JolP6zuIrBkDOMBCI1FXiPMSXiwyZqzSLfMkp/TOR65vW3TscS7FjMauKiP jd0M/qHOLGcTHwCvQmx34c7cXjumpGMKj6mXii1xAUtYke2Aws14bJjdVh+3RsSeAwYn TqDmuYcmWPeFl3IMb25A+FeI+0pva97AjMcGiahX2N28ZqK0K4fd5LiQGVmS1eXDIWxW 5fTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=SUA7qEcP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=dK6WqAJW; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-91953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91953-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s7-20020a05622a1a8700b0042ef6b7402csi3454201qtc.684.2024.03.05.03.35.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91953-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; dkim=pass header.i=@arndb.de header.s=fm3 header.b=SUA7qEcP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=dK6WqAJW; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-91953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91953-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de 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 D3C821C22372 for ; Tue, 5 Mar 2024 09:06:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6E9F5380C; Tue, 5 Mar 2024 09:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="SUA7qEcP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dK6WqAJW" Received: from wfout7-smtp.messagingengine.com (wfout7-smtp.messagingengine.com [64.147.123.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B1635025C; Tue, 5 Mar 2024 09:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.150 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629509; cv=none; b=jLMkebHKu19+W/+rqGCDC47y3G9KZCUIQ8gd8Jbhh0yDiU9HW8go6sd9Q1rIgGwdCKre6zP/gQPoIvtNI3d6Nz6HusXlSTwOnPO5K6hM3oIUPjNHOLxdu+eKDB5QCDK8qgu8WxWrsTaM97SWtcCGMI4frwc6/QwjhdhtphAG1uk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709629509; c=relaxed/simple; bh=4vEnG02ligmP4LrcfFUAEQhjxpcNYEU0JASPzUPZp/M=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=OI7HcGOtHaAphoatAjA+1DDgwQxAeldkrMRefKnzo3G112Jk/ivKcweRdPFIPwP/pqmDUXByzyRIWtP/ojjH/QisoFH5fsfZp3Kpm0+iUaDsYNJV+GO0iLWn033aEfSsRzjibHYGxSqqvsc7G3HvhIqr0kveYWJZJEnQdtd5KQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=SUA7qEcP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=dK6WqAJW; arc=none smtp.client-ip=64.147.123.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 22F5F1C000A7; Tue, 5 Mar 2024 04:05:06 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 05 Mar 2024 04:05:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1709629505; x=1709715905; bh=ekmA5RBZ+C vAhdFbvGw1i/0H90ih8Imy4vkxYH5RFbI=; b=SUA7qEcPhA1VtahsdC2df931yx WPbB2j3ZYmy701buT133pPpg1BhTzr7LF+TWNzdIkaWuMpprUFOS48zOhjCA8X4L QrZ0PgfUBHST7vlB23iK8TH+TnQdfOWnY8aOrjupIq/qqANsZJWFyvJpyjWg49XQ kjRXOzZoQ77VNo+thJ82UMaXMQWyNFyk79VVagp2IFPTRJrbjNr8CBts1AxVPG8M bjO7GLbM23jEwBjN3BWsei4NC56uzvQrCWHyScODnQymG6o+zFz4Vj3N2qCbSW81 wItzocagCMHv3/TV7LNM6a5j/ru4N0O9LvD+qMa63R76kXfYgkWIAudRwfUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1709629505; x=1709715905; bh=ekmA5RBZ+CvAhdFbvGw1i/0H90ih 8Imy4vkxYH5RFbI=; b=dK6WqAJWMa4c4fjlHpghFjdIt3LMY3xxMkWUuukHuwfJ Fn5R3/jVLrvPK8HPH0xCLR/+EQRpUAFUnWeAiAO+ZCuiq7mxhTwCGwC3vudSRYpt MeEvo6I1Ro59HzaAWLL9L8NGtrxfmpvxyurfxdpMhbcqggJi2damWFe0e3ex8i8z Eqv+wuJnxl0fXLh/9OXryAC1UYrzcyYWGCIn8Zkc5jwx6wVXoHqm9AT52SlDjrOs 0f100LdiAiVQXqNw0pVjgHTryUqiRWP7/Beoq04XH3IJ2YH6FjRUMC91NnB331QM 8LzFD0JzIrOBD8QThpScqDeqGHRDE8eYEs7KAfNUMg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheekgdduvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6329AB6008F; Tue, 5 Mar 2024 04:05:05 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-208-g3f1d79aedb-fm-20240301.002-g3f1d79ae Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <5e2f9342-4ee9-4b30-9dcf-393e57e0f7c6@app.fastmail.com> In-Reply-To: <20240305020153.2787423-6-almasrymina@google.com> References: <20240305020153.2787423-1-almasrymina@google.com> <20240305020153.2787423-6-almasrymina@google.com> Date: Tue, 05 Mar 2024 10:04:45 +0100 From: "Arnd Bergmann" To: "Mina Almasry" , Netdev , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Linux-Arch , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: "David S . Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Jonathan Corbet" , "Richard Henderson" , "Ivan Kokshaysky" , "Matt Turner" , "Thomas Bogendoerfer" , "James E . J . Bottomley" , "Helge Deller" , "Andreas Larsson" , "Jesper Dangaard Brouer" , "Ilias Apalodimas" , "Steven Rostedt" , "Masami Hiramatsu" , "Mathieu Desnoyers" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Song Liu" , "Yonghong Song" , "John Fastabend" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "David Ahern" , "Willem de Bruijn" , shuah , "Sumit Semwal" , =?UTF-8?Q?Christian_K=C3=B6nig?= , "Pavel Begunkov" , "David Wei" , "Jason Gunthorpe" , "Yunsheng Lin" , "Shailend Chand" , "Harshitha Ramamurthy" , "Shakeel Butt" , "Jeroen de Borst" , "Praveen Kaligineedi" , "Willem de Bruijn" , "Kaiyuan Zhang" Subject: Re: [RFC PATCH net-next v6 05/15] netdev: support binding dma-buf to netdevice Content-Type: text/plain On Tue, Mar 5, 2024, at 03:01, Mina Almasry wrote: > +int netdev_bind_dmabuf(struct net_device *dev, unsigned int dmabuf_fd, > + struct netdev_dmabuf_binding **out) > +{ > + struct netdev_dmabuf_binding *binding; > + static u32 id_alloc_next; > + struct scatterlist *sg; > + struct dma_buf *dmabuf; > + unsigned int sg_idx, i; > + unsigned long virtual; > + int err; > + > + if (!capable(CAP_NET_ADMIN)) > + return -EPERM; > + > + dmabuf = dma_buf_get(dmabuf_fd); > + if (IS_ERR_OR_NULL(dmabuf)) > + return -EBADFD; You should never need to use IS_ERR_OR_NULL() for a properly defined kernel interface. This one should always return an error or a valid pointer, so don't check for NULL. > + binding->attachment = dma_buf_attach(binding->dmabuf, dev->dev.parent); > + if (IS_ERR(binding->attachment)) { > + err = PTR_ERR(binding->attachment); > + goto err_free_id; > + } > + > + binding->sgt = > + dma_buf_map_attachment(binding->attachment, DMA_BIDIRECTIONAL); > + if (IS_ERR(binding->sgt)) { > + err = PTR_ERR(binding->sgt); > + goto err_detach; > + } Should there be a check to verify that this buffer is suitable for network data? In general, dmabuf allows buffers that are uncached or reside in MMIO space of another device, but I think this would break when you get an skb with those buffers and try to parse the data inside of the kernel on architectures where MMIO space is not a normal pointer or unaligned access is disallowed on uncached data. Arnd