From amistry@am-productions.biz  Sat Mar  8 23:51:54 2008
Return-Path: <amistry@am-productions.biz>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D9D281065670
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  8 Mar 2008 23:51:54 +0000 (UTC)
	(envelope-from amistry@am-productions.biz)
Received: from flpi195.prodigy.net (flpi195.sbcis.sbc.com [207.115.20.197])
	by mx1.freebsd.org (Postfix) with ESMTP id AC6D98FC1C
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  8 Mar 2008 23:51:54 +0000 (UTC)
	(envelope-from amistry@am-productions.biz)
Received: from bigguy.am-productions.biz (adsl-68-250-179-2.dsl.wotnoh.ameritech.net [68.250.179.2])
	by flpi195.prodigy.net (8.13.8 out.dk.spool/8.13.8) with ESMTP id m28NprsL011796
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 8 Mar 2008 15:51:53 -0800
Message-Id: <1205020608.51775@bigguy.am-productions.biz>
Date: Sat, 8 Mar 2008 18:56:48 -0500
From: "Anish Mistry" <amistry@am-productions.biz>
To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@freebsd.org>
Subject: Correctly set hw.acpi.osname on certain machines
X-Send-Pr-Version: gtk-send-pr 0.4.8 
X-GNATS-Notify:

>Number:         121504
>Category:       kern
>Synopsis:       [patch] Correctly set hw.acpi.osname on certain machines
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sbruno
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 09 00:00:02 UTC 2008
>Closed-Date:    Thu Sep 27 19:56:00 UTC 2012
>Last-Modified:  Thu Sep 27 19:56:00 UTC 2012
>Originator:     Anish Mistry
>Release:        FreeBSD 7.0-RC2 i386
>Organization:
AM Productions 
>Environment:


System: FreeBSD 7.0-RC2 #18: Tue Feb 19 00:02:28 EST 2008
    amistry@bigguy.am-productions.biz:/usr/home/amistry/storage/temp/usr/home/amistry/windows-share/build/src/sys/BIGGUY



>Description:


Setting hw.acpi.osname doesn't work correctly on some systems since ACPI is actually checking the _OSI variable.  Since we only set _OS_ we can't override the OS name.  Add the ability to override the _OSI so that hw.acpi.osname works.  This is needed for the Fujitsu P2110, P8010, and probably others.


>How-To-Repeat:





>Fix:


--- osname-fix.patch begins here ---
--- sys/dev/acpica/Osd/OsdTable.c.orig	2007-03-27 11:45:58.000000000 -0400
+++ sys/dev/acpica/Osd/OsdTable.c	2008-03-08 18:50:05.000000000 -0500
@@ -54,7 +54,8 @@
 	return (AE_BAD_PARAMETER);
 
     *NewVal = NULL;
