[Fwd: Re: ohci1394: steps to implement suspend/resume]
Hello LinuxPPC-dev,
we have now patches coming in to fix up the lack of generic suspend + resume support in drivers/ieee1394/ohci1394. Attached is the latest and by far most functional one by Bernhard Kaindl. A big question is how this relates to the already existing PPC-PMAC platform code in ohci1394's suspend and resume hooks.
- Which functionalities does the existing platform code provide in detail?
- Do we have to keep platform code and generic code separate? I.e.
#ifdef CONFIG_PPC_PMAC ...pmac_call_feature... #else ...new generic code...
#endif
- Or are parts of the until now missing, new generic code necessary for PMacs too? If yes, is the platform code treated to be the lowest level as far as the oreder of code is concerned?
- Or would the platform code be obsolete?
We already broke your platform code once by what was meant as a bugfix for non-PMacs. It'd be good to know enough to not repeat such mistakes...
Thanks in advance,
Signature · 3 lines
Stefan Richter -=====-=-==- =--= --==- http://arcgraph.de/sr/
Hi,
I did a quick shot on what I described and the appended patch does the first thing needed for working suspend/resume in ohci1394 which is HW de- and re-initialisation.
It works with suspend2disk on my Ricoh R5C552 IEEE 1394 Controller with the 2.6.17 kernel to the extent that if I call dvgrab --interactive after suspend2disk without unloading ohci1394, it does not lock up dvgrab with 100% CPU but properly connects to the camera, given that I first unplug and plug the camera after coming back from suspend.
I guess that could be fixed by forcing a bus reset in the resume function.
I cannot test suspend to RAM here at the moment and should follow the guidelines in Documentation/power/pci.txt also, so this is rather a quick report than a finished patch and there are some rough edges:
However, with this patch, I have to unload at least some in-kernel users of ohci1394 like dv1394 or video1394 before suspending.
Not doing that caused an Oops and a bad tasklet error, probably from not handling ISO tasklets during suspend/resume properly.
Maybe these can be temporarily cleared or unregistered and re-registered for suspend/resume with help from the other layers or from the highlevel 1394 core, but I do not really know what these do.
But this patch provides a useful base to start from and is already of much help for people which do not need dv1394 and video1394 or can unload them at least during suspend.
I cannot test function with sbp2 at the moment, but raw1394 seems to work fine.
Bernhard
PS: ohci1394-suspendresume-v1.patch:
(I'm only a normal paying FSFE-Fellow)
ieee1394/ohci1394.c +69 -0
@@ -3528,6 +3530,8 @@static int ohci1394_pci_resume (struct pci_dev *pdev) { +struct ti_ohci *ohci; +#ifdef CONFIG_PPC_PMAC if (machine_is (powermac)) {struct device_node *of_node;
@@ -3541,12 +3545,41 @@pci_enable_device (pdev); + ohci =pci_get_drvdata (pdev); +if (!ohci) +return -1 ;// or which exit status to use? + +KERN_DEBUG ,"resume called" ); + +/* The following lines are copied from ohci1394_pci_probe(): */ + +/* Start off with a soft reset, to clear everything to a sane +* state. */ +ohci_soft_reset (ohci); + +/* Now enable LPS, which we need in order to start accessing +* most of the registers. In fact, on some cards (ALI M5251), +* accessing registers in the SClk domain without LPS enabled +* will lock up the machine. Wait 50msec to make sure we have +* full link enabled. */ +reg_write (ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS); + +/* Disable and clear interrupts */ +reg_write (ohci, OHCI1394_IntEventClear,0xffffffff ); +reg_write (ohci, OHCI1394_IntMaskClear,0xffffffff ); + +mdelay (50 ); + +ohci_initialize (ohci); +return 0 ; }static int ohci1394_pci_suspend (struct pci_dev *pdev,pm_message_t state) { +struct ti_ohci *ohci; +#ifdef CONFIG_PPC_PMAC if (machine_is (powermac)) {struct device_node *of_node;
@@ -3558,6 +3591,44 @@ }#endif + ohci =pci_get_drvdata (pdev); +if (!ohci) +return -1 ;// Not sure if this is the correct return code + +KERN_DEBUG ,"suspend called" ); + +/* clear the async DMA contexts and stop using the controller: */ +hpsb_bus_reset (ohci->host); + +/* The following calls are from ohci1394_pci_remove(): */ + +/* Clear out BUS Options */ +reg_write (ohci, OHCI1394_ConfigROMhdr,0 ); +reg_write (ohci, OHCI1394_BusOptions, + (reg_read (ohci, OHCI1394_BusOptions) &0x0000f007 ) | +0x00ff0000 ); + +/* Clear interrupt registers */ +reg_write (ohci, OHCI1394_IntMaskClear,0xffffffff ); +reg_write (ohci, OHCI1394_IntEventClear,0xffffffff ); +reg_write (ohci, OHCI1394_IsoXmitIntMaskClear,0xffffffff ); +reg_write (ohci, OHCI1394_IsoXmitIntEventClear,0xffffffff ); +reg_write (ohci, OHCI1394_IsoRecvIntMaskClear,0xffffffff ); +reg_write (ohci, OHCI1394_IsoRecvIntEventClear,0xffffffff ); + +/* Disable IRM Contender */ +set_phy_reg (ohci,4 , ~0xc0 &get_phy_reg (ohci,4 )); + +/* Clear link control register */ +reg_write (ohci, OHCI1394_LinkControlClear,0xffffffff ); + +/* Let all other nodes know to ignore us */ +ohci_devctl (ohci->host,RESET_BUS ,LONG_RESET_NO_FORCE_ROOT ); + +/* This stops all DMA contexts, disables interrupts, +* and clears linkEnable and LPS: */ +ohci_soft_reset (ohci); +return 0 ; }
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux1394-devel
Quoted 18 lines · Stefan Richter
Hello LinuxPPC-dev,
we have now patches coming in to fix up the lack of generic suspend + resume support in
drivers/ieee1394/ohci1394. Attached is the latest and by far most functional one by Bernhard Kaindl. A big question is how this relates to the already existing PPC-PMAC platform code in ohci1394's suspend and resume hooks.- Which functionalities does the existing platform code provide in detail?
- Do we have to keep platform code and generic code separate? I.e.
#ifdef CONFIG_PPC_PMAC ...pmac_call_feature... #else ...new generic code...#endif
Quoted 8 lines
- Or are parts of the until now missing, new generic code necessary for PMacs too? If yes, is the platform code treated to be the lowest level as far as the oreder of code is concerned?
- Or would the platform code be obsolete?
We already broke your platform code once by what was meant as a bugfix for non-PMacs. It'd be good to know enough to not repeat such mistakes...
The PowerMac code will stop the chip clocks. It should be used as the last step of the suspend sequence and first step of the return sequence, in _addition_ to your new code. Note also that the code you posted lacks calls to pci_set_power_state()...
Ben.
Quoted 1 line · Benjamin Herrenschmidt
On Wed, 2006-09-06 at 16:46 +0200, Stefan Richter wrote:
[...]
Quoted 6 lines
Quoted 2 lines
We already broke your platform code once by what was meant as a bugfix for non-PMacs. It'd be good to know enough to not repeat such mistakes...
The PowerMac code will stop the chip clocks. It should be used as the last step of the suspend sequence and first step of the return sequence, in _addition_ to your new code.
Thanks for the help.
Quoted 1 line
Note also that the code you posted lacks calls to
pci_set_power_state()...
Pavel submitted a respective patch on 2006-09-05; I will integrate them both.
Signature · 3 lines
Stefan Richter -=====-=-==- =--= --=== http://arcgraph.de/sr/
Quoted 11 lines · Stefan Richter
Quoted 1 line · Benjamin Herrenschmidt
On Wed, 2006-09-06 at 16:46 +0200, Stefan Richter wrote:
[...]
Quoted 6 lines
Quoted 2 lines
We already broke your platform code once by what was meant as a bugfix for non-PMacs. It'd be good to know enough to not repeat such mistakes...
The PowerMac code will stop the chip clocks. It should be used as the last step of the suspend sequence and first step of the return sequence, in _addition_ to your new code.
Thanks for the help.
np. I'll try to test if I find some time :)
Ben.