Patchwork libata: remove dead code from libata-acpi.c

login
register
mail settings
Submitter Jiang Liu
Date June 15, 2013, 3:02 a.m.
Message ID <1371265368-7334-1-git-send-email-liuj97@gmail.com>
Download mbox | patch
Permalink /patch/251577/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Jiang Liu - June 15, 2013, 3:02 a.m.
From: Liu Jiang <liu97@gmail.com>

Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
removed ACPI dock notification related code, but there's some dead
code left, so clean up it.

Cc: Tejun Heo <tj@kernel.org>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Aaron Lu <aaron.lu@intel.com>
Cc: linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Liu Jiang <jiang.liu@huawei.com>
---
 drivers/ata/libata-acpi.c | 123 ----------------------------------------------
 1 file changed, 123 deletions(-)
Aaron Lu - June 17, 2013, 1:50 a.m.
On 06/15/2013 11:02 AM, Liu Jiang wrote:
> From: Liu Jiang <liu97@gmail.com>
> 
> Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
> removed ACPI dock notification related code, but there's some dead
> code left, so clean up it.

I never noticed this, but it looks to be the case...

I'm not sure the dock notification code is removed intentionally or
mistakenly though, if it is a mistake, then instead of removing the left
code here, we probably should add the dock notification code back.

But I have no test system or any knowledge about how ata dock works, so
I may be wrong :-)

Thanks,
Aaron

