All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Yinghai Lu <yhlu.kernel@gmail.com>, Greg KH <greg@kroah.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, Tony Camuso <tcamuso@redhat.com>,
	Grant Grundler <grundler@parisc-linux.org>,
	Loic Prylli <loic@myri.com>, Adrian Bunk <bunk@kernel.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Greg KH <gregkh@suse.de>,
	linux-kernel@vger.kernel.org, Jeff Garzik <jeff@garzik.org>,
	linux-pci@atrey.karlin.mff.cuni.cz, Martin Mares <mj@ucw.cz>
Subject: Re: raw_pci_read in quirk_intel_irqbalance
Date: Sun, 10 Feb 2008 22:04:16 -0700	[thread overview]
Message-ID: <20080211050415.GJ5299@parisc-linux.org> (raw)
In-Reply-To: <20080210230204.GH5299@parisc-linux.org>

On Sun, Feb 10, 2008 at 04:02:04PM -0700, Matthew Wilcox wrote:
> The line in question reads:
> 
>         /* read xTPR register */
>         raw_pci_read(0, 0, 0x40, 0x4c, 2, &word);
> 
> That's domain 0, bus 0, device 8, function 0, address 0x4c, length 2.
> 
> I've checked the public E7525 and E7520 MCH datasheets, and they don't
> document the xTPR registers; nor do any of the devices in the datasheet
> have registers documented at 0x4c.
> 
> You can see from my lspci above that I don't _have_ a device 8 on bus 0.
> The aforementioned documentation says:
> 
> "A disabled or non-existent device's configuration register space is
> hidden. A disabled or non-existent device will return all ones for reads
> and will drop writes just as if the cycle terminated with a Master Abort
> on PCI."

I'd like to thank Grant for pointing out to me that this is exactly what
the write immediately above this is doing -- enabling device 8 to
respond to config space cycles.

> Now, my E7525 isn't affected by this quirk as it has a revision greater
> than 0x9.  So maybe it's expected that device 8 is hidden on my machine;
> that it's only present on revisions up to 0x9.  But maybe device 8 is
> always hidden, and that's why the author used raw_pci_ops?
> 
> We can still do better than this, though.  We can do:
> 
> -	raw_pci_read(0, 0, 0x40, 0x4c, 2, &word);
> +	pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
> 
> Using PCI_DEVFN tells people you really did mean device 8, and it's not
> a braino for device 4 or 2 (how many bits for slot and function again?)

Here's the patch to implement the above two suggestions:

----

>From f565b65591a3f90a272b1d511e4ab1728861fe77 Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <matthew@wil.cx>
Date: Sun, 10 Feb 2008 23:18:15 -0500
Subject: [PATCH] Use proper abstractions in quirk_intel_irqbalance

