[kernel/f17] Disable runtime PM for hotpluggable ATA ports (rhbz 806676)

Josh Boyer jwboyer at fedoraproject.org
Wed Apr 4 14:45:38 UTC 2012


commit 008280377a64a0a886e67ad5d70b0a55f020eb03
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Wed Apr 4 10:42:03 2012 -0400

    Disable runtime PM for hotpluggable ATA ports (rhbz 806676)

 kernel.spec                                        |    7 +
 ...-disable-runtime-pm-for-hotpluggable-port.patch |  180 ++++++++++++++++++++
 2 files changed, 187 insertions(+), 0 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index c379a5a..cebe4a6 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -777,6 +777,9 @@ Patch21371: iwlwifi-do-not-nulify-ctx-vif-on-reset.patch
 #rhbz 808603
 Patch21380: wimax-i2400m-prevent-a-possible-kernel-bug-due-to-mi.patch
 
+#rhbz 806676
+Patch21385: libata-disable-runtime-pm-for-hotpluggable-port.patch
+
 Patch21400: unhandled-irqs-switch-to-polling.patch
 
 Patch21501: nfs-Fix-length-of-buffer-copied-in-__nfs4_get_acl_uncached.patch
@@ -1520,6 +1523,9 @@ ApplyPatch uvcvideo-Fix-race-induced-crash-in-uvc_video_clock_update.patch
 #rhbz 808603
 ApplyPatch wimax-i2400m-prevent-a-possible-kernel-bug-due-to-mi.patch
 
+#rhbz 806676
+ApplyPatch libata-disable-runtime-pm-for-hotpluggable-port.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2360,6 +2366,7 @@ fi
 #              '-'
 %changelog
 * Wed Apr 04 2012 Josh Boyer <jwboyer at redhat.com>
+- Disable runtime PM for hotpluggable ATA ports (rhbz 806676)
 - Disable MID_PTI driver (rhbz 783561)
 - Fix NULL pointer dereference in i2400m (rhbz 808603)
 
