Module Name:    src
Committed By:   jruoho
Date:           Thu Mar 24 05:10:06 UTC 2011

Modified Files:
        src/sys/arch/x86/acpi: acpi_cpu_md.c
        src/sys/dev/acpi: acpi_cpu.c acpi_cpu.h

Log Message:
Remove the "simple CPU lock" that was unnecessary.
Thanks to rmind@ for clarifications.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/x86/acpi/acpi_cpu_md.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/acpi/acpi_cpu.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/acpi/acpi_cpu.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/acpi/acpi_cpu_md.c
diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.55 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.56
--- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.55	Sat Mar  5 09:47:19 2011
+++ src/sys/arch/x86/acpi/acpi_cpu_md.c	Thu Mar 24 05:10:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.55 2011/03/05 09:47:19 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.56 2011/03/24 05:10:05 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.55 2011/03/05 09:47:19 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.56 2011/03/24 05:10:05 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -105,10 +105,8 @@
 static char	  native_idle_text[16];
 void		(*native_idle)(void) = NULL;
 
-static u_long	 acpicpu_md_lock(struct acpicpu_softc *);
-static void	 acpicpu_md_unlock(struct acpicpu_softc *, u_long);
 static int	 acpicpu_md_quirk_piix4(struct pci_attach_args *);
-static void	 acpicpu_md_pstate_percent_reset(struct cpu_info *);
+static void	 acpicpu_md_pstate_hwf_reset(void *, void *);
 static int	 acpicpu_md_pstate_fidvid_get(struct acpicpu_softc *,
                                               uint32_t *);
 static int	 acpicpu_md_pstate_fidvid_set(struct acpicpu_pstate *);
@@ -142,24 +140,6 @@
 	return cfaa->ci;
 }
 
-static u_long
-acpicpu_md_lock(struct acpicpu_softc *sc)
-{
-	const u_long flags = x86_read_psl();
-
-	x86_disable_intr();
-	__cpu_simple_lock(&sc->sc_lock);
-
-	return flags;
-}
-
-static void
-acpicpu_md_unlock(struct acpicpu_softc *sc, u_long flags)
-{
-	__cpu_simple_unlock(&sc->sc_lock);
-	x86_write_psl(flags);
-}
-
 uint32_t
 acpicpu_md_cap(void)
 {
@@ -510,10 +490,10 @@
 int
 acpicpu_md_pstate_init(struct acpicpu_softc *sc)
 {
+	struct cpu_info *ci = sc->sc_ci;
 	struct acpicpu_pstate *ps, msr;
-	struct cpu_info *ci = curcpu();
 	uint32_t family, i = 0;
-	uint64_t val;
+	uint64_t val, xc;
 
 	(void)memset(&msr, 0, sizeof(struct acpicpu_pstate));
 
@@ -595,7 +575,6 @@
 			break;
 
 		default:
-
 			/*
 			 * If we have an unknown AMD CPU, rely on XPSS.
 			 */
@@ -639,11 +618,11 @@
 
 	/*
 	 * Reset the APERF and MPERF counters.
-	 *
-	 * XXX: Should be with xc_unicast(9).
 	 */
-	if ((sc->sc_flags & ACPICPU_FLAG_P_HWF) != 0)
-		acpicpu_md_pstate_percent_reset(sc->sc_ci);
+	if ((sc->sc_flags & ACPICPU_FLAG_P_HWF) != 0) {
+		xc = xc_unicast(0, acpicpu_md_pstate_hwf_reset, sc, NULL, ci);
+		xc_wait(xc);
+	}
 
 	return 0;
 }
@@ -671,12 +650,11 @@
  *	2.4.5, Revision 3.48, April 2010.
  */
 uint8_t
-acpicpu_md_pstate_percent(struct cpu_info *ci)
+acpicpu_md_pstate_hwf(struct cpu_info *ci)
 {
 	struct acpicpu_softc *sc;
 	uint64_t aperf, mperf;
 	uint8_t rv = 0;
-	u_long flags;
 
 	sc = acpicpu_sc[ci->ci_acpiid];
 
@@ -686,45 +664,45 @@
 	if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P_HWF) == 0))
 		return 0;
 