Since we may not have a pci_dev for the device we need to access, we can't
use pci_read_config_word.  But raw_pci_read is an internal implementation
detail; it's better to use the architected pci_bus_read_config_word
interface.  Using PCI_DEVFN instead of a mysterious constant helps
reassure everyone that we really do intend to access device 8.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 arch/x86/kernel/quirks.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 1941482..c47208f 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -11,7 +11,7 @@
 static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
 {
 	u8 config, rev;
-	u32 word;
+	u16 word;
 
 	/* BIOS may enable hardware IRQ balancing for
 	 * E7520/E7320/E7525(revision ID 0x9 and below)
@@ -26,8 +26,11 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
 	pci_read_config_byte(dev, 0xf4, &config);
 	pci_write_config_byte(dev, 0xf4, config|0x2);
 
-	/* read xTPR register */
-	raw_pci_read(0, 0, 0x40, 0x4c, 2, &word);
+	/*
+	 * read xTPR register.  We may not have a pci_dev for device 8
+	 * because it might be hidden until the above write.
+	 */
+	pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
 
 	if (!(word & (1 << 13))) {
 		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; "
-- 
1.5.2.5

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2008-02-11  5:04 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-25 11:26 [Patch v2] Make PCI extended config space (MMCONFIG) a driver opt-in Arjan van de Ven
2007-12-27 11:52 ` Jeff Garzik
2007-12-27 14:09   ` Arjan van de Ven
2007-12-27 17:52   ` Linus Torvalds
2008-01-11 19:02 ` Greg KH
2008-01-11 19:09   ` Arjan van de Ven
2008-01-11 19:14     ` Greg KH
2008-01-11 19:28   ` Matthew Wilcox
2008-01-11 19:40     ` Arjan van de Ven
2008-01-11 19:45       ` Greg KH
2008-01-11 19:49         ` Matthew Wilcox
2008-01-11 19:58           ` Linus Torvalds
2008-01-11 20:17             ` Matthew Wilcox
2008-01-11 20:27               ` Linus Torvalds
2008-01-11 20:42                 ` Matthew Wilcox
2008-01-11 21:12                   ` Linus Torvalds
2008-01-11 21:17                     ` Matthew Wilcox
2008-01-11 21:28                       ` Linus Torvalds
2008-01-11 21:38                         ` Matthew Wilcox
2008-01-11 23:58                           ` Ivan Kokshaysky
2008-01-12  0:17                             ` Jesse Barnes
2008-01-12  0:26                             ` Greg KH
2008-01-12 14:40                               ` Ivan Kokshaysky
2008-01-12 15:46                                 ` Arjan van de Ven
2008-01-12 16:23                                   ` Ivan Kokshaysky
2008-01-12 17:45                                 ` Arjan van de Ven
2008-01-12 18:17                                   ` Matthew Wilcox
2008-01-12 21:49                                   ` Ivan Kokshaysky
2008-01-12 23:01                                     ` Arjan van de Ven
2008-01-13  0:12                                       ` Tony Camuso
2008-01-13  0:40                                         ` Arjan van de Ven
2008-01-13  1:36                                           ` Tony Camuso
2008-01-13  4:42                                             ` Arjan van de Ven
2008-01-13  4:47                                               ` Matthew Wilcox
2008-01-13  6:43                                                 ` Jeff Garzik
2008-01-13 12:43                                               ` Tony Camuso
2008-01-13 17:03                                                 ` Arjan van de Ven
2008-01-13 21:28                                                   ` Tony Camuso
2008-01-14  0:54                                                     ` Alan Cox
2008-01-14  1:33                                                       ` Arjan van de Ven
2008-01-14  3:29                                                         ` Tony Camuso
2008-01-14  5:05                                                           ` Arjan van de Ven
2008-01-14 13:01                                                             ` Tony Camuso
2008-01-14 14:46                                                               ` Arjan van de Ven
2008-01-14 15:23                                                                 ` Tony Camuso
2008-01-14 16:01                                                                   ` Arjan van de Ven
2008-01-14 16:08                                                                     ` Tony Camuso
2008-01-14  9:11                                                         ` Alan Cox
2008-01-14  5:20                                                       ` Linus Torvalds
2008-01-13 18:23                                   ` Loic Prylli
2008-01-13 18:41                                     ` Arjan van de Ven
2008-01-13 20:43                                       ` Matthew Wilcox
2008-01-13 21:18                                         ` Loic Prylli
2008-01-13 20:51                                       ` Loic Prylli
2008-01-13  7:08                                 ` Benjamin Herrenschmidt
2008-01-13  7:24                                   ` Matthew Wilcox
2008-01-13  7:58                                     ` Matthew Wilcox
2008-01-13 17:01                                     ` Arjan van de Ven
2008-01-14 22:52                                       ` Matthew Wilcox
2008-01-14 23:04                                         ` Adrian Bunk
2008-01-15 16:00                                           ` Loic Prylli
2008-01-15 17:46                                             ` Greg KH
2008-01-15 17:56                                               ` Matthew Wilcox
2008-01-15 19:27                                                 ` Tony Camuso
2008-01-15 19:38                                                   ` Linus Torvalds
2008-01-15 19:40                                                     ` Matthew Wilcox
2008-01-15 22:12                                                     ` Loic Prylli
2008-01-19 16:58                                                 ` Grant Grundler
2008-01-28 18:32                                                   ` Tony Camuso
2008-01-28 20:44                                                     ` Greg KH
2008-01-28 22:31                                                       ` Matthew Wilcox
2008-01-28 22:53                                                         ` Greg KH
2008-01-29  2:56                                                           ` Matthew Wilcox
2008-01-29  2:57                                                             ` PCI x86: always use conf1 to access config space below 256 bytes Matthew Wilcox
2008-01-29 13:21                                                               ` Greg KH
2008-01-29 23:43                                                                 ` Matthew Wilcox
2008-01-30  0:04                                                                   ` Linus Torvalds
2008-01-29  3:03                                                             ` [PATCH] Change pci_raw_ops to pci_raw_read/write Matthew Wilcox
2008-02-03  7:30                                                               ` Yinghai Lu
2008-02-07 15:54                                                                 ` Tony Camuso
2008-02-07 16:28                                                                   ` Arjan van de Ven
2008-02-07 16:36                                                                     ` Tony Camuso
2008-02-08  2:28                                                                       ` Grant Grundler
2008-02-09 12:41                                                                   ` Matthew Wilcox
2008-02-10  6:25                                                                     ` Yinghai Lu
2008-02-10  7:21                                                                       ` Greg KH
2008-02-10 14:51                                                                         ` Matthew Wilcox
2008-02-10 19:13                                                                           ` Grant Grundler
2008-02-10 19:37                                                                             ` Matthew Wilcox
2008-02-10 20:16                                                                           ` Yinghai Lu
2008-02-10 20:19                                                                             ` Matthew Wilcox
2008-02-10 20:25                                                                               ` Yinghai Lu
2008-02-10 20:32                                                                                 ` Matthew Wilcox
2008-02-10 20:47                                                                                   ` Yinghai Lu
2008-02-10 20:24                                                                             ` Linus Torvalds
2008-02-10 20:45                                                                               ` Matthew Wilcox
2008-02-10 23:02                                                                                 ` raw_pci_read in quirk_intel_irqbalance Matthew Wilcox
2008-02-11  5:04                                                                                   ` Matthew Wilcox [this message]
2008-02-11  7:49                                                                                     ` Grant Grundler
2008-02-11 16:15                                                                                       ` Matthew Wilcox
2008-02-11 17:18                                                                                         ` Linus Torvalds
2008-02-11 19:38                                                                                           ` Grant Grundler
2008-02-11  1:49                                                                                 ` [PATCH] Change pci_raw_ops to pci_raw_read/write Yinghai Lu
2008-02-11  2:53                                                                                   ` Robert Hancock
2008-02-11  5:59                                                                                     ` Yinghai Lu
2008-02-11 22:10                                                                                   ` Andrew Morton
2008-02-11 22:38                                                                                     ` Ingo Molnar
2008-01-29  3:05                                                       ` [Patch v2] Make PCI extended config space (MMCONFIG) a driver opt-in Arjan van de Ven
2008-01-29  3:18                                                         ` Matthew Wilcox
2008-01-29 13:19                                                           ` Greg KH
2008-01-29 14:15                                                             ` Tony Camuso
2008-01-29 14:47                                                               ` Arjan van de Ven
2008-01-29 15:15                                                                 ` Tony Camuso
2008-01-29 15:29                                                                   ` Arjan van de Ven
2008-01-29 16:26                                                                     ` Tony Camuso
2008-01-29 23:57                                                                     ` Matthew Wilcox
2008-01-30  2:30                                                                       ` Tony Camuso
2008-01-30  3:45                                                             ` Matthew Wilcox
2008-01-30 15:15                                                               ` Ivan Kokshaysky
2008-01-30 15:42                                                                 ` Arjan van de Ven
2008-01-30 20:14                                                                   ` Ivan Kokshaysky
2008-01-31  5:51                                                             ` Jesse Barnes
2008-01-11 19:54   ` Arjan van de Ven
2008-01-11 20:55     ` Greg KH
2008-01-15 12:58 ` Øyvind Vågen Jægtnes

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=20080211050415.GJ5299@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=benh@kernel.crashing.org \
    --cc=bunk@kernel.org \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=grundler@parisc-linux.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=loic@myri.com \
    --cc=mingo@elte.hu \
    --cc=mj@ucw.cz \
    --cc=tcamuso@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=yhlu.kernel@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.