diff --git a/libata-disable-runtime-pm-for-hotpluggable-port.patch b/libata-disable-runtime-pm-for-hotpluggable-port.patch
new file mode 100644
index 0000000..06020fd
--- /dev/null
+++ b/libata-disable-runtime-pm-for-hotpluggable-port.patch
@@ -0,0 +1,180 @@
+Path: news.gmane.org!not-for-mail
+From: Lin Ming <ming.m.lin at intel.com>
+Newsgroups: gmane.linux.ide,gmane.linux.kernel
+Subject: [PATCH v2] libata: disable runtime pm for hotpluggable port
+Date: Tue, 13 Mar 2012 09:57:37 +0800
+Lines: 131
+Approved: news at gmane.org
+Message-ID: <1331603857.3436.24.camel at minggr>
+NNTP-Posting-Host: plane.gmane.org
+Mime-Version: 1.0
+Content-Type: text/plain; charset="UTF-8"
+Content-Transfer-Encoding: 7bit
+X-Trace: dough.gmane.org 1331603865 12388 80.91.229.3 (13 Mar 2012 01:57:45 GMT)
+X-Complaints-To: usenet at dough.gmane.org
+NNTP-Posting-Date: Tue, 13 Mar 2012 01:57:45 +0000 (UTC)
+Cc: linux-ide at vger.kernel.org, lkml <linux-kernel at vger.kernel.org>,
+	jslaby at suse.cz, cwillu at cwillu.com, jackdachef at gmail.com,
+	Sergei Shtylyov <sshtylyov at mvista.com>
+To: Jeff Garzik <jgarzik at pobox.com>
+Original-X-From: linux-ide-owner at vger.kernel.org Tue Mar 13 02:57:43 2012
+Return-path: <linux-ide-owner at vger.kernel.org>
+Envelope-to: lnx-linux-ide at plane.gmane.org
+Original-Received: from vger.kernel.org ([209.132.180.67])
+	by plane.gmane.org with esmtp (Exim 4.69)
+	(envelope-from <linux-ide-owner at vger.kernel.org>)
+	id 1S7Gze-0005pE-Sg
+	for lnx-linux-ide at plane.gmane.org; Tue, 13 Mar 2012 02:57:43 +0100
+Original-Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1754650Ab2CMB5l (ORCPT <rfc822;lnx-linux-ide at m.gmane.org>);
+	Mon, 12 Mar 2012 21:57:41 -0400
+Original-Received: from mga14.intel.com ([143.182.124.37]:15186 "EHLO mga14.intel.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1754582Ab2CMB5k (ORCPT <rfc822;linux-ide at vger.kernel.org>);
+	Mon, 12 Mar 2012 21:57:40 -0400
+Original-Received: from azsmga002.ch.intel.com ([10.2.17.35])
+  by azsmga102.ch.intel.com with ESMTP; 12 Mar 2012 18:57:39 -0700
+X-ExtLoop1: 1
+X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; 
+   d="scan'208";a="76719701"
+Original-Received: from minggr.sh.intel.com (HELO [10.239.36.45]) ([10.239.36.45])
+  by AZSMGA002.ch.intel.com with ESMTP; 12 Mar 2012 18:57:38 -0700
+X-Mailer: Evolution 2.30.3 
+Original-Sender: linux-ide-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-ide.vger.kernel.org>
+X-Mailing-List: linux-ide at vger.kernel.org
+Xref: news.gmane.org gmane.linux.ide:51560 gmane.linux.kernel:1266262
+Archived-At: <http://permalink.gmane.org/gmane.linux.ide/51560>
+
+Currently, hotplug doesn't work if port is already runtime suspended.
+For now, we simply disable runtime pm for hotpluggable port.
+Later, we should add runtime pm support for hotpluggable port too.
+
+Bug report:
+https://lkml.org/lkml/2012/2/19/70
+
+v2:
+- Use bit 2 and 3 for flags ATA_FLAG_EXTERNAL and ATA_FLAG_PLUGGABLE.
+
+TODO: add similar hotpluggable port check for controllers other than
+AHCI.
+
+Reported-and-tested-by: Jiri Slaby <jslaby at suse.cz>
+Reported-and-tested-by: cwillu at cwillu.com
+Reported-and-tested-by: jackdachef at gmail.com
+Signed-off-by: Lin Ming <ming.m.lin at intel.com>
+---
+ drivers/ata/ahci.c             |    3 +++
+ drivers/ata/ahci.h             |    3 +++
+ drivers/ata/libahci.c          |   20 ++++++++++++++++++++
+ drivers/ata/libata-transport.c |    6 ++++--
+ include/linux/libata.h         |    2 ++
+ 5 files changed, 32 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
+index d07bf03..02e93ff 100644
+--- a/drivers/ata/ahci.c
++++ b/drivers/ata/ahci.c
+@@ -1145,6 +1145,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+ 	if (hpriv->cap & HOST_CAP_PMP)
+ 		pi.flags |= ATA_FLAG_PMP;
+ 
++	if (hpriv->cap & HOST_CAP_SXS)
++		pi.flags |= ATA_FLAG_EXTERNAL;
++
+ 	ahci_set_em_messages(hpriv, &pi);
+ 
+ 	if (ahci_broken_system_poweroff(pdev)) {
+diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
+index b175000..92f7172 100644
+--- a/drivers/ata/ahci.h
++++ b/drivers/ata/ahci.h
+@@ -172,6 +172,9 @@ enum {
+ 	PORT_CMD_ALPE		= (1 << 26), /* Aggressive Link PM enable */
+ 	PORT_CMD_ATAPI		= (1 << 24), /* Device is ATAPI */
+ 	PORT_CMD_FBSCP		= (1 << 22), /* FBS Capable Port */
++	PORT_CMD_ESP		= (1 << 21), /* External SATA Port */
++	PORT_CMD_MPSP		= (1 << 19), /* Mechanical Presence Switch Attached to Port */
++	PORT_CMD_HPCP		= (1 << 18), /* Hot Plug Capable Port */
+ 	PORT_CMD_PMP		= (1 << 17), /* PMP attached */
+ 	PORT_CMD_LIST_ON	= (1 << 15), /* cmd list DMA engine running */
+ 	PORT_CMD_FIS_ON		= (1 << 14), /* FIS DMA engine running */
+diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
+index a72bfd0..7d72d3c 100644
+--- a/drivers/ata/libahci.c
++++ b/drivers/ata/libahci.c
+@@ -1097,6 +1097,23 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
+ 	writel(1 << port_no, mmio + HOST_IRQ_STAT);
+ }
+ 
++static bool ahci_port_pluggable(struct ata_port *ap)
++{
++	void __iomem *port_mmio = ahci_port_base(ap);
++	u32 cmd;
++
++	cmd = readl(port_mmio + PORT_CMD);
++
++	if ((ap->flags & ATA_FLAG_EXTERNAL) &&
++	    (cmd & PORT_CMD_ESP))
++		return true;
++
++	if (cmd & (PORT_CMD_MPSP | PORT_CMD_HPCP))
++		return true;
++
++	return false;
++}
++
+ void ahci_init_controller(struct ata_host *host)
+ {
+ 	struct ahci_host_priv *hpriv = host->private_data;
+@@ -1112,6 +1129,9 @@ void ahci_init_controller(struct ata_host *host)
+ 		if (ata_port_is_dummy(ap))
+ 			continue;
+ 
++		if (ahci_port_pluggable(ap))
++			ap->flags |= ATA_FLAG_PLUGGABLE;
++
+ 		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
+ 	}
+ 
+diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
+index 74aaee3..a7166b9 100644
+--- a/drivers/ata/libata-transport.c
++++ b/drivers/ata/libata-transport.c
+@@ -292,8 +292,10 @@ int ata_tport_add(struct device *parent,
+ 	}
+ 
+ 	device_enable_async_suspend(dev);
+-	pm_runtime_set_active(dev);
+-	pm_runtime_enable(dev);
++	if (!(ap->flags & ATA_FLAG_PLUGGABLE)) {
++		pm_runtime_set_active(dev);
++		pm_runtime_enable(dev);
++	}
+ 
+ 	transport_add_device(dev);
+ 	transport_configure_device(dev);
+diff --git a/include/linux/libata.h b/include/linux/libata.h
+index cafc09a..f46961d 100644
+--- a/include/linux/libata.h
++++ b/include/linux/libata.h
+@@ -187,6 +187,8 @@ enum {
+ 	ATA_FLAG_SLAVE_POSS	= (1 << 0), /* host supports slave dev */
+ 					    /* (doesn't imply presence) */
+ 	ATA_FLAG_SATA		= (1 << 1),
++	ATA_FLAG_EXTERNAL	= (1 << 2), /* Controller supports external SATA */
++	ATA_FLAG_PLUGGABLE	= (1 << 3), /* Port is hotpluggable */
+ 	ATA_FLAG_NO_ATAPI	= (1 << 6), /* No ATAPI support */
+ 	ATA_FLAG_PIO_DMA	= (1 << 7), /* PIO cmds via DMA */
+ 	ATA_FLAG_PIO_LBA48	= (1 << 8), /* Host DMA engine is LBA28 only */
+-- 
+1.7.2.5
+
+
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-ide" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+


More information about the scm-commits mailing list