Fix potential bug in au1xxx_ddma_add_device()
PATCH 1/1 Fix potential bug in au1xxx_ddma_add_device()
Hi,
Can anybody with a AMD DBAu1200 or DBAu1550 board test this patch out? Unfortunately I don't have one so I was not able to try it out to see if I do not brake something else.
While trying to understand the MMC driver I found a potential glitch in the design of au1xxx_ddma_add_device(). It uses find_dbdev_id(0) to find an available empty device slot in the array dbdev_tab. But id 0 is already taken by DSCR_CMD0_UART0_TX, so this entry will always be overwritten the first time au1xxx_ddma_add_device() is called. This can lead to some surprising effects when one expects the data for DSCR_CMD0_UART0_TX to be in that slot.
Signed-off-by Freddy Spierenburg <[email protected]>
Signature · 4 lines
$ cat ~/.signature Freddy Spierenburg <[email protected]> http://freddy.snarl.nl/ GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1 E588 6F17 FD5D 7941 D1E1 $ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!
include/asm-mips/mach-au1x00/au1xxx_dbdma.h +4 -1
@@ -200,7 +200,10 @@#define DSCR_CMD0_ALWAYS 31#define DSCR_NDEV_IDS 32/* THis macro is used to find/create custom device types */ -#define DSCR_DEV2CUSTOM_ID (x,d) (((((x)&0xFFFF)<<8)|0x32000000)|((d)&0xFF)) +#define DSCR_ID_BASE 0x32000000 +#define DSCR_ID_OFFSET 0x1000 +#define DSCR_ID_FREE DSCR_ID_BASE +#define DSCR_DEV2CUSTOM_ID (x,d) (((((x)&0xFFFF)<<8)|DSCR_ID_BASE)|((d)&0xFF))#define DSCR_CUSTOM2DEV_ID (x) ((x)&0xFF)
arch/mips/au1000/common/dbdma.c +18 -18
@@ -162,22 +162,22 @@ { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },/* Provide 16 user definable device types */ - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, + { DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 }, };#define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / sizeof(dbdev_tab_t))
@@ -208,9 +208,9 @@ {u32 ret =0 ;dbdev_tab_t *p=NULL ; -static u16 new_id=0x1000 ; +static u16 new_id=DSCR_ID_OFFSET ; - p =find_dbdev_id (0 ); + p =find_dbdev_id (DSCR_ID_FREE );if (NULL != p ) {memcpy (p, dev,sizeof (dbdev_tab_t));