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 3A98FCCF9F0 for ; Wed, 29 Oct 2025 16:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=AAflKtaWcrVF6Nhfrfoz1N7w/0F8UwSgA56H4g4glHQ=; b=3PSkdPKrsfiOLo928swmzPwXJv PjOsHMzg9IA26PptON7RiO3V7rSn9dpf3TQcw5GhVOb0scL06Cw+tjYbNunhjAwXF3IuaKuMXSgJE Bkhte65EQAZnKJgQZfUH4Ur+yShL8yeJZ2TuayevcxDtPi599sg1v6KroFkMjl1/Q2W9ChH7PQ0yk q1uXTWc2XMmB30vAAOWhRPcv4SgeZNOKZeDa1HADTl33P9a3F9p1ZtBlliX+gzr/iJqLHHyiFCD8N CP50B7aqQeohIFpIEagssOC/q+35T4IJAv0kPNpFaFF7F4P6otqSheIobsPoqptdiAk3oYt+TMIg0 1FriySeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vE97M-000000021Nk-0sbg; Wed, 29 Oct 2025 16:33:48 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vE97J-000000021Mb-1KP8 for linux-arm-kernel@lists.infradead.org; Wed, 29 Oct 2025 16:33:46 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-475c9881821so8319585e9.0 for ; Wed, 29 Oct 2025 09:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761755623; x=1762360423; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AAflKtaWcrVF6Nhfrfoz1N7w/0F8UwSgA56H4g4glHQ=; b=MGgh4PyutXwQANmmf+PJ/W6elWM+SdAORJbq07Lu8261cFb9QAWr2YfPXHuhTPdgxu KN/rNLOaKOiZU79nPVHZ+1aSoXFRoEPAC28IqjityhHNZig7Zqk1alw/4Gwm/SOOqP09 1ShM5qTEejh4zJag+jEhfIUf0K/qIQqzJSO7V+mrN1510wpFnIbuQARHPuEwMCXwwxcJ N0OTK9u8oL60qqAKEqqrhKstr2sXmOjTuq9k/IF8xFzRR+PZ3PakS7yHZ4WBh9ic11MQ 9PKQmCAhnvBimL1ST75y4G5HdBOvX5h6BpmHcD137lzxtBS+0FdmrDtR0RujEwhs1bDd VfHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761755623; x=1762360423; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AAflKtaWcrVF6Nhfrfoz1N7w/0F8UwSgA56H4g4glHQ=; b=XJPqz+kk6QivlgPkNqT0J8mh2Ne3Wbm8dUh6qiRbgpCuwMVUaZOexYWC+mRhq7zPE8 6D2Nqo66wHMlYXGf6NwetFLNFZQUGfBXnWg1vse9DwPB65pm+ZfODbgSJDFhDQU2xUu1 nT6NonCRhO8JiZyQV7wXx2cZ21UkuY4u3xLbK+bXL66Hyqci6UOcEg5saEwuIgVvrOpv mpj5FxItwq3NFHEzfW/PCZvsOtfnuhBqrc3iG5Dmd+ttY0fQ+Cnkz6vmLqRb5mWNVWwB rjmMu5BDDYbykXZ53g50fO1psCGIBuWVuzSZBQrLxMlepfel87Fe3VWESol8ky/shAsl JTbg== X-Forwarded-Encrypted: i=1; AJvYcCWBRWhyPdYs68/p/oqqyuARzyaZV4cbs9qvFQX25qDfVssMukMGkGXWw7UYEa4bbPVG3iJYqZXYyKZr/NAvltGQ@lists.infradead.org X-Gm-Message-State: AOJu0Yy7iebyYkxlHgIiwMvmxQYChz2IQI4NKIU7VYuVr9oeC3WvoZsi nnCZtDyZkLxTDwoff2XW2d0ctG0K3flVTMVQ14l0i5KlZTTjAnb/tSrE X-Gm-Gg: ASbGncuZ+n/TOXxoVGxyn8kkZg3hsGKlKI2yNN1azfpuuhHVofiMYGU9Yjl9g1CLl/w LctcB8g6/6cpSFugQHY10aY8UgBGsGLD4K16BvEVdPepSSDAUMIkRngOxCugv++9W37koikCEn1 4+uVcjHnYc4S+fny1KNYPd7hUNTLTI9hTzfOZ0dFiIu/D1vNzvrxXhEkbkFwc2JLkDjboWlPiC5 a/PT7qDVOWWTUKHxy6cZWiFs/W7afF7HMcVYyGJFO9OOPeXr0BUFpy/sLw5UoEKYox15CodrS5L ZyVaKdgSB6Ym6NChAzeuljPRUuAxunWRq5SvSnCYgEQ+xAsHGqqT5aLxbuU7dv1m0idkl6i/qUv LLkR/yEoQu6jU2waLNPM98Ovqnd6DYKcNoJefHcPGmROlX6/4K/w7p6uN/0e5WsyP4963U3pE72 PNrW5O2pBNEEKo/oPsezUuSUhNyNk5j1AiHyGqRX/dxpVYcEBRlm7+51Jf9+V0GErEABnT X-Google-Smtp-Source: AGHT+IHTmDPmMpNCDFFQsAevLNP6qOs7nF+wicDIMZb/6KQd4rRWs7Qottj+hraNqh61j+yol+JE4g== X-Received: by 2002:a05:6000:430c:b0:425:86da:325f with SMTP id ffacd0b85a97d-429b4c5303emr258811f8f.27.1761755622916; Wed, 29 Oct 2025 09:33:42 -0700 (PDT) Received: from localhost (p200300e41f274600f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f27:4600:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-429952da12dsm27463002f8f.29.2025.10.29.09.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 09:33:41 -0700 (PDT) From: Thierry Reding To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mips@vger.kernel.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/7] syscore: Pass context data to callbacks Date: Wed, 29 Oct 2025 17:33:29 +0100 Message-ID: <20251029163336.2785270-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251029_093345_407057_6F105010 X-CRM114-Status: GOOD ( 21.51 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding Hi Greg, Rafael, sorry, this took a while to rework because I had to find a large enough block of free time to push through. I played around a bit with different ideas based on our discussion and ended up with a mix between Rafael's and my proposal. struct syscore_ops is now split out and can be made const. struct syscore is introduced to contain the variable data such as the list head and the driver data. It also has a pointer to the ops structure. Registration APIs are changed accordingly. I initially wanted to avoid this churn, but then realized I was already touching all of the files anyway, so might as well make it all consistent. As a result the series is about twice as large in terms of LOC, but that's mostly due to the structure split. For anyone who hasn't seen this yet, here's the full cover letter: Hi, Something that's been bugging me over the years is how some drivers have had to adopt file-scoped variables to pass data into something like the syscore operations. This is often harmless, but usually leads to drivers not being able to deal with multiple instances, or additional frameworks or data structures needing to be created to handle multiple instances. This series proposes to "objectify" struct syscore_ops by passing driver specific data to the syscore callbacks. The contextual data is stored in a new struct syscore before registering the structure with the framework and the structure can be embedded in driver-specific data to make it per instance. Patch 1 contains the bulk of these changes. It's fairly intrusive because it does the conversion of the function signature all in one patch. An alternative would've been to introduce new callbacks such that these changes could be staged in. However, the amount of changes here are not quite numerous enough to justify that, in my opinion, and syscore isn't very frequently used, so the risk of another user getting added while this is merged is rather small. All in all I think merging this in one go is the simplest way. Patches 2-7 are conversions of some existing drivers to take advantage of this new parameter and tie the code to per-instance data. Given that the recipient list for this is huge, I'm limiting this to Greg (because it's at the core a... core change) and a set of larger lists for architectures and subsystems that are impacted. Changes in v3: - add separate syscore structure containing the modifiable fields, including driver-specific data, as well as a pointer to the constified syscore_ops structure - change registration/unregistration API to make these changes more obvious Changes in v2: - kerneldoc fixes Thanks, Thierry Thierry Reding (7): syscore: Pass context data to callbacks MIPS: PCI: Use contextual data instead of global variable bus: mvebu-mbus: Use contextual data instead of global variable clk: ingenic: tcu: Use contextual data instead of global variable clk: mvebu: Use contextual data instead of global variable irqchip/irq-imx-gpcv2: Use contextual data instead of global variable soc/tegra: pmc: Use contextual data instead of global variable arch/arm/mach-exynos/mcpm-exynos.c | 12 ++-- arch/arm/mach-exynos/suspend.c | 48 +++++++------ arch/arm/mach-pxa/generic.h | 6 +- arch/arm/mach-pxa/irq.c | 10 ++- arch/arm/mach-pxa/mfp-pxa2xx.c | 10 ++- arch/arm/mach-pxa/mfp-pxa3xx.c | 10 ++- arch/arm/mach-pxa/pxa25x.c | 4 +- arch/arm/mach-pxa/pxa27x.c | 4 +- arch/arm/mach-pxa/pxa3xx.c | 4 +- arch/arm/mach-pxa/smemc.c | 12 ++-- arch/arm/mach-s3c/irq-pm-s3c64xx.c | 12 ++-- arch/arm/mach-s5pv210/pm.c | 10 ++- arch/arm/mach-versatile/integrator_ap.c | 12 ++-- arch/arm/mm/cache-b15-rac.c | 12 ++-- arch/loongarch/kernel/smp.c | 12 ++-- arch/mips/alchemy/common/dbdma.c | 12 ++-- arch/mips/alchemy/common/irq.c | 24 ++++--- arch/mips/alchemy/common/usb.c | 12 ++-- arch/mips/pci/pci-alchemy.c | 30 +++------ arch/powerpc/platforms/cell/spu_base.c | 10 ++- arch/powerpc/platforms/powermac/pic.c | 12 ++-- arch/powerpc/sysdev/fsl_lbc.c | 12 ++-- arch/powerpc/sysdev/fsl_pci.c | 12 ++-- arch/powerpc/sysdev/ipic.c | 12 ++-- arch/powerpc/sysdev/mpic.c | 14 ++-- arch/powerpc/sysdev/mpic_timer.c | 10 ++- arch/sh/mm/pmb.c | 10 ++- arch/x86/events/amd/ibs.c | 12 ++-- arch/x86/hyperv/hv_init.c | 12 ++-- arch/x86/kernel/amd_gart_64.c | 10 ++- arch/x86/kernel/apic/apic.c | 12 ++-- arch/x86/kernel/apic/io_apic.c | 17 +++-- arch/x86/kernel/cpu/aperfmperf.c | 20 +++--- arch/x86/kernel/cpu/intel_epb.c | 16 +++-- arch/x86/kernel/cpu/mce/core.c | 14 ++-- arch/x86/kernel/cpu/microcode/core.c | 15 ++++- arch/x86/kernel/cpu/mtrr/legacy.c | 12 ++-- arch/x86/kernel/cpu/umwait.c | 10 ++- arch/x86/kernel/i8237.c | 10 ++- arch/x86/kernel/i8259.c | 14 ++-- arch/x86/kernel/kvm.c | 12 ++-- drivers/acpi/pci_link.c | 10 ++- drivers/acpi/sleep.c | 12 ++-- drivers/base/firmware_loader/main.c | 12 ++-- drivers/base/syscore.c | 82 ++++++++++++----------- drivers/bus/mvebu-mbus.c | 19 +++--- drivers/clk/at91/pmc.c | 12 ++-- drivers/clk/imx/clk-vf610.c | 12 ++-- drivers/clk/ingenic/jz4725b-cgu.c | 2 +- drivers/clk/ingenic/jz4740-cgu.c | 2 +- drivers/clk/ingenic/jz4755-cgu.c | 2 +- drivers/clk/ingenic/jz4760-cgu.c | 2 +- drivers/clk/ingenic/jz4770-cgu.c | 2 +- drivers/clk/ingenic/jz4780-cgu.c | 2 +- drivers/clk/ingenic/pm.c | 14 ++-- drivers/clk/ingenic/pm.h | 2 +- drivers/clk/ingenic/tcu.c | 59 ++++++++-------- drivers/clk/ingenic/x1000-cgu.c | 2 +- drivers/clk/ingenic/x1830-cgu.c | 2 +- drivers/clk/mvebu/common.c | 19 ++++-- drivers/clk/rockchip/clk-rk3288.c | 12 ++-- drivers/clk/samsung/clk-s5pv210-audss.c | 12 ++-- drivers/clk/samsung/clk.c | 12 ++-- drivers/clk/tegra/clk-tegra210.c | 12 ++-- drivers/clocksource/timer-armada-370-xp.c | 12 ++-- drivers/cpuidle/cpuidle-psci.c | 12 ++-- drivers/gpio/gpio-mxc.c | 12 ++-- drivers/gpio/gpio-pxa.c | 12 ++-- drivers/gpio/gpio-sa1100.c | 12 ++-- drivers/hv/vmbus_drv.c | 14 ++-- drivers/iommu/amd/init.c | 12 ++-- drivers/iommu/intel/iommu.c | 12 ++-- drivers/irqchip/exynos-combiner.c | 14 ++-- drivers/irqchip/irq-armada-370-xp.c | 12 ++-- drivers/irqchip/irq-bcm7038-l1.c | 12 ++-- drivers/irqchip/irq-gic-v3-its.c | 12 ++-- drivers/irqchip/irq-i8259.c | 12 ++-- drivers/irqchip/irq-imx-gpcv2.c | 30 +++------ drivers/irqchip/irq-loongson-eiointc.c | 12 ++-- drivers/irqchip/irq-loongson-htpic.c | 10 ++- drivers/irqchip/irq-loongson-htvec.c | 12 ++-- drivers/irqchip/irq-loongson-pch-lpc.c | 12 ++-- drivers/irqchip/irq-loongson-pch-pic.c | 12 ++-- drivers/irqchip/irq-mchp-eic.c | 12 ++-- drivers/irqchip/irq-mst-intc.c | 12 ++-- drivers/irqchip/irq-mtk-cirq.c | 12 ++-- drivers/irqchip/irq-renesas-rzg2l.c | 12 ++-- drivers/irqchip/irq-sa11x0.c | 12 ++-- drivers/irqchip/irq-sifive-plic.c | 12 ++-- drivers/irqchip/irq-sun6i-r.c | 18 +++-- drivers/irqchip/irq-tegra.c | 12 ++-- drivers/irqchip/irq-vic.c | 12 ++-- drivers/leds/trigger/ledtrig-cpu.c | 14 ++-- drivers/macintosh/via-pmu.c | 12 ++-- drivers/power/reset/sc27xx-poweroff.c | 10 ++- drivers/sh/clk/core.c | 10 ++- drivers/sh/intc/core.c | 12 ++-- drivers/soc/bcm/brcmstb/biuctrl.c | 12 ++-- drivers/soc/tegra/pmc.c | 21 ++++-- drivers/thermal/intel/intel_hfi.c | 12 ++-- drivers/xen/xen-acpi-processor.c | 12 ++-- include/linux/syscore_ops.h | 15 +++-- kernel/cpu_pm.c | 12 ++-- kernel/irq/generic-chip.c | 14 ++-- kernel/irq/pm.c | 11 ++- kernel/printk/printk.c | 11 ++- kernel/time/sched_clock.c | 22 ++++-- kernel/time/timekeeping.c | 22 ++++-- virt/kvm/kvm_main.c | 18 +++-- 109 files changed, 930 insertions(+), 523 deletions(-) -- 2.51.0