public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-06 19:05 [PATCH 1/2] [PCI] Check that MWI bit really did get set Matthew Wilcox
@ 2006-10-06 19:05 ` Matthew Wilcox
  2006-10-06 19:15   ` Jeff Garzik
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2006-10-06 19:05 UTC (permalink / raw)
  To: Val Henson, Greg Kroah-Hartman
  Cc: netdev, linux-pci, linux-kernel, Matthew Wilcox

We used to check whether pci_set_mwi() had succeeded by testing the
hardware MWI bit.  Now we need only check the return value (and failing
to do so is a warning).  Also, pci_set_mwi() will fail if the cache line
size is 0, so we don't need to check that ourselves any more.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index d11d28c..64d999b 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1135,7 +1135,6 @@ static void __devinit tulip_mwi_config (
 {
 	struct tulip_private *tp = netdev_priv(dev);
 	u8 cache;
-	u16 pci_command;
 	u32 csr0;
 
 	if (tulip_debug > 3)
@@ -1153,21 +1152,15 @@ static void __devinit tulip_mwi_config (
 	/* set or disable MWI in the standard PCI command bit.
 	 * Check for the case where  mwi is desired but not available
 	 */
-	if (csr0 & MWI)	pci_set_mwi(pdev);
-	else		pci_clear_mwi(pdev);
-
-	/* read result from hardware (in case bit refused to enable) */
-	pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
-	if ((csr0 & MWI) && (!(pci_command & PCI_COMMAND_INVALIDATE)))
-		csr0 &= ~MWI;
-
-	/* if cache line size hardwired to zero, no MWI */
-	pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache);
-	if ((csr0 & MWI) && (cache == 0)) {
-		csr0 &= ~MWI;
+	if (csr0 & MWI)	{
+		if (pci_set_mwi(pdev))
+			csr0 &= ~MWI;
+	} else {
 		pci_clear_mwi(pdev);
 	}
 
+	pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cache);
+
 	/* assign per-cacheline-size cache alignment and
 	 * burst length values
 	 */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-06 19:05 ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Matthew Wilcox
@ 2006-10-06 19:15   ` Jeff Garzik
  2006-10-06 19:28     ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Garzik @ 2006-10-06 19:15 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Val Henson, Greg Kroah-Hartman, netdev, linux-pci, linux-kernel

Matthew Wilcox wrote:
> Also, pci_set_mwi() will fail if the cache line
> size is 0, so we don't need to check that ourselves any more.

NAK, not true on all arches.  sparc64 at least presumes that the 
firmware DTRT with cacheline size, which hurts us now given this tulip patch

	Jeff



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-06 19:15   ` Jeff Garzik
@ 2006-10-06 19:28     ` Matthew Wilcox
  2006-10-06 19:59       ` Jeff Garzik
  0 siblings, 1 reply; 7+ messages in thread
From: Matthew Wilcox @ 2006-10-06 19:28 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Val Henson, Greg Kroah-Hartman, netdev, linux-pci, linux-kernel,
	David Miller

On Fri, Oct 06, 2006 at 03:15:15PM -0400, Jeff Garzik wrote:
> Matthew Wilcox wrote:
> >Also, pci_set_mwi() will fail if the cache line
> >size is 0, so we don't need to check that ourselves any more.
> 
> NAK, not true on all arches.  sparc64 at least presumes that the 
> firmware DTRT with cacheline size, which hurts us now given this tulip patch

How does it hurt us?

int pcibios_prep_mwi(struct pci_dev *dev)
{
        /* We set correct PCI_CACHE_LINE_SIZE register values for every
         * device probed on this platform.  So there is nothing to check
         * and this always succeeds.
         */
        return 0;
}

If Dave's wrong about that, it hurts him, not us ;-)

It's still not necessary for the Tulip driver to check.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-06 19:28     ` Matthew Wilcox
@ 2006-10-06 19:59       ` Jeff Garzik
  2006-10-07  5:34         ` Grant Grundler
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Garzik @ 2006-10-06 19:59 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Val Henson, Greg Kroah-Hartman, netdev, linux-pci, linux-kernel,
	David Miller

Matthew Wilcox wrote:
> On Fri, Oct 06, 2006 at 03:15:15PM -0400, Jeff Garzik wrote:
>> Matthew Wilcox wrote:
>>> Also, pci_set_mwi() will fail if the cache line
>>> size is 0, so we don't need to check that ourselves any more.
>> NAK, not true on all arches.  sparc64 at least presumes that the 
>> firmware DTRT with cacheline size, which hurts us now given this tulip patch
> 
> How does it hurt us?
> 
> int pcibios_prep_mwi(struct pci_dev *dev)
> {
>         /* We set correct PCI_CACHE_LINE_SIZE register values for every
>          * device probed on this platform.  So there is nothing to check
>          * and this always succeeds.
>          */
>         return 0;
> }
> 
> If Dave's wrong about that, it hurts him, not us ;-)
> 
> It's still not necessary for the Tulip driver to check.

The unmodified tulip driver checks both MWI and cacheline-size because 
one of the clones (PNIC or PNIC2) will let you set the MWI bit, but 
hardwires cacheline size to zero.

If the arches do not behave consistently, we need to keep the check in 
the tulip driver, to avoid incorrectly programming the csr0 MWI bit.

	Jeff




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
       [not found]       ` <fa.lMwhGlM7h3gT94gAUyYURPCF1Qg@ifi.uio.no>
@ 2006-10-07  0:15         ` Robert Hancock
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Hancock @ 2006-10-07  0:15 UTC (permalink / raw)
  To: Jeff Garzik, linux-kernel; +Cc: Matthew Wilcox

Jeff Garzik wrote:
> The unmodified tulip driver checks both MWI and cacheline-size because 
> one of the clones (PNIC or PNIC2) will let you set the MWI bit, but 
> hardwires cacheline size to zero.
> 
> If the arches do not behave consistently, we need to keep the check in 
> the tulip driver, to avoid incorrectly programming the csr0 MWI bit.
> 
>     Jeff

I should think that pci_set_mwi should fail if either the cache line 
size showed 0 (after either setting the correct size or assuming it 
should have been set already) or the MWI bit ended up clear after we 
tried to turn it on.

That pcibios_prep_mwi code for sparc64 looks wrong, if you plug in a 
device that doesn't implement MWI at all it will probably not let 
anything get written to PCI_CACHE_LINE_SIZE other than 0, but it is 
blindly succeeding in all cases. Even if the arch assumes the firmware 
already set the size properly it should still make sure it is non-zero 
before allowing MWI..

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-06 19:59       ` Jeff Garzik
@ 2006-10-07  5:34         ` Grant Grundler
  2006-10-07 14:44           ` Jeff Garzik
  0 siblings, 1 reply; 7+ messages in thread
From: Grant Grundler @ 2006-10-07  5:34 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Matthew Wilcox, Val Henson, Greg Kroah-Hartman, netdev, linux-pci,
	linux-kernel, David Miller

On Fri, Oct 06, 2006 at 03:59:57PM -0400, Jeff Garzik wrote:
> The unmodified tulip driver checks both MWI and cacheline-size because 
> one of the clones (PNIC or PNIC2) will let you set the MWI bit, but 
> hardwires cacheline size to zero.

Maybe the generic pci_set_mwi() can verify cacheline size is non-zero?
I don't think each driver should need to enforce this.

> If the arches do not behave consistently, we need to keep the check in 
> the tulip driver, to avoid incorrectly programming the csr0 MWI bit.

Why not fix the arches to be consistent?
There's alot more drivers than arches...and we have control
of the arch specific PCI support.

thanks,
grant

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi()
  2006-10-07  5:34         ` Grant Grundler
@ 2006-10-07 14:44           ` Jeff Garzik
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2006-10-07 14:44 UTC (permalink / raw)
  To: Grant Grundler
  Cc: Matthew Wilcox, Val Henson, Greg Kroah-Hartman, netdev, linux-pci,
	linux-kernel, David Miller

Grant Grundler wrote:
> On Fri, Oct 06, 2006 at 03:59:57PM -0400, Jeff Garzik wrote:
>> The unmodified tulip driver checks both MWI and cacheline-size because 
>> one of the clones (PNIC or PNIC2) will let you set the MWI bit, but 
>> hardwires cacheline size to zero.
> 
> Maybe the generic pci_set_mwi() can verify cacheline size is non-zero?
> I don't think each driver should need to enforce this.

Agreed.


>> If the arches do not behave consistently, we need to keep the check in 
>> the tulip driver, to avoid incorrectly programming the csr0 MWI bit.
> 
> Why not fix the arches to be consistent?
> There's alot more drivers than arches...and we have control
> of the arch specific PCI support.

Agreed.

	Jeff




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-10-07 14:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.5vbPpPQ5p6Rqb6w5IQvYeIEZ+o4@ifi.uio.no>
     [not found] ` <fa.5fHFiSyxiA8IzX/z36b4ccRdkwk@ifi.uio.no>
     [not found]   ` <fa.xexLYpZ2s3jlzi3H4j8CMu5nU5M@ifi.uio.no>
     [not found]     ` <fa.DScE5F/ioZsTJQxVaKgCvzyY/+o@ifi.uio.no>
     [not found]       ` <fa.lMwhGlM7h3gT94gAUyYURPCF1Qg@ifi.uio.no>
2006-10-07  0:15         ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Robert Hancock
2006-10-06 19:05 [PATCH 1/2] [PCI] Check that MWI bit really did get set Matthew Wilcox
2006-10-06 19:05 ` [PATCH 2/2] [TULIP] Check the return value from pci_set_mwi() Matthew Wilcox
2006-10-06 19:15   ` Jeff Garzik
2006-10-06 19:28     ` Matthew Wilcox
2006-10-06 19:59       ` Jeff Garzik
2006-10-07  5:34         ` Grant Grundler
2006-10-07 14:44           ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox