From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
To: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Cc: Corentin Chary <corentin.chary@gmail.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [RFC][PATCH] New ACPI-WMI driver for shuttle machines
Date: Wed, 1 Dec 2010 14:17:59 -0200 [thread overview]
Message-ID: <20101201141759.18f6f901@gotham.conectiva> (raw)
In-Reply-To: <20101201141422.19da09e9@gotham.conectiva>
[-- Attachment #1: Type: text/plain, Size: 2955 bytes --]
On Wed, 1 Dec 2010 14:14:22 -0200
Herton Ronaldo Krzesinski <herton@mandriva.com.br> wrote:
> Hi,
>
> > > +static acpi_status wmi_setget_mtd(struct shuttle_cmd *scmd, u32 **res)
> > > +{
> > > + acpi_status status;
> > > + union acpi_object *obj;
> > > + struct acpi_buffer input;
> > > + static DEFINE_MUTEX(mtd_lock);
> > > + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> > > +
> > > + input.length = sizeof(struct shuttle_cmd);
> > > + scmd->hdr = 0xec00;
> > > + input.pointer = (u8 *) scmd;
> > > +
> > > + mutex_lock(&mtd_lock);
> > > + status = wmi_evaluate_method(SHUTTLE_WMI_SETGET_GUID, 0, 2,
> > > + &input, &output);
> > > + mutex_unlock(&mtd_lock);
> >
> > I'm not sure why you need a mutex here ?
>
> I need mutex because of the way the vendor implemented things in its wmi
> interface. If I don't serialize the access to it, when sending commands
> in parallel some of them will fail, for example:
>
> # echo 1 > webcam & rfkill unblock <idx> & echo 1 > touchpad
>
> some of the echos or rfkill will fail. This happens because the vendor used a
> common buffer/variable to store parameters in AML code, from the DSDT:
>
> Name (AC00, Buffer (0x28)
> ...
> CreateDWordField (AC00, Zero, SAC0)
> CreateDWordField (AC00, 0x04, SAC1)
> ...
> CreateByteField (AC00, Zero, SA00)
> CreateByteField (AC00, One, SA01)
> CreateByteField (AC00, 0x02, SA02)
> CreateByteField (AC00, 0x03, SA03)
> CreateByteField (AC00, 0x04, SA04)
> ...
> Method (WMBC, 3, NotSerialized)
> {
> If (LEqual (Arg1, One))
> {
> Return (GETC (Arg0))
> }
>
> If (LEqual (Arg1, 0x02))
> {
> Return (SETC (Arg0, Arg2))
> }
> ...
> Method (SETC, 2, NotSerialized)
> {
> If (LEqual (Arg0, Zero))
> {
> Store (Arg1, AC00)
> OEMF (AC00)
> Return (SAC0)
> }
> ...
> Method (OEMF, 1, NotSerialized)
> {
> If (LEqual (SAC1, 0xEC000300))
> {
> Store (0x73, DBG8)
> Store ("LS", SAC0)
> Return (SAC0)
> }
>
> If (LEqual (SAC1, 0xEC000000))
> {
> WKBC (SA00, SA01, SA02, SA03)
> Return (SAC0)
> }
> ...
>
>
> Note that it uses only buffer AC00 to store and read the
> parameters, so parallel calls will overwrite the value in AC00
> (referenced as SAC?? and SA?? in some places) and some commands
> will fail or have unpredicted behaviour.
>
> Placing the lock prevents the parallel echo/rfkill command I placed
> above as example to fail, all writes/commands are sent successfuly.
>
> I'm attaching here DSDT of both machines I have for you to see the
> entire code.
Too long reply and forgot to attach it :P
here it goes the two gzipped.
--
[]'s
Herton
[-- Attachment #2: DSDT-DA18IE.dsl.gz --]
[-- Type: application/x-gzip, Size: 20796 bytes --]
[-- Attachment #3: DSDT-DA18IM.dsl.gz --]
[-- Type: application/x-gzip, Size: 18424 bytes --]
next prev parent reply other threads:[~2010-12-01 16:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-30 17:27 [RFC][PATCH] New ACPI-WMI driver for shuttle machines Herton Ronaldo Krzesinski
2010-11-30 23:22 ` Corentin Chary
2010-12-01 16:14 ` Herton Ronaldo Krzesinski
2010-12-01 16:17 ` Herton Ronaldo Krzesinski [this message]
2010-12-01 20:05 ` Corentin Chary
2010-12-10 0:12 ` Herton Ronaldo Krzesinski
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=20101201141759.18f6f901@gotham.conectiva \
--to=herton@mandriva.com.br \
--cc=corentin.chary@gmail.com \
--cc=platform-driver-x86@vger.kernel.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