Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1625862 > unrolled thread

Re: [PATCH 2/3] ACPI: Remove platform devices from a bus on removal

Started byjoeyli <jlee@suse.com>
First post2017-04-19 09:00 +0200
Last post2017-04-19 09:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/3] ACPI: Remove platform devices from a bus on removal joeyli <jlee@suse.com> - 2017-04-19 09:00 +0200

#1625862 — Re: [PATCH 2/3] ACPI: Remove platform devices from a bus on removal

Fromjoeyli <jlee@suse.com>
Date2017-04-19 09:00 +0200
SubjectRe: [PATCH 2/3] ACPI: Remove platform devices from a bus on removal
Message-ID<txRKO-8uq-25@gated-at.bofh.it>
On Wed, Apr 19, 2017 at 02:50:17PM +0800, joeyli wrote:
> On Wed, Mar 22, 2017 at 06:33:24PM +0100, Joerg Roedel wrote:
> > From: Joerg Roedel <jroedel@suse.de>
> > 
> > The function acpi_bus_attach() creates platform_devices if
> > this is specified by the firmware. But in acpi_bus_trim()
> > these devices are not removed, leaving a dangling reference
> > to the parent device.
> > 
> > In the case of a PCI root-bus, this results in the
> > host_bridge device not being released on hot-remove.
> > 
> > Fix it by scanning the list of platform_devices for devices
> > to be removed with the bus.
> > 
> > Signed-off-by: Joerg Roedel <jroedel@suse.de>
> > ---
> >  drivers/acpi/scan.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> > index 1926918..b07518b 100644
> > --- a/drivers/acpi/scan.c
> > +++ b/drivers/acpi/scan.c
> > @@ -13,6 +13,7 @@
> >  #include <linux/dmi.h>
> >  #include <linux/nls.h>
> >  #include <linux/dma-mapping.h>
> > +#include <linux/platform_device.h>
> >  
> >  #include <asm/pgtable.h>
> >  
> > @@ -1928,6 +1929,25 @@ int acpi_bus_scan(acpi_handle handle)
> >  EXPORT_SYMBOL(acpi_bus_scan);
> >  
> >  /**
> > + * acpi_bus_trim_platform_device - Check and remove a platform device
> > + *				   from a bus
> > + * @dev: Platform device to check
> > + * @data: pointer to the acpi_device to check dev against
> > + *
> > + * Checks whether the platform_device dev belongs to the acpi_device
> > + * data and unregisters dev if it matches.
> > + */
> > +static int acpi_bus_trim_platform_device(struct device *dev, void *data)
> > +{
> > +	struct acpi_device *adev = data;
> > +
> > +	if (dev->fwnode == acpi_fwnode_handle(adev))
> > +		platform_device_unregister(to_platform_device(dev));
> > +
> > +	return 0;
> > +}
> > +
> > +/**
> >   * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
> >   * @adev: Root of the ACPI namespace scope to walk.
> >   *
> > @@ -1950,6 +1970,12 @@ void acpi_bus_trim(struct acpi_device *adev)
> >  	} else {
> >  		device_release_driver(&adev->dev);
> >  	}
> > +
> > +	/* Remove platform devices from the bus */
> > +	if (adev->pnp.type.platform_id)
> 
> This patch cases that dock_notify() is broken in find_dock_station()
> because the dock_station platform device was removed.
> 
> If anyone wants to apply this patch, then the dock device should be
> excluded:
> 
> +	if (is_dock_device(adev) && adev->pnp.type.platform_id)

Sorry, it should be:
+	if (!is_dock_device(adev) && adev->pnp.type.platform_id)

> 
> > +		bus_for_each_dev(&platform_bus_type, NULL, adev,
> > +				 acpi_bus_trim_platform_device);
> > +
> >  	/*
> >  	 * Most likely, the device is going away, so put it into D3cold before
> >  	 * that.
>

Joey Lee 

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web