From nobody Sat Sep 19 14:40:28 2026 X-Original-To: dev-commits-src-branches@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 4hnBx82nXxz6srky for ; Sat, 19 Sep 2026 14:40:28 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hnBx81d5Fz4Wpk for ; Sat, 19 Sep 2026 14:40:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789828828; 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=UGhyeew54MKSdimJqDvDR7fcR2K/2Mn5NPiOlAPFurM=; b=F9rVa7EyNTkC+qT2j9p9yFs+mydQw6ywXWvgIQtwNB+N/mBTJCPU/2c2mzL4lawccX9vmF QXZPFQGfz/ltVQKMsIyTOx0NEZh0fuyrY2YEn91h7b9MdAF0h+Az5Tcz5NkoYhsffMfsCx CBH0fO+6cvOZywWV1RPpQLfEc2h7bjIvVfLyA1CVTF8uaNH9yA6jrg0nw20YbmyxrDNj9o InUlgRrMNrbOlkytcWiFwxqzdAEpM9sAFmMhOKD0qFCLODsJAV1e806aKFnhE8ULAIGhLC KSPaRYvi/4EAXRBcjj+rWCPnA8DO41GthhxpZYGow1PFx2VLeVv8RHmuOC/Y1w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789828828; b=i2ZtsMHB45FymdoMA/Cm0/u4vVgl76AKO8o3az4/1A6vtMh0ELUf6Rwc+zD2BzavCfW+mb B1yH+Sv6NvzHSVaejxnKqOZNrQY/ndnE5Sjy2W5VoyxLqxv7JC1y6pmNQtk5u1+i/toT8o zW+OpIhlDK6O9APIcNk8IkMCOZpFmbUYlNMqLwHBwmJY79ZQLx/9OBwslxNV6P6haoJ7rN KUW12yv9VL3Wwtiu+Bsj8dEK7lSstuj0Abv34ZLU5vFobG/asjMJ3xSS920pzLp9fRnIsB ctSOmO8XlcnxXLF6JoHztqR/v8UiiVxYGAwcHA3lHbpZnC+pC/a+ADUhCNUpiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789828828; 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=UGhyeew54MKSdimJqDvDR7fcR2K/2Mn5NPiOlAPFurM=; b=o+cr/OV13nCFEOqHiyH3T70dnwzBnojlQmahul4J79YMxwFw/555BaKbRfjCn2EGOL3EDv k5GKCpCZ2aBHPkFiFooD2Oj0wj4BNFDsCNIgPfYpaVu5fP3A6SHKDJMGtaK2pZXTiSnNMY FSBNA8RbfLcaFmpbVIXwcXHdhVg9uBXqFY76O2XN9XfWH+jMALkEdsj4IMPZM8/0wPk7bg oZMemU0b+piY6IDr/tKSAJH0TsPmGGBTxbigx2dc0svRxqw470tx8VjksWLB4UnaF7UoZH BhqiTrGJ5tr0LZLhQNFg9g8LrBffRAt7/eSgcbw0T1ccQ6DJM5laU9nCSDmhRQ== 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 4hnBx80kC6z16nH for ; Sat, 19 Sep 2026 14:40:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18ba1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 19 Sep 2026 14:40:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 0b1dea8f51e4 - stable/15 - LinuxKPI: implement dma_{alloc,free}_{noncoherent,attrs} List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 0b1dea8f51e41fa602294cf2526481c49123e2da Auto-Submitted: auto-generated Date: Sat, 19 Sep 2026 14:40:28 +0000 Message-Id: <6aae9edc.18ba1.6d15bf07@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=0b1dea8f51e41fa602294cf2526481c49123e2da commit 0b1dea8f51e41fa602294cf2526481c49123e2da Author: Bjoern A. Zeeb AuthorDate: 2026-08-16 21:54:36 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-09-19 09:34:10 +0000 LinuxKPI: implement dma_{alloc,free}_{noncoherent,attrs} We use one to implement the other given direction stays unused. This is needed by an upcoming wifi driver. Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D58880 (cherry picked from commit c3fa17a6a331db8aad03e9cb89ba97e1811ab381) --- .../linuxkpi/common/include/linux/dma-mapping.h | 36 ++++++++++++++++ sys/compat/linuxkpi/common/src/linux_pci.c | 50 ++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h index 173b3e8d3c96..bb1ef678e621 100644 --- a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h +++ b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h @@ -98,6 +98,14 @@ void *linuxkpi_dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag); void linuxkpi_dmam_free_coherent(struct device *dev, size_t size, void *addr, dma_addr_t dma_handle); +void *linuxkpi_dma_alloc_noncoherent(struct device *, size_t, dma_addr_t *, + enum dma_data_direction, gfp_t); +void linuxkpi_dma_free_noncoherent(struct device *, size_t, void *, + dma_addr_t, enum dma_data_direction); +void *linuxkpi_dma_alloc_attrs(struct device *, size_t, dma_addr_t *, + gfp_t, unsigned long); +void linuxkpi_dma_free_attrs(struct device *, size_t, void *, + dma_addr_t, unsigned long); dma_addr_t linux_dma_map_phys(struct device *dev, vm_paddr_t phys, size_t len); /* backward compat */ dma_addr_t lkpi_dma_map_phys(struct device *, vm_paddr_t, size_t, enum dma_data_direction, unsigned long); @@ -191,6 +199,34 @@ dmam_free_coherent(struct device *dev, size_t size, void *addr, linuxkpi_dmam_free_coherent(dev, size, addr, dma_handle); } +static inline void * +dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, + enum dma_data_direction direction, gfp_t gfp) +{ + return (linuxkpi_dma_alloc_noncoherent(dev, size, dma_handle, direction, gfp)); +} + +static inline void +dma_free_noncoherent(struct device *dev, size_t size, void *vaddr, + dma_addr_t dma_handle, enum dma_data_direction direction) +{ + linuxkpi_dma_free_noncoherent(dev, size, vaddr, dma_handle, direction); +} + +static inline void * +dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, + gfp_t gfp, unsigned long attrs) +{ + return (linuxkpi_dma_alloc_attrs(dev, size, dma_handle, gfp, attrs)); +} + +static inline void +dma_free_attrs(struct device *dev, size_t size, void *vaddr, + dma_addr_t dma_handle, unsigned long attrs) +{ + linuxkpi_dma_free_attrs(dev, size, vaddr, dma_handle, attrs); +} + static inline dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page, size_t offset, size_t size, enum dma_data_direction direction, unsigned long attrs) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 4909b52150ae..ab8d5cf98534 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -1989,6 +1989,56 @@ linuxkpi_dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_ha return (dr->mem); } +void * +linuxkpi_dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, + enum dma_data_direction direction, gfp_t gfp) +{ + struct linux_dma_priv *priv; + size_t align; + void *mem; + + size = PAGE_ALIGN(size); + align = PAGE_SIZE << get_order(size); + mem = kmem_alloc_contig(size, gfp & GFP_NATIVE_MASK, 0, BUS_SPACE_MAXADDR, + align, 0, VM_MEMATTR_DEFAULT); + if (mem == NULL) { + *dma_handle = 0; + return (NULL); + } + + priv = dev->dma_priv; + *dma_handle = linux_dma_map_phys_common(dev, vtophys(mem), size, priv->dmat); + if (*dma_handle == 0) { + kmem_free(mem, size); + mem = NULL; + } + return (mem); +} + +void +linuxkpi_dma_free_noncoherent(struct device *dev, size_t size, void *vaddr, + dma_addr_t dma_handle, enum dma_data_direction direction) +{ + lkpi_dma_unmap(dev, dma_handle, size, direction, 0); + kmem_free(vaddr, size); +} + +void * +linuxkpi_dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, + gfp_t gfp, unsigned long attrs) +{ + return (linuxkpi_dma_alloc_noncoherent(dev, size, dma_handle, + DMA_BIDIRECTIONAL, gfp)); +} + +void +linuxkpi_dma_free_attrs(struct device *dev, size_t size, void *vaddr, + dma_addr_t dma_handle, unsigned long attrs) +{ + linuxkpi_dma_free_noncoherent(dev, size, vaddr, dma_handle, + DMA_BIDIRECTIONAL); +} + void linuxkpi_dma_sync(struct device *dev, dma_addr_t dma_addr, size_t size, bus_dmasync_op_t op)