Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp186236lqt; Mon, 18 Mar 2024 05:23:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTPexELt451plxchUXpnlSOxr2sWMeGJvZJYlI7IudEgk3fg2N4JmIRXlfwL1PXRVtKIdMgG059H3QbMtnYfTUb5hlKUL+rn//gFHpOA== X-Google-Smtp-Source: AGHT+IHM4Z4u4Y5bkAKaB+1u0x9P7+owlKodWt08BwLJIEOtxBuTSZY8JuIx0DQFjpFPowuEczjm X-Received: by 2002:a05:6808:17a4:b0:3c3:70e8:3ecb with SMTP id bg36-20020a05680817a400b003c370e83ecbmr14437894oib.38.1710764590348; Mon, 18 Mar 2024 05:23:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710764590; cv=pass; d=google.com; s=arc-20160816; b=EUyo7XOPt+hBd3n2GzkgrPxSlScVJLv8fLNUfNxj5WrIScV1vadmIcUHYdOlSWtZ2P NPzfGbqGYTcmOXdSHb8iI5U9gbHb4k8VanBsCyzEXF/ux8Zn1Mx/pCJaP74I/933r1+p ntUn2IPvNJPehZxCEhGDMVjfm0Vl7zay3hHyh7cUK1MxMgKMxVea/m3wEzmX0+80Kz9Y h9zPP6tVO4Abpn7AaA7x9littrGCPIsxhyeIS3PCq50pDRhE/3zkGJqsNgleMJundgcA nfU+mMUgYPfv7rFMMk4BhxQ5lvKYtYuiTNVfhbp1iYQfORBYeQSFAssXXccMr4H83zw+ qoxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WhV9tE00Vd2T5kLJOaHKWaX6XlU5QaksBTiUxYCAiSA=; fh=rLi9L62qXbHn+gFN8fhGmrVjaoTFi4Q8/3WYGV8IRac=; b=BbiGAYnbRF+1gZrjXaG4ZG+j38z7Br537P795Tr5Szu2rlcJvSaULj4zUluO8+CkWL ++m95RUqyQQIjPgMZeLfT6EKSmuK3MzOde74AFbzUlD5H5P+J0cUbyoM+/H2Ms3JOKeH xCletfSvvgcFBkO5Uxud7T9hHrijnWpbeKjh/+9pbvxCjQDxOcRwPkXkpGZf+PRWcGWm BsjVG4dnn38LFLcAbAVzRku2Y/RpOZlnHw4vMoSozdZzhYrIiuOMALwP1om/H5c3j13d 4uI1CI4onenyRYAeJqRxo4fJ5FKJ3Nk0X4mFb6ndUv0yIKmMb3gM/CVGjzuH/7gt39a8 bbJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RLD8w+AY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-106105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j25-20020a634a59000000b005dc0e9aefeasi7855754pgl.809.2024.03.18.05.23.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 05:23:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RLD8w+AY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-106105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 70A47B21AAA for ; Mon, 18 Mar 2024 12:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90D17381C1; Mon, 18 Mar 2024 12:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RLD8w+AY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B733438385; Mon, 18 Mar 2024 12:20:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710764420; cv=none; b=p2sGUj2XUHrhc+ydSuLEFzxxyUk06rXo93px9eYRqzzCk43uCbXK+QOsnYwKV5UK9HdXhTnDAn0cPlvooLAQifAc1fkglHtB4eesxcJ+qJlemqCGO36ZXJeiOMIIPnmlXd9GPOaIk+sqXGVBbWqYFWkPtAlpSDY0xfuXYpKfZtk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710764420; c=relaxed/simple; bh=dTwJg1UGqWh+77kQ3HiGt4CvIU6WqC055dKN/Mu7uKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YOVO9Rg+Bc08iYNhbv9NzyVXbfmggt85uZ0gJ6D2aiiwO+mzM9sBUZmaSDEAbzk2Dcz9mSL1larV4D3Vb7s7I9JLdk3kih4Lma+bbfKPTDvV5xidkuehS8bVx9WS5Ps35h5HV73lgh9hI15paCH7AV89EDJeeogJUjjemhzt49o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RLD8w+AY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7059C433F1; Mon, 18 Mar 2024 12:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710764420; bh=dTwJg1UGqWh+77kQ3HiGt4CvIU6WqC055dKN/Mu7uKg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RLD8w+AY7j9y1TNGzT3oF5CpiUu5Z81E/VX1E2uVP5cOqDq/m8h8jFSLNYZ+kVAmN 0JSIPM7B5dpGr/KKMUlrLJdfOQjrI6ZRJYae3hCPoYuvLBrT+cFGa32ysvGFjKPiKt ds0550JFsGq5VEGor5Pe387SEIx2etrxdG3MG08KJvJuTpwfBMHsTYWy3oZPfG0kMr 5tgQxKxmehF6G0eNNRM1smTm3ZhdV1hq4vEp0SMUFPT6WUNfsaa5asNHJm2oeq9QxJ cARHMo1aJhabfSx6uhDhBzNNKRtCFzRDP6+oVBHiKnH0MeHQQbLfB5BSkNiaLYC7lL wD9Y9nG0pXDPQ== Date: Mon, 18 Mar 2024 14:20:16 +0200 From: Leon Romanovsky To: Breno Leitao Cc: Dennis Dalessandro , Jason Gunthorpe , kuba@kernel.org, keescook@chromium.org, "open list:HFI1 DRIVER" , open list Subject: Re: [PATCH v3] IB/hfi1: allocate dummy net_device dynamically Message-ID: <20240318122016.GA4341@unreal> References: <20240318100858.3696961-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240318100858.3696961-1-leitao@debian.org> On Mon, Mar 18, 2024 at 03:08:57AM -0700, Breno Leitao wrote: > Embedding net_device into structures prohibits the usage of flexible > arrays in the net_device structure. For more details, see the discussion > at [1]. > > Un-embed the net_device from struct hfi1_netdev_rx by converting it > into a pointer. Then use the leverage alloc_netdev() to allocate the > net_device object at hfi1_alloc_rx(). > > [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ > > Signed-off-by: Breno Leitao > Acked-by: Dennis Dalessandro > > v2: > * Free struct hfi1_netdev_rx allocation if alloc_netdev() fails > * Pass zero as the private size for alloc_netdev(). > * Remove wrong reference for iwl in the comments > > v3: > * Re-worded the comment, by removing the first paragraph. Please put changelog below "---" marker. It doesn't belong to commit message. Thanks > --- > drivers/infiniband/hw/hfi1/netdev.h | 2 +- > drivers/infiniband/hw/hfi1/netdev_rx.c | 10 ++++++++-- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/infiniband/hw/hfi1/netdev.h b/drivers/infiniband/hw/hfi1/netdev.h > index 8aa074670a9c..07c8f77c9181 100644 > --- a/drivers/infiniband/hw/hfi1/netdev.h > +++ b/drivers/infiniband/hw/hfi1/netdev.h > @@ -49,7 +49,7 @@ struct hfi1_netdev_rxq { > * When 0 receive queues will be freed. > */ > struct hfi1_netdev_rx { > - struct net_device rx_napi; > + struct net_device *rx_napi; > struct hfi1_devdata *dd; > struct hfi1_netdev_rxq *rxq; > int num_rx_q; > diff --git a/drivers/infiniband/hw/hfi1/netdev_rx.c b/drivers/infiniband/hw/hfi1/netdev_rx.c > index 720d4c85c9c9..cd6e78e257ef 100644 > --- a/drivers/infiniband/hw/hfi1/netdev_rx.c > +++ b/drivers/infiniband/hw/hfi1/netdev_rx.c > @@ -188,7 +188,7 @@ static int hfi1_netdev_rxq_init(struct hfi1_netdev_rx *rx) > int i; > int rc; > struct hfi1_devdata *dd = rx->dd; > - struct net_device *dev = &rx->rx_napi; > + struct net_device *dev = rx->rx_napi; > > rx->num_rx_q = dd->num_netdev_contexts; > rx->rxq = kcalloc_node(rx->num_rx_q, sizeof(*rx->rxq), > @@ -360,7 +360,12 @@ int hfi1_alloc_rx(struct hfi1_devdata *dd) > if (!rx) > return -ENOMEM; > rx->dd = dd; > - init_dummy_netdev(&rx->rx_napi); > + rx->rx_napi = alloc_netdev(0, "dummy", NET_NAME_UNKNOWN, > + init_dummy_netdev); > + if (!rx->rx_napi) { > + kfree(rx); > + return -ENOMEM; > + } > > xa_init(&rx->dev_tbl); > atomic_set(&rx->enabled, 0); > @@ -374,6 +379,7 @@ void hfi1_free_rx(struct hfi1_devdata *dd) > { > if (dd->netdev_rx) { > dd_dev_info(dd, "hfi1 rx freed\n"); > + free_netdev(dd->netdev_rx->rx_napi); > kfree(dd->netdev_rx); > dd->netdev_rx = NULL; > } > -- > 2.43.0 >