Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Use acpi_md_intr_establish/disestablish to handle de...
details: https://anonhg.NetBSD.org/src/rev/ccd2e210a4bf
branches: trunk
changeset: 445901:ccd2e210a4bf
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Nov 16 23:05:50 2018 +0000
description:
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.
diffstat:
sys/dev/acpi/acpi_intr.h | 8 ++++----
sys/dev/acpi/acpi_util.c | 31 ++++++++++++++++---------------
sys/dev/acpi/sdhc_acpi.c | 38 ++++++++++++--------------------------
sys/dev/i2c/ihidev.c | 14 +++++++-------
4 files changed, 39 insertions(+), 52 deletions(-)
diffs (277 lines):
diff -r 8a24f85f4bf4 -r ccd2e210a4bf sys/dev/acpi/acpi_intr.h
--- a/sys/dev/acpi/acpi_intr.h Fri Nov 16 23:03:55 2018 +0000
+++ b/sys/dev/acpi/acpi_intr.h Fri Nov 16 23:05:50 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_intr.h,v 1.2 2018/03/20 12:14:52 bouyer Exp $ */
+/* $NetBSD: acpi_intr.h,v 1.3 2018/11/16 23:05:50 jmcneill Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-void * acpi_intr_establish(device_t, uint64_t,
- unsigned int (*intr)(void *), void *, const char *);
-void acpi_intr_disestablish(void *, unsigned int (*intr)(void *));
+void * acpi_intr_establish(device_t, uint64_t, int, bool,
+ int (*intr)(void *), void *, const char *);
+void acpi_intr_disestablish(void *);
const char * acpi_intr_string(void *, char *, size_t len);
diff -r 8a24f85f4bf4 -r ccd2e210a4bf sys/dev/acpi/acpi_util.c
--- a/sys/dev/acpi/acpi_util.c Fri Nov 16 23:03:55 2018 +0000
+++ b/sys/dev/acpi/acpi_util.c Fri Nov 16 23:05:50 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.13 2018/10/12 23:25:29 jmcneill Exp $ */
+/* $NetBSD: acpi_util.c,v 1.14 2018/11/16 23:05:50 jmcneill Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.13 2018/10/12 23:25:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.14 2018/11/16 23:05:50 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -75,6 +75,8 @@
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_intr.h>
+#include <machine/acpi_machdep.h>
+
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_util")
@@ -550,18 +552,19 @@
struct acpi_irq_handler {
ACPI_HANDLE aih_hdl;
uint32_t aih_irq;
- int (*aih_intr)(void *);
+ void *aih_ih;
};
void *
-acpi_intr_establish(device_t dev, uint64_t c,
- unsigned int (*intr)(void *), void *iarg, const char *xname)
+acpi_intr_establish(device_t dev, uint64_t c, int ipl, bool mpsafe,
+ int (*intr)(void *), void *iarg, const char *xname)
{
ACPI_STATUS rv;
ACPI_HANDLE hdl = (void *)(uintptr_t)c;
struct acpi_resources res;
struct acpi_irq *irq;
struct acpi_irq_handler *aih = NULL;
+ void *ih;
rv = acpi_resource_parse(dev, hdl, "_CRS", &res,
&acpi_resource_parse_ops_quiet);
@@ -572,30 +575,28 @@
if (irq == NULL)
goto end;
- aih = kmem_alloc(sizeof(struct acpi_irq_handler), KM_NOSLEEP);
- if (aih == NULL)
+ const int type = (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL;
+ ih = acpi_md_intr_establish(irq->ar_irq, ipl, type, intr, iarg, mpsafe, xname);
+ if (ih == NULL)
goto end;
+ aih = kmem_alloc(sizeof(struct acpi_irq_handler), KM_SLEEP);
aih->aih_hdl = hdl;
aih->aih_irq = irq->ar_irq;
- rv = AcpiOsInstallInterruptHandler_xname(irq->ar_irq, intr, iarg, xname);
- if (ACPI_FAILURE(rv)) {
- kmem_free(aih, sizeof(struct acpi_irq_handler));
- aih = NULL;
- }
+ aih->aih_ih = ih;
+
end:
acpi_resource_cleanup(&res);
return aih;
}
void
-acpi_intr_disestablish(void *c, unsigned int (*intr)(void *))
+acpi_intr_disestablish(void *c)
{
struct acpi_irq_handler *aih = c;
- AcpiOsRemoveInterruptHandler(aih->aih_irq, intr);
+ acpi_md_intr_disestablish(aih->aih_ih);
kmem_free(aih, sizeof(struct acpi_irq_handler));
- return;
}
const char *
diff -r 8a24f85f4bf4 -r ccd2e210a4bf sys/dev/acpi/sdhc_acpi.c
--- a/sys/dev/acpi/sdhc_acpi.c Fri Nov 16 23:03:55 2018 +0000
+++ b/sys/dev/acpi/sdhc_acpi.c Fri Nov 16 23:05:50 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $ */
+/* $NetBSD: sdhc_acpi.c,v 1.6 2018/11/16 23:05:50 jmcneill Exp $ */
/*
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%NetBSD.org@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.6 2018/11/16 23:05:50 jmcneill Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -35,6 +35,7 @@
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_intr.h>
#include <dev/sdmmc/sdhcreg.h>
#include <dev/sdmmc/sdhcvar.h>
@@ -53,7 +54,7 @@
bus_space_tag_t sc_memt;
bus_space_handle_t sc_memh;
bus_size_t sc_memsize;
- int sc_irq;
+ void *sc_ih;
ACPI_HANDLE sc_crs, sc_srs;
ACPI_BUFFER sc_crs_buffer;
@@ -62,7 +63,6 @@
CFATTACH_DECL_NEW(sdhc_acpi, sizeof(struct sdhc_acpi_softc),
sdhc_acpi_match, sdhc_acpi_attach, sdhc_acpi_detach, NULL);
-static uint32_t sdhc_acpi_intr(void *);
static void sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *,
struct sdhc_host *);
@@ -140,7 +140,6 @@
sc->sc.sc_dmat = aa->aa_dmat;
sc->sc.sc_host = NULL;
sc->sc_memt = aa->aa_memt;
- sc->sc_irq = -1;
slot = sdhc_acpi_find_slot(aa->aa_node->ad_devinfo);
if (slot->type == SLOT_TYPE_EMMC)
@@ -180,14 +179,13 @@
goto cleanup;
}
- /* XXX acpi_intr_establish? */
- rv = AcpiOsInstallInterruptHandler(irq->ar_irq, sdhc_acpi_intr, sc);
- if (ACPI_FAILURE(rv)) {
+ sc->sc_ih = acpi_intr_establish(self, (uint64_t)aa->aa_node->ad_handle,
+ IPL_BIO, false, sdhc_intr, &sc->sc, device_xname(self));
+ if (sc->sc_ih == NULL) {
aprint_error_dev(self,
"couldn't establish interrupt handler\n");
goto unmap;
}
- sc->sc_irq = irq->ar_irq;
sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_NOSLEEP);
if (sc->sc.sc_host == NULL) {
@@ -217,10 +215,9 @@
kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *));
sc->sc.sc_host = NULL;
intr_disestablish:
- if (sc->sc_irq >= 0)
- /* XXX acpi_intr_disestablish? */
- AcpiOsRemoveInterruptHandler(sc->sc_irq, sdhc_acpi_intr);
- sc->sc_irq = -1;
+ if (sc->sc_ih != NULL)
+ acpi_intr_disestablish(sc->sc_ih);
+ sc->sc_ih = NULL;
unmap:
bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_memsize);
sc->sc_memsize = 0;
@@ -243,9 +240,8 @@
if (rv)
return rv;
- if (sc->sc_irq >= 0)
- /* XXX acpi_intr_disestablish? */
- AcpiOsRemoveInterruptHandler(sc->sc_irq, sdhc_acpi_intr);
+ if (sc->sc_ih != NULL)
+ acpi_intr_disestablish(sc->sc_ih);
if (sc->sc.sc_host != NULL)
kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *));
@@ -275,16 +271,6 @@
return sdhc_resume(self, qual);
}
-static uint32_t
-sdhc_acpi_intr(void *context)
-{
- struct sdhc_acpi_softc *sc = context;
-
- if (!sdhc_intr(&sc->sc))
- return ACPI_INTERRUPT_NOT_HANDLED;
- return ACPI_INTERRUPT_HANDLED;
-}
-
static void
sdhc_acpi_intel_emmc_hw_reset(struct sdhc_softc *sc, struct sdhc_host *hp)
{
diff -r 8a24f85f4bf4 -r ccd2e210a4bf sys/dev/i2c/ihidev.c
--- a/sys/dev/i2c/ihidev.c Fri Nov 16 23:03:55 2018 +0000
+++ b/sys/dev/i2c/ihidev.c Fri Nov 16 23:05:50 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.6 2018/11/15 23:01:45 jakllsch Exp $ */
+/* $NetBSD: ihidev.c,v 1.7 2018/11/16 23:05:50 jmcneill Exp $ */
/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
/*-
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.6 2018/11/15 23:01:45 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.7 2018/11/16 23:05:50 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -112,7 +112,7 @@
static bool ihidev_suspend(device_t, const pmf_qual_t *);
static bool ihidev_resume(device_t, const pmf_qual_t *);
static int ihidev_hid_command(struct ihidev_softc *, int, void *, bool);
-static unsigned int ihidev_intr(void *);
+static int ihidev_intr(void *);
static int ihidev_reset(struct ihidev_softc *, bool);
static int ihidev_hid_desc_parse(struct ihidev_softc *);
@@ -208,8 +208,8 @@
{
char buf[100];
- sc->sc_ih = acpi_intr_establish(self,
- sc->sc_phandle, ihidev_intr, sc, device_xname(self));
+ sc->sc_ih = acpi_intr_establish(self, sc->sc_phandle, IPL_TTY,
+ false, ihidev_intr, sc, device_xname(self));
if (sc->sc_ih == NULL)
aprint_error_dev(self, "can't establish interrupt\n");
aprint_normal_dev(self, "interrupting at %s\n",
@@ -264,7 +264,7 @@
mutex_enter(&sc->sc_intr_lock);
#if NACPICA > 0
if (sc->sc_ih != NULL)
- acpi_intr_disestablish(sc->sc_ih, ihidev_intr);
+ acpi_intr_disestablish(sc->sc_ih);
#endif
if (ihidev_hid_command(sc, I2C_HID_CMD_SET_POWER,
&I2C_HID_POWER_OFF, true))
@@ -651,7 +651,7 @@
return (0);
}
-static unsigned int
+static int
ihidev_intr(void *arg)
{
struct ihidev_softc *sc = arg;
Home |
Main Index |
Thread Index |
Old Index