public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Samuel Ortiz <sameo@linux.intel.com>,
	Faouaz TENOUTIT <faouaz.tenoutit@intel.com>
Cc: linux-acpi@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v4 1/2] USB: Use ACPI device information
Date: Thu, 04 Sep 2014 00:02:21 +0200	[thread overview]
Message-ID: <2546089.bskfW4VexO@vostro.rjw.lan> (raw)
In-Reply-To: <1407950132-15863-1-git-send-email-sameo@linux.intel.com>

On Wednesday, August 13, 2014 07:15:31 PM Samuel Ortiz wrote:
> From: Faouaz TENOUTIT <faouaz.tenoutit@intel.com>
> 
> Use ACPI device pld information instead of calling
> acpi_get_physical_device_location.
> 
> Signed-off-by: Faouaz TENOUTIT <faouaz.tenoutit@intel.com>
> Acked-by: Samuel Ortiz <samuel.ortiz@intel.com>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There is a problem with this approach I've been overlooking, sorry about that.

Namely, the information returned by _PLD is generally not guaranteed to be
the same every time that object is evaluated, so either we shouldn't cache it,
or we should change the cached data in response to specific device notifications
as described in the _PLD section of the spec.

> ---
>  drivers/acpi/scan.c         | 13 +++++++++++++
>  drivers/usb/core/usb-acpi.c | 14 +++++---------
>  include/acpi/acpi_bus.h     |  1 +
>  3 files changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 0a817ad..2ca42d5 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -767,6 +767,13 @@ static int acpi_device_setup_files(struct acpi_device *dev)
>  						    &dev_attr_real_power_state);
>  	}
>  
> +	/*
> +	 * If device has _PLD, initialize the 'pld' struct
> +	 */
> +	if (acpi_has_method(dev->handle, "_PLD"))
> +		acpi_get_physical_device_location(dev->handle,
> +						  &dev->pld);
> +
>  end:
>  	return result;
>  }
> @@ -806,6 +813,12 @@ static void acpi_device_remove_files(struct acpi_device *dev)
>  		device_remove_file(&dev->dev, &dev_attr_status);
>  	if (dev->handle)
>  		device_remove_file(&dev->dev, &dev_attr_path);
> +
> +	/*
> +	 * If device has _PLD, free 'pld' struct
> +	 */
> +	if (dev->pld)
> +		ACPI_FREE(dev->pld);
>  }
>  /* --------------------------------------------------------------------------
>  			ACPI Bus operations
> diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
> index 2776cfe..940b3e5 100644
> --- a/drivers/usb/core/usb-acpi.c
> +++ b/drivers/usb/core/usb-acpi.c
> @@ -157,9 +157,6 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev)
>  	} else if (is_usb_port(dev)) {
>  		struct usb_port *port_dev = to_usb_port(dev);
>  		int port1 = port_dev->portnum;
> -		struct acpi_pld_info *pld;
> -		acpi_handle *handle;
> -		acpi_status status;
>  
>  		/* Get the struct usb_device point of port's hub */
>  		udev = to_usb_device(dev->parent->parent);
> @@ -190,15 +187,14 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev)
>  			if (!adev)
>  				return NULL;
>  		}
> -		handle = adev->handle;
> -		status = acpi_get_physical_device_location(handle, &pld);
> -		if (ACPI_FAILURE(status) || !pld)
> +		if (!adev->pld)
>  			return adev;
>  
>  		port_dev->location = USB_ACPI_LOCATION_VALID
> -			| pld->group_token << 8 | pld->group_position;
> -		port_dev->connect_type = usb_acpi_get_connect_type(handle, pld);
> -		ACPI_FREE(pld);
> +			| adev->pld->group_token << 8
> +			| adev->pld->group_position;
> +		port_dev->connect_type = usb_acpi_get_connect_type(adev->handle,
> +								   adev->pld);
>  
>  		return adev;
>  	}
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index bcfd808..e439cfa 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -357,6 +357,7 @@ struct acpi_device {
>  	struct acpi_scan_handler *handler;
>  	struct acpi_hotplug_context *hp;
>  	struct acpi_driver *driver;
> +	struct acpi_pld_info *pld;
>  	void *driver_data;
>  	struct device dev;
>  	unsigned int physical_node_count;
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

      parent reply	other threads:[~2014-09-03 21:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 17:15 [PATCH v4 1/2] USB: Use ACPI device information Samuel Ortiz
2014-08-13 17:15 ` [PATCH v4 2/2] ACPI: Export PLD (Physical Location of Device) Samuel Ortiz
2014-08-13 22:05   ` Greg Kroah-Hartman
2014-08-14  0:15     ` Rafael J. Wysocki
2014-08-14  0:46       ` Greg Kroah-Hartman
2014-08-13 22:03 ` [PATCH v4 1/2] USB: Use ACPI device information Greg Kroah-Hartman
2014-08-14  0:17   ` Rafael J. Wysocki
2014-08-14  0:45     ` Greg Kroah-Hartman
2014-08-15  0:03       ` Rafael J. Wysocki
2014-09-03 22:02 ` Rafael J. Wysocki [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=2546089.bskfW4VexO@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=faouaz.tenoutit@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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