From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by gmr-mx.google.com with ESMTPS id ne6si1126597pjb.1.2020.12.14.13.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Dec 2020 13:13:11 -0800 (PST) Message-ID: <0f8eda3bbed1100c1c1f7015dd5c172f8d735c94.camel@kernel.org> Subject: Re: [patch 22/30] net/mlx5: Replace irq_to_desc() abuse From: Saeed Mahameed Date: Mon, 14 Dec 2020 13:13:07 -0800 In-Reply-To: <20201210194044.769458162@linutronix.de> References: <20201210192536.118432146@linutronix.de> <20201210194044.769458162@linutronix.de> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit To: Thomas Gleixner , LKML Cc: Peter Zijlstra , Marc Zyngier , "James E.J. Bottomley" , Helge Deller , afzal mohammed , linux-parisc@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Mark Rutland , Catalin Marinas , Will Deacon , Christian Borntraeger , Heiko Carstens , linux-s390@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Pankaj Bharadiya , Chris Wilson , Wambui Karuga , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Tvrtko Ursulin , Linus Walleij , linux-gpio@vger.kernel.org, Lee Jones , Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com, Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas , Michal Simek , linux-pci@vger.kernel.org, Karthikeyan Mitran , Hou Zhiqiang , Tariq Toukan , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, Leon Romanovsky , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , xen-devel@lists.xenproject.org List-ID: On Thu, 2020-12-10 at 20:25 +0100, Thomas Gleixner wrote: > No driver has any business with the internals of an interrupt > descriptor. Storing a pointer to it just to use yet another helper at > the > actual usage site to retrieve the affinity mask is creative at best. > Just > because C does not allow encapsulation does not mean that the kernel > has no > limits. > you can't blame the developers for using stuff from include/linux/ Not all developers are the same, and sometime we don't read in between the lines, you can't assume all driver developers to be expert on irq APIs disciplines. your rules must be programmatically expressed, for instance, you can just hide struct irq_desc and irq_to_desc() in kernel/irq/ and remove them from include/linux/ header files, if you want privacy in your subsystem, don't put all your header files on display under include/linux. > Retrieve a pointer to the affinity mask itself and use that. It's > still > using an interface which is usually not for random drivers, but > definitely > less hideous than the previous hack. > > Signed-off-by: Thomas Gleixner > --- > drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- > drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- > drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 6 +----- > 3 files changed, 3 insertions(+), 7 deletions(-) > > --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h > @@ -669,7 +669,7 @@ struct mlx5e_channel { > spinlock_t async_icosq_lock; > > /* data path - accessed per napi poll */ > - struct irq_desc *irq_desc; > + const struct cpumask *aff_mask; > struct mlx5e_ch_stats *stats; > > /* control */ > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > @@ -1998,7 +1998,7 @@ static int mlx5e_open_channel(struct mlx > c->num_tc = params->num_tc; > c->xdp = !!params->xdp_prog; > c->stats = &priv->channel_stats[ix].ch; > - c->irq_desc = irq_to_desc(irq); > + c->aff_mask = irq_get_affinity_mask(irq); as long as the affinity mask pointer stays the same for the lifetime of the irq vector. Assuming that: Acked-by: Saeed Mahameed