Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E

2014-07-15 Thread Daniele Mazzotti
Hello Anthony,

I made a few step ahead (at least on my side) and tried to follow the
recommendation from the handbook (
http://www.pl.freebsd.org/doc/handbook/acpi-debug.html).

I was able to turn on the verbose boot and here you can find the output:
http://pastebin.com/kkDAZEVb. At boot time I can see an error stating
battery0: battery initialization failed, giving up which is thrown by the
acpi_cmbat_init_battery within acpi_cmbat.c module. After six retries the
error is printed out. Actually I am not able to figure out who is calling
the method, but that is another story.

I just noticed that I forgot to answer the part where you proposed me to
patch my ACPI. Unfortunately I am running and AMD 64 architecture and I
do not think this is fitting with what you already patched.

By the way I am not sure that what I wrote is that relevant to you, but I
just wanted to give you the feeling that I am not just passively requiring
help.
Cheers,
Daniele.


2014-07-14 20:21 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:

 Hi Anthony,

 no problem for the delay. I did not expect you to answer 5 seconds or 5
 minutes after my email as I think we all have lives and jobs that keep us
 busy quite a lot. So, no problem at all!

 Regarding the issue we are discussing about, I think I already posted the
 output of acpidump -dt here http://pastebin.com/F0a2mZP4 and I also
 tried to understand a bit of the contents but I had no luck. Unfortunately
 I am not so much into this ACPI thing, but I am very interested to know how
 it works and fix (my maybe also someone's else) bug.

 I followed your recommendation and enabled the debug in the loader.conf.
 You can find my output here: http://pastebin.com/JXMjBhyx.
 Thanks again for the precious help.

 Cheers,
 Daniele.




 2014-07-14 14:54 GMT+02:00 Anthony Jenkins anthony.b.jenk...@att.net:

 Hi Daniele,

 Sorry it took so long to get back to you.  I tried the .layer and .level
 sysctls I asked you to set, and they didn't result in any valuable output.
  I tried setting debug.acpi.level to ACPI_LV_VERBOSITY2 which prints every
 statement interpreted from the AML (presumably only the ACPI_BATTERY
 related calls), which /might/ be useful, but I wouldn't know what I was
 looking for.  So if you want, you can try setting debug.acpi.layer to
 ACPI_BATTERY and debug.acpi.level to ACPI_LV_VERBOSITY2 and post the gobs
 of info from /var/log/messages somewhere, but dunno if that'd be useful.

 It might be more useful to look at your DSDT ASL, as recommended in the
 FreeBSD ACPI debugging handbook page:

 http://www.pl.freebsd.org/doc/handbook/acpi-debug.html

 Also I'm not a huge fan of throwing random fixes at a problem, but I do
 have a patch that enables (x86) FreeBSD machines to read/write ACPI CMOS
 regions.  Some BIOSes rely on that functionality for stuff; it fixes most
 of my suspend/resume and poweroff problems.  I can provide that for you to
 try at some point.

 Anthony

 On 07/12/2014 12:57, Daniele Mazzotti wrote:
  Hi Guys,
 
  I have successfully compiled and installed the kernel with ACPI debug.
 
  @Anthony: my problem was definitely related to an outdated code base.
 
  So my question is now: what should I do?. Is there any log or command
 I
  should issue in order to have a better understanding of the problem?
 
  Cheers,
  Daniele.
 
 
  2014-07-11 23:26 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:
 
  Hi Anthony,
 
  here it is: $FreeBSD: release/10.0.0/Makefile 255784 2013-09-22
 07:30:17Z
  andrew $
 
  I will try to check how it is possible to update the code base.
  Cheers,
  Daniele.
 
 
  2014-07-11 20:03 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:
 
  Hi Anthony,
  Thanks for the good hint. I will be searching for the revision info as
  soon as I will be back home (3 hours from now more or less).
 
  Cheers,
  Daniele.
  Il 11/lug/2014 19:59 Anthony Jenkins anthony.b.jenk...@att.net ha
  scritto:
 
   E... good question :-)  I got mine from Subversion, so in
 '/usr/src'
  I can run 'svn info' and see the revision.
 
  Your revision might be at the top of /usr/src/Makefile - it is in
 mine:
 
  #
  # $FreeBSD: head/Makefile 268191 2014-07-02 22:34:06Z marcel $
  #
 
  I'm only wondering because it might be a bad copy.  Might try getting
  the sources again.
 
  Thanks,
  Anthony
 
  On 07/11/2014 13:44, Daniele Mazzotti wrote:
  Actually I think I downloaded the source code back in May when I
  updated
  from RC3 to the current version.
 
  How can I check the code revision on my machine?
 
  Cheers,
  Daniele.
  Il 11/lug/2014 19:37 Anthony Jenkins anthony.b.jenk...@att.net
 ha
  scritto:
 
  I just tried a build of GENERIC + 'options ACPI_DEBUG' and it seems
  to get
  past the error you're seeing.  What revision of the source code are
  you
  using... or where'd you get it from?
 
  Anthony
 
  On 07/11/2014 13:12, Daniele Mazzotti wrote:
  Hi guys,
 
  everything as planned! I am getting a compiling error :-).
 
  This is the way i managed 

Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E

