From: Peter Wu <peter-VTkQYDcBqhK7DlmcbJSQ7g@public.gmane.org>
To: Marcos Souza <marcos.souza.org-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: airlied-cv59FeDIM0c@public.gmane.org,
dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
christian.koenig-5C7GfCeVMHo@public.gmane.org
Subject: Re: [PATCH] gpu/nouveau/nouveau_acpi.c: Fix Type Mismatch ACPI warning
Date: Sun, 22 May 2016 12:25:45 +0200 [thread overview]
Message-ID: <20160522102545.GA1970@al> (raw)
In-Reply-To: <CAH0vN5+s8CGjTwW_W7Z-AC9ZMsq7GqygYtCbEkL2+9y3DhJWAw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Fri, May 20, 2016 at 02:22:57AM +0000, Marcos Souza wrote:
[..]
> > > I don't know if this is the right thing to do, I just looked at
> > intel_acpi.c to check how to use/check for ACPI Package.
> > > The patch below silenced the "type mismatch" warnings, and some of the
> > "evaluated _DSM" ones.
> > >
> > > If this is not the right approach, please let me know how to fix it, I
> > don't have knowledge in ACPI, but I really want to help.
> > >
> > > drivers/gpu/drm/nouveau/nouveau_acpi.c | 14 +-------------
> > > 1 file changed, 1 insertion(+), 13 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> > b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> > > index cdf5227..f04aef3 100644
> > > --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> > > +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> > > @@ -73,22 +73,10 @@ static const char nouveau_op_dsm_muid[] = {
> > >
> > > static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg,
> > uint32_t *result)
> > > {
> > > - int i;
> > > union acpi_object *obj;
> > > - char args_buff[4];
> > > - union acpi_object argv4 = {
> > > - .buffer.type = ACPI_TYPE_BUFFER,
> > > - .buffer.length = 4,
> > > - .buffer.pointer = args_buff
> > > - };
> > > -
> > > - /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */
> > > - for (i = 0; i < 4; i++)
> > > - args_buff[i] = (arg >> i * 8) & 0xFF;
> > > -
> > > *result = 0;
> > > obj = acpi_evaluate_dsm_typed(handle, nouveau_op_dsm_muid,
> > 0x00000100,
> > > - func, &argv4, ACPI_TYPE_BUFFER);
> > > + func, NULL, ACPI_TYPE_PACKAGE);
This effectively removes the fourth parameter (actually, using a zero
as fourth argument), making the function useless.
> > The last parameter you give to `acpi_evaluate_dsm_typed()` is the return
> > type
> > you expect (see [3]), which will be a buffer if func is 0, and is
> > implementation dependent otherwise (see section 9.14.1 _DSM of [4]). So you
> > don’t want to change it to ACPI_TYPE_PACKAGE. If you look at the
> > implementation
> > of `acpi_evaluate_dsm()` (which is called by `acpi_evaluate_dsm_typed()`),
> > it
> > will automatically create a package for the 4th argument, if you pass it a
> > NULL
> > pointer (see [5]).
> >
> > [3]:
> > https://github.com/torvalds/linux/blob/46c13450624e36302547a2ac3695f2350fe7ffc3/include/acpi/acpi_bus.h#L69
> > [4]: http://www.acpi.info/DOWNLOADS/ACPI_5_Errata%20A.pdf
> > [5]:
> > https://github.com/torvalds/linux/blob/46c13450624e36302547a2ac3695f2350fe7ffc3/drivers/acpi/utils.c#L628
>
>
> Thanks for all the links. I'll read the docs and send a new version of the
> patch when it makes more sense instead of just replacing random things.
The warning is unavoidable, most firmware expect a Buffer for the fourth
argument (counting from 0, this is Arg3). Excerpt from the DSM method on
a recent Skylake laptop (Clevo P651, but this format is found on many
other models from various manufacturers too):
If ((Arg2 == 0x1A))
{
CreateField (Arg3, 0x18, 0x02, OMPR)
CreateField (Arg3, Zero, One, FLCH)
CreateField (Arg3, One, One, DVSR)
CreateField (Arg3, 0x02, One, DVSC)
(The sections below refer to the one in the ACPI 6.1 document that can
be found at http://uefi.org/specifications.)
The first parameter for CreateField is evaluated as buffer (sec 19.6.21).
According to 19.3.5.6 (Data Types and Type Conversions) an implicit
conversion to a Buffer is only possible from an Integer and String, a
Package does not belong to the possibilities.
Note that the return value may be an integer for unsupported revision
IDs or UUIDs (like 0x80000002). These should be compatible with Buffers
though as stated above and acpi_check_dsm() can handle that case, but
unfortunately sets a Package as fourth argument and can therefore not be
used in nouveau.
--
Kind regards,
Peter Wu
https://lekensteyn.nl
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
prev parent reply other threads:[~2016-05-22 10:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 0:42 [PATCH] gpu/nouveau/nouveau_acpi.c: Fix Type Mismatch ACPI warning Marcos Paulo de Souza
[not found] ` <1463618578-5662-1-git-send-email-marcos.souza.org-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-19 9:49 ` Pierre Moreau
2016-05-20 2:22 ` Marcos Souza
[not found] ` <CAH0vN5+s8CGjTwW_W7Z-AC9ZMsq7GqygYtCbEkL2+9y3DhJWAw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-22 10:25 ` Peter Wu [this message]
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=20160522102545.GA1970@al \
--to=peter-vtkqydcbqhk7dlmcbjsq7g@public.gmane.org \
--cc=airlied-cv59FeDIM0c@public.gmane.org \
--cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=dvhart-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=marcos.souza.org-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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;
as well as URLs for NNTP newsgroup(s).