From nobody Wed Jun 29 07:56:00 2022 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 59E418A196B; Wed, 29 Jun 2022 07:56:02 +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 4LXv0d5Zzxz4bMf; Wed, 29 Jun 2022 07:56:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656489361; 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=yVUNpOEaMe805PoqoORapTeXiiB+dXw3nUewqJGyUE8=; b=AGKffevwYTOo4KxOhI2Qw5P/JhzGut9bJyMQKeGSRniBoI7E8mgjwznBLBKTqVwlJRgmi2 H/V3ZFYI1eXzmC3kY8w/70aZOjtacxZjRhgSvvttpfm72hGRydmqOpalbPBAOnkeW0Hu98 WY3nbrGmmQsqVubLxOFaAQYeNYw1AM6pwy9nJbkQExx7Lht0FdilZdhRBcKmjsKwej5ZT9 5FA8H0Rpyf2AuAE/pqMoatdwf/gmmcTuVTWc9INIggPE8yfhftsFWaXw1ZRSjXql9r1W50 +w4qbGuFvuEQjjgfqjn7R6ohtNNNNnK7nu8UTTabFYkpNSnEMNDq2Uj3LoVtOA== 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 E19005768; Wed, 29 Jun 2022 07:56:00 +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 25T7u0Q2076492; Wed, 29 Jun 2022 07:56:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25T7u0iN076491; Wed, 29 Jun 2022 07:56:00 GMT (envelope-from git) Date: Wed, 29 Jun 2022 07:56:00 GMT Message-Id: <202206290756.25T7u0iN076491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 0e45856f9a2d - main - linuxkpi: Add asm/set_memory.h List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 0e45856f9a2d4f136cbfb4091ad254d0461f4614 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656489361; 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=yVUNpOEaMe805PoqoORapTeXiiB+dXw3nUewqJGyUE8=; b=vRVGwJd+tNKNBjFRdSq1LITlrYT622dBfpnrTtdPc8m7J0dZiXJ829Bv5TI+I33jUj+05y 7yoU+x+syPICWoKbTjiwrd9bSsuhQyhL4u0fKHJFfkCI7Js4MrAWodbpCJbgB4cPjaCOLE 5sIG9+QBDFwOdx+gYh4qy+5G2WQbk9kuGe42aHBWQtXQZoef1pL+sUP44tlix4hcAzAPDr cA9Ct2YylwKATcF0c7heEX/KUmgy1PpdHVjYxuQd8UuoOjtMrMvVPm6UJqWsrGlISZNMMA hgeQw/q8qGQQ7bbuavhjS5gWkxG9i3QdVmHMVoLBjhbKgbkXzlWGb64Nm2aqJg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656489361; a=rsa-sha256; cv=none; b=F5pLcIXbtt3rwHpl0GZUReOXY/U6ARQrE1yKZ+YjYBm/FEEz6l345pnSfLPcGh7aplUUwW Ev/DD8hJQj7gkHlsfPCtMuDD1DqgbcKtiLu8vIa+x1dCb5VkD7tnLM/KdNBvJafwILwG9D eaQlHQZ7i95BvwQDV01uV9IgApvl66FQ2AN9EH9hajqobusz7lxWuDfAs5ZyrZBH4/MBew PqS7ExUB1s3ogSr0w64Ad7O4OC46qaZP05mhV783gkN2ExBJglZQR8XGybpvBu2lONaU6x gKMcFETohBNVIKeMJsWFqwg0EX8fvTbtCZWJw4y0LqOAajHkAygnnFs/J/cviw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=0e45856f9a2d4f136cbfb4091ad254d0461f4614 commit 0e45856f9a2d4f136cbfb4091ad254d0461f4614 Author: Emmanuel Vadot AuthorDate: 2022-06-23 08:14:30 +0000 Commit: Emmanuel Vadot CommitDate: 2022-06-29 07:55:23 +0000 linuxkpi: Add asm/set_memory.h Provide functions needed for drm-kmod. MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D35571 --- .../linuxkpi/common/include/asm/set_memory.h | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/asm/set_memory.h b/sys/compat/linuxkpi/common/include/asm/set_memory.h new file mode 100644 index 000000000000..cdb7ad912acc --- /dev/null +++ b/sys/compat/linuxkpi/common/include/asm/set_memory.h @@ -0,0 +1,117 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2016 Matt Macy (mmacy@nextbsd.org) + * Copyright (c) 2017 Mellanox Technologies, Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_ASM_SET_MEMORY_H_ +#define _LINUXKPI_ASM_SET_MEMORY_H_ + +#include + +static inline int +set_memory_uc(unsigned long addr, int numpages) +{ + return (pmap_change_attr(addr, numpages, VM_MEMATTR_UNCACHEABLE)); +} + +static inline int +set_memory_wc(unsigned long addr, int numpages) +{ +#ifdef VM_MEMATTR_WRITE_COMBINING + return (pmap_change_attr(addr, numpages, VM_MEMATTR_WRITE_COMBINING)); +#else + return (set_memory_uc(addr, numpages)); +#endif +} + +static inline int +set_memory_wb(unsigned long addr, int numpages) +{ + return (pmap_change_attr(addr, numpages, VM_MEMATTR_WRITE_BACK)); +} + +static inline int +set_pages_uc(vm_page_t page, int numpages) +{ + KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); + + pmap_page_set_memattr(page, VM_MEMATTR_UNCACHEABLE); + return (0); +} + +static inline int +set_pages_wc(vm_page_t page, int numpages) +{ + KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); + +#ifdef VM_MEMATTR_WRITE_COMBINING + pmap_page_set_memattr(page, VM_MEMATTR_WRITE_COMBINING); +#else + return (set_pages_uc(page, numpages)); +#endif + return (0); +} + +static inline int +set_pages_wb(vm_page_t page, int numpages) +{ + KASSERT(numpages == 1, ("%s: numpages %d", __func__, numpages)); + + pmap_page_set_memattr(page, VM_MEMATTR_WRITE_BACK); + return (0); +} + +static inline int +set_pages_array_wb(vm_page_t *pages, int addrinarray) +{ + int i; + + for (i = 0; i < addrinarray; i++) + set_pages_wb(pages[i], 1); + return (0); +} + +static inline int +set_pages_array_wc(vm_page_t *pages, int addrinarray) +{ + int i; + + for (i = 0; i < addrinarray; i++) + set_pages_wc(pages[i], 1); + return (0); +} + +static inline int +set_pages_array_uc(vm_page_t *pages, int addrinarray) +{ + int i; + + for (i = 0; i < addrinarray; i++) + set_pages_uc(pages[i], 1); + return (0); +} + +#endif /* _LINUXKPI_ASM_SET_MEMORY_H_ */