2014-07-15 Thread Daniele Mazzotti
Hi Ian,

I have just rebooted the PC after turning the deep debug on. Here is the
output: http://pastebin.com/H61zJhqc. It is very likely that the dmesg has
been cut due to the large amount of output. Is there any way to have it all?

Cheers,
Daniele.


2014-07-15 20:22 GMT+02:00 Ian Smith smi...@nimnet.asn.au:

 On Tue, 15 Jul 2014 19:49:46 +0200, Daniele Mazzotti wrote:

   I made a few step ahead (at least on my side) and tried to follow the
   recommendation from the handbook (
   http://www.pl.freebsd.org/doc/handbook/acpi-debug.html).
  
   I was able to turn on the verbose boot and here you can find the output:
   http://pastebin.com/kkDAZEVb. At boot time I can see an error stating
   battery0: battery initialization failed, giving up which is thrown by
 the
   acpi_cmbat_init_battery within acpi_cmbat.c module. After six retries
 the
   error is printed out. Actually I am not able to figure out who is
 calling
   the method, but that is another story.

 Actually you'll see those messages on a 'normal' verbose boot, ie
 there's nothing extra logged of note regarding battery issues.  If you
 are up for lots more output on one boot at least, perhaps try what
 acpi(4) suggests:

debug.acpi.layer=ACPI_ALL_COMPONENTS ACPI_ALL_DRIVERS
debug.acpi.level=ACPI_LV_ALL_EXCEPTIONS

 which is less deep, but wider :)  Communications with batteries often,
 likely usually, is moderated by the embedded controler (ACPI_EC) and it
 wouldn't hurt to report any exceptions from other subsystems also. If
 that yields nothing useful you could increase the level ..

 Sorry, I can't read messages backwards very well, so I'll drop the tail.

 cheers, Ian

___
freebsd-acpi@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
To unsubscribe, send any mail to freebsd-acpi-unsubscr...@freebsd.org


Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E

2014-07-15 Thread Anthony Jenkins
On 07/15/2014 13:49, Daniele Mazzotti wrote:
 Hello Anthony,
 I just noticed that I forgot to answer the part where you proposed me to
 patch my ACPI. Unfortunately I am running and AMD 64 architecture and I
 do not think this is fitting with what you already patched.
x86-based architectures use my patch, including amd64.  It patches the 
sys/x86/isa/atrtc.c driver.  I'll attach it... might fix some stuff.  I've been 
running it on my laptop for several weeks and posted it to this newsgroup some 
time ago, so it should be safe at least.

# cd /usr/src  patch  path/to/atrtc.c.patch

 By the way I am not sure that what I wrote is that relevant to you, but I
 just wanted to give you the feeling that I am not just passively requiring
 help.

Not at all... I'm scared I can't really help you with your problem.  At least 
it helps me learn ACPI.

Anthony

P.S. I alternate between top-posting and bottom-posting, depending on the 
audience...I know I've switched at least twice in this thread.


 Cheers,
 Daniele.


 2014-07-14 20:21 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:

 Hi Anthony,

 no problem for the delay. I did not expect you to answer 5 seconds or 5
 minutes after my email as I think we all have lives and jobs that keep us
 busy quite a lot. So, no problem at all!

 Regarding the issue we are discussing about, I think I already posted the
 output of acpidump -dt here http://pastebin.com/F0a2mZP4 and I also
 tried to understand a bit of the contents but I had no luck. Unfortunately
 I am not so much into this ACPI thing, but I am very interested to know how
 it works and fix (my maybe also someone's else) bug.

 I followed your recommendation and enabled the debug in the loader.conf.
 You can find my output here: http://pastebin.com/JXMjBhyx.
 Thanks again for the precious help.

 Cheers,
 Daniele.


Index: sys/x86/isa/atrtc.c
===
--- sys/x86/isa/atrtc.c	(revision 267519)
+++ sys/x86/isa/atrtc.c	(working copy)
@@ -31,6 +31,7 @@
 __FBSDID($FreeBSD$);
 
 #include opt_isa.h
+#include opt_acpi.h
 
 #include sys/param.h
 #include sys/systm.h
@@ -53,6 +54,10 @@
 #include machine/intr_machdep.h
 #include clock_if.h
 
+#include contrib/dev/acpica/include/acpi.h
+#include contrib/dev/acpica/include/accommon.h
+#include dev/acpica/acpivar.h
+
 #define	RTC_LOCK	do { if (!kdb_active) mtx_lock_spin(clock_lock); } while (0)
 #define	RTC_UNLOCK	do { if (!kdb_active) mtx_unlock_spin(clock_lock); } while (0)
 
@@ -161,8 +166,33 @@
 	struct resource *intr_res;
 	void *intr_handler;
 	struct eventtimer et;
+	ACPI_HANDLE acpi_handle;	/* Handle of the PNP0B00 node */
 };
 
