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 3C991C433EF for ; Wed, 23 Feb 2022 15:46:53 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=R5nNfxOdenJWhcS0hJwUpFGn3fZ9oTtsJ/Y0uDgZEa0=; b=ygLtFxsw6jnqkZ TzxDAhATbG+yuEIq2MsxkuxJbTJkKJ85dYZzIc57ziEmK8v1OHeMV9EW3jmr6HVHtJxTLEvK1Qp3A gBBPrkLLKMurqJcLBDJFXSmQm5KFBHRM8SrPyORpsCaNgXUijny8Eqd2VDgKMMVkxozCUwHTsknZX a85hm7SxzFOiGg795YJaJmlg3/nVoocQgGfdTN3KjtkHdxmvGeD74HL702ulb/wx6qO467aOao6hl m1TYrUjlkZO7dH7yMCxE+Ykb9hA54/Vtgg70RfBzxPG4/p1EKwuMqZrPpIwFAAJGMQwhL7DjEiVF7 Aonakxpd1yrwfrMORSxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMtpT-00F7FS-OY; Wed, 23 Feb 2022 15:45:23 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMtoY-00F6oA-9y for linux-arm-kernel@lists.infradead.org; Wed, 23 Feb 2022 15:44:28 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B9B85B82086; Wed, 23 Feb 2022 15:44:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 739EFC340E7; Wed, 23 Feb 2022 15:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645631063; bh=PVgeRt4LHCp9CTieLVRpqy0rj4cCYLX/Dq99wsHMmPU=; h=From:To:Cc:Subject:Date:From; b=tlZZm79gjjtiP8+zk3/zOOLSkEoC4f6peYZ6h0GfuWhfOU9WR19HvhIKFX9AfC36K V69iwNnjpt56KnRRNZDoip11T58CLJZvHM8b3sMkw+ixcWjTFw8A3+GCvAKL7lPBgu 8V0KTwVLhkxlsyOMim11/HsU34l7bhs55snoAApFW1Et1mr4Ae7Pd6TlnifbBCgmOu u7x7PQZM2kkUfABVRUTzGB75JZmPmoEBEvmLQeVH2HfI4M1Y1mlAAvJF09mCPig1sy YSvpspIxbb6gKOBC/iCKFFyKQIkIOMsrfquTLNGptMvk7mtTxXJVLvkAJ6GDuR9mw4 UixT8ABNV0afg== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nMtoT-009wgt-7P; Wed, 23 Feb 2022 15:44:21 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Thierry Reding , Joey Gouly , Jonathan Hunter , Hector Martin , Sven Peter , Alyssa Rosenzweig , Bjorn Andersson , Andy Gross , Thomas Gleixner , 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 Subject: [PATCH 0/5] gpiolib: Handle immutable irq_chip structures Date: Wed, 23 Feb 2022 15:44:00 +0000 Message-Id: <20220223154405.54912-1-maz@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linus.walleij@linaro.org, brgl@bgdev.pl, thierry.reding@gmail.com, joey.gouly@arm.com, jonathanh@nvidia.com, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, bjorn.andersson@linaro.org, agross@kernel.org, tglx@linutronix.de, 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-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220223_074426_717714_40B3695C X-CRM114-Status: GOOD ( 17.18 ) 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 I recently realised that the gpiolib play ugly tricks on the unsuspecting irq_chip structures by patching the callbacks. 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 there. 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. 3 drivers are updated to this new model: M1, QC and Tegra, as I actively use them (though Tegra is hosed at the moment), 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. Another approach was to let gpiolib provide its own irq_chip structure and stack it, but: - only a few drivers are hierarchy aware - the diversity of interrupt flows makes it impractical I'd welcome comments on the approach. If deemed acceptable, there are another 300+ drivers to update! Not to mention the documentation. I appreciate that this is a lot of potential changes, but the current situation is messy. Note that these patches are on top of irqchip-next, which contains more constifying work. M. Marc Zyngier (5): gpio: Don't fiddle with irqchips marked as immutable gpio: Expose the gpiochip_irq_re[ql]res helpers pinctrl: apple-gpio: Make the irqchip immutable pinctrl: msmgpio: Make the irqchip immutable gpio: tegra186: Make the irqchip immutable drivers/gpio/gpio-tegra186.c | 33 ++++++++++++----- drivers/gpio/gpiolib.c | 13 +++++-- drivers/pinctrl/pinctrl-apple-gpio.c | 30 +++++++++------- drivers/pinctrl/qcom/pinctrl-msm.c | 53 +++++++++++++++++----------- include/linux/gpio/driver.h | 4 +++ include/linux/irq.h | 2 ++ kernel/irq/debugfs.c | 1 + 7 files changed, 91 insertions(+), 45 deletions(-) -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel