Skip to content

Commit 00be43a

Browse files
AndybnACTdavem330
authored andcommitted
net: axienet: make the 64b addresable DMA depends on 64b archectures
Currently it is not safe to config the IP as 64-bit addressable on 32-bit archectures, which cannot perform a double-word store on its descriptor pointers. The pointer is 64-bit wide if the IP is configured as 64-bit, and the device would process the partially updated pointer on some states if the pointer was updated via two store-words. To prevent such condition, we force a probe fail if we discover that the IP has 64-bit capability but it is not running on a 64-Bit kernel. This is a series of patch (1/2). The next patch must be applied in order to make 64b DMA safe on 64b archectures. Signed-off-by: Andy Chiu <[email protected]> Reported-by: Max Hsu <[email protected]> Reviewed-by: Greentime Hu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a5b00f5 commit 00be43a

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

drivers/net/ethernet/xilinx/xilinx_axienet.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,42 @@ static inline void axienet_iow(struct axienet_local *lp, off_t offset,
547547
iowrite32(value, lp->regs + offset);
548548
}
549549

550+
/**
551+
* axienet_dma_out32 - Memory mapped Axi DMA register write.
552+
* @lp: Pointer to axienet local structure
553+
* @reg: Address offset from the base address of the Axi DMA core
554+
* @value: Value to be written into the Axi DMA register
555+
*
556+
* This function writes the desired value into the corresponding Axi DMA
557+
* register.
558+
*/
559+
560+
static inline void axienet_dma_out32(struct axienet_local *lp,
561+
off_t reg, u32 value)
562+
{
563+
iowrite32(value, lp->dma_regs + reg);
564+
}
565+
566+
#ifdef CONFIG_64BIT
567+
static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
568+
dma_addr_t addr)
569+
{
570+
axienet_dma_out32(lp, reg, lower_32_bits(addr));
571+
572+
if (lp->features & XAE_FEATURE_DMA_64BIT)
573+
axienet_dma_out32(lp, reg + 4, upper_32_bits(addr));
574+
}
575+
576+
#else /* CONFIG_64BIT */
577+
578+
static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
579+
dma_addr_t addr)
580+
{
581+
axienet_dma_out32(lp, reg, lower_32_bits(addr));
582+
}
583+
584+
#endif /* CONFIG_64BIT */
585+
550586
/* Function prototypes visible in xilinx_axienet_mdio.c for other files */
551587
int axienet_mdio_enable(struct axienet_local *lp);
552588
void axienet_mdio_disable(struct axienet_local *lp);

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,30 +133,6 @@ static inline u32 axienet_dma_in32(struct axienet_local *lp, off_t reg)
133133
return ioread32(lp->dma_regs + reg);
134134
}
135135

136-
/**
137-
* axienet_dma_out32 - Memory mapped Axi DMA register write.
138-
* @lp: Pointer to axienet local structure
139-
* @reg: Address offset from the base address of the Axi DMA core
140-
* @value: Value to be written into the Axi DMA register
141-
*
142-
* This function writes the desired value into the corresponding Axi DMA
143-
* register.
144-
*/
145-
static inline void axienet_dma_out32(struct axienet_local *lp,
146-
off_t reg, u32 value)
147-
{
148-
iowrite32(value, lp->dma_regs + reg);
149-
}
150-
151-
static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
152-
dma_addr_t addr)
153-
{
154-
axienet_dma_out32(lp, reg, lower_32_bits(addr));
155-
156-
if (lp->features & XAE_FEATURE_DMA_64BIT)
157-
axienet_dma_out32(lp, reg + 4, upper_32_bits(addr));
158-
}
159-
160136
static void desc_set_phys_addr(struct axienet_local *lp, dma_addr_t addr,
161137
struct axidma_bd *desc)
162138
{
@@ -2061,6 +2037,10 @@ static int axienet_probe(struct platform_device *pdev)
20612037
iowrite32(0x0, desc);
20622038
}
20632039
}
2040+
if (!IS_ENABLED(CONFIG_64BIT) && lp->features & XAE_FEATURE_DMA_64BIT) {
2041+
dev_err(&pdev->dev, "64-bit addressable DMA is not compatible with 32-bit archecture\n");
2042+
goto cleanup_clk;
2043+
}
20642044

20652045
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_width));
20662046
if (ret) {

0 commit comments

Comments
 (0)