From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABCACC4332F for ; Tue, 19 Apr 2022 21:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358104AbiDSV7P (ORCPT ); Tue, 19 Apr 2022 17:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353379AbiDSV7O (ORCPT ); Tue, 19 Apr 2022 17:59:14 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C52940A2B for ; Tue, 19 Apr 2022 14:56:29 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-2ec04a2ebadso187397307b3.12 for ; Tue, 19 Apr 2022 14:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o5U1cn6+o5nTDbwZR88CUNrm0hxDesFUSzgqVEiUi5k=; b=Rgs08pIBuoNzE/5T67y5y27kHtxOzCdiKXIXfbLP1qlmASEYTIEu/XjHcO/rDO14A6 GQofJtAwB0/xUZLDKRcnIEIXp2FsW1WwyL7vydwDc0dU8fbMhwh8hBmxz6STE937cn9Y q2wjhmuR4iVMC9hCbZvSiEDPnjzDEO/nDjs153YTLRSBVAhoAqw65EqVZfN28Kkxyobj khYzChEq1we63DZSaHCfxzxQG4wjqi+tM4F/RZDXbUcfs0nyU7WRkd+vyTJaweEv1IJT 35X+lqw214/+wupT0lHG8hOkDdMPQkm/VkaSnzhZ39CvUL0swNgKVlFkhcusk9FLuMlX IKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o5U1cn6+o5nTDbwZR88CUNrm0hxDesFUSzgqVEiUi5k=; b=uOT0nyS5jNq3DjftuKJ4nMu0J6HxO3uJXLIAnx6n14aqRm/FSuf5c9+/r8exWiuHz4 f0c+twJlFvsVKOldWtmPH0/k0qjtofFP5QEyjpMU2HUrlJEdMK65NVbHjloXIUX8RsAx HNRaXYjl8kyHmK8qR8+1noWT6I2E1RsuOEt/OaEAsjhwyO+5oNN8PDW06yTWvy3y8XYb 5pOB30GFU0db0tLNRzvBacOKh55s3H4g3qMFUQUlHg3XBSS+YaVIo+kBkTWTsEbVIcwJ umE6NaneNx+uxJeq4+EaNImU8+7rQw/ussqNWfs3wcn8/0Vg3ka4oRL7kpSvllh/P0lV NF+A== X-Gm-Message-State: AOAM532L9hh/oOGUZIvRIrxO9bQyiB4Ico9roFm0QPVFKrufi/yptxzT 8dxX2IJ9PhcY+liPxE03+UMA285y7ezJDf0mupab1w== X-Google-Smtp-Source: ABdhPJxFEHSE/pis5LX657I4YxyA6XvsGZ/n2P/4VzVlx4ahwA45KoXz1mcjGguqs6qs5VDzjUIJdwSIBd9PekozwM0= X-Received: by 2002:a81:b50d:0:b0:2e5:b653:7e97 with SMTP id t13-20020a81b50d000000b002e5b6537e97mr19299462ywh.140.1650405388892; Tue, 19 Apr 2022 14:56:28 -0700 (PDT) MIME-Version: 1.0 References: <20220405135444.199295-1-maz@kernel.org> In-Reply-To: <20220405135444.199295-1-maz@kernel.org> From: Linus Walleij Date: Tue, 19 Apr 2022 23:56:17 +0200 Message-ID: Subject: Re: [PATCH v2 00/10] gpiolib: Handle immutable irq_chip structures To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Thierry Reding , Joey Gouly , Jonathan Hunter , Hector Martin , Sven Peter , Alyssa Rosenzweig , Bjorn Andersson , Andy Gross , Jeffrey Hugo , Thomas Gleixner , Basavaraj Natikar , Shyam Sundar S K , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Tue, Apr 5, 2022 at 3:55 PM Marc Zyngier wrote: > Not only this breaks when an irq_chip structure is made const (which > really should be the default case), but it also forces this structure > to be copied at nauseam for each instance of the GPIO block, which is > a waste of memory. > > My current approach is to add a new irq_chip flag (IRQCHIP_IMMUTABLE) > which does what it says on the tin: don't you dare writing to them. > Gpiolib is further updated not to install its own callbacks, and it > becomes the responsibility of the driver to call into the gpiolib when > required. This is similar to what we do for other subsystems such as > PCI-MSI. > > 5 drivers are updated to this new model: M1, QC, Tegra, pl061 and AMD > (as I actively use them) keeping a single irq_chip structure, marking > it const, and exposing the new flag. > > Nothing breaks, the volume of change is small, the memory usage goes > down and we have fewer callbacks that can be used as attack vectors. > What's not to love? > > * From v1 [1]: > - pl061 and AMD drivers converted > - New helpers to keep the changes small > - New warning for non-converted drivers > - Documentation and TODO updates > > [1] https://lore.kernel.org/r/20220223154405.54912-1-maz@kernel.org > > Marc Zyngier (10): > gpio: Don't fiddle with irqchips marked as immutable > gpio: Expose the gpiochip_irq_re[ql]res helpers > gpio: Add helpers to ease the transition towards immutable irq_chip > gpio: tegra186: Make the irqchip immutable > gpio: pl061: Make the irqchip immutable > pinctrl: apple-gpio: Make the irqchip immutable > pinctrl: msmgpio: Make the irqchip immutable > pinctrl: amd: Make the irqchip immutable > gpio: Update TODO to mention immutable irq_chip structures > Documentation: Update the recommended pattern for GPIO irqchips Acked-by: Linus Walleij Yours, Linus Walleij From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A446C433EF for ; Tue, 19 Apr 2022 21:57:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h6y5Y+6O3TdmCD/aC7XWlIJi50EzXh2sNYaLCatKVpI=; b=pKzVmK16o0eGUO WdDXhlut/OhN/+6v8b6fuutWh2x/6fSDL7m1VeOYjwt8iDCeR//HRFsg39FsiOx/1GsZdYxwmOp27 K99dYz62qMji80xAybs6QHk0uQcJZnIny9Xk7t1QnMuK1X4i3VCJlZoDNHZLr1/+BD9rtsLgiBoQN l6FEErEkC17Dx5CC+IgDZ4Jn5CgTBaQMgOCVrq+lqY9IiW685trpld17wTXEvAarSYolZVItEJJEY 14m2TXo7Q42md5UmIP9Dx9dojAI4z+kvlIItKl3FFLF4G7BBCE1ziz0cjt4f/O+tNYOf3rZO9L02x QNGFo7ry5cQYPxYKGyQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngvpp-006SpN-SU; Tue, 19 Apr 2022 21:56:34 +0000 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngvpm-006Sns-IB for linux-arm-kernel@lists.infradead.org; Tue, 19 Apr 2022 21:56:32 +0000 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-2eba37104a2so188281957b3.0 for ; Tue, 19 Apr 2022 14:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o5U1cn6+o5nTDbwZR88CUNrm0hxDesFUSzgqVEiUi5k=; b=Rgs08pIBuoNzE/5T67y5y27kHtxOzCdiKXIXfbLP1qlmASEYTIEu/XjHcO/rDO14A6 GQofJtAwB0/xUZLDKRcnIEIXp2FsW1WwyL7vydwDc0dU8fbMhwh8hBmxz6STE937cn9Y q2wjhmuR4iVMC9hCbZvSiEDPnjzDEO/nDjs153YTLRSBVAhoAqw65EqVZfN28Kkxyobj khYzChEq1we63DZSaHCfxzxQG4wjqi+tM4F/RZDXbUcfs0nyU7WRkd+vyTJaweEv1IJT 35X+lqw214/+wupT0lHG8hOkDdMPQkm/VkaSnzhZ39CvUL0swNgKVlFkhcusk9FLuMlX IKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o5U1cn6+o5nTDbwZR88CUNrm0hxDesFUSzgqVEiUi5k=; b=ThCdFwIpZSjFdL4vhefHtHt8Uxl0U0cmLsJNESDNH+4DCIyuwNCEVMu0tNUHt8ny2u Juegigxcg9JdOBOI0RIF1HrTyOFq12GFR7WhTesWulOuaPXxhlZqhaF7aUlbkD4Yl3xh wB1oM/wujToq7ekOMGUZ43owm5P1wpOikGnEKzBqZlduQu+8mxAZjHIjHjdm21CHczxW sAGBbAnHWT3gLUbxyq88FNpfLG0NzuTy2w0ehz6BuB85RJFRfscRwVjdfV2EqSDxHmJs iAZr5+rTO5fM9Y2txdfSRP3bYa6fnZxWL2gFUBO7jOdvb25cKAX/nh9BR6hZxWOlJV32 v4hw== X-Gm-Message-State: AOAM5305jzluPp1EiVSEEwQpeCIzx9fA+8R+OgKuY/6NiY7mnwHJHjJV NILPvfbHVWPOGWmYFMj9eQ/FHbyk0za1lmZxU16U8g== X-Google-Smtp-Source: ABdhPJxFEHSE/pis5LX657I4YxyA6XvsGZ/n2P/4VzVlx4ahwA45KoXz1mcjGguqs6qs5VDzjUIJdwSIBd9PekozwM0= X-Received: by 2002:a81:b50d:0:b0:2e5:b653:7e97 with SMTP id t13-20020a81b50d000000b002e5b6537e97mr19299462ywh.140.1650405388892; Tue, 19 Apr 2022 14:56:28 -0700 (PDT) MIME-Version: 1.0 References: <20220405135444.199295-1-maz@kernel.org> In-Reply-To: <20220405135444.199295-1-maz@kernel.org> From: Linus Walleij Date: Tue, 19 Apr 2022 23:56:17 +0200 Message-ID: Subject: Re: [PATCH v2 00/10] gpiolib: Handle immutable irq_chip structures To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Thierry Reding , Joey Gouly , Jonathan Hunter , Hector Martin , Sven Peter , Alyssa Rosenzweig , Bjorn Andersson , Andy Gross , Jeffrey Hugo , Thomas Gleixner , Basavaraj Natikar , Shyam Sundar S K , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220419_145630_646977_85BA9E42 X-CRM114-Status: GOOD ( 22.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Apr 5, 2022 at 3:55 PM Marc Zyngier wrote: > Not only this breaks when an irq_chip structure is made const (which > really should be the default case), but it also forces this structure > to be copied at nauseam for each instance of the GPIO block, which is > a waste of memory. > > My current approach is to add a new irq_chip flag (IRQCHIP_IMMUTABLE) > which does what it says on the tin: don't you dare writing to them. > Gpiolib is further updated not to install its own callbacks, and it > becomes the responsibility of the driver to call into the gpiolib when > required. This is similar to what we do for other subsystems such as > PCI-MSI. > > 5 drivers are updated to this new model: M1, QC, Tegra, pl061 and AMD > (as I actively use them) keeping a single irq_chip structure, marking > it const, and exposing the new flag. > > Nothing breaks, the volume of change is small, the memory usage goes > down and we have fewer callbacks that can be used as attack vectors. > What's not to love? > > * From v1 [1]: > - pl061 and AMD drivers converted > - New helpers to keep the changes small > - New warning for non-converted drivers > - Documentation and TODO updates > > [1] https://lore.kernel.org/r/20220223154405.54912-1-maz@kernel.org > > Marc Zyngier (10): > gpio: Don't fiddle with irqchips marked as immutable > gpio: Expose the gpiochip_irq_re[ql]res helpers > gpio: Add helpers to ease the transition towards immutable irq_chip > gpio: tegra186: Make the irqchip immutable > gpio: pl061: Make the irqchip immutable > pinctrl: apple-gpio: Make the irqchip immutable > pinctrl: msmgpio: Make the irqchip immutable > pinctrl: amd: Make the irqchip immutable > gpio: Update TODO to mention immutable irq_chip structures > Documentation: Update the recommended pattern for GPIO irqchips Acked-by: Linus Walleij Yours, Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel