Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1104816ybd; Wed, 26 Jun 2019 11:15:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWYvZMpw0Ua5rS0FyX/9pZxUyrxfCNHpTnsV00VbwsepMjHQwbNRgm1dr9eKS/KK9j6lke X-Received: by 2002:a17:902:8546:: with SMTP id d6mr6808189plo.207.1561572955638; Wed, 26 Jun 2019 11:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561572955; cv=none; d=google.com; s=arc-20160816; b=FTIw03SAi7Og6I0H2FS/wuA23qI19cSK4IGPKdv0EfjYNN1Vr6J8wpupCMJ7WKEtmS vbJVeffggFYqFJ3hy5kTBaMMU/Qtu7uO/LHbhxpo0DcU00XW8U1JoFbDKyn1j0BMbslv cLaQOQxLQz6POzxLJ/Sjk8Q/TOT4T5mt9KQo0YAj1y6laHDQSSGLAHqHf0ROJHDm2wk8 X04dEKKotQms8u11mR30+HL1zbE1o4AaRss723MYFYc6pPxT1XysIN2AawKLfjZ6Za7J 3Sc9M/0QspoxW8YuPycy9YiPG9akgTrx/5OxKuPReWQC8hkyFgR7Ftd/iUqZaa5I9ZI9 mXrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=7U/wcOkARKzInXge0mokxOUM4Y+LffGC7GDc3WY2UjQ=; b=AgwVeUAhFYfeVYNeCQH/Sm85EcLpDy3pKozZmOVeg0UcAMNGFm/zkr88ZTzeIko4QM /FNXMn1nRGufMMdy1ogDuDVEkA2YLu/raAmu4ej99siDmdjrhbaJDDbDVkiOj41rWj9U tmGLANrbVzl+2TNsa+ox5JOg9rNDmW1zQtprZ7hz8PiKHMQ3t4aADr9XtzMDGp92uUrM MA6rULaQ/UaYpBDS46YEaVuS5aL06XceL0V/+V1HvfFV416hmSvhhyh8sCwL4u+j8t5i ltzWfIDmLMpZA87BQ9FhxeUw3+iDgJv/03pb8U+aIfCI24miWMm/dmLg2c/sIL4IG0+Z mruA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rvDwRHPZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191si16916920pgc.73.2019.06.26.11.15.39; Wed, 26 Jun 2019 11:15:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rvDwRHPZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfFZSPa (ORCPT + 99 others); Wed, 26 Jun 2019 14:15:30 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40488 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726470AbfFZSP3 (ORCPT ); Wed, 26 Jun 2019 14:15:29 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190626181527euoutp024a48c670b8b0a7472981c2b5ec9c8695~r0k3n4FIy0824508245euoutp02G for ; Wed, 26 Jun 2019 18:15:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190626181527euoutp024a48c670b8b0a7472981c2b5ec9c8695~r0k3n4FIy0824508245euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1561572927; bh=7U/wcOkARKzInXge0mokxOUM4Y+LffGC7GDc3WY2UjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rvDwRHPZ+JTYFC41E/8TXn2Q/xzQcFkiJocIkC2mS7OR1RRoJaywVP+U8j1+pca4T RZend4y0MccEbr02x9UKD4Gyf+GdlwUmqaShLwjWiLtkd45r/lFoW/nSV7Z8bTscnu FUSiV7PVIJculNQe6hT93PER8HHoUc9OlXImcKnQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190626181526eucas1p1e846f4feb146d197b3d26a8762330588~r0k2K9Gy41404414044eucas1p1p; Wed, 26 Jun 2019 18:15:26 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 04.DF.04377.E36B31D5; Wed, 26 Jun 2019 19:15:26 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190626181525eucas1p2d0f467c8ba7504b7dcc639712575032e~r0k1QCoBt0246102461eucas1p2W; Wed, 26 Jun 2019 18:15:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190626181525eusmtrp1831b5309fe2fd1958b332093af990f7f~r0k1B-L120317303173eusmtrp1n; Wed, 26 Jun 2019 18:15:25 +0000 (GMT) X-AuditID: cbfec7f4-12dff70000001119-ca-5d13b63e80ed Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D8.2B.04146.C36B31D5; Wed, 26 Jun 2019 19:15:24 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190626181524eusmtip2c0b67caaa1dc4603efb08bff71dd6b69~r0k0FKqZe0894308943eusmtip2E; Wed, 26 Jun 2019 18:15:24 +0000 (GMT) From: Ilya Maximets To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org, "David S. Miller" , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Jonathan Lemon , Jakub Kicinski , Daniel Borkmann , Ilya Maximets Subject: [PATCH bpf v4 1/2] xdp: hold device for umem regardless of zero-copy mode Date: Wed, 26 Jun 2019 21:15:14 +0300 Message-Id: <20190626181515.1640-2-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626181515.1640-1-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsWy7djPc7p224RjDbb9ZbL407aB0eLzkeNs FosXfmO2mHO+hcXiSvtPdotjL1rYLHatm8lscXnXHDaLFYdOAMUWiFls79/H6MDtsWXlTSaP nbPusnss3vOSyaPrxiVmj+ndD5k9+rasYvT4vEkugD2KyyYlNSezLLVI3y6BK2PFktmMBfO5 KrbOW8rYwLiEo4uRk0NCwERi7odDLF2MXBxCAisYJbo+XWSEcL4wSuzav5YNwvnMKPGv6S8T TMuG/XuhqpYzSlyc85QJwvnBKPHk21wWkCo2AR2JU6uPMILYIgJSEh93bGcHKWIWmMksseXx FLAiYYEQiZ0f1oKNZRFQlbh9YAE7iM0rYCVxY88eZoh18hKrNxwAszkFrCVOTPgEtlpCYDq7 RM/rg1BFLhI317azQ9jCEq+Ob4GyZSROT+5hgbDrJe63vIRq7mCUmH7oH9RD9hJbXp8DauAA Ok9TYv0ufYiwo8TU7xPBwhICfBI33gqChJmBzEnbpjNDhHklOtqEIKpVJH4fXA51jZTEzXef oS7wkGh5/JgVEkB9jBI/v9xjn8AoPwth2QJGxlWM4qmlxbnpqcVG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HLitW Xrrcysp6MWK69P17+0zeu2rX+pVfFFj7WUTve2dNzqe4rB8V1ptClnpG7J44m0G84F+a6wb5 uaZfCkWyzxzauHV3r/7jPDG/Rdzcs68Yz1ySY2WSdXONEktxRqKhFnNRcSIAzIkrAosCAAA= X-CMS-MailID: 20190626181525eucas1p2d0f467c8ba7504b7dcc639712575032e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190626181525eucas1p2d0f467c8ba7504b7dcc639712575032e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190626181525eucas1p2d0f467c8ba7504b7dcc639712575032e References: <20190626181515.1640-1-i.maximets@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Device pointer stored in umem regardless of zero-copy mode, so we heed to hold the device in all cases. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets --- net/xdp/xdp_umem.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 9c6de4f114f8..267b82a4cbcf 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -105,6 +105,9 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev, umem->dev = dev; umem->queue_id = queue_id; + + dev_hold(dev); + if (force_copy) /* For copy-mode, we are done. */ goto out_rtnl_unlock; @@ -124,7 +127,6 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev, goto err_unreg_umem; rtnl_unlock(); - dev_hold(dev); umem->zc = true; return 0; @@ -163,10 +165,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem) xdp_clear_umem_at_qid(umem->dev, umem->queue_id); rtnl_unlock(); - if (umem->zc) { - dev_put(umem->dev); - umem->zc = false; - } + dev_put(umem->dev); + umem->dev = NULL; + umem->zc = false; } static void xdp_umem_unpin_pages(struct xdp_umem *umem) -- 2.17.1