All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Mark Brown <broonie@kernel.org>,
	Ronald Tschalaer <ronald@innovation.ch>,
	Federico Lorenzi <florenzi@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Leif Liddy <leif.liddy@gmail.com>,
	Daniel Roschka <danielroschka@phoenitydawn.de>,
	linux-acpi@vger.kernel.org, linux-spi@vger.kernel.org
Subject: Re: [PATCH 2/3] ACPI / property: Support Apple _DSM properties
Date: Thu, 22 Jun 2017 13:04:22 +0300	[thread overview]
Message-ID: <20170622100422.GX629@lahna.fi.intel.com> (raw)
In-Reply-To: <20170622095439.vquuet562i5scl3n@wunner.de>

On Thu, Jun 22, 2017 at 11:54:39AM +0200, Lukas Wunner wrote:
> On Thu, Jun 22, 2017 at 11:06:55AM +0300, Mika Westerberg wrote:
> > On Wed, Jun 21, 2017 at 08:05:53PM +0200, Lukas Wunner wrote:
> > > +	props = acpi_evaluate_dsm_typed(adev->handle, apple_prp_uuid, 1, 0,
> > > +					NULL, ACPI_TYPE_BUFFER);
> > > +	if (!props || !props->buffer.length)
> > > +		goto out_free;
> > > +
> > > +	version = props->buffer.pointer[0];
> > > +	ACPI_FREE(props);
> > > +	if (version != 3) {
> > > +		acpi_handle_err(adev->handle,
> > > +				"unsupported properties version %u\n", version);
> > 
> > I don't think this is error. More like debug if anything.
> 
> It would be good to be able to google for this message to detect if there
> are ever Macs out there which return something different than "3" to this
> _DSM call.  How about KERN_WARN or KERN_INFO?

Well, this is something the user might see and then gets confused on the
grounds: is my machine somehow broken?

> The AppleACPIPlatform.kext which shipped with 10.4.11 (2007) already checked
> for a return value of 3 and the newest Macs still return "3", so this has
> never changed in at least 10 years and the whole issue is thus theoretical.
> I just wanted to be compatible to what macOS does, they check for "3" and
> abort if the return value is different.

Yes, we can check for the return value but there is no need to spam
dmesg for this.

> > > +	if (skipped)
> > > +		acpi_handle_err(adev->handle,
> > > +				"skipped %u properties: wrong type\n", skipped);
> > 
> > Same here.
> 
> This would be a firmware bug.  We've got FW_BUG, FW_WARN, FW_INFO defined in
> include/linux/printk.h.  Granted this is not high priority, but FW_WARN or
> at least FW_INFO would seem to be justified.

or debug :-)

> > > +	WARN_ON(free_space != (void *)newprops + newsize);
> > 
> > Again, there is not need to scare the user if we can't parse these. We
> > can log an error here and give up but definitely no need to trigger
> > backtrace and register dump.
> 
> This is not for parse errors but programming errors.  free_space is a
> pointer into the newprops allocation.
> 
> If (free_space < newprops + newsize) then the allocation was too large
> and we're wasting memory.
> 
> If (free_space > newprops + newsize) then the allocation was too small
> and we've corrupted memory behind the allocation.
> 
> I'm fairly sure the WARN_ON will never trigger but what do I know? :-)

Fair enough.

  reply	other threads:[~2017-06-22 10:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 18:05 [PATCH 0/3] Apple SPI properties Lukas Wunner
2017-06-21 18:05 ` [PATCH 2/3] ACPI / property: Support Apple _DSM properties Lukas Wunner
2017-06-21 23:05   ` Rafael J. Wysocki
2017-06-22  8:57     ` Lukas Wunner
2017-06-22 14:18       ` Rafael J. Wysocki
2017-06-22  8:06   ` Mika Westerberg
2017-06-22  9:54     ` Lukas Wunner
2017-06-22 10:04       ` Mika Westerberg [this message]
2017-06-22 11:24         ` Lukas Wunner
     [not found]           ` <20170622112428.q3hpwpfs4xwumued-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2017-06-22 13:25             ` Mark Brown
2017-06-21 18:05 ` [PATCH 1/3] ACPI / property: Don't evaluate objects for devices w/o handle Lukas Wunner
2017-06-21 18:05 ` [PATCH 3/3] spi: Use Apple device properties in absence of ACPI resources Lukas Wunner
2017-06-22  8:10   ` Mika Westerberg
2017-06-22  8:44     ` Lukas Wunner
2017-06-22  9:28     ` Mark Brown

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=20170622100422.GX629@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=danielroschka@phoenitydawn.de \
    --cc=florenzi@gmail.com \
    --cc=leif.liddy@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=rafael.j.wysocki@intel.com \
    --cc=ronald@innovation.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.