public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reverse pci config space restore order
@ 2006-04-25  6:50 Yu, Luming
  2006-04-25 10:48 ` Matthew Garrett
  0 siblings, 1 reply; 6+ messages in thread
From: Yu, Luming @ 2006-04-25  6:50 UTC (permalink / raw)
  To: Andrew Morton, Brown, Len; +Cc: linux-acpi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]


According to Intel ICH spec, there are several rules that
Base Address should be programmed before IOSE 
(PCICMD register ) enabled. 

For example ICH7:
12.1.3  SATA : the base address register for the bus 
master register should be programmed before this bit is set.

11.1.3:  PCICMD (USB): The base address register for
USB should be programmed before this bit is set.
....
To make sure kernel code follow this rule 
, and prevent unnecessary confusion. I proposal this
patch. 

Note:
I'm sorry the patch is NOT in good format.
If you want to apply please use the attached patch file.
sorry for my email client.


Signed-off-by: Luming Yu <luming.yu@intel.com>

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bea1ad1..19a71a6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -456,7 +456,7 @@ pci_restore_state(struct pci_dev *dev)
 {
 	int i;
 
-	for (i = 0; i < 16; i++)
+	for (i = 15; i >= 0 ; i--)
 		pci_write_config_dword(dev,i * 4,
dev->saved_config_space[i]);
 	return 0;
 }

[-- Attachment #2: reverse_pci_config_space_restore_order.patch --]
[-- Type: application/octet-stream, Size: 339 bytes --]

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bea1ad1..19a71a6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -456,7 +456,7 @@ pci_restore_state(struct pci_dev *dev)
 {
 	int i;
 
-	for (i = 0; i < 16; i++)
+	for (i = 15; i >= 0 ; i--)
 		pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
 	return 0;
 }

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

* Re: [PATCH] reverse pci config space restore order
  2006-04-25  6:50 [PATCH] reverse pci config space restore order Yu, Luming
@ 2006-04-25 10:48 ` Matthew Garrett
  2006-04-25 10:51   ` Arjan van de Ven
  0 siblings, 1 reply; 6+ messages in thread
From: Matthew Garrett @ 2006-04-25 10:48 UTC (permalink / raw)
  To: Yu, Luming; +Cc: Andrew Morton, Brown, Len, linux-acpi, linux-kernel

On Tue, Apr 25, 2006 at 02:50:57PM +0800, Yu, Luming wrote:

> -	for (i = 0; i < 16; i++)
> +	for (i = 15; i >= 0 ; i--)

We certainly need to do /something/ here, but I'm not sure this is it. 
Adam Belay has code to limit PCI state restoration to the PCI-specified 
registers, with the idea being that individual drivers fix things up 
properly. While this has the obvious drawback that almost every PCI 
driver in the tree would then need fixing up, it's also probably the 
right thing.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* Re: [PATCH] reverse pci config space restore order
  2006-04-25 10:48 ` Matthew Garrett
@ 2006-04-25 10:51   ` Arjan van de Ven
  2006-04-25 11:01     ` Matthew Garrett
  0 siblings, 1 reply; 6+ messages in thread
From: Arjan van de Ven @ 2006-04-25 10:51 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Yu, Luming, Andrew Morton, Brown, Len, linux-acpi, linux-kernel

On Tue, 2006-04-25 at 11:48 +0100, Matthew Garrett wrote:
> On Tue, Apr 25, 2006 at 02:50:57PM +0800, Yu, Luming wrote:
> 
> > -	for (i = 0; i < 16; i++)
> > +	for (i = 15; i >= 0 ; i--)
> 
> We certainly need to do /something/ here, but I'm not sure this is it. 
> Adam Belay has code to limit PCI state restoration to the PCI-specified 
> registers, with the idea being that individual drivers fix things up 
> properly. While this has the obvious drawback that almost every PCI 
> driver in the tree would then need fixing up, it's also probably the 
> right thing.

it has a second drawback: it assumes all devices HAVE a driver, which
isn't normally the case...


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

* Re: [PATCH] reverse pci config space restore order
  2006-04-25 10:51   ` Arjan van de Ven
@ 2006-04-25 11:01     ` Matthew Garrett
  0 siblings, 0 replies; 6+ messages in thread
From: Matthew Garrett @ 2006-04-25 11:01 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Yu, Luming, Andrew Morton, Brown, Len, linux-acpi, linux-kernel

On Tue, Apr 25, 2006 at 12:51:01PM +0200, Arjan van de Ven wrote:

> it has a second drawback: it assumes all devices HAVE a driver, which
> isn't normally the case...

