All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] net: stmmac: fix dma physical address of descriptor when display ring
@ 2026-06-23  9:38 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-06-23  9:38 UTC (permalink / raw)
  To: Joakim Zhang; +Cc: netdev, linux-stm32

Hello Joakim Zhang,

Commit bfaf91ca848e ("net: stmmac: fix dma physical address of
descriptor when display ring") from Feb 25, 2021 (linux-next), leads
to the following Smatch static checker warning:

	drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:431 dwmac4_display_ring()
	warn: duplicate check 'desc_size == 32' (previous on line 418)

drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
    399 static void dwmac4_display_ring(void *head, unsigned int size, bool rx,
    400                                 dma_addr_t dma_rx_phy, unsigned int desc_size)
    401 {
    402         dma_addr_t dma_addr;
    403         int i;
    404 
    405         pr_info("%s descriptor ring:\n", rx ? "RX" : "TX");
    406 
    407         if (desc_size == sizeof(struct dma_desc)) {
    408                 struct dma_desc *p = (struct dma_desc *)head;
    409 
    410                 for (i = 0; i < size; i++) {
    411                         dma_addr = dma_rx_phy + i * sizeof(*p);
    412                         pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x\n",
    413                                 i, &dma_addr,
    414                                 le32_to_cpu(p->des0), le32_to_cpu(p->des1),
    415                                 le32_to_cpu(p->des2), le32_to_cpu(p->des3));
    416                         p++;
    417                 }
    418         } else if (desc_size == sizeof(struct dma_extended_desc)) {
    419                 struct dma_extended_desc *extp = (struct dma_extended_desc *)head;
    420 
    421                 for (i = 0; i < size; i++) {
    422                         dma_addr = dma_rx_phy + i * sizeof(*extp);
    423                         pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
    424                                 i, &dma_addr,
    425                                 le32_to_cpu(extp->basic.des0), le32_to_cpu(extp->basic.des1),
    426                                 le32_to_cpu(extp->basic.des2), le32_to_cpu(extp->basic.des3),
    427                                 le32_to_cpu(extp->des4), le32_to_cpu(extp->des5),
    428                                 le32_to_cpu(extp->des6), le32_to_cpu(extp->des7));
    429                         extp++;
    430                 }
--> 431         } else if (desc_size == sizeof(struct dma_edesc)) {

The dma_extended_desc and dma_edesc structs are the same size but
just the basic info is at the start vs at the end.  This code is
quite old, but I think maybe we changed the Kconfig so now it's showing
up as a static checker warning?

/* Extended descriptor structure (e.g. >= databook 3.50a) */
struct dma_extended_desc {
	struct dma_desc basic;	/* Basic descriptors */
	__le32 des4;	/* Extended Status */
	__le32 des5;	/* Reserved */
	__le32 des6;	/* Tx/Rx Timestamp Low */
	__le32 des7;	/* Tx/Rx Timestamp High */
};

/* Enhanced descriptor for TBS */
struct dma_edesc {
	__le32 des4;
	__le32 des5;
	__le32 des6;
	__le32 des7;
	struct dma_desc basic;
};

    432                 struct dma_edesc *ep = dma_desc_to_edesc(head);
    433 
    434                 for (i = 0; i < size; i++) {
    435                         dma_addr = dma_rx_phy + i * sizeof(*ep);
    436                         pr_info("%03d [%pad]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
    437                                 i, &dma_addr,
    438                                 le32_to_cpu(ep->des4), le32_to_cpu(ep->des5),
    439                                 le32_to_cpu(ep->des6), le32_to_cpu(ep->des7),
    440                                 le32_to_cpu(ep->basic.des0), le32_to_cpu(ep->basic.des1),
    441                                 le32_to_cpu(ep->basic.des2), le32_to_cpu(ep->basic.des3));
    442                         ep++;
    443                 }
    444         } else {
    445                 pr_err("unsupported descriptor!");
    446         }
    447 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-23  9:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23  9:38 [bug report] net: stmmac: fix dma physical address of descriptor when display ring Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.