From nobody Wed Sep 07 15:10:00 2022 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 4MN5K45hdjz4bPCv; Wed, 7 Sep 2022 15:10:00 +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 4MN5K42z18z3XTp; Wed, 7 Sep 2022 15:10:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662563400; 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=TKEgmuqpgFwKlSckTlwI2FKvR3hlB4kIltOIkGarMok=; b=N1lcdIOK4SFcidY4Lcxs0Lh6FG7h7Hl/lzjkqMuIQn+inEK6GsQbTfnZmwavpzVSp18HRu 0AKyYENEVhXzbAj+JU1cpgaojovaa4Dnaud/U1DRs76p59FzYIyM257sbB4r9Eg+Pl+NHa wIxCGVaIDzC66emavikWIwrLrBM5EiWMmxm1P+x340vny8NzeddNZ7+wu1lkjWjYeyx6o7 BiDSCZ853/8OlCaT+vTgWml5WDEsJA6E+i3kOU5zb0oDQrFDivh3TTixWiT5LjBDvBQCf5 bxwlGGAqgdnLPStopi198ska598Mt2Wpq5Iq83jhN90ZsCbPNQSFZ5weMwl3Og== 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 4MN5K41nmDzYyF; Wed, 7 Sep 2022 15:10: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 287FA0vZ017354; Wed, 7 Sep 2022 15:10:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 287FA0pD017349; Wed, 7 Sep 2022 15:10:00 GMT (envelope-from git) Date: Wed, 7 Sep 2022 15:10:00 GMT Message-Id: <202209071510.287FA0pD017349@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 4988dd49733c - stable/13 - linuxkpi: Add asm/set_memory.h 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 4988dd49733c6dbda46f4122dc09ce301f495be0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662563400; 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=TKEgmuqpgFwKlSckTlwI2FKvR3hlB4kIltOIkGarMok=; b=l6r6YphLbR15GuhvI0oHLoMn1qj9TpqjkWeLvsQnqDBG0Cj5u1ylzl9QGdqL8+LAQwP3le f8srEQAYG4SQw+SGIRk4AyQWWJ0wFI6JxWzR7iUGVQVesUjSkyj2Qw3Upuh5gaC72apEET ZLCteN/++Ny3JuprrtIIBUFqKL6mWWyGzF1hKViYtnX+Y/V/D/Bhu2EEl+QJXyT485Imct I/MLsHJWKkMegptwwlUlFBQZZpezLelTluseyS0TNQgschPWWdZkMAAI39ueOtcVoBkxau kmn2voPnrvelAKNUL3I9A6mC+mt+ZwWSBoy6Kj1nvWdHtf5kDwkAYVW3yA1K1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662563400; a=rsa-sha256; cv=none; b=PBgsRvwROuSA0uGpcN6sgtb/77MddV0FbhqWfFzHLIBaX8SWt4iqoKZwA7oBTeri64kNg0 NUc/ntRSWfqH7Hakr2s3+N4K32VcI7tAytJvrGj+Y7tFFtViaOUXlfvPQ5wnykA+h7cb8q 6hwa7SP4jR6CaM+6R/dHCxpnZf56Mseo+D7wxlZ7pEH6J9yKvJSF+sfM8TChBXAHuK3Gco C2mU3OY/XVL0vut4lPNFekL1bdFYjZZHe2ciuulMpYKhD8fV8krP21o6uEjf3//81i/tao a6ER+ea8ra6DBsRXn7u2VOnPYMYP386fvSNICHHZ7mExMndTSFs5SvMh54+DXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=4988dd49733c6dbda46f4122dc09ce301f495be0 commit 4988dd49733c6dbda46f4122dc09ce301f495be0 Author: Emmanuel Vadot AuthorDate: 2022-06-23 08:14:30 +0000 Commit: Emmanuel Vadot CommitDate: 2022-09-07 15:09:03 +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 (cherry picked from commit 0e45856f9a2d4f136cbfb4091ad254d0461f4614) --- .../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_ */