Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3008959ybd; Fri, 28 Jun 2019 01:04:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCRaEq/3udBKTWVvUgmAq3BJYRytzOxJhpqhmmCKfvhz9leae7JYTDB9yJiYQ6/LrU0lNJ X-Received: by 2002:a63:78c3:: with SMTP id t186mr8037954pgc.340.1561709091478; Fri, 28 Jun 2019 01:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561709091; cv=none; d=google.com; s=arc-20160816; b=eaZRBFI+Q97r79iEsgoAnRkOpsJHmEfrl+Etgu4pw5sOx827rz9UxkWBBsPY02qClM Y7x08gBjipEOIa3LWEF2gH+q7FqJGdXszroRdh1DKywP98q9NaZqAbqica3wrqcYpiFG CJBxBWrcsaOacVx5RTRX5r0PzzRjq9FWFfrBiWKuf9pJmbtoh2yeIbgdpM+VZdEgfrI1 dC8Nl6tPkVxEuNwpIrUDoUEuhn6rtVJXZ3U7IH0S1XicXLVv0LbL1WzcQOZUs1iyFYf5 T9sp9x7q/on7ivMLb44quZYi+Bhp5NIIvKGfdYBoE3JaCFUtjJJyIb39/qcFmyYVa/yX cvBw== 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=/DCcaQL4KIaru6eSY0qTOKmLgKNdZSlhfLXy28ktkDo=; b=n0P8jkdW/xnspnIpikh5p/90w9qSQw79IZLVBufkmIaV+wtMAXbGUCIKp2K/Emghp+ g3GTAk6wccdrUFlM7viecZAthvCUoO9CUdrF9g6W+U+aIjUpbEgyY8TdXgX4c5zEpkMs lZWKvAQWvmuGxw0Xpq9zE1R4c1yIFFJxgOgN4lXEVeF85yFQHKAMe4wS8wT7xKx/HiTs XDHvPOpBn6LExzbYUAmBLDdM/fXKS0tqLJVNDp/CQdVsRQ+dHzLf2zQiOLhu2yDvNykM 3HLBl8SzMehXdh+j7KjwMwpmOpNQ87kNVEqfDMmX5DAKJmmaAb4Z6+mGiIu6BF95GM0V jx0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ZmkvJjBi; 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 79si1426763pga.276.2019.06.28.01.04.34; Fri, 28 Jun 2019 01:04:51 -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=ZmkvJjBi; 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 S1726690AbfF1IEW (ORCPT + 99 others); Fri, 28 Jun 2019 04:04:22 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:52803 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbfF1IEV (ORCPT ); Fri, 28 Jun 2019 04:04:21 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190628080419euoutp0131bcb22e761c8a4d95b51cb1d1fd7906~sTh2eF33v1756317563euoutp01b for ; Fri, 28 Jun 2019 08:04:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190628080419euoutp0131bcb22e761c8a4d95b51cb1d1fd7906~sTh2eF33v1756317563euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1561709059; bh=/DCcaQL4KIaru6eSY0qTOKmLgKNdZSlhfLXy28ktkDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZmkvJjBijRsco2QTreUM7nLg3G3/ceygOxXHwClmarYqwrI2XLnliUE7rfFN8vOea Bsn1cnRJ0a9rtw+WAmFnsdcQrdB5QtcNfDoVjUyRCHaJCHWKxpgI5vcq4y4fzPQwbY 3ibh4P2lfTH+3bu2VW7cENvolE5JLUm+tVwL0KeA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190628080418eucas1p2f39d2a67f27d91a536f94fc2d9d378fa~sTh1lBOi81539015390eucas1p2G; Fri, 28 Jun 2019 08:04:18 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 5F.63.04377.20AC51D5; Fri, 28 Jun 2019 09:04:18 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190628080418eucas1p1fa312ee412b805346dce631e81f7c093~sTh0zQtFM1751917519eucas1p14; Fri, 28 Jun 2019 08:04:18 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190628080417eusmtrp1e55a76b06e7fe4c6d934a2b791f410f4~sTh0lEaZL2335823358eusmtrp17; Fri, 28 Jun 2019 08:04:17 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-92-5d15ca02bf44 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 9A.10.04140.10AC51D5; Fri, 28 Jun 2019 09:04:17 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190628080416eusmtip192d14bf957130d1f1b7f63f0f65783dd~sThzrPJBv2336323363eusmtip1S; Fri, 28 Jun 2019 08:04:16 +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 v6 1/2] xdp: hold device for umem regardless of zero-copy mode Date: Fri, 28 Jun 2019 11:04:06 +0300 Message-Id: <20190628080407.30354-2-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190628080407.30354-1-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsWy7djP87pMp0RjDZbu0bL407aB0eLzkeNs FosXfmO2mHO+hcXiSvtPdotjL1rYLHatm8lscXnXHDaLFYdOAMUWiFls79/H6MDtsWXlTSaP nbPusnss3vOSyaPrxiVmj+ndD5k9+rasYvT4vEkugD2KyyYlNSezLLVI3y6BK6Nt2jX2gitc Ff8m9LE3MF7h6GLk5JAQMJE40/6KqYuRi0NIYAWjxIeO7VDOF0aJVfv2MkM4nxkl1kw9xgzT suPucUaIxHJGienH1rBAOD8YJb5en8EGUsUmoCNxavURRhBbREBK4uOO7ewgRcwCM5kltjye wgKSEBYIkTj2cAlYEYuAqkTz/C52EJtXwFri2Lk17BDr5CVWbzgAtppTwEbi/fM2sNUSApPZ JTq234YqcpHofLCeBcIWlnh1fAtUXEbi9OQeqHi9xP2Wl1DNHUB3H/rHBJGwl9jy+hxQAwfQ eZoS63fpQ4QdJU5PBAUNB5DNJ3HjrSBImBnInLRtOjNEmFeio00IolpF4vfB5dAQkpK4+e4z 1AUeEttm/mWHBFA/o8TR/a9YJjDKz0JYtoCR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y9bb1wwWbuqUfJO9g/1lpE/Im/DbNmVX7Iun fy3ht/pXl+HhEaCUsvfPmd41J45IyJ/V6Pi3/g93RJO8ZEv8+aqPPV+ebjx0KvSDeN/qoE// 2ndqPxPwetOxdYHpkvifj37Nm9XJV3n6V6bkc7UfFUosxRmJhlrMRcWJAH7Q8QeNAgAA X-CMS-MailID: 20190628080418eucas1p1fa312ee412b805346dce631e81f7c093 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190628080418eucas1p1fa312ee412b805346dce631e81f7c093 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190628080418eucas1p1fa312ee412b805346dce631e81f7c093 References: <20190628080407.30354-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 Acked-by: Jonathan Lemon --- 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