summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2005-10-28 07:11:14 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2005-10-28 07:11:14 +0000
commit60aa19b6a784ffcbe7ae3faf83b0c65addb6d95e (patch)
tree1218d376ead3f0dd90e7403004ab0feab10f2191
parentd42fc8ad09f099e6ef849a99eb522a0dd2f44938 (diff)
malloc(M_WAITOK) is bad in init code, M_DEVBUF is nicer than M_TEMP,
and if the cpu gets stuck, don't spin too long.
-rw-r--r--sys/arch/i386/i386/powernow-k7.c6
-rw-r--r--sys/arch/i386/i386/powernow-k8.c8
2 files changed, 9 insertions, 5 deletions
diff --git a/sys/arch/i386/i386/powernow-k7.c b/sys/arch/i386/i386/powernow-k7.c
index 15f4d52b91c..4833f174740 100644
--- a/sys/arch/i386/i386/powernow-k7.c
+++ b/sys/arch/i386/i386/powernow-k7.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: powernow-k7.c,v 1.5 2005/10/28 07:03:41 tedu Exp $ */
+/* $OpenBSD: powernow-k7.c,v 1.6 2005/10/28 07:11:13 tedu Exp $ */
/*
* Copyright (c) 2004 Martin Végiard.
* All rights reserved.
@@ -350,7 +350,9 @@ k7_powernow_init(void)
char *techname = NULL;
ci = curcpu();
- cstate = malloc(sizeof(struct k7pnow_cpu_state), M_TEMP, M_WAITOK);
+ cstate = malloc(sizeof(struct k7pnow_cpu_state), M_DEVBUF, M_NOWAIT);
+ if (!cstate)
+ return;
cpuid(0x80000001, regs);
if ((regs[0] & 0xfff) == 0x760)
diff --git a/sys/arch/i386/i386/powernow-k8.c b/sys/arch/i386/i386/powernow-k8.c
index 8724f5d593d..cfc2899d1cd 100644
--- a/sys/arch/i386/i386/powernow-k8.c
+++ b/sys/arch/i386/i386/powernow-k8.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: powernow-k8.c,v 1.1 2005/10/28 07:03:41 tedu Exp $ */
+/* $OpenBSD: powernow-k8.c,v 1.2 2005/10/28 07:11:13 tedu Exp $ */
/*
* Copyright (c) 2004 Martin Végiard.
* All rights reserved.
@@ -189,7 +189,7 @@ int k8pnow_read_pending_wait(uint64_t * status) {
unsigned int i = 0;
while(PN8_STA_PENDING(*status)) {
i++;
- if (i > 0x1000000) {
+ if (i > 1000) {
printf("k8pnow_read_pending_wait: change pending stuck"
".\n");
return 1;
@@ -400,7 +400,9 @@ k8_powernow_init(void)
char * techname = NULL;
ci = curcpu();
- cstate = malloc(sizeof(struct k8pnow_cpu_state), M_TEMP, M_WAITOK);
+ cstate = malloc(sizeof(struct k8pnow_cpu_state), M_DEVBUF, M_NOWAIT);
+ if (!cstate)
+ return;
rate = pentium_mhz;
status = rdmsr(MSR_AMDK7_FIDVID_STATUS);