-    if (strncmp(InitVal->Name, "_OS_", ACPI_NAME_SIZE) == 0 &&
+    if ((strncmp(InitVal->Name, "_OS_", ACPI_NAME_SIZE) == 0 ||
+    	strncmp(InitVal->Name, "_OSI", ACPI_NAME_SIZE) == 0) &&
 	strlen(acpi_osname) > 0) {
 	printf("ACPI: Overriding _OS definition with \"%s\"\n", acpi_osname);
 	*NewVal = acpi_osname;
--- osname-fix.patch ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-acpi 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Sun Mar 9 01:21:00 UTC 2008 
Responsible-Changed-Why:  

catch misfiled PR; Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121504 

From: John Baldwin <jhb@FreeBSD.org>
To: bug-followup@FreeBSD.org, amistry@am-productions.biz
Cc: njl@FreeBSD.org
Subject: Re: kern/121504: [patch] Correctly set hw.acpi.osname on certain machines
Date: Mon, 10 Mar 2008 12:20:49 -0400

 This is not the correct patch.  The _OSI method does not return an OS name 
 like _OS.  Instead, it is a function that returns a boolean (True/False) to 
 say if a given OS name is supported (OS name is passed as an argument).  The 
 proper fix is to say that the osname is supported in the 
 AcpiOsValidateInterface() method.  Something like this should work:
 
 Index: Osd/OsdMemory.c
 ===================================================================
 RCS file: /usr/cvs/src/sys/dev/acpica/Osd/OsdMemory.c,v
 retrieving revision 1.15
 diff -u -r1.15 OsdMemory.c
 --- Osd/OsdMemory.c	22 Mar 2007 18:16:41 -0000	1.15
 +++ Osd/OsdMemory.c	10 Mar 2008 16:20:03 -0000
 @@ -77,6 +77,9 @@
  ACPI_STATUS
  AcpiOsValidateInterface (char *Interface)
  {
 +
 +    if (strcmp(Interface, acpi_osname) == 0)
 +	return (AE_OK);
      return (AE_SUPPORT);
  }
  
 
 -- 
 John Baldwin

From: Anish Mistry <amistry@am-productions.biz>
To: John Baldwin <jhb@freebsd.org>
Cc: bug-followup@freebsd.org, njl@freebsd.org
Subject: Re: kern/121504: [patch] Correctly set hw.acpi.osname on certain machines
Date: Mon, 10 Mar 2008 15:09:04 -0400

 --nextPart11816881.8XfUQkhbdk
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 On Monday 10 March 2008, John Baldwin wrote:
 > This is not the correct patch.  The _OSI method does not return an
 > OS name like _OS.  Instead, it is a function that returns a boolean
 > (True/False) to say if a given OS name is supported (OS name is
 > passed as an argument).  The proper fix is to say that the osname
 > is supported in the
 > AcpiOsValidateInterface() method.  Something like this should work:
 >
 > Index: Osd/OsdMemory.c
 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 > RCS file: /usr/cvs/src/sys/dev/acpica/Osd/OsdMemory.c,v
 > retrieving revision 1.15
 > diff -u -r1.15 OsdMemory.c
 > --- Osd/OsdMemory.c	22 Mar 2007 18:16:41 -0000	1.15
 > +++ Osd/OsdMemory.c	10 Mar 2008 16:20:03 -0000
 > @@ -77,6 +77,9 @@
 >  ACPI_STATUS
 >  AcpiOsValidateInterface (char *Interface)
 >  {
 > +
 > +    if (strcmp(Interface, acpi_osname) =3D=3D 0)
 > +	return (AE_OK);
 >      return (AE_SUPPORT);
 >  }
 
 I get acpi_osname undeclared on compile.
 
 
 =2D-=20
 Anish Mistry
 amistry@am-productions.biz
 AM Productions http://am-productions.biz/
 
 --nextPart11816881.8XfUQkhbdk
 Content-Type: application/pgp-signature; name=signature.asc 
 Content-Description: This is a digitally signed message part.
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.8 (FreeBSD)
 
 iEYEABECAAYFAkfVh1EACgkQxqA5ziudZT2+3ACffUTYiddpl9B116V1ir7UF8AM
 I+kAoKZfbYaukN3CA6ATmaOYbtmRSFeB
 =29gj
 -----END PGP SIGNATURE-----
 
 --nextPart11816881.8XfUQkhbdk--

From: Jung-uk Kim <jkim@FreeBSD.org>
To: "Anish Mistry" <amistry@am-productions.biz>
Cc: bug-followup@FreeBSD.org,
 John Baldwin <jhb@FreeBSD.org>
Subject: Re: kern/121504: [patch] Correctly set hw.acpi.osname on certain machines
Date: Fri, 31 Oct 2008 20:09:50 -0400

 --Boundary-00=_Q55CJS/aKGjigvh
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 If you are still feeling adventurous, please try the attached patch.  
 Note that _OSI is very different from _OS_ and we cannot reuse 
 "hw.acpi.osname" tunable here.  First of all, _OSI method must be 
 able to match multiple entries, not just predefined OS strings, e.g., 
 "3.0 Thermal Model", "Extended Address Space Descriptor", etc. 
 although nobody really uses these 'feature group strings' for their 
 BIOS implementations.  (Ideally, if there is a device driver which 
 implemented the feature, the driver is responsible for registering 
 its capabilities to this table.)
 
 With the attached patch, you can add multiple entries by setting 
 "hw.acpi.supported_osi" tunable and they must be comma-separated, 
 e.g.:
 
 hw.acpi.supported_osi="Windows 2006, Processor Device"
 
 You can even try something like this:
 
 hw.acpi.supported_osi="FreeBSD,Linux,Windows 2001,Windows 2006"
 
 It means the OS supports all of the above OS interfaces (but we 
 don't).  Well, it is not impossible, at least in theory. :-)
 
 Warning #1:
 It may affect your system badly if the BIOS implements OS-specific 
 "workarounds" or "features" for You-Know-Who. ;-)
 
 Warning #2:
 Even if your DSDT contains _OSI("FreeBSD"), it does not mean that you 
 can set hw.acpi.supported_osi="FreeBSD" and expect an improvement.  
 Most likely the code path is never tested and it may even cause 
 regression.  See http://ubuntuforums.org/showthread.php?t=869249 for 
 the latest Linux episode.  With the exact same reason, I am not 
 setting any default value here.
 
 Cheers,
 
 Jung-uk Kim
 
 --Boundary-00=_Q55CJS/aKGjigvh
 Content-Type: text/plain;
   charset="iso-8859-1";
   name="OsdMemory.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="OsdMemory.patch"
 
 --- sys/dev/acpica/Osd/OsdMemory.c	22 Mar 2007 18:16:41 -0000	1.15
 +++ sys/dev/acpica/Osd/OsdMemory.c	31 Oct 2008 22:52:58 -0000
 @@ -40,6 +40,9 @@
  #include <vm/vm.h>
  #include <vm/pmap.h>
  
 +static char acpi_osi[128];
 +TUNABLE_STR("hw.acpi.supported_osi", acpi_osi, sizeof(acpi_osi));
 +
  MALLOC_DEFINE(M_ACPICA, "acpica", "ACPI CA memory pool");
  
  void *
 @@ -77,6 +80,29 @@
  ACPI_STATUS
  AcpiOsValidateInterface (char *Interface)
  {
 +    size_t	len;
 +    char	*cp;
 +
 +    if (Interface == NULL || *Interface == '\0')
 +	return (AE_BAD_PARAMETER);
 +
 +    if (*acpi_osi != '\0') {
 +	cp = acpi_osi;
 +	len = strlen(Interface);
 +	for (;;) {
 +	    if (strlen(cp) < len || (cp = strstr(cp, Interface)) == NULL)
 +		break;
 +	    cp += len;
 +	    if (*cp == '\0' || *cp == ',') {
 +		if (bootverbose)
 +		    printf("ACPI: _OSI(\"%s\") matched\n", Interface);
 +		return (AE_OK);
 +	    }
 +	    while (*cp != '\0' && *cp != ',')
 +		cp++;
 +	}
 +    }
 +
      return (AE_SUPPORT);
  }
  
 
 --Boundary-00=_Q55CJS/aKGjigvh--

From: Anish Mistry <amistry@am-productions.biz>
To: Jung-uk Kim <jkim@freebsd.org>
Cc: bug-followup@freebsd.org, John Baldwin <jhb@freebsd.org>
Subject: Re: kern/121504: [patch] Correctly set hw.acpi.osname on certain machines
Date: Sun, 2 Nov 2008 16:59:02 -0400

 --nextPart19176370.nKuXPQD2aR
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 On Friday 31 October 2008, Jung-uk Kim wrote:
 > If you are still feeling adventurous, please try the attached
 > patch. Note that _OSI is very different from _OS_ and we cannot
 > reuse "hw.acpi.osname" tunable here.  First of all, _OSI method
 > must be able to match multiple entries, not just predefined OS
 > strings, e.g., "3.0 Thermal Model", "Extended Address Space
 > Descriptor", etc. although nobody really uses these 'feature group
 > strings' for their BIOS implementations.  (Ideally, if there is a
 > device driver which implemented the feature, the driver is
 > responsible for registering its capabilities to this table.)
 >
 > With the attached patch, you can add multiple entries by setting
 > "hw.acpi.supported_osi" tunable and they must be comma-separated,
 > e.g.:
 Still no change on my system, but it seems that this would be good to=20
 get in as it might help other people.
 
 
 =2D-=20
 Anish Mistry
 amistry@am-productions.biz
 AM Productions http://am-productions.biz/
 
 --nextPart19176370.nKuXPQD2aR
 Content-Type: application/pgp-signature; name=signature.asc 
 Content-Description: This is a digitally signed message part.
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iEYEABECAAYFAkkOFJcACgkQxqA5ziudZT04VwCdEw8KJL/kTofrccYWCAJIfLq0
 shsAoK9wWQe3cR/pP6ARj5tbveUvdovx
 =UHQt
 -----END PGP SIGNATURE-----
 
 --nextPart19176370.nKuXPQD2aR--

From: Andriy Gapon <avg@freebsd.org>
To: bug-followup@freebsd.org, amistry@am-productions.biz
Cc:  
Subject: Re: kern/121504: [patch] Correctly set hw.acpi.osname on certain
 machines
Date: Sun, 05 Dec 2010 17:18:36 +0200

 I guess that the general _OSI/_OS issue should be resolved now.
 Anish, what's the status of your problem?
 Thanks!
 -- 
 Andriy Gapon
State-Changed-From-To: open->feedback 
State-Changed-By: sbruno 
State-Changed-When: Mon Jul 2 17:00:48 UTC 2012 
State-Changed-Why:  
Feedback was requested for this PR and the original patch was rejected by the  
maintainers.  Supplemental patches have been applied and the maintainers wanted 
to know if there is further issues on the requestor's system. 


Responsible-Changed-From-To: freebsd-acpi->sbruno 
Responsible-Changed-By: sbruno 
Responsible-Changed-When: Mon Jul 2 17:00:48 UTC 2012 
Responsible-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=121504 
State-Changed-From-To: feedback->closed 
State-Changed-By: sbruno 
State-Changed-When: Thu Sep 27 18:17:03 UTC 2012 
State-Changed-Why:  
Request for response timeout. Issue is no longer relevant after svn r214390 


http://www.freebsd.org/cgi/query-pr.cgi?pr=121504 
>Unformatted:
