Skip to content

Commit 16f4605

Browse files
tndavedavem330
authored andcommitted
dbri: Fix compiler warning
dbri uses 'u32' for dma handle while invoking kernel DMA APIs, instead of using dma_addr_t. This hasn't caused any 'incompatible pointer type' warning on SPARC because until now dma_addr_t is of type u32. However, recent changes in SPARC ATU (iommu) enabled 64bit DMA and therefore dma_addr_t became of type u64. This makes 'incompatible pointer type' warnings inevitable. e.g. sound/sparc/dbri.c: In function ‘snd_dbri_create’: sound/sparc/dbri.c:2538: warning: passing argument 3 of ‘dma_zalloc_coherent’ from incompatible pointer type ./include/linux/dma-mapping.h:608: note: expected ‘dma_addr_t *’ but argument is of type ‘u32 *’ For the record, dbri(sbus) driver never executes on sun4v. Therefore even though 64bit DMA is enabled on SPARC, dbri continues to use legacy iommu that guarantees DMA address is always in 32bit range. This patch resolves above compiler warning. Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com> Reviewed-by: thomas tai <thomas.tai@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e58566b commit 16f4605

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

sound/sparc/dbri.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct snd_dbri {
304304
spinlock_t lock;
305305

306306
struct dbri_dma *dma; /* Pointer to our DMA block */
307-
u32 dma_dvma; /* DBRI visible DMA address */
307+
dma_addr_t dma_dvma; /* DBRI visible DMA address */
308308

309309
void __iomem *regs; /* dbri HW regs */
310310
int dbri_irqp; /* intr queue pointer */
@@ -657,12 +657,14 @@ static void dbri_cmdwait(struct snd_dbri *dbri)
657657
*/
658658
static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
659659
{
660+
u32 dvma_addr = (u32)dbri->dma_dvma;
661+
660662
/* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */
661663
len += 2;
662664
spin_lock(&dbri->cmdlock);
663665
if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2)
664666
return dbri->cmdptr + 2;
665-
else if (len < sbus_readl(dbri->regs + REG8) - dbri->dma_dvma)
667+
else if (len < sbus_readl(dbri->regs + REG8) - dvma_addr)
666668
return dbri->dma->cmd;
667669
else
668670
printk(KERN_ERR "DBRI: no space for commands.");
@@ -680,6 +682,7 @@ static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len)
680682
*/
681683
static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len)
682684
{
685+
u32 dvma_addr = (u32)dbri->dma_dvma;
683686
s32 tmp, addr;
684687
static int wait_id = 0;
685688

@@ -689,7 +692,7 @@ static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len)
689692
*(cmd+1) = DBRI_CMD(D_WAIT, 1, wait_id);
690693

691694
/* Replace the last command with JUMP */
692-
addr = dbri->dma_dvma + (cmd - len - dbri->dma->cmd) * sizeof(s32);
695+
addr = dvma_addr + (cmd - len - dbri->dma->cmd) * sizeof(s32);
693696
*(dbri->cmdptr+1) = addr;
694697
*(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0);
695698

@@ -747,6 +750,7 @@ static void dbri_reset(struct snd_dbri *dbri)
747750
/* Lock must not be held before calling this */
748751
static void dbri_initialize(struct snd_dbri *dbri)
749752
{
753+
u32 dvma_addr = (u32)dbri->dma_dvma;
750754
s32 *cmd;
751755
u32 dma_addr;
752756
unsigned long flags;
@@ -764,7 +768,7 @@ static void dbri_initialize(struct snd_dbri *dbri)
764768
/*
765769
* Initialize the interrupt ring buffer.
766770
*/
767-
dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0);
771+
dma_addr = dvma_addr + dbri_dma_off(intr, 0);
768772
dbri->dma->intr[0] = dma_addr;
769773
dbri->dbri_irqp = 1;
770774
/*
@@ -778,7 +782,7 @@ static void dbri_initialize(struct snd_dbri *dbri)
778782
dbri->cmdptr = cmd;
779783
*(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
780784
*(cmd++) = DBRI_CMD(D_WAIT, 1, 0);
781-
dma_addr = dbri->dma_dvma + dbri_dma_off(cmd, 0);
785+
dma_addr = dvma_addr + dbri_dma_off(cmd, 0);
782786
sbus_writel(dma_addr, dbri->regs + REG8);
783787
spin_unlock(&dbri->cmdlock);
784788

@@ -1077,6 +1081,7 @@ static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr)
10771081
static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
10781082
{
10791083
struct dbri_streaminfo *info = &dbri->stream_info[streamno];
1084+
u32 dvma_addr = (u32)dbri->dma_dvma;
10801085
__u32 dvma_buffer;
10811086
int desc;
10821087
int len;
@@ -1177,7 +1182,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
11771182
else {
11781183
dbri->next_desc[last_desc] = desc;
11791184
dbri->dma->desc[last_desc].nda =
1180-
dbri->dma_dvma + dbri_dma_off(desc, desc);
1185+
dvma_addr + dbri_dma_off(desc, desc);
11811186
}
11821187

11831188
last_desc = desc;
@@ -1192,7 +1197,7 @@ static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period)
11921197
}
11931198

11941199
dbri->dma->desc[last_desc].nda =
1195-
dbri->dma_dvma + dbri_dma_off(desc, first_desc);
1200+
dvma_addr + dbri_dma_off(desc, first_desc);
11961201
dbri->next_desc[last_desc] = first_desc;
11971202
dbri->pipes[info->pipe].first_desc = first_desc;
11981203
dbri->pipes[info->pipe].desc = first_desc;
@@ -1697,6 +1702,7 @@ interrupts are disabled.
16971702
static void xmit_descs(struct snd_dbri *dbri)
16981703
{
16991704
struct dbri_streaminfo *info;
1705+
u32 dvma_addr = (u32)dbri->dma_dvma;
17001706
s32 *cmd;
17011707
unsigned long flags;
17021708
int first_td;
@@ -1718,7 +1724,7 @@ static void xmit_descs(struct snd_dbri *dbri)
17181724
*(cmd++) = DBRI_CMD(D_SDP, 0,
17191725
dbri->pipes[info->pipe].sdp
17201726
| D_SDP_P | D_SDP_EVERY | D_SDP_C);
1721-
*(cmd++) = dbri->dma_dvma +
1727+
*(cmd++) = dvma_addr +
17221728
dbri_dma_off(desc, first_td);
17231729
dbri_cmdsend(dbri, cmd, 2);
17241730

@@ -1740,7 +1746,7 @@ static void xmit_descs(struct snd_dbri *dbri)
17401746
*(cmd++) = DBRI_CMD(D_SDP, 0,
17411747
dbri->pipes[info->pipe].sdp
17421748
| D_SDP_P | D_SDP_EVERY | D_SDP_C);
1743-
*(cmd++) = dbri->dma_dvma +
1749+
*(cmd++) = dvma_addr +
17441750
dbri_dma_off(desc, first_td);
17451751
dbri_cmdsend(dbri, cmd, 2);
17461752

@@ -2539,7 +2545,7 @@ static int snd_dbri_create(struct snd_card *card,
25392545
if (!dbri->dma)
25402546
return -ENOMEM;
25412547

2542-
dprintk(D_GEN, "DMA Cmd Block 0x%p (0x%08x)\n",
2548+
dprintk(D_GEN, "DMA Cmd Block 0x%p (%pad)\n",
25432549
dbri->dma, dbri->dma_dvma);
25442550

25452551
/* Map the registers into memory. */

0 commit comments

Comments
 (0)