[ltp] [Fwd: [PATCH] Fixups to ATA ACPI hotplug]
Florian Manschwetus
linux-thinkpad@linux-thinkpad.org
Mon, 19 May 2008 19:33:14 +0200
This is a cryptographically signed message in MIME format.
--------------ms000102080407060607010807
Content-Type: multipart/mixed;
boundary="------------090701040006000706020306"
This is a multi-part message in MIME format.
--------------090701040006000706020306
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
--------------090701040006000706020306
Content-Type: message/rfc822;
name="[PATCH] Fixups to ATA ACPI hotplug.eml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="[PATCH] Fixups to ATA ACPI hotplug.eml"
X-Account-Key: account2
X-Mozilla-Keys:
Return-Path: <linux-acpi-owner@vger.kernel.org>
X-Flags: 1001
Delivered-To: GMX delivery to florianmanschwetus@gmx.de
Received: (qmail invoked by alias); 19 May 2008 16:30:43 -0000
Received: from vger.kernel.org (EHLO vger.kernel.org) [209.132.176.167]
by mx0.gmx.net (mx024) with SMTP; 19 May 2008 18:30:43 +0200
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1752507AbYESQ35 (ORCPT <rfc822;dl9pf@gmx.de> + 3 others);
Mon, 19 May 2008 12:29:57 -0400
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751569AbYESQ35
(ORCPT <rfc822;linux-acpi-outgoing>);
Mon, 19 May 2008 12:29:57 -0400
Received: from cavan.codon.org.uk ([93.93.128.6]:51805 "EHLO
vavatch.codon.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1751313AbYESQ34 (ORCPT
<rfc822;linux-acpi@vger.kernel.org>); Mon, 19 May 2008 12:29:56 -0400
Received: from mjg59 by vavatch.codon.org.uk with local (Exim 4.62)
(envelope-from <mjg59@codon.org.uk>)
id 1Jy8Ew-00047M-Q0; Mon, 19 May 2008 17:29:45 +0100
Date: Mon, 19 May 2008 17:29:34 +0100
From: Matthew Garrett <mjg59@srcf.ucam.org>
To: Tejun Heo <htejun@gmail.com>, linux-ide@vger.kernel.org,
Jeff Garzik <jeff@garzik.org>
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
hmacht@suse.de
Message-ID: <20080519162934.GA15623@srcf.ucam.org>
References: <20080505223357.GA2839@srcf.ucam.org> <20080506081347.GA8688@homac> <20080506082110.GA10355@srcf.ucam.org> <48201987.4020009@gmail.com> <20080506092653.GB4378@homac> <20080506093628.GA12469@srcf.ucam.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080506093628.GA12469@srcf.ucam.org>
User-Agent: Mutt/1.5.12-2006-07-14
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: mjg59@codon.org.uk
X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-26) on
vavatch.codon.org.uk
X-Spam-Status: No, score=0.3 required=4.0 tests=MAILTO_TO_SPAM_ADDR,NO_RELAYS
autolearn=disabled version=3.1.4
Subject: [PATCH] Fixups to ATA ACPI hotplug
X-SA-Exim-Version: 4.2.1 (built Tue, 20 Jun 2006 01:35:45 +0000)
X-SA-Exim-Scanned: Yes (on vavatch.codon.org.uk)
Sender: linux-acpi-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-acpi.vger.kernel.org>
X-Mailing-List: linux-acpi@vger.kernel.org
X-GMX-Antivirus: -1 (not scanned, may not use virus scanner)
X-GMX-Htest: 0.41
X-GMX-Antispam: 0 (Mail was not recognized as spam)
X-GMX-UID: A5MHeZVoYmYSAt+OF3c3+6ZKWkZTQZTe
The libata-acpi.c code currently accepts hotplug messages from both the
port and the device. This does not match the behaviour of the bay
driver, and may result in confusion when two hotplug requests are
received for the same device. This patch limits the hotplug notification
to removable ACPI devices, which in turn allows it to use the _STA
method to determine whether the device has been removed or inserted.
On removal, devices are marked as detached. On insertion, a hotplug scan
is started. This should avoid lockups caused by the ata layer attempting
to scan devices which have been removed. The uevent sending is moved
outside the spinlock in order to avoid a warning generated by it firing
when interrupts are disabled.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
Holger, I'm pretty sure that this deals with the docking station removal
case, but don't have the hardware to test. If EJECT_REQUEST is genuinely
the only notification we receive (ie, no BUS_CHECK or DEVICE_CHECK) then
we'll need to add a separate callback for docking.
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 70b77e0..865a552 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -118,8 +118,8 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap)
ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
}
-static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
- u32 event)
+static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device
+ *dev, u32 event)
{
char event_string[12];
char *envp[] = { event_string, NULL };
@@ -127,39 +127,67 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
struct kobject *kobj = NULL;
int wait = 0;
unsigned long flags;
-
+ acpi_handle handle, tmphandle;
+ unsigned long sta;
+ acpi_status status;
+
if (!ap)
ap = dev->link->ap;
ehi = &ap->link.eh_info;
spin_lock_irqsave(ap->lock, flags);
+ if (dev)
+ handle = dev->acpi_handle;
+ else
+ handle = ap->acpi_handle;
+
+ status = acpi_get_handle(handle, "_EJ0", &tmphandle);
+ if (ACPI_FAILURE(status)) {
+ /* This device is not ejectable */
+ spin_unlock_irqrestore(ap->lock, flags);
+ return;
+ }
+
+ status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
+ if (ACPI_FAILURE(status)) {
+ printk ("Unable to determine bay status\n");
+ spin_unlock_irqrestore(ap->lock, flags);
+ return;
+ }
+
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");
- if (dev)
- dev->flags |= ATA_DFLAG_DETACH;
- else {
- struct ata_link *tlink;
- struct ata_device *tdev;
-
- ata_port_for_each_link(tlink, ap)
- ata_link_for_each_dev(tdev, tlink)
- tdev->flags |= ATA_DFLAG_DETACH;
+ if (!sta) {
+ /* Device has been unplugged */
+ if (dev)
+ dev->flags |= ATA_DFLAG_DETACH;
+ else {
+ struct ata_link *tlink;
+ struct ata_device *tdev;
+
+ ata_port_for_each_link(tlink, ap) {
+ ata_link_for_each_dev(tdev, tlink) {
+ tdev->flags |=
+ ATA_DFLAG_DETACH;
+ }
+ }
+ }
+ ata_port_schedule_eh(ap);
+ wait = 1;
+ } else {
+ ata_ehi_hotplugged(ehi);
+ ata_port_freeze(ap);
}
-
- ata_port_schedule_eh(ap);
- wait = 1;
- break;
}
+ spin_unlock_irqrestore(ap->lock, flags);
+
+ if (wait)
+ ata_port_wait_eh(ap);
+
if (dev) {
if (dev->sdev)
kobj = &dev->sdev->sdev_gendev.kobj;
@@ -170,11 +198,6 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
sprintf(event_string, "BAY_EVENT=%d", event);
kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
}
-
- spin_unlock_irqrestore(ap->lock, flags);
-
- if (wait)
- ata_port_wait_eh(ap);
}
static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data)
--
Matthew Garrett | mjg59@srcf.ucam.org
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
--------------090701040006000706020306--
--------------ms000102080407060607010807
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIK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