Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On Thursday, February 20, 2014 09:26:39 AM Tejun Heo wrote: > On Thu, Feb 20, 2014 at 02:47:19AM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > Modify the SATA subsystem to add hotplug contexts to ACPI companions > > of SATA devices and ports instead of registering special ACPI dock > > operations using register_hotplug_dock_device(). > > > > That change will allow the entire code handling those special ACPI > > dock operations to be dropped in the next commit. > > > > Signed-off-by: Rafael J. Wysocki > > --- > > > > As noted by Aaron, the hotplug contexts are not freed during ATA device > > unregistration, but that is not necessary, because the struct acpi_device > > things they are attached to never go away. However, they obviously should > > not be created more than once per struct acpi_device, so I've modified the > > patch to skip the creation of hotplug contexts for devices that already > > have them. > > Please feel free to route with the rest of acpi changes. I will. > Acked-by: Tejun Heo Thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On Thu, Feb 20, 2014 at 02:47:19AM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Modify the SATA subsystem to add hotplug contexts to ACPI companions > of SATA devices and ports instead of registering special ACPI dock > operations using register_hotplug_dock_device(). > > That change will allow the entire code handling those special ACPI > dock operations to be dropped in the next commit. > > Signed-off-by: Rafael J. Wysocki > --- > > As noted by Aaron, the hotplug contexts are not freed during ATA device > unregistration, but that is not necessary, because the struct acpi_device > things they are attached to never go away. However, they obviously should > not be created more than once per struct acpi_device, so I've modified the > patch to skip the creation of hotplug contexts for devices that already > have them. Please feel free to route with the rest of acpi changes. Acked-by: Tejun Heo Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On 02/20/2014 09:47 AM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Modify the SATA subsystem to add hotplug contexts to ACPI companions > of SATA devices and ports instead of registering special ACPI dock > operations using register_hotplug_dock_device(). > > That change will allow the entire code handling those special ACPI > dock operations to be dropped in the next commit. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Aaron Lu -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On 02/20/2014 09:47 AM, Rafael J. Wysocki wrote: From: Rafael J. Wysocki rafael.j.wyso...@intel.com Modify the SATA subsystem to add hotplug contexts to ACPI companions of SATA devices and ports instead of registering special ACPI dock operations using register_hotplug_dock_device(). That change will allow the entire code handling those special ACPI dock operations to be dropped in the next commit. Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com Reviewed-by: Aaron Lu aaron...@intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On Thu, Feb 20, 2014 at 02:47:19AM +0100, Rafael J. Wysocki wrote: From: Rafael J. Wysocki rafael.j.wyso...@intel.com Modify the SATA subsystem to add hotplug contexts to ACPI companions of SATA devices and ports instead of registering special ACPI dock operations using register_hotplug_dock_device(). That change will allow the entire code handling those special ACPI dock operations to be dropped in the next commit. Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com --- As noted by Aaron, the hotplug contexts are not freed during ATA device unregistration, but that is not necessary, because the struct acpi_device things they are attached to never go away. However, they obviously should not be created more than once per struct acpi_device, so I've modified the patch to skip the creation of hotplug contexts for devices that already have them. Please feel free to route with the rest of acpi changes. Acked-by: Tejun Heo t...@kernel.org Thanks. -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
On Thursday, February 20, 2014 09:26:39 AM Tejun Heo wrote: On Thu, Feb 20, 2014 at 02:47:19AM +0100, Rafael J. Wysocki wrote: From: Rafael J. Wysocki rafael.j.wyso...@intel.com Modify the SATA subsystem to add hotplug contexts to ACPI companions of SATA devices and ports instead of registering special ACPI dock operations using register_hotplug_dock_device(). That change will allow the entire code handling those special ACPI dock operations to be dropped in the next commit. Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com --- As noted by Aaron, the hotplug contexts are not freed during ATA device unregistration, but that is not necessary, because the struct acpi_device things they are attached to never go away. However, they obviously should not be created more than once per struct acpi_device, so I've modified the patch to skip the creation of hotplug contexts for devices that already have them. Please feel free to route with the rest of acpi changes. I will. Acked-by: Tejun Heo t...@kernel.org Thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
From: Rafael J. Wysocki Modify the SATA subsystem to add hotplug contexts to ACPI companions of SATA devices and ports instead of registering special ACPI dock operations using register_hotplug_dock_device(). That change will allow the entire code handling those special ACPI dock operations to be dropped in the next commit. Signed-off-by: Rafael J. Wysocki --- As noted by Aaron, the hotplug contexts are not freed during ATA device unregistration, but that is not necessary, because the struct acpi_device things they are attached to never go away. However, they obviously should not be created more than once per struct acpi_device, so I've modified the patch to skip the creation of hotplug contexts for devices that already have them. Thanks, Rafael --- drivers/ata/libata-acpi.c | 76 +- 1 file changed, 49 insertions(+), 27 deletions(-) Index: linux-pm/drivers/ata/libata-acpi.c === --- linux-pm.orig/drivers/ata/libata-acpi.c +++ linux-pm/drivers/ata/libata-acpi.c @@ -38,6 +38,16 @@ static void ata_acpi_clear_gtf(struct at dev->gtf_cache = NULL; } +struct ata_acpi_hotplug_context { + struct acpi_hotplug_context hp; + union { + struct ata_port *ap; + struct ata_device *dev; + } data; +}; + +#define ata_hotplug_data(context) (container_of((context), struct ata_acpi_hotplug_context, hp)->data) + /** * ata_dev_acpi_handle - provide the acpi_handle for an ata_device * @dev: the acpi_handle returned will correspond to this device @@ -121,18 +131,17 @@ static void ata_acpi_handle_hotplug(stru ata_port_wait_eh(ap); } -static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) +static int ata_acpi_dev_notify_dock(struct acpi_device *adev, u32 event) { - struct ata_device *dev = data; - + struct ata_device *dev = ata_hotplug_data(adev->hp).dev; ata_acpi_handle_hotplug(dev->link->ap, dev, event); + return 0; } -static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data) +static int ata_acpi_ap_notify_dock(struct acpi_device *adev, u32 event) { - struct ata_port *ap = data; - - ata_acpi_handle_hotplug(ap, NULL, event); + ata_acpi_handle_hotplug(ata_hotplug_data(adev->hp).ap, NULL, event); + return 0; } static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev, @@ -154,31 +163,23 @@ static void ata_acpi_uevent(struct ata_p } } -static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data) +static void ata_acpi_ap_uevent(struct acpi_device *adev, u32 event) { - ata_acpi_uevent(data, NULL, event); + ata_acpi_uevent(ata_hotplug_data(adev->hp).ap, NULL, event); } -static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data) +static void ata_acpi_dev_uevent(struct acpi_device *adev, u32 event) { - struct ata_device *dev = data; + struct ata_device *dev = ata_hotplug_data(adev->hp).dev; 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, -}; - /* bind acpi handle to pata port */ void ata_acpi_bind_port(struct ata_port *ap) { struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); + struct acpi_device *adev; + struct ata_acpi_hotplug_context *context; if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion) return; @@ -188,9 +189,19 @@ void ata_acpi_bind_port(struct ata_port if (ata_acpi_gtm(ap, >__acpi_init_gtm) == 0) ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; - /* we might be on a docking station */ - register_hotplug_dock_device(ACPI_HANDLE(>tdev), -_acpi_ap_dock_ops, ap, NULL, NULL); + adev = ACPI_COMPANION(>tdev); + if (!adev || adev->hp) + return; + + context = kzalloc(sizeof(*context), GFP_KERNEL); + if (!context) + return; + + context->data.ap = ap; + acpi_lock_hp_context(); + acpi_set_hp_context(adev, >hp, ata_acpi_ap_notify_dock, + ata_acpi_ap_uevent, NULL); + acpi_unlock_hp_context(); } void ata_acpi_bind_dev(struct ata_device *dev) @@ -198,7 +209,8 @@ void ata_acpi_bind_dev(struct ata_device struct ata_port *ap = dev->link->ap; struct acpi_device *port_companion = ACPI_COMPANION(>tdev); struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev); - struct acpi_device *parent; + struct acpi_device *parent, *adev; + struct ata_acpi_hotplug_context *context;
[Update][PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
From: Rafael J. Wysocki rafael.j.wyso...@intel.com Modify the SATA subsystem to add hotplug contexts to ACPI companions of SATA devices and ports instead of registering special ACPI dock operations using register_hotplug_dock_device(). That change will allow the entire code handling those special ACPI dock operations to be dropped in the next commit. Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com --- As noted by Aaron, the hotplug contexts are not freed during ATA device unregistration, but that is not necessary, because the struct acpi_device things they are attached to never go away. However, they obviously should not be created more than once per struct acpi_device, so I've modified the patch to skip the creation of hotplug contexts for devices that already have them. Thanks, Rafael --- drivers/ata/libata-acpi.c | 76 +- 1 file changed, 49 insertions(+), 27 deletions(-) Index: linux-pm/drivers/ata/libata-acpi.c === --- linux-pm.orig/drivers/ata/libata-acpi.c +++ linux-pm/drivers/ata/libata-acpi.c @@ -38,6 +38,16 @@ static void ata_acpi_clear_gtf(struct at dev-gtf_cache = NULL; } +struct ata_acpi_hotplug_context { + struct acpi_hotplug_context hp; + union { + struct ata_port *ap; + struct ata_device *dev; + } data; +}; + +#define ata_hotplug_data(context) (container_of((context), struct ata_acpi_hotplug_context, hp)-data) + /** * ata_dev_acpi_handle - provide the acpi_handle for an ata_device * @dev: the acpi_handle returned will correspond to this device @@ -121,18 +131,17 @@ static void ata_acpi_handle_hotplug(stru ata_port_wait_eh(ap); } -static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) +static int ata_acpi_dev_notify_dock(struct acpi_device *adev, u32 event) { - struct ata_device *dev = data; - + struct ata_device *dev = ata_hotplug_data(adev-hp).dev; ata_acpi_handle_hotplug(dev-link-ap, dev, event); + return 0; } -static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data) +static int ata_acpi_ap_notify_dock(struct acpi_device *adev, u32 event) { - struct ata_port *ap = data; - - ata_acpi_handle_hotplug(ap, NULL, event); + ata_acpi_handle_hotplug(ata_hotplug_data(adev-hp).ap, NULL, event); + return 0; } static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev, @@ -154,31 +163,23 @@ static void ata_acpi_uevent(struct ata_p } } -static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data) +static void ata_acpi_ap_uevent(struct acpi_device *adev, u32 event) { - ata_acpi_uevent(data, NULL, event); + ata_acpi_uevent(ata_hotplug_data(adev-hp).ap, NULL, event); } -static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data) +static void ata_acpi_dev_uevent(struct acpi_device *adev, u32 event) { - struct ata_device *dev = data; + struct ata_device *dev = ata_hotplug_data(adev-hp).dev; 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, -}; - /* bind acpi handle to pata port */ void ata_acpi_bind_port(struct ata_port *ap) { struct acpi_device *host_companion = ACPI_COMPANION(ap-host-dev); + struct acpi_device *adev; + struct ata_acpi_hotplug_context *context; if (libata_noacpi || ap-flags ATA_FLAG_ACPI_SATA || !host_companion) return; @@ -188,9 +189,19 @@ void ata_acpi_bind_port(struct ata_port if (ata_acpi_gtm(ap, ap-__acpi_init_gtm) == 0) ap-pflags |= ATA_PFLAG_INIT_GTM_VALID; - /* we might be on a docking station */ - register_hotplug_dock_device(ACPI_HANDLE(ap-tdev), -ata_acpi_ap_dock_ops, ap, NULL, NULL); + adev = ACPI_COMPANION(ap-tdev); + if (!adev || adev-hp) + return; + + context = kzalloc(sizeof(*context), GFP_KERNEL); + if (!context) + return; + + context-data.ap = ap; + acpi_lock_hp_context(); + acpi_set_hp_context(adev, context-hp, ata_acpi_ap_notify_dock, + ata_acpi_ap_uevent, NULL); + acpi_unlock_hp_context(); } void ata_acpi_bind_dev(struct ata_device *dev) @@ -198,7 +209,8 @@ void ata_acpi_bind_dev(struct ata_device struct ata_port *ap = dev-link-ap; struct acpi_device *port_companion = ACPI_COMPANION(ap-tdev); struct acpi_device *host_companion = ACPI_COMPANION(ap-host-dev); - struct acpi_device *parent; + struct acpi_device *parent, *adev;