From nobody Fri Nov 11 17:57:47 2022 X-Original-To: dev-commits-src-main@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 4N85yg5qXxz4dThg; Fri, 11 Nov 2022 17:57:47 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N85yg59Cjz3Qwp; Fri, 11 Nov 2022 17:57:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668189467; 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=E2rKakTgIz0uRXNs8C093g3598OF1QWInRP6ec5sR+w=; b=kl0UB2G5XqRIF2nMO1X4TJMl+Df9DUCb7Abdhtd4UoeKiVWPEpKwDUVITPXGB7HXu/TdKp kxZlZjKKC4PBpGa9L9VHwyXLmsaim5ucg446JrOuZGCyuMUzfHRmQ2FtgShfVZnrk6NwWz 2ml1Srl7Ru0RBE+I4/SP7JQASqt/cSJtwaDneBXza3CU211r2yHlMWY/J2/vWvVTNU1t2W SlIZh/8F1r7b6c8Cx89CyyAH1M5Bw0FWUlHil6l8c37zkr05e4dypA424xmog7bLKDzbKv BxSYcLo4UHsuKzMF/7c+lxx5S6ahd1MZpWCOrTGby1PxuHjvvU9pCYKquu1nog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668189467; 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=E2rKakTgIz0uRXNs8C093g3598OF1QWInRP6ec5sR+w=; b=nHY5xEwZssIT+lBO9VT4YcdUKyP0UQv/JqFH79UOJOclz85v+jPRslBUsQp+l38ZL6uTuP sBwg/MI/Fru/cySeZMxp1zELR1h7cfn7yHxPK34UnZApusTrWseQBYy+edtqAZCQaNgUxc qbGxTaMwndbB83aCHUXf3pU3BvJKhRm/XAdYxdsjLX4BacXMsPvi8SZBzFKh6/MedgYusT RWSKFJ1ZJwBR5w11ZjVzBkyUvrnnOPTzLJQnZphW2JvNa4vrTtQVpbmoHTzRWfv6oRt8DD f4DjL0MJbJLngagpJc6Y/WGW6yQi6sa0TkvNvkf/CCnE6YwLwIbtQJkW5iys3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668189467; a=rsa-sha256; cv=none; b=tLFMev6dWN7oVbNfCdrr+lPAbKWOk+M3WsJVgGn9bJbBRkOU1+7UsmnPeg7qemSXg7dY5l /EMYEXxIzrRO431s8zRK6lfBfYBRx2p0yMRXX64hGng0nqVxU6gFuP/0UqSjk8SsGYScQU fwtl749OQEBkK+55RSFuXsyhOnxVk5oDMqzpFvQkDRkEvs7d50eAuI86aT0DywzQ0NtGi6 pxHgzQ/ovBXB8nWpPHj+HW9p6PCAEb2Gl9uf0mR1S22eMfHgb5ysu+OfELp8jQqwOfiK18 ILQBomgrRLxXZdMlHdqQlbLOr01Fv3QwjKJeGtUU4krNPdAzf34b64oUvEOnFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N85yg4765zrhc; Fri, 11 Nov 2022 17:57:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2ABHvlBn044883; Fri, 11 Nov 2022 17:57:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ABHvl3q044882; Fri, 11 Nov 2022 17:57:47 GMT (envelope-from git) Date: Fri, 11 Nov 2022 17:57:47 GMT Message-Id: <202211111757.2ABHvl3q044882@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 0e5569a08cf0 - main - linuxkpi: Add List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0e5569a08cf02e036774235e54e1008a26167b36 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=0e5569a08cf02e036774235e54e1008a26167b36 commit 0e5569a08cf02e036774235e54e1008a26167b36 Author: Jean-Sébastien Pédron AuthorDate: 2022-11-11 17:40:57 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2022-11-11 17:40:57 +0000 linuxkpi: Add I took the implementation from OpenBSD, commit d55ef580b1748517027c3eabdb715316ca5b1442. The only difference is the addition of `dma_buf_map_is_equal()`. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D36963 --- .../linuxkpi/common/include/linux/dma-buf-map.h | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/dma-buf-map.h b/sys/compat/linuxkpi/common/include/linux/dma-buf-map.h new file mode 100644 index 000000000000..567ce3b072b3 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/dma-buf-map.h @@ -0,0 +1,91 @@ +/* Public domain. */ + +#ifndef _LINUX_DMA_BUF_MAP_H +#define _LINUX_DMA_BUF_MAP_H + +#include +#include + +struct dma_buf_map { + union { + void *vaddr_iomem; + void *vaddr; + }; + bool is_iomem; +}; + +static inline void +dma_buf_map_incr(struct dma_buf_map *dbm, size_t n) +{ + if (dbm->is_iomem) + dbm->vaddr_iomem += n; + else + dbm->vaddr += n; +} + +static inline void +dma_buf_map_memcpy_to(struct dma_buf_map *dbm, const void *src, size_t len) +{ + if (dbm->is_iomem) + memcpy_toio(dbm->vaddr_iomem, src, len); + else + memcpy(dbm->vaddr, src, len); +} + +static inline bool +dma_buf_map_is_null(const struct dma_buf_map *dbm) +{ + if (dbm->is_iomem) + return (dbm->vaddr_iomem == NULL); + else + return (dbm->vaddr == NULL); +} + +static inline bool +dma_buf_map_is_set(const struct dma_buf_map *dbm) +{ + if (dbm->is_iomem) + return (dbm->vaddr_iomem != NULL); + else + return (dbm->vaddr != NULL); +} + +static inline bool +dma_buf_map_is_equal( + const struct dma_buf_map *dbm_a, const struct dma_buf_map *dbm_b) +{ + if (dbm_a->is_iomem != dbm_b->is_iomem) + return (false); + + if (dbm_a->is_iomem) + return (dbm_a->vaddr_iomem == dbm_b->vaddr_iomem); + else + return (dbm_a->vaddr == dbm_b->vaddr); +} + +static inline void +dma_buf_map_clear(struct dma_buf_map *dbm) +{ + if (dbm->is_iomem) { + dbm->vaddr_iomem = NULL; + dbm->is_iomem = false; + } else { + dbm->vaddr = NULL; + } +} + +static inline void +dma_buf_map_set_vaddr_iomem(struct dma_buf_map *dbm, void *addr) +{ + dbm->vaddr_iomem = addr; + dbm->is_iomem = true; +} + +static inline void +dma_buf_map_set_vaddr(struct dma_buf_map *dbm, void *addr) +{ + dbm->vaddr = addr; + dbm->is_iomem = false; +} + +#endif