From: "François Valenduc" <fvalenduc-IWqWACnzNjyZIoH1IeqzKA@public.gmane.org>
To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: Re: Smart Battery System driver
Date: Tue, 06 Sep 2005 22:38:22 +0200 [thread overview]
Message-ID: <431DFE3E.5010400@tiscali.be> (raw)
In-Reply-To: <75eeb70e050906125344c326ad-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]
Antoni Villalonga a écrit :
>2005/9/6, Antoni Villalonga:
>
>
>>I know about sbs-linux project in sourceforge, but I get a big delay
>>(about ~20 seconds) with my Acer TM 4001 when I try to read battery
>>status.
>>
>>There are any way to fix it?
>>
>>Thanks!!
>>
>>
>
>Thanks to Olaf and Yu!
>
>It doesn't work for me, I don't have more time today at weekend I'll retry. :-)
>
>THANKS!!
>
>
>
See the bug report here:
https://sourceforge.net/tracker/index.php?func=detail&aid=1191536&group_id=129330&atid=714494
I have exactely the same laptop than you and I manage to read battery
state without problem using a modified DSDT table. If you use kernels
2.6.11 or 2.6.12, you can use the attached patch which includes the
changes suggested in the bug report. If you use kernel 2.6.13, this
patch doesn't apply cleanly. However, without extra patch, it works
correctly for me.
François Valenduc
[-- Attachment #2: acpi-ec-nospinlock-2.6.11.diff --]
[-- Type: text/x-patch, Size: 5716 bytes --]
diff -urN linux-2.6.11.5-original/drivers/acpi/ec.c linux-2.6.11.5/drivers/acpi/ec.c
--- linux-2.6.11.5-original/drivers/acpi/ec.c 2005-03-21 15:58:25.000000000 +0000
+++ linux-2.6.11.5/drivers/acpi/ec.c 2005-03-21 16:03:55.000000000 +0000
@@ -31,6 +31,7 @@
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <asm/semaphore.h>
#include <asm/io.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
@@ -54,8 +55,8 @@
#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */
#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */
-#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
-#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
+#define ACPI_EC_MSLEEP 1 /* Sleep 1ms between polling */
+#define ACPI_EC_MSLEEP_COUNT 10 /* Wait 10ms max. during EC ops */
#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
#define ACPI_EC_COMMAND_READ 0x80
@@ -87,7 +88,7 @@
struct acpi_generic_address command_addr;
struct acpi_generic_address data_addr;
unsigned long global_lock;
- spinlock_t lock;
+ struct semaphore sem;
};
/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -106,7 +107,7 @@
u8 event)
{
u32 acpi_ec_status = 0;
- u32 i = ACPI_EC_UDELAY_COUNT;
+ u32 i = ACPI_EC_MSLEEP_COUNT;
if (!ec)
return -EINVAL;
@@ -118,7 +119,7 @@
acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
if (acpi_ec_status & ACPI_EC_FLAG_OBF)
return 0;
- udelay(ACPI_EC_UDELAY);
+ msleep(ACPI_EC_MSLEEP);
} while (--i>0);
break;
case ACPI_EC_EVENT_IBE:
@@ -126,7 +127,7 @@
acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
return 0;
- udelay(ACPI_EC_UDELAY);
+ msleep(ACPI_EC_MSLEEP);
} while (--i>0);
break;
default:
@@ -137,7 +138,7 @@
}
-static int
+int
acpi_ec_read (
struct acpi_ec *ec,
u8 address,
@@ -145,7 +146,6 @@
{
acpi_status status = AE_OK;
int result = 0;
- unsigned long flags = 0;
u32 glk = 0;
ACPI_FUNCTION_TRACE("acpi_ec_read");
@@ -161,7 +161,10 @@
return_VALUE(-ENODEV);
}
- spin_lock_irqsave(&ec->lock, flags);
+ if (down_interruptible (&ec->sem)) {
+ result = -ERESTARTSYS;
+ goto end_nosem;
+ }
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
@@ -180,7 +183,8 @@
*data, address));
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ up (&ec->sem);
+end_nosem:
if (ec->global_lock)
acpi_release_global_lock(glk);
@@ -189,7 +193,7 @@
}
-static int
+int
acpi_ec_write (
struct acpi_ec *ec,
u8 address,
@@ -197,7 +201,6 @@
{
int result = 0;
acpi_status status = AE_OK;
- unsigned long flags = 0;
u32 glk = 0;
ACPI_FUNCTION_TRACE("acpi_ec_write");
@@ -211,7 +214,10 @@
return_VALUE(-ENODEV);
}
- spin_lock_irqsave(&ec->lock, flags);
+ if (down_interruptible (&ec->sem)) {
+ result = -ERESTARTSYS;
+ goto end_nosem;
+ }
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
@@ -232,7 +238,8 @@
data, address));
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ up (&ec->sem);
+end_nosem:
if (ec->global_lock)
acpi_release_global_lock(glk);
@@ -284,14 +291,13 @@
EXPORT_SYMBOL(ec_write);
-static int
+int
acpi_ec_query (
struct acpi_ec *ec,
u32 *data)
{
int result = 0;
acpi_status status = AE_OK;
- unsigned long flags = 0;
u32 glk = 0;
ACPI_FUNCTION_TRACE("acpi_ec_query");
@@ -312,7 +318,10 @@
* Note that successful completion of the query causes the ACPI_EC_SCI
* bit to be cleared (and thus clearing the interrupt source).
*/
- spin_lock_irqsave(&ec->lock, flags);
+ if (down_interruptible (&ec->sem)) {
+ result = -ERESTARTSYS;
+ goto end_nosem;
+ }
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr);
result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
@@ -324,7 +333,8 @@
result = -ENODATA;
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ up (&ec->sem);
+end_nosem:
if (ec->global_lock)
acpi_release_global_lock(glk);
@@ -348,7 +358,6 @@
{
struct acpi_ec *ec = (struct acpi_ec *) ec_cxt;
u32 value = 0;
- unsigned long flags = 0;
static char object_name[5] = {'_','Q','0','0','\0'};
const char hex[] = {'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'};
@@ -358,9 +367,11 @@
if (!ec_cxt)
goto end;
- spin_lock_irqsave(&ec->lock, flags);
+ if (down_interruptible (&ec->sem)) {
+ return_VOID;
+ }
acpi_hw_low_level_read(8, &value, &ec->command_addr);
- spin_unlock_irqrestore(&ec->lock, flags);
+ up(&ec->sem);
/* TBD: Implement asynch events!
* NOTE: All we care about are EC-SCI's. Other EC events are
@@ -623,7 +634,7 @@
ec->handle = device->handle;
ec->uid = -1;
- spin_lock_init(&ec->lock);
+ sema_init(&ec->sem, 1);
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
acpi_driver_data(device) = ec;
@@ -832,7 +843,7 @@
status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit);
if (ACPI_FAILURE(status))
return status;
- spin_lock_init(&ec_ecdt->lock);
+ sema_init(&ec_ecdt->sem, 1);
ec_ecdt->global_lock = TRUE;
ec_ecdt->handle = handle;
@@ -909,7 +920,7 @@
ec_ecdt->status_addr = ecdt_ptr->ec_control;
ec_ecdt->data_addr = ecdt_ptr->ec_data;
ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
- spin_lock_init(&ec_ecdt->lock);
+ sema_init(&ec_ecdt->sem, 1);
/* use the GL just to be safe */
ec_ecdt->global_lock = TRUE;
ec_ecdt->uid = ecdt_ptr->uid;
next prev parent reply other threads:[~2005-09-06 20:38 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-14 19:23 Smart Battery System driver Rich Townsend
[not found] ` <41E81C2C.8010809-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-15 0:06 ` David Gómez
2005-01-15 0:12 ` Pedro Venda
2005-01-15 0:13 ` Matthew Garrett
2005-01-15 3:03 ` Johannes Kuhlmann
[not found] ` <47e0449d05011419037877f931-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2005-01-15 10:57 ` Johan Vromans
[not found] ` <m2fz13x8mw.fsf-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-15 14:24 ` Johannes Kuhlmann
2005-01-16 8:55 ` Rich Townsend
[not found] ` <41EA2C1D.3030909-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-16 10:48 ` François Valenduc
[not found] ` <41EA4661.4000304-IWqWACnzNjyZIoH1IeqzKA@public.gmane.org>
2005-01-16 14:36 ` François Valenduc
2005-01-16 10:49 ` Karol Kozimor
2005-01-17 11:41 ` Bruno Ducrot
2005-01-17 16:27 ` Pedro Venda
[not found] ` <41EBE769.7050107-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-18 1:36 ` Rich Townsend
[not found] ` <41EC6829.1070901-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-18 11:11 ` Matthew Garrett
2005-01-18 11:23 ` Zdzisław A. Kaleta
[not found] ` <200501181223.22954.sanskryt-FWhLrETftxM@public.gmane.org>
2005-01-18 12:20 ` Zdzisław A. Kaleta
2005-01-18 15:46 ` Rich Townsend
2005-01-18 3:03 ` Rich Townsend
[not found] ` <41EC7C7D.1070003-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-18 4:39 ` Rich Townsend
[not found] ` <41EC9316.80109-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-18 13:00 ` Pedro Venda
2005-01-19 4:32 ` Rich Townsend
[not found] ` <41EDE2EA.7090404-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-19 9:36 ` Johan Vromans
[not found] ` <m2u0pdn4js.fsf-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-19 13:31 ` Rich Townsend
2005-01-19 14:11 ` Johan Vromans
2005-01-19 18:49 ` Jeroen Wijnhout
[not found] ` <200501191949.03558.Jeroen.Wijnhout-sVbgdUKTYbrR7s880joybQ@public.gmane.org>
2005-01-19 19:10 ` Olaf Jansen-Olliges
[not found] ` <200501192010.25975.o.jansen-n+qsWun7DryELgA04lAiVw@public.gmane.org>
2005-01-19 21:55 ` Johan Vromans
[not found] ` <m28y6pytgs.fsf-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-19 22:24 ` Rich Townsend
2005-01-20 8:36 ` Olaf Jansen-Olliges
[not found] ` <200501200936.21831.o.jansen-n+qsWun7DryELgA04lAiVw@public.gmane.org>
2005-01-20 9:22 ` Johan Vromans
2005-01-20 9:10 ` Jeroen Wijnhout
2005-01-20 3:03 ` Rich Townsend
[not found] ` <41EF1F6A.5000807-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-20 15:12 ` Pedro Venda
[not found] ` <41EFCA59.6040100-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-20 16:04 ` Rich Townsend
[not found] ` <41EFD672.2040308-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-20 21:10 ` Stefan Seyfried
[not found] ` <20050120211044.GA27543-l0tNAEGuAhhzZ8+rp42Dbp9+tswZ0GTaehPwdyo5hKaELgA04lAiVw@public.gmane.org>
2005-01-21 13:16 ` Pedro Venda
[not found] ` <41F1009C.30201-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-21 17:48 ` Stefan Seyfried
2005-09-06 3:25 ` Antoni Villalonga
[not found] ` <75eeb70e05090520257be89afa-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2005-09-06 6:19 ` Olaf Jansen-Olliges
[not found] ` <200509060819.13292.o.jansen-n+qsWun7DryELgA04lAiVw@public.gmane.org>
2005-09-06 6:48 ` Yu Luming
[not found] ` <200509061448.12234.luming.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2005-09-06 6:54 ` Olaf Jansen-Olliges
[not found] ` <200509060854.14417.o.jansen-n+qsWun7DryELgA04lAiVw@public.gmane.org>
2005-09-06 6:57 ` Yu Luming
[not found] ` <200509061457.23947.luming.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2005-09-06 7:05 ` Olaf Jansen-Olliges
2005-09-06 8:41 ` Olaf Jansen-Olliges
[not found] ` <200509061041.21722.o.jansen-n+qsWun7DryELgA04lAiVw@public.gmane.org>
2005-09-06 9:34 ` Yu Luming
[not found] ` <200509061734.11182.luming.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2005-09-06 11:57 ` Olaf Jansen-Olliges
2005-09-08 9:04 ` Olaf Jansen-Olliges
2005-09-06 6:38 ` Yu Luming
2005-09-06 19:53 ` Antoni Villalonga
[not found] ` <75eeb70e050906125344c326ad-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2005-09-06 20:38 ` François Valenduc [this message]
2005-09-09 21:59 ` Antoni Villalonga
2005-09-07 7:51 ` David Gómez
2005-01-20 20:38 ` Johan Vromans
[not found] ` <m2wtu74yzq.fsf-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-20 20:48 ` Rich Townsend
[not found] ` <41F01923.1000503-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-20 21:31 ` Johan Vromans
[not found] ` <m2sm4v4wk7.fsf-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-21 2:57 ` Bernard Blackham
2005-01-21 13:20 ` Pedro Venda
2005-01-21 13:24 ` Johan Vromans
[not found] ` <16881.652.864369.5956-KjnUIgV0B0bak1Ioo/c9IoRWq/SkRNHw@public.gmane.org>
2005-01-21 13:34 ` Pedro Venda
[not found] ` <41F10180.60008-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-21 13:26 ` Rich Townsend
[not found] ` <41F1031E.60507-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-21 13:42 ` Pedro Venda
[not found] ` <41F106C9.5020404-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-21 15:01 ` Rich Townsend
[not found] ` <41F11940.5010101-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-21 20:16 ` Pedro Venda
[not found] ` <41F1631C.1030701-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-21 20:31 ` Rich Townsend
2005-01-21 14:17 ` Zdzisław A. Kaleta
2005-01-23 16:02 ` Pavel Machek
[not found] ` <20050123160244.GA1364-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2005-01-23 17:36 ` Pedro Venda
[not found] ` <41F3E095.6060805-pQd4kjVL+REh2FBCd0jGRA@public.gmane.org>
2005-01-24 11:50 ` Stefan Seyfried
2005-01-21 0:31 ` ultrakorne
[not found] ` <41F04D5A.8060304-XtQPfPCVGG7srOwW+9ziJQ@public.gmane.org>
2005-01-25 4:54 ` Rich Townsend
2005-01-18 10:26 ` Bruno Ducrot
[not found] ` <20050118102635.GV19199-kk6yZipjEM5g9hUCZPvPmw@public.gmane.org>
2005-01-18 15:39 ` Rich Townsend
[not found] ` <41ED2DB8.70707-OBnUx95tOyn10jlvfTC4gA@public.gmane.org>
2005-01-19 11:09 ` Bruno Ducrot
2005-01-15 6:38 ` Rich Townsend
2005-01-17 13:20 ` Bruno Ducrot
[not found] ` <20050117132023.GT19199-kk6yZipjEM5g9hUCZPvPmw@public.gmane.org>
2005-01-17 14:21 ` Hendrik Jürgens
2005-01-17 11:33 ` Bruno Ducrot
2005-01-17 21:11 ` Zdzisław A. Kaleta
[not found] ` <200501172211.37583.sanskryt-FWhLrETftxM@public.gmane.org>
2005-01-17 23:58 ` Zdzisław A. Kaleta
2005-01-17 22:40 ` ultrakorne
-- strict thread matches above, loose matches on Subject: below --
2005-01-20 22:04 Grover, Andrew
[not found] ` <F760B14C9561B941B89469F59BA3A84708CBB988-sBd4vmA9Se6krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2005-01-20 22:12 ` Karol Kozimor
2005-01-21 0:03 ` Matthew Garrett
2005-01-21 12:02 ` Paul Ionescu
2005-01-21 10:06 ` Simon Fowler
[not found] ` <20050121100618.GA3945-Ji7FXtOmRLs@public.gmane.org>
2005-01-21 13:22 ` Rich Townsend
2005-01-21 14:14 ` Stefan Seyfried
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=431DFE3E.5010400@tiscali.be \
--to=fvalenduc-iwqwacnznjyzioh1ieqzka@public.gmane.org \
--cc=acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox