From nobody Thu Oct 30 01:04:16 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cxm8w4HZSz6DP3T; Thu, 30 Oct 2025 01:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cxm8w1qYSz3c68; Thu, 30 Oct 2025 01:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761786256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lQd/V8ksNNpMaq6bqFPjr8AtXWJAcCNmuO8mr/Pd6+M=; b=SkFY/Uwn3agP+2OuuPVISvtpOCNBj2PmvK4wyUAnQGTJKZw4s+KcOYa56+oFo19mMLlktW XrgkQWBoKt3fqf7PeLPpx3z6+0UElQFItoOcMp1uqvcuraR5PEmHighaAvzWLPiNk7sjlw eHhjln8lA/ZHdyt3uansmd3H2N6/1RQU4NwBCwcjm3Hj09q63ZKBrRhzV0KBb546woqE7h nyDyF+UuoMUlcl7+emtiIY5MGjsLkwxp9/elY0OmSiZCE2vWgtLnYBJ5E57YcqakW7qaJj BbD3XUuHRenOhEbTzAhGpdnn+ljvZmmXSTwYickF6iiI+5Qp0SUc7NZcE7RyHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761786256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lQd/V8ksNNpMaq6bqFPjr8AtXWJAcCNmuO8mr/Pd6+M=; b=JTFu7F4NXp0tgpO++KDeUX3c+rZjKgYz6dyodNicIWZfzap4Y6e+GvqdpxQZWsR+L4QCm3 RWU4dX6BNSEliFmICJLXt/Zj6T9l1ECEfxm4A01pZmIf2GE3r3pXIV59OFYsHaYrrRrXus a7URvIrl302/7L1zjKAx570ZPSD5uegvN+BUfAP/T9cN6nEZyRZQrG0z9lTMmbGAbzbeL2 kTxcQ4Rz2wSCun1rf2ZWCuW95nRGEGrpNQR2bCWVwOCEU9nt/n4sFS7QSMd6Cc+lG/GEsb XjqvnXUSTPPTIn7f5Fj+gN6+fxJaQqQO5ctKFO0jCeOLikelO3jQgqlwPZR6OQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761786256; a=rsa-sha256; cv=none; b=Q2MIt+raRtzj7cyns/s6UnMX0Vpn6KadhI7T5BOQ+oQKGc1aUAg5krmHP2s5MMmmC/BsiG AZTxXfzHEIW+wJYdTXl3nN05xDC6SD22sYBd2fuEXUp/20W4OcR4G9z9gC03fnoopENuJI RrKTLSohBIyE545wXi3lFImwh4qpFqGn0Bjmdx2uGmuE8QPQCW/aFdWjJ1n5jc1Da+ZeOV opTl7i4143TanA0WoU6/+wWaLSHYODyCyTI4y1NVmIO2IUr8Vj5gHjg79NXx9GfQGAbyWZ CT0cj7o7irjimAXv+OKPoNlFJt+KCYQhW8iMCdv+3XEB3L9ebQmTQnrEcqrngg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cxm8w1Crxz10hS; Thu, 30 Oct 2025 01:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59U14GId007210; Thu, 30 Oct 2025 01:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59U14G4f007207; Thu, 30 Oct 2025 01:04:16 GMT (envelope-from git) Date: Thu, 30 Oct 2025 01:04:16 GMT Message-Id: <202510300104.59U14G4f007207@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 8fb17896120d - main - intr/powerpc: create openpic_class kobj List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8fb17896120d8e7c499a13f4459f9894c20c6131 Auto-Submitted: auto-generated The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=8fb17896120d8e7c499a13f4459f9894c20c6131 commit 8fb17896120d8e7c499a13f4459f9894c20c6131 Author: Elliott Mitchell AuthorDate: 2025-01-02 19:03:40 +0000 Commit: Justin Hibbits CommitDate: 2025-10-30 01:02:15 +0000 intr/powerpc: create openpic_class kobj Using kobj allows implementing most PIC functions merely by inheriting from the parent class. As there are multiple OpenPIC implementations, this ensures all common hooks go through by default. Note, this adds the suspend/resume functions to other PICs. This should be harmless as suspend/resume isn't working on the devices anyway. Reviewed by: jhibbits MFC after: 2 weeks --- sys/powerpc/include/openpicvar.h | 9 +++------ sys/powerpc/ofw/openpic_ofw.c | 18 ++---------------- sys/powerpc/powermac/cpcht.c | 13 +++---------- sys/powerpc/powerpc/openpic.c | 33 +++++++++++++++++++++++++++------ sys/powerpc/psim/openpic_iobus.c | 17 +++-------------- 5 files changed, 38 insertions(+), 52 deletions(-) diff --git a/sys/powerpc/include/openpicvar.h b/sys/powerpc/include/openpicvar.h index 3a170a8a35fe..12f01cb80406 100644 --- a/sys/powerpc/include/openpicvar.h +++ b/sys/powerpc/include/openpicvar.h @@ -28,6 +28,8 @@ #ifndef _POWERPC_OPENPICVAR_H_ #define _POWERPC_OPENPICVAR_H_ +#include + #define OPENPIC_DEVSTR "OpenPIC Interrupt Controller" #define OPENPIC_IRQMAX 256 /* h/w allows more */ @@ -75,16 +77,11 @@ int openpic_common_attach(device_t, uint32_t); /* * PIC interface. */ -void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **); void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); -void openpic_dispatch(device_t, struct trapframe *); void openpic_enable(device_t, u_int, u_int, void **); void openpic_eoi(device_t, u_int, void *); -void openpic_ipi(device_t, u_int); -void openpic_mask(device_t, u_int, void *); void openpic_unmask(device_t, u_int, void *); -int openpic_suspend(device_t dev); -int openpic_resume(device_t dev); +DECLARE_CLASS(openpic_class); #endif /* _POWERPC_OPENPICVAR_H_ */ diff --git a/sys/powerpc/ofw/openpic_ofw.c b/sys/powerpc/ofw/openpic_ofw.c index fdab55fb30f5..4083e9eba749 100644 --- a/sys/powerpc/ofw/openpic_ofw.c +++ b/sys/powerpc/ofw/openpic_ofw.c @@ -68,29 +68,15 @@ static device_method_t openpic_ofw_methods[] = { /* Device interface */ DEVMETHOD(device_probe, openpic_ofw_probe), DEVMETHOD(device_attach, openpic_ofw_attach), - DEVMETHOD(device_suspend, openpic_suspend), - DEVMETHOD(device_resume, openpic_resume), /* PIC interface */ - DEVMETHOD(pic_bind, openpic_bind), - DEVMETHOD(pic_config, openpic_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), - DEVMETHOD(pic_enable, openpic_enable), - DEVMETHOD(pic_eoi, openpic_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), - DEVMETHOD(pic_unmask, openpic_unmask), - DEVMETHOD(pic_translate_code, openpic_ofw_translate_code), DEVMETHOD_END }; -static driver_t openpic_ofw_driver = { - "openpic", - openpic_ofw_methods, - sizeof(struct openpic_softc), -}; +DEFINE_CLASS_1(openpic, openpic_ofw_driver, openpic_ofw_methods, + sizeof(struct openpic_softc), openpic_class); EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, 0, 0, BUS_PASS_INTERRUPT); diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c index 5b5c03cf83f6..448144c9749e 100644 --- a/sys/powerpc/powermac/cpcht.c +++ b/sys/powerpc/powermac/cpcht.c @@ -520,16 +520,12 @@ static device_method_t openpic_cpcht_methods[] = { DEVMETHOD(device_attach, openpic_cpcht_attach), /* PIC interface */ - DEVMETHOD(pic_bind, openpic_bind), DEVMETHOD(pic_config, openpic_cpcht_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), DEVMETHOD(pic_enable, openpic_cpcht_enable), DEVMETHOD(pic_eoi, openpic_cpcht_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), DEVMETHOD(pic_unmask, openpic_cpcht_unmask), - { 0, 0 }, + DEVMETHOD_END }; struct openpic_cpcht_softc { @@ -538,11 +534,8 @@ struct openpic_cpcht_softc { struct mtx sc_ht_mtx; }; -static driver_t openpic_cpcht_driver = { - "htpic", - openpic_cpcht_methods, - sizeof(struct openpic_cpcht_softc), -}; +DEFINE_CLASS_1(htpic, openpic_cpcht_driver, openpic_cpcht_methods, + sizeof(struct openpic_cpcht_softc), openpic_class); EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, 0, 0, BUS_PASS_INTERRUPT); diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c index 0c717aaf6060..e2de52638d79 100644 --- a/sys/powerpc/powerpc/openpic.c +++ b/sys/powerpc/powerpc/openpic.c @@ -225,7 +225,7 @@ openpic_common_attach(device_t dev, uint32_t node) * PIC I/F methods */ -void +static void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused) { struct openpic_softc *sc; @@ -291,7 +291,7 @@ openpic_intr(void *arg) return (FILTER_HANDLED); } -void +static void openpic_dispatch(device_t dev, struct trapframe *tf) { struct openpic_softc *sc; @@ -343,7 +343,7 @@ openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused) openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0); } -void +static void openpic_ipi(device_t dev, u_int cpu) { struct openpic_softc *sc; @@ -357,7 +357,7 @@ openpic_ipi(device_t dev, u_int cpu) sched_unpin(); } -void +static void openpic_mask(device_t dev, u_int irq, void *priv __unused) { struct openpic_softc *sc; @@ -393,7 +393,7 @@ openpic_unmask(device_t dev, u_int irq, void *priv __unused) } } -int +static int openpic_suspend(device_t dev) { struct openpic_softc *sc; @@ -424,7 +424,7 @@ openpic_suspend(device_t dev) return (0); } -int +static int openpic_resume(device_t dev) { struct openpic_softc *sc; @@ -453,3 +453,24 @@ openpic_resume(device_t dev) return (0); } + +static device_method_t openpic_methods[] = { + /* Device interface */ + DEVMETHOD(device_suspend, openpic_suspend), + DEVMETHOD(device_resume, openpic_resume), + + /* PIC interface */ + DEVMETHOD(pic_bind, openpic_bind), + DEVMETHOD(pic_config, openpic_config), + DEVMETHOD(pic_dispatch, openpic_dispatch), + DEVMETHOD(pic_enable, openpic_enable), + DEVMETHOD(pic_eoi, openpic_eoi), + DEVMETHOD(pic_ipi, openpic_ipi), + DEVMETHOD(pic_mask, openpic_mask), + DEVMETHOD(pic_unmask, openpic_unmask), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(openpic, openpic_class, openpic_methods, + sizeof(struct openpic_softc)); diff --git a/sys/powerpc/psim/openpic_iobus.c b/sys/powerpc/psim/openpic_iobus.c index bf5bd8235a6c..21950e248b6d 100644 --- a/sys/powerpc/psim/openpic_iobus.c +++ b/sys/powerpc/psim/openpic_iobus.c @@ -69,22 +69,11 @@ static device_method_t openpic_iobus_methods[] = { DEVMETHOD(device_probe, openpic_iobus_probe), DEVMETHOD(device_attach, openpic_iobus_attach), - /* PIC interface */ - DEVMETHOD(pic_config, openpic_config), - DEVMETHOD(pic_dispatch, openpic_dispatch), - DEVMETHOD(pic_enable, openpic_enable), - DEVMETHOD(pic_eoi, openpic_eoi), - DEVMETHOD(pic_ipi, openpic_ipi), - DEVMETHOD(pic_mask, openpic_mask), - DEVMETHOD(pic_unmask, openpic_unmask), - { 0, 0 } + DEVMETHOD_END }; -static driver_t openpic_iobus_driver = { - "openpic", - openpic_iobus_methods, - sizeof(struct openpic_softc) -}; +DEFINE_CLASS_1(openpic, openpic_iobus_driver, openpic_iobus_methods, + sizeof(struct openpic_softc), openpic_class); DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0);