> 
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Matthew Garrett <mjg@redhat.com>
> Cc: Aaron Lu <aaron.lu@intel.com>
> Cc: linux-ide@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Liu Jiang <jiang.liu@huawei.com>
> ---
>  drivers/ata/libata-acpi.c | 123 ----------------------------------------------
>  1 file changed, 123 deletions(-)
> 
> diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
> index 87f2f39..e50c987 100644
> --- a/drivers/ata/libata-acpi.c
> +++ b/drivers/ata/libata-acpi.c
> @@ -91,129 +91,6 @@ acpi_handle ata_dev_acpi_handle(struct ata_device *dev)
>  }
>  EXPORT_SYMBOL(ata_dev_acpi_handle);
>  
> -/* @ap and @dev are the same as ata_acpi_handle_hotplug() */
> -static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
> -{
> -	if (dev)
> -		dev->flags |= ATA_DFLAG_DETACH;
> -	else {
> -		struct ata_link *tlink;
> -		struct ata_device *tdev;
> -
> -		ata_for_each_link(tlink, ap, EDGE)
> -			ata_for_each_dev(tdev, tlink, ALL)
> -				tdev->flags |= ATA_DFLAG_DETACH;
> -	}
> -
> -	ata_port_schedule_eh(ap);
> -}
> -
> -/**
> - * ata_acpi_handle_hotplug - ACPI event handler backend
> - * @ap: ATA port ACPI event occurred
> - * @dev: ATA device ACPI event occurred (can be NULL)
> - * @event: ACPI event which occurred
> - *
> - * All ACPI bay / device realted events end up in this function.  If
> - * the event is port-wide @dev is NULL.  If the event is specific to a
> - * device, @dev points to it.
> - *
> - * Hotplug (as opposed to unplug) notification is always handled as
> - * port-wide while unplug only kills the target device on device-wide
> - * event.
> - *
> - * LOCKING:
> - * ACPI notify handler context.  May sleep.
> - */
> -static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
> -				    u32 event)
> -{
> -	struct ata_eh_info *ehi = &ap->link.eh_info;
> -	int wait = 0;
> -	unsigned long flags;
> -
> -	spin_lock_irqsave(ap->lock, flags);
> -	/*
> -	 * When dock driver calls into the routine, it will always use
> -	 * ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
> -	 * ACPI_NOTIFY_EJECT_REQUEST for remove
> -	 */
> -	switch (event) {
> -	case ACPI_NOTIFY_BUS_CHECK:
> -	case ACPI_NOTIFY_DEVICE_CHECK:
> -		ata_ehi_push_desc(ehi, "ACPI event");
> -
> -		ata_ehi_hotplugged(ehi);
> -		ata_port_freeze(ap);
> -		break;
> -	case ACPI_NOTIFY_EJECT_REQUEST:
> -		ata_ehi_push_desc(ehi, "ACPI event");
> -
> -		ata_acpi_detach_device(ap, dev);
> -		wait = 1;
> -		break;
> -	}
> -
> -	spin_unlock_irqrestore(ap->lock, flags);
> -
> -	if (wait)
> -		ata_port_wait_eh(ap);
> -}
> -
> -static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
> -{
> -	struct ata_device *dev = data;
> -
> -	ata_acpi_handle_hotplug(dev->link->ap, dev, event);
> -}
> -
> -static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
> -{
> -	struct ata_port *ap = data;
> -
> -	ata_acpi_handle_hotplug(ap, NULL, event);
> -}
> -
> -static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
> -	u32 event)
> -{
> -	struct kobject *kobj = NULL;
> -	char event_string[20];
> -	char *envp[] = { event_string, NULL };
> -
> -	if (dev) {
> -		if (dev->sdev)
> -			kobj = &dev->sdev->sdev_gendev.kobj;
> -	} else
> -		kobj = &ap->dev->kobj;
> -
> -	if (kobj) {
> -		snprintf(event_string, 20, "BAY_EVENT=%d", event);
> -		kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
> -	}
> -}
> -
> -static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data)
> -{
> -	ata_acpi_uevent(data, NULL, event);
> -}
> -
> -static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
> -{
> -	struct ata_device *dev = data;
> -	ata_acpi_uevent(dev->link->ap, dev, event);
> -}
> -
> -static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
> -	.handler = ata_acpi_dev_notify_dock,
> -	.uevent = ata_acpi_dev_uevent,
> -};
> -
> -static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
> -	.handler = ata_acpi_ap_notify_dock,
> -	.uevent = ata_acpi_ap_uevent,
> -};
> -
>  /**
>   * ata_acpi_dissociate - dissociate ATA host from ACPI objects
>   * @host: target ATA host
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo - June 17, 2013, 6:01 p.m.
On Mon, Jun 17, 2013 at 09:50:20AM +0800, Aaron Lu wrote:
> On 06/15/2013 11:02 AM, Liu Jiang wrote:
> > From: Liu Jiang <liu97@gmail.com>
> > 
> > Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
> > removed ACPI dock notification related code, but there's some dead
> > code left, so clean up it.
> 
> I never noticed this, but it looks to be the case...
> 
> I'm not sure the dock notification code is removed intentionally or
> mistakenly though, if it is a mistake, then instead of removing the left
> code here, we probably should add the dock notification code back.
> 
> But I have no test system or any knowledge about how ata dock works, so
> I may be wrong :-)

Looks like a regression to me.  We're probably locking up on some
older laptops which connects optical drives with hotpluggable PATA.
Matthew, can you please fix it?

Thanks.
Jiang Liu - June 18, 2013, 1:15 a.m.
On 2013/6/18 2:01, Tejun Heo wrote:
> On Mon, Jun 17, 2013 at 09:50:20AM +0800, Aaron Lu wrote:
>> On 06/15/2013 11:02 AM, Liu Jiang wrote:
>>> From: Liu Jiang <liu97@gmail.com>
>>>
>>> Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
>>> removed ACPI dock notification related code, but there's some dead
>>> code left, so clean up it.
>>
>> I never noticed this, but it looks to be the case...
>>
>> I'm not sure the dock notification code is removed intentionally or
>> mistakenly though, if it is a mistake, then instead of removing the left
>> code here, we probably should add the dock notification code back.
>>
>> But I have no test system or any knowledge about how ata dock works, so
>> I may be wrong :-)
>
> Looks like a regression to me.  We're probably locking up on some
> older laptops which connects optical drives with hotpluggable PATA.
> Matthew, can you please fix it?
>
> Thanks.
>
Yeah, Aaron is right. We should restore the dock notification
handler to support ATA hotplug on some IBM laptops.
Regards!
Gerry

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Aaron Lu - June 18, 2013, 9:16 a.m.
On 06/18/2013 02:01 AM, Tejun Heo wrote:
> On Mon, Jun 17, 2013 at 09:50:20AM +0800, Aaron Lu wrote:
>> On 06/15/2013 11:02 AM, Liu Jiang wrote:
>>> From: Liu Jiang <liu97@gmail.com>
>>>
>>> Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
>>> removed ACPI dock notification related code, but there's some dead
>>> code left, so clean up it.
>>
>> I never noticed this, but it looks to be the case...
>>
>> I'm not sure the dock notification code is removed intentionally or
>> mistakenly though, if it is a mistake, then instead of removing the left
>> code here, we probably should add the dock notification code back.
>>
>> But I have no test system or any knowledge about how ata dock works, so
>> I may be wrong :-)
> 
> Looks like a regression to me.  We're probably locking up on some
> older laptops which connects optical drives with hotpluggable PATA.
> Matthew, can you please fix it?

A user just reported a bug for this:
https://bugzilla.kernel.org/show_bug.cgi?id=59871

And bisected to commit 30dcf76acc69. I proposed a fix patch there, let's
see what the user's test result.

Thanks,
Aaron
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 87f2f39..e50c987 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -91,129 +91,6 @@  acpi_handle ata_dev_acpi_handle(struct ata_device *dev)
 }
 EXPORT_SYMBOL(ata_dev_acpi_handle);
 
-/* @ap and @dev are the same as ata_acpi_handle_hotplug() */
-static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
-{
-	if (dev)
-		dev->flags |= ATA_DFLAG_DETACH;
-	else {
-		struct ata_link *tlink;
-		struct ata_device *tdev;
-
-		ata_for_each_link(tlink, ap, EDGE)
-			ata_for_each_dev(tdev, tlink, ALL)
-				tdev->flags |= ATA_DFLAG_DETACH;
-	}
-
-	ata_port_schedule_eh(ap);
-}
-
-/**
- * ata_acpi_handle_hotplug - ACPI event handler backend
- * @ap: ATA port ACPI event occurred
- * @dev: ATA device ACPI event occurred (can be NULL)
- * @event: ACPI event which occurred
- *
- * All ACPI bay / device realted events end up in this function.  If
- * the event is port-wide @dev is NULL.  If the event is specific to a
- * device, @dev points to it.
- *
- * Hotplug (as opposed to unplug) notification is always handled as
- * port-wide while unplug only kills the target device on device-wide
- * event.
- *
- * LOCKING:
- * ACPI notify handler context.  May sleep.
- */
-static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
-				    u32 event)
-{
-	struct ata_eh_info *ehi = &ap->link.eh_info;
-	int wait = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(ap->lock, flags);
-	/*
-	 * When dock driver calls into the routine, it will always use
-	 * ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
-	 * ACPI_NOTIFY_EJECT_REQUEST for remove
-	 */
-	switch (event) {
-	case ACPI_NOTIFY_BUS_CHECK:
-	case ACPI_NOTIFY_DEVICE_CHECK:
-		ata_ehi_push_desc(ehi, "ACPI event");
-
-		ata_ehi_hotplugged(ehi);
-		ata_port_freeze(ap);
-		break;
-	case ACPI_NOTIFY_EJECT_REQUEST:
-		ata_ehi_push_desc(ehi, "ACPI event");
-
-		ata_acpi_detach_device(ap, dev);
-		wait = 1;
-		break;
-	}
-
-	spin_unlock_irqrestore(ap->lock, flags);
-
-	if (wait)
-		ata_port_wait_eh(ap);
-}
-
-static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
-{
-	struct ata_device *dev = data;
-
-	ata_acpi_handle_hotplug(dev->link->ap, dev, event);
-}
-
-static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
-{
-	struct ata_port *ap = data;
-
-	ata_acpi_handle_hotplug(ap, NULL, event);
-}
-
-static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
-	u32 event)
-{
-	struct kobject *kobj = NULL;
-	char event_string[20];
-	char *envp[] = { event_string, NULL };
-
-	if (dev) {
-		if (dev->sdev)
-			kobj = &dev->sdev->sdev_gendev.kobj;
-	} else
-		kobj = &ap->dev->kobj;
-
-	if (kobj) {
-		snprintf(event_string, 20, "BAY_EVENT=%d", event);
-		kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
-	}
-}
-
-static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data)
-{
-	ata_acpi_uevent(data, NULL, event);
-}
-
-static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
-{
-	struct ata_device *dev = data;
-	ata_acpi_uevent(dev->link->ap, dev, event);
-}
-
-static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
-	.handler = ata_acpi_dev_notify_dock,
-	.uevent = ata_acpi_dev_uevent,
-};
-
-static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
-	.handler = ata_acpi_ap_notify_dock,
-	.uevent = ata_acpi_ap_uevent,
-};
-
 /**
  * ata_acpi_dissociate - dissociate ATA host from ACPI objects
  * @host: target ATA host