Yeah, I guess there's a call for keeping a pci_save_entire_state type 
call and getting pci_device_suspend to use that in the no-driver case 
(also for the "Make my driver work again quickly" case, but still)

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* RE: [PATCH] reverse pci config space restore order
@ 2006-04-25 18:22 Brown, Len
  2006-04-25 23:59 ` abelay
  0 siblings, 1 reply; 6+ messages in thread
From: Brown, Len @ 2006-04-25 18:22 UTC (permalink / raw)
  To: Arjan van de Ven, Matthew Garrett, abelay
  Cc: Yu, Luming, Andrew Morton, linux-acpi, linux-kernel


>On Tue, 2006-04-25 at 11:48 +0100, Matthew Garrett wrote:
>> On Tue, Apr 25, 2006 at 02:50:57PM +0800, Yu, Luming wrote:
>> 
>> > -	for (i = 0; i < 16; i++)
>> > +	for (i = 15; i >= 0 ; i--)
>> 
>> We certainly need to do /something/ here, but I'm not sure 
>> this is it. 
>> Adam Belay has code to limit PCI state restoration to the 
>> PCI-specified 
>> registers, with the idea being that individual drivers fix things up 
>> properly. While this has the obvious drawback that almost every PCI 
>> driver in the tree would then need fixing up, it's also probably the 
>> right thing.
>
>it has a second drawback: it assumes all devices HAVE a driver, which
>isn't normally the case...

Adam mentioned earlier, and I agree, that it is probably a bad
idea for this code to blindly scribble on the BIST field at i=3.
Probably we should clear that field before restoring it.

Re: this patch
I think that this patch is likely a positive forward step.
It seems logical to restore the BARs before the CMD/STATUS in general,
nothing specific to the ICH here.

But yes, this is a helper routine and devices where it hurts
instead of helps should have their own routine.  Complex devices
need to handle the device-specific config space state above these
1st 16 locations anyway.

-Len

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

* RE: [PATCH] reverse pci config space restore order
  2006-04-25 18:22 Brown, Len
@ 2006-04-25 23:59 ` abelay
  0 siblings, 0 replies; 6+ messages in thread
From: abelay @ 2006-04-25 23:59 UTC (permalink / raw)
  To: Brown, Len, Arjan van de Ven
  Cc: Matthew Garrett, Yu, Luming, Andrew Morton, linux-acpi,
	linux-kernel

Quoting "Brown, Len" <len.brown@intel.com>:

>
>> On Tue, 2006-04-25 at 11:48 +0100, Matthew Garrett wrote:
>>> On Tue, Apr 25, 2006 at 02:50:57PM +0800, Yu, Luming wrote:
>>>
>>> > -	for (i = 0; i < 16; i++)
>>> > +	for (i = 15; i >= 0 ; i--)
>>>
>>> We certainly need to do /something/ here, but I'm not sure
>>> this is it.
>>> Adam Belay has code to limit PCI state restoration to the
>>> PCI-specified
>>> registers, with the idea being that individual drivers fix things up
>>> properly. While this has the obvious drawback that almost every PCI
>>> driver in the tree would then need fixing up, it's also probably the
>>> right thing.
>>
>> it has a second drawback: it assumes all devices HAVE a driver, which
>> isn't normally the case...
>
> Adam mentioned earlier, and I agree, that it is probably a bad
> idea for this code to blindly scribble on the BIST field at i=3.
> Probably we should clear that field before restoring it.
>
> Re: this patch
> I think that this patch is likely a positive forward step.
> It seems logical to restore the BARs before the CMD/STATUS in general,
> nothing specific to the ICH here.
>
> But yes, this is a helper routine and devices where it hurts
> instead of helps should have their own routine.  Complex devices
> need to handle the device-specific config space state above these
> 1st 16 locations anyway.

Right, and because we only restore the first 0x40 or so registers (they're all
standard), I don't think implementing pci_save/restore_state() properly 
is going
to break much at all.  I'm planning to merge these changes with -mm, so
hopefully it won't be difficult to tell. :)

Re: devices without drivers

We can certainly call a generic save and restore function when there isn't a
driver available, but beyond handling standard registers mentioned in 
the spec,
if important hardware context is lost there's really no way around it.

-Adam


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

end of thread, other threads:[~2006-04-26  0:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-25  6:50 [PATCH] reverse pci config space restore order Yu, Luming
2006-04-25 10:48 ` Matthew Garrett
2006-04-25 10:51   ` Arjan van de Ven
2006-04-25 11:01     ` Matthew Garrett
  -- strict thread matches above, loose matches on Subject: below --
2006-04-25 18:22 Brown, Len
2006-04-25 23:59 ` abelay

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