+static ACPI_STATUS
+acpi_rtc_cmos_handler(UINT32 function, ACPI_PHYSICAL_ADDRESS address, UINT32 width,
+			UINT64 *value, void *context, void *region_context)
+{
+	struct atrtc_softc *sc;
+
+	sc = (struct atrtc_softc *)context;
+	if (!value || !sc)
+		return AE_BAD_PARAMETER;
+	if (width != 8 || address = 64U)
+		return AE_BAD_PARAMETER;
+	switch (function) {
+		case ACPI_READ:
+			*((UINT8 *)value) = rtcin((int)address);
+			break;
+		case ACPI_WRITE:
+			writertc((int)address, *((UINT8 *)value));
+			break;
+		default:
+			return AE_BAD_PARAMETER;
+	}
+	return AE_OK;
+}
+
 static int
 rtc_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
 {
@@ -245,10 +275,17 @@
 	int i;
 
 	sc = device_get_softc(dev);
+	sc-acpi_handle = acpi_get_handle(dev);
 	sc-port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, sc-port_rid,
 	IO_RTC, IO_RTC + 1, 2, RF_ACTIVE);
 	if (sc-port_res == NULL)
 		device_printf(dev, Warning: Couldn't map I/O.\n);
+	if (ACPI_FAILURE(AcpiInstallAddressSpaceHandler(sc-acpi_handle,
+		ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler, NULL, sc)))
+	{
+		device_printf(dev, Error registering ACPI CMOS address space handler.\n);
+		return 0;
+	}
 	atrtc_start();
 	clock_register(dev, 100);
 	bzero(sc-et, sizeof(struct eventtimer));
@@ -286,6 +323,15 @@
 	return(0);
 }
 
+static int atrtc_detach(device_t dev)
+{
+	struct atrtc_softc *sc;
+
+	sc = device_get_softc(dev);
+	AcpiRemoveAddressSpaceHandler(sc-acpi_handle, ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler);
+	return bus_generic_detach(dev);
+}
+
 static int
 atrtc_resume(device_t dev)
 {
@@ -366,7 +412,7 @@
 	/* Device interface */
 	DEVMETHOD(device_probe,		atrtc_probe),
 	DEVMETHOD(device_attach,	atrtc_attach),
-	DEVMETHOD(device_detach,	bus_generic_detach),
+	DEVMETHOD(device_detach,	atrtc_detach),
 	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
 	DEVMETHOD(device_suspend,	bus_generic_suspend),
 		/* XXX stop statclock? */
@@ -402,3 +448,4 @@
 		rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
 }
 #endif /* DDB */
+
___
freebsd-acpi@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
To unsubscribe, send any mail to freebsd-acpi-unsubscr...@freebsd.org

Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E

2014-07-15 Thread Daniele Mazzotti
Hi Anthony,

I tried to apply the patch but it seems like 6 out of 7 entries are
dismissed. Is it enough to just type

# cd /usr/src  patch  path/to/atrtc.c.patch

as root? Shouldn't I recompile anything?

Cheers,
Daniele.


2014-07-15 21:39 GMT+02:00 Anthony Jenkins anthony.b.jenk...@att.net:

 On 07/15/2014 13:49, Daniele Mazzotti wrote:
  Hello Anthony,
  I just noticed that I forgot to answer the part where you proposed me to
  patch my ACPI. Unfortunately I am running and AMD 64 architecture and I
  do not think this is fitting with what you already patched.
 x86-based architectures use my patch, including amd64.  It patches the
 sys/x86/isa/atrtc.c driver.  I'll attach it... might fix some stuff.  I've
 been running it on my laptop for several weeks and posted it to this
 newsgroup some time ago, so it should be safe at least.

 # cd /usr/src  patch  path/to/atrtc.c.patch

  By the way I am not sure that what I wrote is that relevant to you, but I
  just wanted to give you the feeling that I am not just passively
 requiring
  help.

 Not at all... I'm scared I can't really help you with your problem.  At
 least it helps me learn ACPI.

 Anthony

 P.S. I alternate between top-posting and bottom-posting, depending on the
 audience...I know I've switched at least twice in this thread.


  Cheers,
  Daniele.
 
 
  2014-07-14 20:21 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:
 
  Hi Anthony,
 
  no problem for the delay. I did not expect you to answer 5 seconds or
 5
  minutes after my email as I think we all have lives and jobs that keep
 us
  busy quite a lot. So, no problem at all!
 
  Regarding the issue we are discussing about, I think I already posted
 the
  output of acpidump -dt here http://pastebin.com/F0a2mZP4 and I also
  tried to understand a bit of the contents but I had no luck.
 Unfortunately
  I am not so much into this ACPI thing, but I am very interested to know
 how
  it works and fix (my maybe also someone's else) bug.
 
  I followed your recommendation and enabled the debug in the loader.conf.
  You can find my output here: http://pastebin.com/JXMjBhyx.
  Thanks again for the precious help.
 
  Cheers,
  Daniele.
 


___
freebsd-acpi@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
To unsubscribe, send any mail to freebsd-acpi-unsubscr...@freebsd.org


Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E

2014-07-15 Thread Anthony Jenkins
What's the error(s)?  As root, you should type

cd /usr/src  patch  path/to/atrtc.c.patch


...the '#' was just an indicator of the root user shell prompt.  If it applies 
properly, rebuild the kernel and reboot.  If not, send your 
/usr/src/sys/x86/isa/atrtc.c file and I can manually patch it and send it back. 
 I guess I could roll my kernel sources back to the revision you indicated 
earlier...

Anthony

On 07/15/2014 16:09, Daniele Mazzotti wrote:
 Hi Anthony,

 I tried to apply the patch but it seems like 6 out of 7 entries are
 dismissed. Is it enough to just type

 # cd /usr/src  patch  path/to/atrtc.c.patch

 as root? Shouldn't I recompile anything?

 Cheers,
 Daniele.


 2014-07-15 21:39 GMT+02:00 Anthony Jenkins anthony.b.jenk...@att.net:

 On 07/15/2014 13:49, Daniele Mazzotti wrote:
 Hello Anthony,
 I just noticed that I forgot to answer the part where you proposed me to
 patch my ACPI. Unfortunately I am running and AMD 64 architecture and I
 do not think this is fitting with what you already patched.
 x86-based architectures use my patch, including amd64.  It patches the
 sys/x86/isa/atrtc.c driver.  I'll attach it... might fix some stuff.  I've
 been running it on my laptop for several weeks and posted it to this
 newsgroup some time ago, so it should be safe at least.

 # cd /usr/src  patch  path/to/atrtc.c.patch

 By the way I am not sure that what I wrote is that relevant to you, but I
 just wanted to give you the feeling that I am not just passively
 requiring
 help.
 Not at all... I'm scared I can't really help you with your problem.  At
 least it helps me learn ACPI.

 Anthony

 P.S. I alternate between top-posting and bottom-posting, depending on the
 audience...I know I've switched at least twice in this thread.


 Cheers,
 Daniele.


 2014-07-14 20:21 GMT+02:00 Daniele Mazzotti kappe...@gmail.com:

 Hi Anthony,

 no problem for the delay. I did not expect you to answer 5 seconds or
 5
 minutes after my email as I think we all have lives and jobs that keep
 us
 busy quite a lot. So, no problem at all!

 Regarding the issue we are discussing about, I think I already posted
 the
 output of acpidump -dt here http://pastebin.com/F0a2mZP4 and I also
 tried to understand a bit of the contents but I had no luck.
 Unfortunately
 I am not so much into this ACPI thing, but I am very interested to know
 how
 it works and fix (my maybe also someone's else) bug.

 I followed your recommendation and enabled the debug in the loader.conf.
 You can find my output here: http://pastebin.com/JXMjBhyx.
 Thanks again for the precious help.

 Cheers,
 Daniele.


 ___
 freebsd-acpi@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
 To unsubscribe, send any mail to freebsd-acpi-unsubscr...@freebsd.org


___
freebsd-acpi@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
To unsubscribe, send any mail to freebsd-acpi-unsubscr...@freebsd.org