Power Computing DEAD dbdma fix (finally)
Hi List,
Here is (finally working, we think) a patch for people with Power Computing machines which exhibit DEAD dbdma status on PCI/dma interaction.
This patch is for test - the driver ID comes up 99.7 - and please ignore the comment about spin-locks. I've left those out of the patch because they are still under test.
Many thanks to Michael Zucca who tested the latest set of changes and Kostas Gewrgiou who did most of the orignally trials...
Please note that it cannot cure the "glitch" - by the time dbdma is DEAD the damage is done - what it should do is to keep the sound going with minimum disruption
The patch should apply to either BK 2.4.x (after my other patch has been applied) or to Ben H's tree (which already has those patches).
enjoy - and Power Computing machine owners - tell us how it does.
Iain.
dmasound_awacs-pow-comp-test.c renamed from usr/local/benh-2-4/drivers/sound/dmasound/dmasound_awacs.c +29 -14
@@ -29,17 +29,22 @@* input selectors are just two-state (>50% == ON) and the * Input Gain slider handles the rest of the gain issues. * - try to pick slider representations that most closely match -* the actual use - e.g. IGain for input gain... +* the actual use - e.g. IGain for input gain... +* - first stab at over/under-run detection. * - minor cosmetic changes to IRQ identification. * - fix bug where rates > max would be reported as supported. * - first stab at over/under-run detection. * - make use of i2c for mixer settings conditional on perch -* rather than cuda (some machines without perch have cuda). +* rather than cuda (some machines without perch have cuda). +* - fix bug where TX stops when dbdma status comes up "DEAD" * so far only reported on PowerComputing clones ... but. * - put in AWACS/Screamer register write timeouts. * - part way to partitioning the init() stuff * - first pass at 'tumbler' stuff (not support - just an attempt * to allow the driver to load on new G4s). +* 28/04/2001 [99.7] ***TEST VERSION will be 0.7 when it's working *** +* - put in spin_locks. +* 26/07/2000 - mods to DEAD status handling. */ /* GENERAL FIXME/TODO: check that the assumptions about what is written to
@@ -77,8 +82,8 @@#include "awacs_defs.h" #include "dmasound.h" -#define DMASOUND_AWACS_REVISION 0 -#define DMASOUND_AWACS_EDITION 6 +#define DMASOUND_AWACS_REVISION 99 +#define DMASOUND_AWACS_EDITION 7#define AWACS_BURGUNDY 100/* fake revision # for burgundy */ #define AWACS_TUMBLER 90/* fake revision # for tumbler */
@@ -689,9 +694,6 @@if (stat &DEAD ) {unsigned short req, res ;unsigned int phy ; -#ifdef DEBUG_DMASOUND -printk ("dmasound_pmac: tx-irq: xfer died - patching it up...\n" ) ; -#endif /* to clear DEAD status we must first clear RUN set it to quiescent to be on the safe side */ (void )in_le32 (&awacs_txdma->status);
@@ -714,7 +716,7 @@st_le16 (&cp->res_count,0 );st_le16 (&cp->xfer_status,0 );st_le32 (&cp->phy_addr, phy); -st_le16 (&cp->command,OUTPUT_MORE +INTR_ALWAYS ); +st_le16 (&cp->command,OUTPUT_MORE +INTR_ALWAYS +BR_ALWAYS );/* point at our patched up command block */ out_le32 (&awacs_txdma->cmdptr,virt_to_bus (cp));/* we must re-start the controller */
@@ -722,6 +724,9 @@/* should complete clearing the DEAD status */ out_le32 (&awacs_txdma->control, ((RUN |WAKE ) <<16 ) + (RUN |WAKE )); +#ifdef DEBUG_DMASOUND +printk ("dmasound_pmac: tx-irq: xfer died - patched it up...\n" ) ; +#endif break ;/* this block is still going */ }if ((stat &ACTIVE ) ==0 )
@@ -784,9 +789,6 @@TODO: figure out how best to fix it up */ if (stat &DEAD ){ -#ifdef DEBUG_DMASOUND -printk ("dmasound_pmac: rx-irq: DIED - attempting resurection\n" ); -#endif /* to clear DEAD status we must first clear RUN set it to quiescent to be on the safe side */ (void )in_le32 (&awacs_txdma->status);
@@ -804,6 +806,9 @@/* should complete clearing the DEAD status */ out_le32 (&awacs_rxdma->control, ((RUN |WAKE ) <<16 ) + (RUN |WAKE )); +#ifdef DEBUG_DMASOUND +printk ("dmasound_pmac: rx-irq: DIED - attempted resurrection\n" ); +#endif return ;/* try this block again */ }/* Clear status and move on to next buffer.
@@ -1016,6 +1021,10 @@out_le32 (&awacs->byteswap,0 ); } +/* Iain: all current models support power-saving - should this stuff really +be conditional on PowerBooks? +*/ +#ifdef CONFIG_PMAC_PBOOK /* * Save state when going to sleep, restore it afterwards.
@@ -1773,8 +1782,12 @@ cp = awacs_tx_cmds;memset ((void *)cp,0 , (write_sq.max_count+1 ) *sizeof (struct dbdma_cmd )); -for (i =0 ; i < write_sq.max_count; ++i, ++cp) { +for (i =0 ; i < write_sq.max_count; i++, cp++) { +st_le32 (&cp->cmd_dep,virt_to_bus (cp+1 ));/* for DEAD recov */ st_le32 (&cp->phy_addr,virt_to_bus (write_sq.buffers[i])); +st_le16 (&cp->command,OUTPUT_MORE +INTR_ALWAYS ); +st_le16 (&cp->req_count, write_sq.block_size); +st_le16 (&cp->xfer_status,0 ); }st_le16 (&cp->command,DBDMA_NOP +BR_ALWAYS );st_le32 (&cp->cmd_dep,virt_to_bus (awacs_tx_cmds));
@@ -1831,6 +1844,7 @@/* Set dma buffers up in a loop */ for (i =0 ; i < read_sq.max_count; i++,cp++) {st_le32 (&cp->phy_addr,virt_to_bus (read_sq.buffers[i])); +st_le32 (&cp->cmd_dep,virt_to_bus (cp+1 ));/* for DEAD recov */ st_le16 (&cp->command,INPUT_MORE +INTR_ALWAYS );st_le16 (&cp->req_count, read_sq.block_size);st_le16 (&cp->xfer_status,0 );
@@ -2258,10 +2272,10 @@break ; } } -if (rev ==2 ) { +if (rev ==2 || rev ==3 ) { hw_can_byteswap =0 ;#ifdef DEBUG_DMASOUND -printk ("dmasound_pmac: found Keylargo rev 2 - H/W byte-swap disabled\n" ) ; +printk ("dmasound_pmac: found Keylargo rev 2/3 - H/W byte-swap disabled\n" ) ;#endif } }
@@ -2293,6 +2307,7 @@DBDMA_ALIGN (beep_dbdma_cmd_space);/* set up emergency dbdma cmd */ emergency_dbdma_cmd = beep_dbdma_cmd+1 ; + beep_buf = (short *)kmalloc (BEEP_BUFLEN *4 ,GFP_KERNEL );if (beep_buf ==NULL ) {printk (KERN_ERR "dmasound_pmac: no memory for beep buffer\n" );
Hats off to Iain for fixing this bug!
The fix can't be understated. I noticed that when this patch wasn't fixed, the DEAD dbdma engine was somehow messing with PCI bus data. I noticed this under X when I was using sound, there was garbage in some of the pixmaps and scrolled regions. After the patch, X runs fine. This sort of corruption behavior would be disasterous on something like a PCI disk controller.
So I ask that anybody currently maintaining a device which uses the DBDMA engine to check your code and see if it deals with the DEAD status properly.
Thanks folks!
____________________________________________________________________
Michael Zucca - [email protected] - http://www.mdc.net/~mrz5149/
"I will choose a path that's clear. I will choose Freewill. "
--Rush, Freewill
____________________________________________________________________
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Thank you! This does the job. Any chance of getting this into the -benh or Linus kernel?
Just to let you know how much I had to run my "killall xmms; rmmod dmasound; insmod dmasound" script before your patch:
Aug 30 01:46:51 like kernel: dmasound_pmac: tx-irq: xfer died - patched it up... Aug 30 01:50:15 like kernel: dmasound_pmac: tx-irq: xfer died - patched it up... Aug 30 01:51:19 like last message repeated 4 times Aug 30 01:52:29 like last message repeated 2 times Aug 30 02:05:01 like last message repeated 2 times Aug 30 02:06:02 like last message repeated 52 times
Thanks,
Peter
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/