-	flags = acpicpu_md_lock(sc);
-
 	aperf = sc->sc_pstate_aperf;
 	mperf = sc->sc_pstate_mperf;
 
+	x86_disable_intr();
+
 	sc->sc_pstate_aperf = rdmsr(MSR_APERF);
 	sc->sc_pstate_mperf = rdmsr(MSR_MPERF);
 
+	x86_enable_intr();
+
 	aperf = sc->sc_pstate_aperf - aperf;
 	mperf = sc->sc_pstate_mperf - mperf;
 
 	if (__predict_true(mperf != 0))
 		rv = (aperf * 100) / mperf;
 
-	acpicpu_md_unlock(sc, flags);
-
 	return rv;
 }
 
 static void
-acpicpu_md_pstate_percent_reset(struct cpu_info *ci)
+acpicpu_md_pstate_hwf_reset(void *arg1, void *arg2)
 {
+	struct cpu_info *ci = curcpu();
 	struct acpicpu_softc *sc;
-	u_long flags;
 
 	sc = acpicpu_sc[ci->ci_acpiid];
 
 	if (__predict_false(sc == NULL))
 		return;
 
-	flags = acpicpu_md_lock(sc);
+	x86_disable_intr();
 
 	wrmsr(MSR_APERF, 0);
 	wrmsr(MSR_MPERF, 0);
 
+	x86_enable_intr();
+
 	sc->sc_pstate_aperf = 0;
 	sc->sc_pstate_mperf = 0;
-
-	acpicpu_md_unlock(sc, flags);
 }
 
 int

Index: src/sys/dev/acpi/acpi_cpu.c
diff -u src/sys/dev/acpi/acpi_cpu.c:1.38 src/sys/dev/acpi/acpi_cpu.c:1.39
--- src/sys/dev/acpi/acpi_cpu.c:1.38	Sat Mar 19 12:57:30 2011
+++ src/sys/dev/acpi/acpi_cpu.c	Thu Mar 24 05:10:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.c,v 1.38 2011/03/19 12:57:30 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.c,v 1.39 2011/03/24 05:10:06 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.38 2011/03/19 12:57:30 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.39 2011/03/24 05:10:06 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -187,8 +187,6 @@
 	KASSERT(sc->sc_node->ad_device == NULL);
 
 	sc->sc_node->ad_device = self;
-
-	__cpu_simple_lock_init(&sc->sc_lock);
 	mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE);
 
 	acpicpu_cstate_attach(self);

Index: src/sys/dev/acpi/acpi_cpu.h
diff -u src/sys/dev/acpi/acpi_cpu.h:1.39 src/sys/dev/acpi/acpi_cpu.h:1.40
--- src/sys/dev/acpi/acpi_cpu.h:1.39	Sat Mar 19 12:57:31 2011
+++ src/sys/dev/acpi/acpi_cpu.h	Thu Mar 24 05:10:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.39 2011/03/19 12:57:31 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.40 2011/03/24 05:10:06 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen <jruoho...@iki.fi>
@@ -224,7 +224,6 @@
 	uint32_t		 sc_tstate_max;
 	uint32_t		 sc_tstate_min;
 
-	__cpu_simple_lock_t	 sc_lock;
 	kmutex_t		 sc_mtx;
 	uint32_t		 sc_cap;
 	uint32_t		 sc_ncpus;
@@ -270,7 +269,7 @@
 int		 acpicpu_md_pstate_start(struct acpicpu_softc *);
 int		 acpicpu_md_pstate_stop(void);
 int		 acpicpu_md_pstate_init(struct acpicpu_softc *);
-uint8_t		 acpicpu_md_pstate_percent(struct cpu_info *);
+uint8_t		 acpicpu_md_pstate_hwf(struct cpu_info *);
 int		 acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
 int		 acpicpu_md_pstate_set(struct acpicpu_pstate *);
 int		 acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);

Reply via email to