NetBSD Problem Report #48706

From www@NetBSD.org  Fri Apr  4 13:52:03 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E3B01A5807
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  4 Apr 2014 13:52:03 +0000 (UTC)
Message-Id: <20140404135202.CD93AA580B@mollari.NetBSD.org>
Date: Fri,  4 Apr 2014 13:52:02 +0000 (UTC)
From: nonakap@gmail.com
Reply-To: nonakap@gmail.com
To: gnats-bugs@NetBSD.org
Subject: i915drmkms(4): Too late to have become console.
X-Send-Pr-Version: www-1.0

>Number:         48706
>Category:       kern
>Synopsis:       i915drmkms(4): Too late to have become console.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    riastradh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 04 13:55:00 +0000 2014
>Closed-Date:    Fri Apr 25 23:55:03 +0000 2014
>Last-Modified:  Fri Apr 25 23:55:03 +0000 2014
>Originator:     NONAKA Kimihiro
>Release:        6.99.39
>Organization:
>Environment:
NetBSD koharu.myhome.local 6.99.39 NetBSD 6.99.39 (KOHARU) #2230: Fri Apr  4 21:13:54 JST 2014  nonaka@koharu.myhome.local:/usr/obj.amd64/sys/arch/amd64/compile/KOHARU amd64
>Description:
I think i915drmkms(4) should become console at earlier stage.
>How-To-Repeat:
boot with DRMKMS kernel.
>Fix:
diff -uNr sys.orig/external/bsd/drm2/dist/drm/i915/intel_drv.h sys/external/bsd/drm2/dist/drm/i915/intel_drv.h
--- sys.orig/external/bsd/drm2/dist/drm/i915/intel_drv.h	18 Mar 2014 18:20:42 -0000
+++ sys/external/bsd/drm2/dist/drm/i915/intel_drv.h	4 Apr 2014 12:11:20 -0000
@@ -34,6 +34,59 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_dp_helper.h>

+#ifdef __NetBSD__
+#define _wait_for(COND, MS, W) ({ \
+	int ret__ = 0;							\
+	if (cold) {							\
+		int us = MS * 1000;					\
+		while (!(COND)) {					\
+			if (--us < 0) {					\
+				ret__ = -ETIMEDOUT;			\
+				break;					\
+			}						\
+			DELAY(1);					\
+		}							\
+	} else {							\
+		unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
+		while (!(COND)) {					\
+			if (time_after(jiffies, timeout__)) {		\
+				ret__ = -ETIMEDOUT;			\
+				break;					\
+			}						\
+			if (W && drm_can_sleep())  {			\
+				msleep(W);				\
+			} else {					\
+				cpu_relax();				\
+			}						\
+		}							\
+	}								\
+	ret__;								\
+})
+
+#define wait_for_atomic_us(COND, US) ({ \
+	int ret__ = 0;							\
+	if (cold) {							\
+		int us = US;						\
+		while (!(COND)) {					\
+			if (--us < 0) {					\
+				ret__ = -ETIMEDOUT;			\
+				break;					\
+			}						\
+			DELAY(1);					\
+		}							\
+	} else {							\
+		unsigned long timeout__ = jiffies + usecs_to_jiffies(US); \
+		while (!(COND)) {					\
+			if (time_after(jiffies, timeout__)) {		\
+				ret__ = -ETIMEDOUT;			\
+				break;					\
+			}						\
+			cpu_relax();					\
+		}							\
+	}								\
+	ret__;								\
+})
+#else	/* !NetBSD */
 #define _wait_for(COND, MS, W) ({ \
 	unsigned long timeout__ = jiffies + msecs_to_jiffies(MS);	\
 	int ret__ = 0;							\
@@ -63,6 +116,7 @@
 	}								\
 	ret__;								\
 })
+#endif	/* NetBSD */

 #define wait_for(COND, MS) _wait_for(COND, MS, 1)
 #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
diff -uNr sys.orig/external/bsd/drm2/i915drm/i915_pci.c sys/external/bsd/drm2/i915drm/i915_pci.c
--- sys.orig/external/bsd/drm2/i915drm/i915_pci.c	2014-04-03 22:09:45.000000000 +0900
+++ sys/external/bsd/drm2/i915drm/i915_pci.c	2014-04-03 22:17:45.000000000 +0900
@@ -179,8 +179,8 @@
 		return;
 	}

-	/* Attach a framebuffer, but not until interrupts work.  */
-	config_interrupts(self, &i915drm_attach_framebuffer);
+	/* Attach a framebuffer */
+	i915drm_attach_framebuffer(self);
 }

 static int

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->riastradh
Responsible-Changed-By: riastradh@NetBSD.org
Responsible-Changed-When: Mon, 07 Apr 2014 13:50:17 +0000
Responsible-Changed-Why:
mine


From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48706 CVS commit: src/sys/external/bsd/drm2/dist/drm/i915
Date: Fri, 25 Apr 2014 18:38:54 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr 25 18:38:54 UTC 2014

 Modified Files:
 	src/sys/external/bsd/drm2/dist/drm/i915: intel_drv.h

 Log Message:
 Adapt Linux i915 wait_for to use DELAY so it works while cold.

 Adapted from a patch by nonaka@ in PR 48706.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h

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

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48706 CVS commit: src/sys/external/bsd/drm2/i915drm
Date: Fri, 25 Apr 2014 19:02:52 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri Apr 25 19:02:51 UTC 2014

 Modified Files:
 	src/sys/external/bsd/drm2/i915drm: i915_pci.c

 Log Message:
 Take the console only from vga or generic genfb.

 Adapted from a patch by nonaka@ in PR 48705.

 While here, attach i915 genfb earlier as in PR 48706.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/i915drm/i915_pci.c

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

State-Changed-From-To: open->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 25 Apr 2014 23:55:03 +0000
State-Changed-Why:
fixed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.