From nobody Fri Nov 20 13:55:55 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jWH175pR5z71ncL for ; Fri, 20 Nov 2026 13:55:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jWH173wjBz4TjC for ; Fri, 20 Nov 2026 13:55:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795182955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4/ty3nPMrOrW2by+x5UbPX8T+0SYlnJSimGR00qHQvc=; b=fO7hTuDKVvarlbiolJjUvYI0Fex/sG7NiB4ysE1sWrR81lyVx7EkOpW9RDaoNc3Q/CA7YT kmO7dZPjytEMBcImJYqqAG2pESO33J6u9zlP2HAkJ7o5vIm0tGUcAVwIs0snGwjw4+WcEf Nzf5TaLReYMONBaJBC5YaOGPtBLbP/COMnzicbWAdEB1nbq630BOcKwRpq7u3HUmy9cjzZ F5xnDAplcf3Ti5DNC5F1B7RWTt8Wjp2dA5PzneCIcRceYi6MISw7Au6wK2bDKTsyyCzQ+o 98JDOD0l0E0tBVNVMGhvKuujAekH3xwI9Xml76+BIVFjGo9f6/2tiyzNj3qXuw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795182955; b=W0sMr8KY34B8T0EIuJ5fA22L/YJ1PGv1+yZoS+3QLnk/+4OpDZtF0fJ4XN3Lb6czg9SxF+ UH5uad5RDKKAnCZDBk86AwpcCpVFNVQncsD1Im/a70ACsKhSyElwkrHGklXWXvE+zIC1aP hITMeGnOI1IN5R8HuEnsWVCtjl++x/PSnmQqMAO/jDqLMNFFiGruqQEoGHsIkjpde4jvjC 9lwccNF/WuO3ad9iW5aAsQ62wsTiO89MnWb6MnIPCvQgEwyJWrtPoaXw/0jMAFFvTwswqF ZLGYrN2L45gpUokfRXgACjAi5NTGrH2JJAxkphU5q6OGTDjD/aF8E1bbKB3DTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795182955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4/ty3nPMrOrW2by+x5UbPX8T+0SYlnJSimGR00qHQvc=; b=J8tQVijR9CH4xfKxDWAVBx7UVU/4pmmw5y5o1kb7lrhTklID2crDYTGtdH2srM/CaptELj yjTBJZPW0jSMK/q6K1LRyljXv1J+W7DXam70Z6kpvA86MqRxXGwmTqYqCmckAF0MIMYkdX +kO0wwenY8dUSfmjP5yDj9CKPeG4ikTTforuECzY3FlJaMmaiaIUt6PdRCaZMq9UGDQZMK SjgHDuwSswx+mdYsm9C2tC0XmcNRiwAl+WSF93jfzOZh0+VOXwZTfq1RQsFaFd4/Ktz9Fr AnUdwJR9Jp4nj8OjKgpeiS96v58G2sb+dCo49VN/3VjigmZotm7OPHjgTT4HFA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jWH173b2bzrHp for ; Fri, 20 Nov 2026 13:55:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id ffb2 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 20 Nov 2026 13:55:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 200b2faf4819 - main - dwc: Limit the DMA of the QoS core to the address width of the hardware List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 200b2faf481930ae66984743f04efccebde920d3 Auto-Submitted: auto-generated Date: Fri, 20 Nov 2026 13:55:55 +0000 Message-Id: <6b00516b.ffb2.333c61eb@gitrepo.freebsd.org> The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=200b2faf481930ae66984743f04efccebde920d3 commit 200b2faf481930ae66984743f04efccebde920d3 Author: Emmanuel Vadot AuthorDate: 2026-10-27 11:07:48 +0000 Commit: Emmanuel Vadot CommitDate: 2026-11-20 13:55:33 +0000 dwc: Limit the DMA of the QoS core to the address width of the hardware The QoS core is used with the 64 bits descriptor address scheme, TDES1 and the *DLAR_HI registers holding the upper 32 bits. This only works when the core was synthesized with a wider than 32 bits address bus. The RK3568 GMAC for example has a 32 bits DMA: DMASBMR.EAME cannot be set and the *DLAR_HI registers read back as zero. The DMA tags allowed any address, so on systems with memory above 4GB the descriptor rings and the mbufs could be allocated there and the core fetched descriptors and data from the truncated addresses. Nothing could be sent or received. Read the address width from the ADDR64 field of the MAC hardware feature 1 register, like Linux does, and limit the DMA tags to it. Memory that cannot be reached is bounced by busdma. Tested on a Quartz64 Model A with 8GB of RAM and on a NanoPi R5S. Reviewed by: br Differential Revision: https://reviews.freebsd.org/D61018 --- sys/dev/dwc/dwc4_dma.c | 26 ++++++++++++++++++++++---- sys/dev/dwc/dwc4_reg.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/dev/dwc/dwc4_dma.c b/sys/dev/dwc/dwc4_dma.c index 15a454dcee15..c42fb1e5e8c5 100644 --- a/sys/dev/dwc/dwc4_dma.c +++ b/sys/dev/dwc/dwc4_dma.c @@ -621,10 +621,28 @@ int dma4_init(struct dwc_softc *sc) { struct mbuf *m; + bus_addr_t lowaddr; uint32_t reg; + u_int addr_bits; int error; int idx; + /* The address width of the DMA is a synthesis option of the core. */ + reg = READ4(sc, ETH_MACHWF1R); + switch ((reg & MACHWF1R_ADDR64_M) >> MACHWF1R_ADDR64_S) { + case 1: + addr_bits = 40; + break; + case 2: + addr_bits = 48; + break; + default: + addr_bits = 32; + break; + } + lowaddr = (bus_addr_t)MIN(((uint64_t)1 << addr_bits) - 1, + (uint64_t)BUS_SPACE_MAXADDR); + WRITE4(sc, ETH_MACQ0TXFCR, 0xffff << 16 | 1); WRITE4(sc, ETH_MACRXFCR, 1); @@ -692,7 +710,7 @@ dma4_init(struct dwc_softc *sc) error = bus_dma_tag_create( bus_get_dma_tag(sc->dev), /* Parent tag. */ DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ TX_DESC_SIZE, 1, /* maxsize, nsegments */ @@ -727,7 +745,7 @@ dma4_init(struct dwc_softc *sc) error = bus_dma_tag_create( bus_get_dma_tag(sc->dev), /* Parent tag. */ 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ MCLBYTES * TX_MAP_MAX_SEGS, /* maxsize */ @@ -766,7 +784,7 @@ dma4_init(struct dwc_softc *sc) error = bus_dma_tag_create( bus_get_dma_tag(sc->dev), /* Parent tag. */ DWC_DESC_RING_ALIGN, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ RX_DESC_SIZE, 1, /* maxsize, nsegments */ @@ -801,7 +819,7 @@ dma4_init(struct dwc_softc *sc) error = bus_dma_tag_create( bus_get_dma_tag(sc->dev), /* Parent tag. */ 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ MCLBYTES, 1, /* maxsize, nsegments */ diff --git a/sys/dev/dwc/dwc4_reg.h b/sys/dev/dwc/dwc4_reg.h index 87d234274159..b7c96433cb55 100644 --- a/sys/dev/dwc/dwc4_reg.h +++ b/sys/dev/dwc/dwc4_reg.h @@ -76,6 +76,8 @@ #define ETH_MACDR 0x0114 #define ETH_MACHWF0R 0x011C #define ETH_MACHWF1R 0x0120 +#define MACHWF1R_ADDR64_S 14 /* Address Width */ +#define MACHWF1R_ADDR64_M (0x3 << MACHWF1R_ADDR64_S) #define ETH_MACHWF2R 0x0124 #define ETH_MACHWF3R 0x0128 #define ETH_MACMDIOAR 0x0200