diff mbox

[v2] Fix breakage of enable_cnt in quirk_resource_alignment

Message ID 20090406102153.04A3.27C06F64@necst.nec.co.jp (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Yuji Shimada April 6, 2009, 1:24 a.m. UTC
This patch fixes breakage of of enable_cnt in quirk_resource_alignment.

Current quirk_resource_alignment calls pci_disable_device.
pci_disable_device decrements enable_cnt, so that enable_cnt becomes -1.

The patch disables memory decoding, writing command register directly.
So enable_cnt is not broken.

v1 -> v2
    - Fix a message.

Thanks,
--
Yuji Shimada


Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>


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

Comments

Jesse Barnes April 6, 2009, 6:48 p.m. UTC | #1
On Mon, 06 Apr 2009 10:24:21 +0900
Yuji Shimada <shimada-yxb@necst.nec.co.jp> wrote:

> This patch fixes breakage of of enable_cnt in
> quirk_resource_alignment.
> 
> Current quirk_resource_alignment calls pci_disable_device.
> pci_disable_device decrements enable_cnt, so that enable_cnt becomes
> -1.
> 
> The patch disables memory decoding, writing command register directly.
> So enable_cnt is not broken.
> 

We may be able to do this more cleanly at some point, but I've applied
this patch for now.  Thanks.
diff mbox

Patch

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 9b2f0d9..755dd32 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -36,17 +36,18 @@  EXPORT_SYMBOL(pcie_mch_quirk);
 
 #ifdef CONFIG_PCI_QUIRKS
 /*
- * This quirk function disables the device and releases resources
- * which is specified by kernel's boot parameter 'pci=resource_alignment='.
+ * This quirk function disables memory decoding and releases memory resources
+ * of the device specified by kernel's boot parameter 'pci=resource_alignment='.
  * It also rounds up size to specified alignment.
  * Later on, the kernel will assign page-aligned memory resource back
- * to that device.
+ * to the device.
  */
 static void __devinit quirk_resource_alignment(struct pci_dev *dev)
 {
 	int i;
 	struct resource *r;
 	resource_size_t align, size;
+	u16 command;
 
 	if (!pci_is_reassigndev(dev))
 		return;
@@ -58,8 +59,11 @@  static void __devinit quirk_resource_alignment(struct pci_dev *dev)
 		return;
 	}
 
-	dev_info(&dev->dev, "Disabling device and release resources.\n");
-	pci_disable_device(dev);
+	dev_info(&dev->dev,
+		"Disabling memory decoding and releasing memory resources.\n");
+	pci_read_config_word(dev, PCI_COMMAND, &command);
+	command &= ~PCI_COMMAND_MEMORY;
+	pci_write_config_word(dev, PCI_COMMAND, command);
 
 	align = pci_specified_resource_alignment(dev);
 	for (i=0; i < PCI_BRIDGE_RESOURCES; i++) {