mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: lkml <linux-kernel@vger.kernel.org>,
	linux-pci <linux-pci@atrey.karlin.mff.cuni.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>, Greg KH <gregkh@suse.de>
Subject: [RFC] disable PCIE 'Enable No Snoop' bit by default
Date: Thu, 06 Sep 2007 13:35:08 +0800	[thread overview]
Message-ID: <1189056908.24368.9.camel@sli10-conroe.sh.intel.com> (raw)

PCIE 'Enable No Snoop' bit is set by default per PCIE spec, but OS
assumes PCI DMA is snooped, which is legacy PCI device does. Enabling no
snoop might cause potential DMA issues. This patch disables it, if a
driver can work with no snoop, we can provide a helper to enable it.

I didn't see any real breaks, but did see some devices with the bit enabled

Signed-off-by: Shaohua Li <shaohua.li@intel.com>

Index: linux/drivers/pci/probe.c
===================================================================
--- linux.orig/drivers/pci/probe.c	2007-09-06 13:18:07.000000000 +0800
+++ linux/drivers/pci/probe.c	2007-09-06 13:21:30.000000000 +0800
@@ -694,6 +694,19 @@ static void pci_read_irq(struct pci_dev 
 
 #define LEGACY_IO_RESOURCE	(IORESOURCE_IO | IORESOURCE_PCI_FIXED)
 
+static void pcie_setup_device(struct pci_dev *dev)
+{
+	u16 reg16;
+	int pos;
+
+	pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
+	if (pos) {
+		pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16);
+		reg16 &= ~PCI_EXP_DEVCTL_NOSNOOP_EN;
+		pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16);
+	}
+}
+
 /**
  * pci_setup_device - fill in class and map information of a device
  * @dev: the device structure to fill
@@ -795,6 +808,7 @@ static int pci_setup_device(struct pci_d
 		dev->class = PCI_CLASS_NOT_DEFINED;
 	}
 
+	pcie_setup_device(dev);
 	/* We found a fine healthy device, go go go... */
 	return 0;
 }

             reply	other threads:[~2007-09-06  5:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-06  5:35 Shaohua Li [this message]
2007-09-06 11:57 ` Matthew Wilcox
2007-09-06 12:40   ` David Miller
2007-09-09 16:43     ` Greg KH
2007-09-11  1:29       ` Shaohua Li
2007-09-11  6:15         ` Greg KH
2007-09-11  6:27           ` Shaohua Li
2007-09-07  0:51   ` Shaohua Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1189056908.24368.9.camel@sli10-conroe.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®