From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035007; cv=none; d=zohomail.com; s=zohoarc; b=AtYABzFyawJ9PfunvNX/LSD9Np6ea8HRep5rAZ6Kf2JKu92fuG1FWRO+Ki9XoxfDVOZLFE/mabRepcXA7CYdH1XCsZ5QBt6P7f2xroicURkjE3vahVNRCiGv3wemqjn48yYWop5dBAWrb3QArbdbzURIYMV0JDSKLGwlCj/6VxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035007; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5gytA2pLllrFj6CH99Xdk/Opt3jWfGlT8ShBqhaNetg=; b=LepzHW7HRtASSXx9QC/NMvdX1CH4Ug9Df0FJ4CEaje0t6t5oWEf9M+qq2GfLr3Z3Fa7KC+vCwlCycpiyLnx8Qsp5eH1jXzx2NdkSts2dU8hzV5GzaDxBCpyzCRdvLXM3XscHRjvkl8hiDkrBQ9pNsHnx/4nlUzDlOEDhjH3snVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035007356481.9237216728666; Mon, 20 Dec 2021 13:16:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249993.430485 (Exim 4.92) (envelope-from ) id 1mzQ15-0005LD-Bx; Mon, 20 Dec 2021 21:16:19 +0000 Received: by outflank-mailman (output) from mailman id 249993.430485; Mon, 20 Dec 2021 21:16:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ15-0005Kp-59; Mon, 20 Dec 2021 21:16:19 +0000 Received: by outflank-mailman (input) for mailman id 249993; Mon, 20 Dec 2021 21:16:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ13-0005IG-AV for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:17 +0000 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [2a00:1450:4864:20::134]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1119e5da-61da-11ec-9e60-abaf8a552007; Mon, 20 Dec 2021 22:16:16 +0100 (CET) Received: by mail-lf1-x134.google.com with SMTP id x21so16375186lfa.5 for ; Mon, 20 Dec 2021 13:16:15 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:15 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1119e5da-61da-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5gytA2pLllrFj6CH99Xdk/Opt3jWfGlT8ShBqhaNetg=; b=Cdq4GjJ/2iK2iIIDzgHUFWhpcJBt2NTM2SeUjG+PuWAccmKfbquvFCKrO8Ez+FFwHY j111WBq0jRNFONhvtOulyEGsd1uE8GrmfipXT25rC/jzrCa/2mWJxkbPiNiNFvtwYjts GGa0E43hrhogNSeQPjJhaorFWWucTU2cQtt1RbtbkyzjF9wjvM0c5XxbMs8TJxBxcIK9 UuGDvoU+OfsP7bPu8VX5JmKNzsOxXb+US2eNpRCaEtd/6WHXFfa2XK7GToLiBlQGvOX8 JHwdxdmuFUmDT5SQm/OzzoKiDS8kJVoCL7P9GjMK2l4CrMaEb9O9qu2+EE7ZVSa1AmYD Q1dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5gytA2pLllrFj6CH99Xdk/Opt3jWfGlT8ShBqhaNetg=; b=KNQUR3+RpFwnnt8fZ/R+g94yd7NWIM+7jeWnVkgMiVVcPR/YoLdjwdANn+cZiCjA73 PyAk6iobzS2ITOFvmUPV9NwRasuUfClNtQUPoTJS9cH4g/th8kNOTJS+3+UcbQhoTEnC NnFacY9BzGeOSW4l5yPlR+yxZ9qqz2VNvMkYUtp6xal7ITPfYYt3/eSj5BHOiimn2M/D DGcoeB1Ww+WY+MLQkaTyyfs12ZsLY72+U1Uc5TkrvM8lS0mYGFTT3azhHdLTVUOAgJez /ux2Nr+cts4jPM6tc7X6JbaxNhrCs/3FItaSVLdYqgor7XF/LOEoP2FzsOS7zayWOTPd 8mGw== X-Gm-Message-State: AOAM531ZW/1jAxzCTefvA8eYem2CtNUh+zU28J+ro/ptbKZ5Pu55iRkn as1eTakfBbL10jhYapxquavUcqonBoE= X-Google-Smtp-Source: ABdhPJxaDOs+TBKah+ukRAfspi33bXHs6F6TXrKYX+7z3geOaurnZi1gkTrB2n7oqg3+F9pCzFg0Wg== X-Received: by 2002:a05:6512:3054:: with SMTP id b20mr2857265lfb.359.1640034975570; Mon, 20 Dec 2021 13:16:15 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 01/10] iommu/ipmmu-vmsa: Remove all unused register definitions Date: Mon, 20 Dec 2021 23:15:48 +0200 Message-Id: <1640034957-19764-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035008440100002 From: Oleksandr Tyshchenko This is a non-verbatim port of corresponding Linux upsteam commit: 77cf983892b2e0d40dc256b784930a9ffaad4fc8 Original commit message: commit 77cf983892b2e0d40dc256b784930a9ffaad4fc8 Author: Yoshihiro Shimoda Date: Wed Nov 6 11:35:45 2019 +0900 iommu/ipmmu-vmsa: Remove all unused register definitions To support different registers memory mapping hardware easily in the future, this patch removes all unused register definitions. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Niklas S=C3=B6derlund Signed-off-by: Joerg Roedel ********** This is a prereq work needed to add support for S4 series easily in the future. Although Linux and Xen drivers have a lot in common, the main differences are in translation stages (table formats), VMSAv8 modes, supported SoC generations, etc, therefore that's why there is a slight difference in registers/bits each driver considers unused. No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 59 ++--------------------------= ---- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 1255b0d..4a8a974 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -166,15 +166,11 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); =20 #define IMCTR 0x0000 /* - * These fields are implemented in IPMMU-MM only. So, can be set for + * This field is implemented in IPMMU-MM only. So, can be set for * Root IPMMU only. */ #define IMCTR_VA64 (1 << 29) -#define IMCTR_TRE (1 << 17) -#define IMCTR_AFE (1 << 16) -#define IMCTR_RTSEL_MASK (3 << 4) -#define IMCTR_RTSEL_SHIFT 4 -#define IMCTR_TREN (1 << 3) + /* * These fields are common for all IPMMU devices. So, can be set for * Cache IPMMUs as well. @@ -184,42 +180,9 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMCTR_MMUEN (1 << 0) #define IMCTR_COMMON_MASK (7 << 0) =20 -#define IMCAAR 0x0004 - #define IMTTBCR 0x0008 #define IMTTBCR_EAE (1U << 31) #define IMTTBCR_PMB (1 << 30) -#define IMTTBCR_SH1_NON_SHAREABLE (0 << 28) -#define IMTTBCR_SH1_OUTER_SHAREABLE (2 << 28) -#define IMTTBCR_SH1_INNER_SHAREABLE (3 << 28) -#define IMTTBCR_SH1_MASK (3 << 28) -#define IMTTBCR_ORGN1_NC (0 << 26) -#define IMTTBCR_ORGN1_WB_WA (1 << 26) -#define IMTTBCR_ORGN1_WT (2 << 26) -#define IMTTBCR_ORGN1_WB (3 << 26) -#define IMTTBCR_ORGN1_MASK (3 << 26) -#define IMTTBCR_IRGN1_NC (0 << 24) -#define IMTTBCR_IRGN1_WB_WA (1 << 24) -#define IMTTBCR_IRGN1_WT (2 << 24) -#define IMTTBCR_IRGN1_WB (3 << 24) -#define IMTTBCR_IRGN1_MASK (3 << 24) -#define IMTTBCR_TSZ1_MASK (0x1f << 16) -#define IMTTBCR_TSZ1_SHIFT 16 -#define IMTTBCR_SH0_NON_SHAREABLE (0 << 12) -#define IMTTBCR_SH0_OUTER_SHAREABLE (2 << 12) -#define IMTTBCR_SH0_INNER_SHAREABLE (3 << 12) -#define IMTTBCR_SH0_MASK (3 << 12) -#define IMTTBCR_ORGN0_NC (0 << 10) -#define IMTTBCR_ORGN0_WB_WA (1 << 10) -#define IMTTBCR_ORGN0_WT (2 << 10) -#define IMTTBCR_ORGN0_WB (3 << 10) -#define IMTTBCR_ORGN0_MASK (3 << 10) -#define IMTTBCR_IRGN0_NC (0 << 8) -#define IMTTBCR_IRGN0_WB_WA (1 << 8) -#define IMTTBCR_IRGN0_WT (2 << 8) -#define IMTTBCR_IRGN0_WB (3 << 8) -#define IMTTBCR_IRGN0_MASK (3 << 8) -#define IMTTBCR_SL0_LVL_2 (0 << 6) #define IMTTBCR_SL0_LVL_1 (1 << 6) #define IMTTBCR_TSZ0_MASK (0x1f << 0) #define IMTTBCR_TSZ0_SHIFT 0 @@ -228,18 +191,8 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMTTLBR0_TTBR_MASK (0xfffff << 12) #define IMTTUBR0 0x0014 #define IMTTUBR0_TTBR_MASK (0xff << 0) -#define IMTTLBR1 0x0018 -#define IMTTLBR1_TTBR_MASK (0xfffff << 12) -#define IMTTUBR1 0x001c -#define IMTTUBR1_TTBR_MASK (0xff << 0) =20 #define IMSTR 0x0020 -#define IMSTR_ERRLVL_MASK (3 << 12) -#define IMSTR_ERRLVL_SHIFT 12 -#define IMSTR_ERRCODE_TLB_FORMAT (1 << 8) -#define IMSTR_ERRCODE_ACCESS_PERM (4 << 8) -#define IMSTR_ERRCODE_SECURE_ACCESS (5 << 8) -#define IMSTR_ERRCODE_MASK (7 << 8) #define IMSTR_MHIT (1 << 4) #define IMSTR_ABORT (1 << 2) #define IMSTR_PF (1 << 1) @@ -251,11 +204,7 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMUCTR(n) ((n) < 32 ? IMUCTR0(n) : IMUCTR32(n)) #define IMUCTR0(n) (0x0300 + ((n) * 16)) #define IMUCTR32(n) (0x0600 + (((n) - 32) * 16)) -#define IMUCTR_FIXADDEN (1U << 31) -#define IMUCTR_FIXADD_MASK (0xff << 16) -#define IMUCTR_FIXADD_SHIFT 16 #define IMUCTR_TTSEL_MMU(n) ((n) << 4) -#define IMUCTR_TTSEL_PMB (8 << 4) #define IMUCTR_TTSEL_MASK (15 << 4) #define IMUCTR_TTSEL_SHIFT 4 #define IMUCTR_FLUSH (1 << 1) @@ -264,10 +213,6 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMUASID(n) ((n) < 32 ? IMUASID0(n) : IMUASID32(n)) #define IMUASID0(n) (0x0308 + ((n) * 16)) #define IMUASID32(n) (0x0608 + (((n) - 32) * 16)) -#define IMUASID_ASID8_MASK (0xff << 8) -#define IMUASID_ASID8_SHIFT 8 -#define IMUASID_ASID0_MASK (0xff << 0) -#define IMUASID_ASID0_SHIFT 0 =20 #define IMSAUXCTLR 0x0504 #define IMSAUXCTLR_S2PTE (1 << 3) --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=hio6It9qbT5YRX4jrmwQBOIXWuiLulVU1am9mByGExKBQfEJ8a4RITzTr3SFCu1Yw4XrsgVX56PTURZbuOrd1hOTtxrIzFEFoxkvRMjU18Ov96TcpZW85sw55ysu+6ENNsUDO4Ht+wGkrjYF4FegcvtNgzo83JiRetRaJRYk2gQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IcYUSZSwq8KqsYZymm7EDYV5w0Nvikp7Q2gZniejYm0=; b=FS3br674iYfp4xe7eAhn0arKXzWYVqfTwYmqmjJT895cm0n10077usCTo+udB5imYotwdW+5koaJ3myBtsNU1yh1AsETvI9gu4SiuAb7h7X3d6thxBJMIuSDOmjWeI7VGoAE3nBdP/A4Zx3ayn4ChdHJDz95Zsur83im1lL1cxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035008450145.7011594593829; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249994.430493 (Exim 4.92) (envelope-from ) id 1mzQ15-0005Qi-Lo; Mon, 20 Dec 2021 21:16:19 +0000 Received: by outflank-mailman (output) from mailman id 249994.430493; Mon, 20 Dec 2021 21:16:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ15-0005Pt-Da; Mon, 20 Dec 2021 21:16:19 +0000 Received: by outflank-mailman (input) for mailman id 249994; Mon, 20 Dec 2021 21:16:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ13-0005IB-FC for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:17 +0000 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [2a00:1450:4864:20::136]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 117e7a93-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:16 +0100 (CET) Received: by mail-lf1-x136.google.com with SMTP id b22so24579611lfb.9 for ; Mon, 20 Dec 2021 13:16:16 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:16 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 117e7a93-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IcYUSZSwq8KqsYZymm7EDYV5w0Nvikp7Q2gZniejYm0=; b=AyKxPiiJPVhC/7JOQ/aRq6rTrMS0jzHgIDPh5CteMINaaQk//DlcT8W2eCtp5t/ruD 1OXJneoc0AWC/P3AG9DbIijvwHyh00kh4GfqxyxmQlz67ZMubIFHMpPcMKqEMTN96bdJ 5rLX1Jqgkjv9k6jaQI/ZCJqFPxrxaBoK6rYL5PgngX2Oo447nXOdeee4Vl9OfFXzscbV ZlUkBkjHNVpY6T01xqZWLDoxqlDkk5wMkirGNL20txR5uYuMUw/FzF+El1SSmT47c6KY Ra6G5ul4X6aEKW7mlCyY/c+lpNkbSTxM1qdfZuUY0sm5Vraz4yIvGinZad7uLx/KYJgn IQAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IcYUSZSwq8KqsYZymm7EDYV5w0Nvikp7Q2gZniejYm0=; b=ZJRSB/e1IAQXcGpBpuJZhqszCOMbmwXTDF+kmH47KHlegiCy3Zb8ogprGtGVrOwC2k 9XNTO1Ap9Rir1+VSz+5SK6ZCg322OAuZlf0kshGbE6QDVY+8IpzQ7oVBMWQC9PMImjYF wIa4jj7IV6bSMyqy0QmBBIvwOX/YCQn4HRiJfPORcy5F4yaRjADiWaq+Hf8xO0UqA9RM roQWKvQJOn49ZRkB7XMqYW/OhqcVhvVB8nZSGHTDhR02DXOraas9q8Fx5WfHCUifajvm Dr/gwgtGYxvT12e9H3/HpABqhDk6Y4iL2m2XoPSLmMEVG7x9kFX5N4jQBQAsaAR3yMdN peDQ== X-Gm-Message-State: AOAM530hCVHktdr1gZpoLMXFPWFgWbhn0H8PyLSDY7IcsoezhOlrD6bf fXGD+iREaVVvNy3IrkFXZHMql6gmKdc= X-Google-Smtp-Source: ABdhPJxtcms+sAXHt2sK2O2BBuG/He6QCMgCPzr3nG5Rz21E4S6lu+3lxbKwcZQsk5kkqukgFKw33A== X-Received: by 2002:a05:6512:b81:: with SMTP id b1mr15523896lfv.301.1640034976255; Mon, 20 Dec 2021 13:16:16 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 02/10] iommu/ipmmu-vmsa: Add helper functions for MMU "context" registers Date: Mon, 20 Dec 2021 23:15:49 +0200 Message-Id: <1640034957-19764-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010367100011 From: Oleksandr Tyshchenko This is a non-verbatim port of corresponding Linux upsteam commit: 16d9454f5e0447f9c19cbf350b35ed377b9f64eb Original commit message: commit 16d9454f5e0447f9c19cbf350b35ed377b9f64eb Author: Yoshihiro Shimoda Date: Wed Nov 6 11:35:47 2019 +0900 iommu/ipmmu-vmsa: Add helper functions for MMU "context" registers Since we will have changed memory mapping of the IPMMU in the future, This patch adds helper functions ipmmu_ctx_{reg,read,write}() for MMU "context" registers. No behavior change. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Niklas S=C3=B6derlund Signed-off-by: Joerg Roedel ********** This is a prereq work needed to add support for S4 series easily in the future. Besides changes done in the original commit, we also need to update an extra call sites which Linux driver doesn't have, but Xen driver has such as ipmmu_ctx_write_cache(), etc. No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 31 ++++++++++++++++++++++++----= --- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 4a8a974..ce5c3bc 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -307,18 +307,35 @@ static void ipmmu_write(struct ipmmu_vmsa_device *mmu= , uint32_t offset, writel(data, mmu->base + offset); } =20 +static unsigned int ipmmu_ctx_reg(struct ipmmu_vmsa_device *mmu, + unsigned int context_id, uint32_t reg) +{ + return context_id * IM_CTX_SIZE + reg; +} + +static uint32_t ipmmu_ctx_read(struct ipmmu_vmsa_device *mmu, + unsigned int context_id, uint32_t reg) +{ + return ipmmu_read(mmu, ipmmu_ctx_reg(mmu, context_id, reg)); +} + +static void ipmmu_ctx_write(struct ipmmu_vmsa_device *mmu, + unsigned int context_id, uint32_t reg, + uint32_t data) +{ + ipmmu_write(mmu, ipmmu_ctx_reg(mmu, context_id, reg), data); +} + static uint32_t ipmmu_ctx_read_root(struct ipmmu_vmsa_domain *domain, uint32_t reg) { - return ipmmu_read(domain->mmu->root, - domain->context_id * IM_CTX_SIZE + reg); + return ipmmu_ctx_read(domain->mmu->root, domain->context_id, reg); } =20 static void ipmmu_ctx_write_root(struct ipmmu_vmsa_domain *domain, uint32_t reg, uint32_t data) { - ipmmu_write(domain->mmu->root, - domain->context_id * IM_CTX_SIZE + reg, data); + ipmmu_ctx_write(domain->mmu->root, domain->context_id, reg, data); } =20 static void ipmmu_ctx_write_cache(struct ipmmu_vmsa_domain *domain, @@ -329,8 +346,8 @@ static void ipmmu_ctx_write_cache(struct ipmmu_vmsa_dom= ain *domain, =20 /* Mask fields which are implemented in IPMMU-MM only. */ if ( !ipmmu_is_root(domain->mmu) ) - ipmmu_write(domain->mmu, domain->context_id * IM_CTX_SIZE + reg, - data & IMCTR_COMMON_MASK); + ipmmu_ctx_write(domain->mmu, domain->context_id, reg, + data & IMCTR_COMMON_MASK); } =20 /* @@ -693,7 +710,7 @@ static void ipmmu_device_reset(struct ipmmu_vmsa_device= *mmu) =20 /* Disable all contexts. */ for ( i =3D 0; i < mmu->num_ctx; ++i ) - ipmmu_write(mmu, i * IM_CTX_SIZE + IMCTR, 0); + ipmmu_ctx_write(mmu, i, IMCTR, 0); } =20 /* R-Car Gen3 SoCs product and cut information. */ --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035007; cv=none; d=zohomail.com; s=zohoarc; b=nxnweHh4xfPP2dCRJ+iAXxi+CaDLYq9NuIKzfkhGmX+2ZzLRi7H0oDvH9lsgObW6vwce3OMN/+OvwPfixYH9ZV7UTOX3lgmzI547szMb8IOAqv3MW4lnjgkJHKgLCqwJiiwg+ksOTl5mhIzupaLfnysAXivehxwcy1B7yZpJnSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035007; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hajm4OA2mR1rqKBWo1oPRyQ75UieT0Vx1ZnO7YitzIM=; b=M1PqeffPll9SvH0itGkZstm6YzcZkZRWkNr4SAG84RWFnFdGL8VBhYN/BXS4MbKdHo8eYt3XGBbqzQD/XbkRAGW2y3NnX9d2VUkBx82zIe9zFTtisqdvh5t/sn98B59bGblwaeyYNexY4opmSabkj9ZTxj13Q3ahob/AajH8sj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035007099122.31930153459473; Mon, 20 Dec 2021 13:16:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249995.430502 (Exim 4.92) (envelope-from ) id 1mzQ16-0005gn-7I; Mon, 20 Dec 2021 21:16:20 +0000 Received: by outflank-mailman (output) from mailman id 249995.430502; Mon, 20 Dec 2021 21:16:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ15-0005eI-VZ; Mon, 20 Dec 2021 21:16:19 +0000 Received: by outflank-mailman (input) for mailman id 249995; Mon, 20 Dec 2021 21:16:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ14-0005IB-EW for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:18 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 11ee8156-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:17 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id bt1so24502703lfb.13 for ; Mon, 20 Dec 2021 13:16:17 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:16 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 11ee8156-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hajm4OA2mR1rqKBWo1oPRyQ75UieT0Vx1ZnO7YitzIM=; b=qIXmN3ldE/ZN74+4YThza4AYid4jpygjX+xdmfkD6EAA5y37CvzdUbPtTSqP+1hezy FbateqQKdPFMOjjVuW3VU6Std4HufcBhyTDj+OTVAdRyBwkZNr0k/MHwOk9aYF+ijU1z 50fNGe+Ij8QFC6URM0g//2mLElYzbjnUFC4cs4myBgUpaHWUG9fB3EfSmWFmWIlCqG/R e4uCVxbL6WrKLuyi/hgXa5dpUx1cVncs8xDJoil1jpJPbOdHZiQEuTIpBnDUonl6P6kI Pweo79tXZ5V1g8p0e8nexsWb8XlHgeuno1/k/jxl3Sp9RBn9Su9HDg01r8kaK3EVMhWF v9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hajm4OA2mR1rqKBWo1oPRyQ75UieT0Vx1ZnO7YitzIM=; b=z70XkiH2NGmtAtHattaH6UB4GV+988PBJwoQYJkJ/iftam1D068s1rOKIH2QzwNclj f2aFUt11kE1nijbcMIwGi3Nq7FHIfHkTY8VmHbYtMaxV+jjhsQ0snJjQudsvwsCosidR BVoC7jzgkBS1YXBugV3SSBKKveizofBmaa3fvTYICxLbXnVfWWkeedP6dVdoITEyHo+L 00fg8A2H+jSqIq0cHjf1tR7lf6hUFWwW1otP+WaD6d1Zz3CYvqtERFmcJJikhBULr13f aylHy1la0tACvfplAoDUeIGZMs7mDNQfh88GzO6UpamNjEptV6Z5X5ob/eWWEmFQ5qcv tpSQ== X-Gm-Message-State: AOAM531Lbzhh+U4WQqfkTdGpUmznGyNfrAK73Ufvjd1m2gzZrjoNzB9h A9sBooliReySq1WWltcpt5+QucRfkOY= X-Google-Smtp-Source: ABdhPJxzTfRun3YkUwibQaiDMstuUa+taVcJp9VRWabBxAHUy/4zPZawhc2OjDWcR5BYP0Abgva61g== X-Received: by 2002:a05:6512:3054:: with SMTP id b20mr2857353lfb.359.1640034976971; Mon, 20 Dec 2021 13:16:16 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 03/10] iommu/ipmmu-vmsa: Add helper functions for "uTLB" registers Date: Mon, 20 Dec 2021 23:15:50 +0200 Message-Id: <1640034957-19764-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035008417100001 From: Oleksandr Tyshchenko This is a non-verbatim port of corresponding Linux upsteam commit: 3667c9978b2911dc1ded77f5971df477885409c4 Original commit message: commit 3667c9978b2911dc1ded77f5971df477885409c4 Author: Yoshihiro Shimoda Date: Wed Nov 6 11:35:49 2019 +0900 iommu/ipmmu-vmsa: Add helper functions for "uTLB" registers Since we will have changed memory mapping of the IPMMU in the future, This patch adds helper functions ipmmu_utlb_reg() and ipmmu_imu{asid,ctr}_write() for "uTLB" registers. No behavior change. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Niklas S=C3=B6derlund Signed-off-by: Joerg Roedel ********** This is a prereq work needed to add support for S4 series easily in the future. Besides changes done in the original commit, we also need to introduce ipmmu_imuctr_read() since Xen driver contains an additional logic in ipmmu_utlb_enable() to prevent the use cases where devices which use the same micro-TLB are assigned to different Xen domains. No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 33 +++++++++++++++++++++++++++-= ---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index ce5c3bc..1b94af2 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -366,6 +366,29 @@ static void ipmmu_ctx_write_all(struct ipmmu_vmsa_doma= in *domain, ipmmu_ctx_write_root(domain, reg, data); } =20 +static uint32_t ipmmu_utlb_reg(struct ipmmu_vmsa_device *mmu, uint32_t reg) +{ + return reg; +} + +static void ipmmu_imuasid_write(struct ipmmu_vmsa_device *mmu, + unsigned int utlb, uint32_t data) +{ + ipmmu_write(mmu, ipmmu_utlb_reg(mmu, IMUASID(utlb)), data); +} + +static void ipmmu_imuctr_write(struct ipmmu_vmsa_device *mmu, + unsigned int utlb, uint32_t data) +{ + ipmmu_write(mmu, ipmmu_utlb_reg(mmu, IMUCTR(utlb)), data); +} + +static uint32_t ipmmu_imuctr_read(struct ipmmu_vmsa_device *mmu, + unsigned int utlb) +{ + return ipmmu_read(mmu, ipmmu_utlb_reg(mmu, IMUCTR(utlb))); +} + /* TLB and micro-TLB Management */ =20 /* Wait for any pending TLB invalidations to complete. */ @@ -413,7 +436,7 @@ static int ipmmu_utlb_enable(struct ipmmu_vmsa_domain *= domain, * context_id for already enabled micro-TLB and prevent different cont= ext * bank from being set. */ - imuctr =3D ipmmu_read(mmu, IMUCTR(utlb)); + imuctr =3D ipmmu_imuctr_read(mmu, utlb); if ( imuctr & IMUCTR_MMUEN ) { unsigned int context_id; @@ -431,9 +454,9 @@ static int ipmmu_utlb_enable(struct ipmmu_vmsa_domain *= domain, * TODO: Reference-count the micro-TLB as several bus masters can be * connected to the same micro-TLB. */ - ipmmu_write(mmu, IMUASID(utlb), 0); - ipmmu_write(mmu, IMUCTR(utlb), imuctr | - IMUCTR_TTSEL_MMU(domain->context_id) | IMUCTR_MMUEN); + ipmmu_imuasid_write(mmu, utlb, 0); + ipmmu_imuctr_write(mmu, utlb, imuctr | + IMUCTR_TTSEL_MMU(domain->context_id) | IMUCTR_MMUEN= ); =20 return 0; } @@ -444,7 +467,7 @@ static void ipmmu_utlb_disable(struct ipmmu_vmsa_domain= *domain, { struct ipmmu_vmsa_device *mmu =3D domain->mmu; =20 - ipmmu_write(mmu, IMUCTR(utlb), 0); + ipmmu_imuctr_write(mmu, utlb, 0); } =20 /* Domain/Context Management */ --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=kv1Bs97llCq961gAYy8+yhvgfroIEK+m2YIibRJkbK/8zLSV/OxYHP706gNBQ7TFbANOsXxWda2KaeHyISh4+HzefyZHQB/ysPyEdnNLucC33NGjvlJCUwZj1rVfo7VHzGLfqAgyG0HnF+TJK2qY196hFLt6ft5ARHyDkcrhGHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=KJJAXoBnqeeexsUsPrxE65JqoMaWk11lTyVByXKTYSU=; b=Jw8PO1glOYxUvQx6qGezDhddLxuyD5C4NEafnv8dUjEhuGso3iLZ8p7dpfQSllQVDh3C2FWaUiAr/wZZ1k5Qva6H7Mazwohh2gQtJelhPITPt5BsRYP/mM8reHaq5S43iW6l/DAKTUrMfWY93Ch7PVY1SBE1vkqCt8xKk6ymU9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035008389843.1667909992939; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249996.430507 (Exim 4.92) (envelope-from ) id 1mzQ16-0005p6-Iz; Mon, 20 Dec 2021 21:16:20 +0000 Received: by outflank-mailman (output) from mailman id 249996.430507; Mon, 20 Dec 2021 21:16:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ16-0005nM-By; Mon, 20 Dec 2021 21:16:20 +0000 Received: by outflank-mailman (input) for mailman id 249996; Mon, 20 Dec 2021 21:16:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ14-0005IG-RZ for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:18 +0000 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [2a00:1450:4864:20::130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 125b3604-61da-11ec-9e60-abaf8a552007; Mon, 20 Dec 2021 22:16:18 +0100 (CET) Received: by mail-lf1-x130.google.com with SMTP id b22so24579781lfb.9 for ; Mon, 20 Dec 2021 13:16:18 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:17 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 125b3604-61da-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KJJAXoBnqeeexsUsPrxE65JqoMaWk11lTyVByXKTYSU=; b=gOLATyKm4zSuOWV9E6Se+183dJv3dZ4/1hi1dCnT5d0xz/p49ipsWk4V+62Um9IuBV rXA6KY/y9/6AbhC7qupKNiWW2cVU68mDGL7tetdBNNv1EtYpiFMhUVL2ihZ7sGQxh3M9 cVb7anEJhQ2h3n6Z2f32MmLl6TWR+uugTRwLnidi1KpP4CFIO0Dn9ztq49JAzMtWx/nZ OI/iBvIwdtbUhiX81WTHj1fvg+TJi10f6qqRdn0KEmkhI9SHbfRvkevt71a8XedKaQkc IV1Kjwr0YxIQZvKezY9U/6U5tg4DhurweX+Yna+L9OBmffGONeFCvmXZoW6Ktzu8f5UH phqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KJJAXoBnqeeexsUsPrxE65JqoMaWk11lTyVByXKTYSU=; b=JeaTIAcOoi00fNUCrMfXj9FnPM0kHTd6CxIKb3c9VR7/brW90m1WLx0GWmF+IebHjQ 6A6QYWcY+q9xkOpHF1HAE8jSAJ/WOpybjubcD9XYh6hnrOa9j6g/TFjAAjhne3OIR/fX ybIAbxsH5VZncI9SXpKV0xohWOh0qXxcmVhZ49oaIuMjMqqjZQgTV4CdAEclY9WjKUFW Yr6mkAPQjbhO9e/MQHM/ilxrhKnB1x/StnxfI/DBkFop52Fy/Ma5NKUoKyv2WC8N6k3E blWqh/5JtC+5Rd+/Gclyf1bf2H48wAxGR1ccqgI94SqDpwZzPv8Gv5T65AC5gJ12RsrT btwA== X-Gm-Message-State: AOAM530Lfr0WFzL/C+WqWtc/c8mzry2i9tb+7vKIdqdMJzqawPgFdQXW lsGzCoC0lPd2/jGDEsROR4cEudD+bZE= X-Google-Smtp-Source: ABdhPJzeapJ3eaEjC6WFLDArDArLz+er0iTpagcYpbad82rG1wadmR8bGLj+UfFhkSAmAEukK9hM2w== X-Received: by 2002:a19:dc4b:: with SMTP id f11mr17029793lfj.585.1640034977686; Mon, 20 Dec 2021 13:16:17 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 04/10] iommu/ipmmu-vmsa: Add light version of Linux's ipmmu_features Date: Mon, 20 Dec 2021 23:15:51 +0200 Message-Id: <1640034957-19764-5-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010371100014 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This is a prereq work needed to add support for S4 series easily in the future. We don't need to pull the whole struct and all instances as Xen driver doesn't support old Arm32 based Gen2 SoCs, so there is no point in keeping all differences between Gen2 and Gen3 here. All what we need is a minimal support to be able to operate with Gen3 and new S4. Add Gen3 specific info with only two fields (number_of_contexts and num_utlbs) for now, the subsequent patches will add remaining bits. No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 54 +++++++++++++++++++++++-----= ---- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 1b94af2..369be4c 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -71,9 +71,9 @@ * R-Car Gen3 SoCs make use of up to 8 IPMMU contexts (sets of page table)= and * these can be managed independently. Each context is mapped to one Xen d= omain. */ -#define IPMMU_CTX_MAX 8 +#define IPMMU_CTX_MAX 8U /* R-Car Gen3 SoCs make use of up to 48 micro-TLBs per IPMMU device. */ -#define IPMMU_UTLB_MAX 48 +#define IPMMU_UTLB_MAX 48U =20 /* IPMMU context supports IPA size up to 40 bit. */ #define IPMMU_MAX_P2M_IPA_BITS 40 @@ -106,17 +106,22 @@ struct ipmmu_vmsa_xen_device { struct ipmmu_vmsa_device *mmu; }; =20 +struct ipmmu_features { + unsigned int number_of_contexts; + unsigned int num_utlbs; +}; + /* Root/Cache IPMMU device's information */ struct ipmmu_vmsa_device { struct device *dev; void __iomem *base; struct ipmmu_vmsa_device *root; struct list_head list; - unsigned int num_utlbs; unsigned int num_ctx; spinlock_t lock; /* Protects ctx and domains[] */ DECLARE_BITMAP(ctx, IPMMU_CTX_MAX); struct ipmmu_vmsa_domain *domains[IPMMU_CTX_MAX]; + const struct ipmmu_features *features; }; =20 /* @@ -727,6 +732,11 @@ static int ipmmu_init_platform_device(struct device *d= ev, return 0; } =20 +static const struct ipmmu_features ipmmu_features_rcar_gen3 =3D { + .number_of_contexts =3D 8, + .num_utlbs =3D 48, +}; + static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu) { unsigned int i; @@ -798,6 +808,27 @@ static __init bool ipmmu_stage2_supported(void) return stage2_supported; } =20 +static const struct dt_device_match ipmmu_dt_match[] __initconst =3D +{ + { + .compatible =3D "renesas,ipmmu-r8a7795", + .data =3D &ipmmu_features_rcar_gen3, + }, + { + .compatible =3D "renesas,ipmmu-r8a77965", + .data =3D &ipmmu_features_rcar_gen3, + }, + { + .compatible =3D "renesas,ipmmu-r8a7796", + .data =3D &ipmmu_features_rcar_gen3, + }, + { + .compatible =3D "renesas,ipmmu-r8a77961", + .data =3D &ipmmu_features_rcar_gen3, + }, + { /* sentinel */ }, +}; + /* * This function relies on the fact that Root IPMMU device is being probed * the first. If not the case, it denies further Cache IPMMU device probes @@ -806,6 +837,7 @@ static __init bool ipmmu_stage2_supported(void) */ static int ipmmu_probe(struct dt_device_node *node) { + const struct dt_device_match *match; struct ipmmu_vmsa_device *mmu; uint64_t addr, size; int irq, ret; @@ -817,9 +849,12 @@ static int ipmmu_probe(struct dt_device_node *node) return -ENOMEM; } =20 + match =3D dt_match_node(ipmmu_dt_match, node); + ASSERT(match); + mmu->features =3D match->data; + mmu->dev =3D &node->dev; - mmu->num_utlbs =3D IPMMU_UTLB_MAX; - mmu->num_ctx =3D IPMMU_CTX_MAX; + mmu->num_ctx =3D min(IPMMU_CTX_MAX, mmu->features->number_of_contexts); spin_lock_init(&mmu->lock); bitmap_zero(mmu->ctx, IPMMU_CTX_MAX); =20 @@ -1296,15 +1331,6 @@ static const struct iommu_ops ipmmu_iommu_ops =3D .add_device =3D ipmmu_add_device, }; =20 -static const struct dt_device_match ipmmu_dt_match[] __initconst =3D -{ - DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a7795"), - DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a77965"), - DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a7796"), - DT_MATCH_COMPATIBLE("renesas,ipmmu-r8a77961"), - { /* sentinel */ }, -}; - static __init int ipmmu_init(struct dt_device_node *node, const void *data) { int ret; --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=aHj1YyZRM0MOZGN2pkydJyksG/DbfGgO4EQLAxGN7v5o09suUtELqU6uNnyQST48Jw7ZN1ZBw4LeJ0QR7Y9qrNRc0zzI/9BVEQLQjKIop4mPHvPtFRNwEAkMpojxiNIHcxXXiY027bsApbtMXmBBFskqydthQUx8oeF0dWMVyW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pEksiNlvmWwQkzdEtzPAm9Nfk2gTNz+eLaCmNe+DTYo=; b=ZHT5+8+qkcQbxv8hZ917edrvijdprTG6Eglem0+UfbncjLJdOJ4ckuGsW/PKhHNxGY5oY/2vGBBdLY+Xxe8RFK7lyIcWarDdGSfkk/H64b4jIrKyyG5DoWvPy0y8NFjJ5KaU1cUXMKFhgn4BNi/Kxrmw/5mgGjZgQiIUXGdt1t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035008317434.9240963840317; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249997.430514 (Exim 4.92) (envelope-from ) id 1mzQ17-0005uL-3h; Mon, 20 Dec 2021 21:16:21 +0000 Received: by outflank-mailman (output) from mailman id 249997.430514; Mon, 20 Dec 2021 21:16:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ16-0005s8-NX; Mon, 20 Dec 2021 21:16:20 +0000 Received: by outflank-mailman (input) for mailman id 249997; Mon, 20 Dec 2021 21:16:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ15-0005IG-EK for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:19 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 12c2dda6-61da-11ec-9e60-abaf8a552007; Mon, 20 Dec 2021 22:16:18 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id g26so8789170lfv.11 for ; Mon, 20 Dec 2021 13:16:18 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:18 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 12c2dda6-61da-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pEksiNlvmWwQkzdEtzPAm9Nfk2gTNz+eLaCmNe+DTYo=; b=am8z/7Yob+H2UTGTjya6uTQa7rUdvCbUngOkebg+qKaeSpYGyzSIrvJ7EMwWj1XoKr K06N30dXH4Ya6r5NRkfP7Kbq3AUyovcKRlhFAifLaKFjh0wpyqlA1CCvMqnxUIP300XO qPZHBw7A3XMfUzY98CqLsXjq4rblPZMW+izlcDchQkkG2Ln7nOn6fsDI3TZmCPIevUhi 7xTDEfKfOl/tPU8p4Uf4B5yltkAugzAGRcCMG04YsLopZJVabFguruqaafRE5EZUtxdf hINrPiF0dBUdgotgLlJGIxiu4AYpO5s6VDf4TTk6b30x2gtrFxSdDjmEYM1T7PqlRLhK tasQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pEksiNlvmWwQkzdEtzPAm9Nfk2gTNz+eLaCmNe+DTYo=; b=dDuPw21a8x04vSHfw12wt1DQx7QLg40m1FXsnEOFvqhNJgi026dsKrqrIH+GJ1W+VU BkVC4iCRQ0RSV1OtW/zyMlQ0kV4POB3Z2QymLYwJ7trc8Oczf9xUo05fBKf8IdmhRUKb 7IMD7UahJ5OHTrQ3f0oOvNYlu3mmelFhQ4t7HZRk7tCuyC1I3h90w78cVrMsyFDrtj9d cprcCdY1aT38LZdkdSF83QVifZKSVdkzTq9ZoEv9o6UGxdMMtQJYKtCFMjHZ2s/QeDxm aaf/rm4PtSWFMESgfgWFtqhljZX3vXU5ZCgNnaVYSc4EY8K3l11bnQxm1gPPcR6DHnE0 Wqyg== X-Gm-Message-State: AOAM530GVZ+ZtNg9BpCTMV2kA/+vEdiET7qFmqwRkkVtQg07DlNQPvlZ 6Oy7H+B8Izj5PvHifGBXsv13biq9Fos= X-Google-Smtp-Source: ABdhPJw93aoMRmely2aqCzGAJO09jqMJYElGYtnjBWYvpkqFmTS/JmHJB974Po0oKy9cfrYkXDq3kQ== X-Received: by 2002:a19:690e:: with SMTP id e14mr9186lfc.298.1640034978409; Mon, 20 Dec 2021 13:16:18 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 05/10] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro Date: Mon, 20 Dec 2021 23:15:52 +0200 Message-Id: <1640034957-19764-6-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010322100009 From: Oleksandr Tyshchenko This is a non-verbatim port of corresponding Linux upsteam commit: 3dc28d9f59eaae41461542b27afe70339347ebb3 Original commit message: commit 3dc28d9f59eaae41461542b27afe70339347ebb3 Author: Yoshihiro Shimoda Date: Wed Nov 6 11:35:48 2019 +0900 iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro Since we will have changed memory mapping of the IPMMU in the future, this patch uses ipmmu_features values instead of a macro to calculate context registers offset. No behavior change. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Reviewed-by: Niklas S=C3=B6derlund Signed-off-by: Joerg Roedel ********** This is a prereq work needed to add support for S4 series easily in the future. Almost the same change as original commit makes, but without updating struct ipmmu_features_default which Xen driver doesn't have (there is no support of old Arm32 based Gen2 SoCs). No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 369be4c..ca33456 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -109,6 +109,8 @@ struct ipmmu_vmsa_xen_device { struct ipmmu_features { unsigned int number_of_contexts; unsigned int num_utlbs; + unsigned int ctx_offset_base; + unsigned int ctx_offset_stride; }; =20 /* Root/Cache IPMMU device's information */ @@ -167,8 +169,6 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define TLB_LOOP_TIMEOUT 100 /* 100us */ =20 /* Registers Definition */ -#define IM_CTX_SIZE 0x40 - #define IMCTR 0x0000 /* * This field is implemented in IPMMU-MM only. So, can be set for @@ -315,7 +315,8 @@ static void ipmmu_write(struct ipmmu_vmsa_device *mmu, = uint32_t offset, static unsigned int ipmmu_ctx_reg(struct ipmmu_vmsa_device *mmu, unsigned int context_id, uint32_t reg) { - return context_id * IM_CTX_SIZE + reg; + return mmu->features->ctx_offset_base + + context_id * mmu->features->ctx_offset_stride + reg; } =20 static uint32_t ipmmu_ctx_read(struct ipmmu_vmsa_device *mmu, @@ -735,6 +736,8 @@ static int ipmmu_init_platform_device(struct device *de= v, static const struct ipmmu_features ipmmu_features_rcar_gen3 =3D { .number_of_contexts =3D 8, .num_utlbs =3D 48, + .ctx_offset_base =3D 0, + .ctx_offset_stride =3D 0x40, }; =20 static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu) --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=J6T3r2wjEZtEwFCiTXuG4qyX2a8NjG3CAVtS8uTQM5Zn+GUB1Zcj5WcNpP1c4zgGytjt8A/zoAqoDUbC8c9e67OFGqf/PYAUfQSXHESJ1GFkZC/61FD0iStQH/Mm6FRaPM+vOsLg0mrUrwyR4GIg818fpiigY8kaU1SkMcdC5yE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=87T9wZal9/PpckvFihuEE4uSOyOrETTBOP9Ojac4rmQ=; b=QIOxkKtr2NDjXoIhKaND3Qsre7km8O+Ie48r3F2RYEoNw1dZozPQC7MuYlLO95a5NiFN7S9cPYDSPTQ/913QcxkegzhpWw3h1/FoGMzPS/fNFe2Uq3oHXmsiHw77c7pVcEl2SyB7J1wt0jJaVFJ6YX3mNikx5VeaKpY9PtPqjro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035008301479.982641854946; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249998.430539 (Exim 4.92) (envelope-from ) id 1mzQ18-0006eA-U9; Mon, 20 Dec 2021 21:16:22 +0000 Received: by outflank-mailman (output) from mailman id 249998.430539; Mon, 20 Dec 2021 21:16:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ18-0006aW-LE; Mon, 20 Dec 2021 21:16:22 +0000 Received: by outflank-mailman (input) for mailman id 249998; Mon, 20 Dec 2021 21:16:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ16-0005IB-Dq for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:20 +0000 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [2a00:1450:4864:20::130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 13523567-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:19 +0100 (CET) Received: by mail-lf1-x130.google.com with SMTP id x7so63029lfu.8 for ; Mon, 20 Dec 2021 13:16:19 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:18 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 13523567-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=87T9wZal9/PpckvFihuEE4uSOyOrETTBOP9Ojac4rmQ=; b=lm/UwovJiZ2A0shy8on5i1ls/8SdPLOeJgsONiV+OnXuTRDbCHZSaTi1SVmXyF3DC5 bHHt7lF3q1aAfQSuuGe0OH9IGb5m+X3iinBjYBihd2XqsxftqKzWTHFS2KBwBWGWtVWQ U85NZU+PmJeqBJY1fAGUkb0UVuQ3AImVOCSe5hv3VhiIF9yTH9bXI48A7lWcTk/NuNjg nDEg001M6hMYrGFoUiEz4YQ3m5kp7E9tMgE5RB6XgExlJN0X3ArrP6vIu7nQZKupAdzN hBNmtkgA6mY8X72r122WfilD7nY+iVCVsR2EDN6CdF1+jqmLKXJgH0MngZw2+WpxOZg3 SG7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=87T9wZal9/PpckvFihuEE4uSOyOrETTBOP9Ojac4rmQ=; b=Mihs2RE0gY8g7PSsRHPtICEqdlGfoa6eXBTbaVbRtoiBYtScyTyDz+snQPz4ZJ0F/b bG6BMH/0JFrn/NGQWVDrz2/FTND3Khtt77XDey6oJ2FGgwMVu/mGpql7+YJaK6YRW8UD KULVibL+7rslLxRORxY80HCdz6cLP51IOyl5ZS3awUnYBWox1tRhn7NyRYgUsycilTBD m1j8dzYSPfVnePXRlubaxi23PZNc7U7k6//PjCJ4dSliyZM4s0wRzlBQf9UFIZErSADG SBeJoWuJH30+A0ObSAuzhn0Uh+xZtcuqcp6LTawB07nfVeMYulqpC3XFKfSWkw7npXJv tI0w== X-Gm-Message-State: AOAM530WtNLeSjAukE4PRcFZbLoQH6EWv9iQrQV88TJ9HX14adzz1+Wt qDJRFzPotfGONd5wHqIFTKeXC5PzH5Y= X-Google-Smtp-Source: ABdhPJwCNkbhTcm5bsmmqZ29yWpUf5zoMFKKU17b6heYFWrAoMSYvi/3Cd/DsQK+ZG+g3LKFDRzqNg== X-Received: by 2002:a05:6512:695:: with SMTP id t21mr6375lfe.390.1640034979130; Mon, 20 Dec 2021 13:16:19 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 06/10] iommu/ipmmu-vmsa: Add utlb_offset_base Date: Mon, 20 Dec 2021 23:15:53 +0200 Message-Id: <1640034957-19764-7-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010267100006 From: Oleksandr Tyshchenko This is a non-verbatim port of corresponding Linux upsteam commit: 1289f7f15001c7ed36be6d23cb145c1d5feacdc8 Original commit message: commit 1289f7f15001c7ed36be6d23cb145c1d5feacdc8 Author: Yoshihiro Shimoda Date: Wed Nov 6 11:35:50 2019 +0900 iommu/ipmmu-vmsa: Add utlb_offset_base Since we will have changed memory mapping of the IPMMU in the future, this patch adds a utlb_offset_base into struct ipmmu_features for IMUCTR and IMUASID registers. No behavior change. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Niklas S=C3=B6derlund Signed-off-by: Joerg Roedel ********** This is a prereq work needed to add support for S4 series easily in the future. Almost the same change as original commit makes, but without updating struct ipmmu_features_default which Xen driver doesn't have (there is no support of old Arm32 based Gen2 SoCs). No change in behavior. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index ca33456..d8f96fc 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -111,6 +111,7 @@ struct ipmmu_features { unsigned int num_utlbs; unsigned int ctx_offset_base; unsigned int ctx_offset_stride; + unsigned int utlb_offset_base; }; =20 /* Root/Cache IPMMU device's information */ @@ -374,7 +375,7 @@ static void ipmmu_ctx_write_all(struct ipmmu_vmsa_domai= n *domain, =20 static uint32_t ipmmu_utlb_reg(struct ipmmu_vmsa_device *mmu, uint32_t reg) { - return reg; + return mmu->features->utlb_offset_base + reg; } =20 static void ipmmu_imuasid_write(struct ipmmu_vmsa_device *mmu, @@ -738,6 +739,7 @@ static const struct ipmmu_features ipmmu_features_rcar_= gen3 =3D { .num_utlbs =3D 48, .ctx_offset_base =3D 0, .ctx_offset_stride =3D 0x40, + .utlb_offset_base =3D 0, }; =20 static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu) --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035012; cv=none; d=zohomail.com; s=zohoarc; b=gAxoIwPcHCN6gcwjLQPB8x3867gg/goUWp30KbsIRHwITz9b+vZgY17IgMoHnZfmHIpNbU58+/QO0Wo1RzmAvcyzxEe0BqVXa3JrNNiScSDP+JUGyZwSk3uh3orgXgsqhUaZ0FZPrH91bcadK+RQcHeg5s86Fjxq8Yu9P3We89M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035012; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qvpXNTLTS2Ou2xoiYRMuZM4a44G4SigTrlNi3wejEhU=; b=Di/EME2Jft/IEGvwmb5ZdTJLMCSQGbltJdT7+ru6nUUNudn1Ec1xcdxBTry6OOHsA0bx6VdERHz0g6lVcQE2TVBQhRoBiI2iUxREuAVcQGKUcXJrb02B28FcLQ+BD+s/JbRNy+3UMQz3fXyhRnogbl6OT84NXki8hbTMl8Kxi9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16400350122538.045031901040147; Mon, 20 Dec 2021 13:16:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.249999.430553 (Exim 4.92) (envelope-from ) id 1mzQ1A-0006wV-EP; Mon, 20 Dec 2021 21:16:24 +0000 Received: by outflank-mailman (output) from mailman id 249999.430553; Mon, 20 Dec 2021 21:16:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ19-0006sE-UQ; Mon, 20 Dec 2021 21:16:23 +0000 Received: by outflank-mailman (input) for mailman id 249999; Mon, 20 Dec 2021 21:16:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ17-0005IB-KY for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:21 +0000 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [2a00:1450:4864:20::22c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 13d17607-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:20 +0100 (CET) Received: by mail-lj1-x22c.google.com with SMTP id a37so18017962ljq.13 for ; Mon, 20 Dec 2021 13:16:20 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:19 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 13d17607-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qvpXNTLTS2Ou2xoiYRMuZM4a44G4SigTrlNi3wejEhU=; b=f4oJF2gkVGsK6/9ewRqi+f5aAOA1Nb1HZ8Q04mKakwVTxo62yuJLYRYDebhnjBSZcx GIlAslICYpPvlevexgjuP4Ar64EhJZ7U+pIeHTQDvR1m7i0Dmv/R3AV26YqzjvPLdAt0 Dl8gdT6iXKtLSVIwlAKH9YXHIzc9b61vZrPC5hEQPO2KXk26Ix7KtRMJS0q6HVZIHB1q 98lNyRZXUK0y23oqhTOJXN8t5p8mEL5tQN9Ms3SfqFpZMTI3XCqvQug5kQOxPyfBXRao VYyJVi7hR/BXOausPApKYjuWxS+Dq+Ka+yIrUM32SDTKj8ofNhqRZtDPiREKFc/9jSk/ +RJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qvpXNTLTS2Ou2xoiYRMuZM4a44G4SigTrlNi3wejEhU=; b=pNvYMXpecA7F+ll9zstPr48ra3OEGE6CCYoS5LS178ufaUo49mDl0ljOis4FXPUR2o 9xdlmM2k6c8kfHKelopr0aWZAje942LHsHzPOzJVSvp0TQPkMwc+Pioga61mc0h00oB8 +w8cnXtZVaCn31ZLtBYNHiYHmTXOvQPrcMQhrSGMwoFTl3gtANI+gDo/heJYSszXWO+K 7csa1uCvnNAI9siQDPAIryHtzz1JBzyzO2uY7cBOPkZrZKCmKnYnSEXanNaJxHPH4+DV LROdNwTmi9cLfds4g3LytzHrdkXK6fj6h9nqP2BiAh/ZgpBeASDPZGWGTzPYuKSBo//D CUBw== X-Gm-Message-State: AOAM5329SApkWWV4hfDd0flPlFxT8qx3ZI8einM4BrueFRUmhSFUtqJb XN6wU0GLlHDYnK8/VeufR0LsXep3+gA= X-Google-Smtp-Source: ABdhPJxWPezQF6NbeQ18VRNYks8+OCfDkLbPeHBRDUAWe/GGifNO9f82mjeawDjmJjCu/EpwKVrHsQ== X-Received: by 2002:a2e:a482:: with SMTP id h2mr15951927lji.87.1640034979903; Mon, 20 Dec 2021 13:16:19 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Jan Beulich , Paul Durrant , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 07/10] iommu/ipmmu-vmsa: Add Renesas R8A779F0 (R-Car S4) support Date: Mon, 20 Dec 2021 23:15:54 +0200 Message-Id: <1640034957-19764-8-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035013155100003 From: Oleksandr Tyshchenko Based on the following Linux upsteam commit: 7a62ced8ebd0e1b692c9dc4781a8d4ddb0f74792 Original commit message: commit 7a62ced8ebd0e1b692c9dc4781a8d4ddb0f74792 Author: Yoshihiro Shimoda Date: Tue Sep 7 17:30:20 2021 +0900 iommu/ipmmu-vmsa: Add support for r8a779a0 Add support for r8a779a0 (R-Car V3U). The IPMMU hardware design of this SoC differs than others. So, add a new ipmmu_features for it. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20210907083020.907648-3-yoshihiro.shimoda= .uh@renesas.com Signed-off-by: Joerg Roedel ********** The R-Car S4 is an automotive System-on-Chip (SoC) for Car Server/Communication Gateway and is one of the first products in Renesas=E2=80=99 4th-generation R-Car Family. The integrated IOMMU HW is also VMSA-compatible and supports stage 2 translation table format, therefore can be used with current driver with slight modifications (thanks to the prereq work). In the context of Xen driver the main differences between Gen3 and Gen4 are the following: - HW capacity was enlarged to support up to 16 IPMMU contexts (sets of page table) and up to 64 micro-TLBs per IPMMU device - the memory mapped registers have different bases and offsets Please note that Linux upstream doesn't support R-Car S4 SoC yet unlike Renesas BSP [1], but it was decided to reuse upstream patch for R-Car V3U anyway as the IPMMU HW settings are similar. [1] 7003b9f732cf iommu/ipmmu-vmsa: Add Renesas R8A779F0 (R-Car S4) support https://github.com/renesas-rcar/linux-bsp/tree/v5.10.41/rcar-5.1.3.rc5 Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Oleksandr Andrushchenko Acked-by: Julien Grall Reviewed-by: Yoshihiro Shimoda --- Changes V1 -> V2: - base on the Linux upsteam patch instead of BSP's one - update patch description and comments in code - replace ipmmu_features_rcar_s4 with ipmmu_features_rcar_gen4 - introduce control_offset_base field --- xen/drivers/passthrough/Kconfig | 6 +-- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 63 +++++++++++++++++++++++-----= ---- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kcon= fig index 09505aa..479d7de 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -25,14 +25,14 @@ config ARM_SMMU_V3 the ARM SMMUv3 architecture. =20 config IPMMU_VMSA - bool "Renesas IPMMU-VMSA found in R-Car Gen3 SoCs" + bool "Renesas IPMMU-VMSA found in R-Car Gen3/Gen4 SoCs" depends on ARM_64 ---help--- Support for implementations of the Renesas IPMMU-VMSA found - in R-Car Gen3 SoCs. + in R-Car Gen3/Gen4 SoCs. =20 Say Y here if you are using newest R-Car Gen3 SoCs revisions - (H3 ES3.0, M3-W+, etc) which IPMMU hardware supports stage 2 + (H3 ES3.0, M3-W+, etc) or Gen4 SoCs which IPMMU hardware supports stage= 2 translation table format and is able to use CPU's P2M table as is. =20 endif diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index d8f96fc..14848ce 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -1,15 +1,15 @@ /* * xen/drivers/passthrough/arm/ipmmu-vmsa.c * - * Driver for the Renesas IPMMU-VMSA found in R-Car Gen3 SoCs. + * Driver for the Renesas IPMMU-VMSA found in R-Car Gen3/Gen4 SoCs. * * The IPMMU-VMSA is VMSA-compatible I/O Memory Management Unit (IOMMU) * which provides address translation and access protection functionalities * to processing units and interconnect networks. * * Please note, current driver is supposed to work only with newest - * R-Car Gen3 SoCs revisions which IPMMU hardware supports stage 2 transla= tion - * table format and is able to use CPU's P2M table as is. + * R-Car Gen3/Gen4 SoCs revisions which IPMMU hardware supports stage 2 + * translation table format and is able to use CPU's P2M table as is. * * Based on Linux's IPMMU-VMSA driver from Renesas BSP: * drivers/iommu/ipmmu-vmsa.c @@ -20,9 +20,9 @@ * and Xen's SMMU driver: * xen/drivers/passthrough/arm/smmu.c * - * Copyright (C) 2014-2019 Renesas Electronics Corporation + * Copyright (C) 2014-2021 Renesas Electronics Corporation * - * Copyright (C) 2016-2019 EPAM Systems Inc. + * Copyright (C) 2016-2021 EPAM Systems Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms and conditions of the GNU General Public @@ -68,12 +68,13 @@ dev_print(dev, XENLOG_ERR, fmt, ## __VA_ARGS__) =20 /* - * R-Car Gen3 SoCs make use of up to 8 IPMMU contexts (sets of page table)= and - * these can be managed independently. Each context is mapped to one Xen d= omain. + * R-Car Gen3/Gen4 SoCs make use of up to 16 IPMMU contexts (sets of page = table) + * and these can be managed independently. Each context is mapped to one X= en + * domain. */ -#define IPMMU_CTX_MAX 8U -/* R-Car Gen3 SoCs make use of up to 48 micro-TLBs per IPMMU device. */ -#define IPMMU_UTLB_MAX 48U +#define IPMMU_CTX_MAX 16U +/* R-Car Gen3/Gen4 SoCs make use of up to 64 micro-TLBs per IPMMU device. = */ +#define IPMMU_UTLB_MAX 64U =20 /* IPMMU context supports IPA size up to 40 bit. */ #define IPMMU_MAX_P2M_IPA_BITS 40 @@ -112,6 +113,8 @@ struct ipmmu_features { unsigned int ctx_offset_base; unsigned int ctx_offset_stride; unsigned int utlb_offset_base; + unsigned int control_offset_base; + unsigned int imuctr_ttsel_mask; }; =20 /* Root/Cache IPMMU device's information */ @@ -211,7 +214,6 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMUCTR0(n) (0x0300 + ((n) * 16)) #define IMUCTR32(n) (0x0600 + (((n) - 32) * 16)) #define IMUCTR_TTSEL_MMU(n) ((n) << 4) -#define IMUCTR_TTSEL_MASK (15 << 4) #define IMUCTR_TTSEL_SHIFT 4 #define IMUCTR_FLUSH (1 << 1) #define IMUCTR_MMUEN (1 << 0) @@ -316,8 +318,12 @@ static void ipmmu_write(struct ipmmu_vmsa_device *mmu,= uint32_t offset, static unsigned int ipmmu_ctx_reg(struct ipmmu_vmsa_device *mmu, unsigned int context_id, uint32_t reg) { - return mmu->features->ctx_offset_base + - context_id * mmu->features->ctx_offset_stride + reg; + unsigned int base =3D mmu->features->ctx_offset_base; + + if ( context_id > 7 ) + base +=3D 0x800 - 8 * 0x40; + + return base + context_id * mmu->features->ctx_offset_stride + reg; } =20 static uint32_t ipmmu_ctx_read(struct ipmmu_vmsa_device *mmu, @@ -448,7 +454,8 @@ static int ipmmu_utlb_enable(struct ipmmu_vmsa_domain *= domain, { unsigned int context_id; =20 - context_id =3D (imuctr & IMUCTR_TTSEL_MASK) >> IMUCTR_TTSEL_SHIFT; + context_id =3D (imuctr & mmu->features->imuctr_ttsel_mask) >> + IMUCTR_TTSEL_SHIFT; if ( domain->context_id !=3D context_id ) { dev_err(mmu->dev, "Micro-TLB %u already assigned to IPMMU cont= ext %u\n", @@ -740,6 +747,18 @@ static const struct ipmmu_features ipmmu_features_rcar= _gen3 =3D { .ctx_offset_base =3D 0, .ctx_offset_stride =3D 0x40, .utlb_offset_base =3D 0, + .control_offset_base =3D 0, + .imuctr_ttsel_mask =3D (15 << 4), +}; + +static const struct ipmmu_features ipmmu_features_rcar_gen4 =3D { + .number_of_contexts =3D 16, + .num_utlbs =3D 64, + .ctx_offset_base =3D 0x10000, + .ctx_offset_stride =3D 0x1040, + .utlb_offset_base =3D 0x3000, + .control_offset_base =3D 0x1000, + .imuctr_ttsel_mask =3D (31 << 4), }; =20 static void ipmmu_device_reset(struct ipmmu_vmsa_device *mmu) @@ -751,11 +770,12 @@ static void ipmmu_device_reset(struct ipmmu_vmsa_devi= ce *mmu) ipmmu_ctx_write(mmu, i, IMCTR, 0); } =20 -/* R-Car Gen3 SoCs product and cut information. */ +/* R-Car Gen3/Gen4 SoCs product and cut information. */ #define RCAR_PRODUCT_MASK 0x00007F00 #define RCAR_PRODUCT_H3 0x00004F00 #define RCAR_PRODUCT_M3W 0x00005200 #define RCAR_PRODUCT_M3N 0x00005500 +#define RCAR_PRODUCT_S4 0x00005A00 #define RCAR_CUT_MASK 0x000000FF #define RCAR_CUT_VER30 0x00000020 =20 @@ -803,6 +823,10 @@ static __init bool ipmmu_stage2_supported(void) stage2_supported =3D true; break; =20 + case RCAR_PRODUCT_S4: + stage2_supported =3D true; + break; + default: printk(XENLOG_ERR "ipmmu: Unsupported SoC version\n"); break; @@ -831,6 +855,10 @@ static const struct dt_device_match ipmmu_dt_match[] _= _initconst =3D .compatible =3D "renesas,ipmmu-r8a77961", .data =3D &ipmmu_features_rcar_gen3, }, + { + .compatible =3D "renesas,ipmmu-r8a779f0", + .data =3D &ipmmu_features_rcar_gen4, + }, { /* sentinel */ }, }; =20 @@ -845,6 +873,7 @@ static int ipmmu_probe(struct dt_device_node *node) const struct dt_device_match *match; struct ipmmu_vmsa_device *mmu; uint64_t addr, size; + uint32_t reg; int irq, ret; =20 mmu =3D xzalloc(struct ipmmu_vmsa_device); @@ -930,8 +959,8 @@ static int ipmmu_probe(struct dt_device_node *node) * Use stage 2 translation table format when stage 2 translation * enabled. */ - ipmmu_write(mmu, IMSAUXCTLR, - ipmmu_read(mmu, IMSAUXCTLR) | IMSAUXCTLR_S2PTE); + reg =3D IMSAUXCTLR + mmu->features->control_offset_base; + ipmmu_write(mmu, reg, ipmmu_read(mmu, reg) | IMSAUXCTLR_S2PTE); =20 dev_info(&node->dev, "IPMMU context 0 is reserved\n"); set_bit(0, mmu->ctx); --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=EP0ITwa6/hpXomg4YGyuPGN2X1uu+JsNqGMDXbJFtMjfVl1O4W95aCA0dp9NL9APKOkJrrwthHJPSAEqEGc/UVTiS8q6nzcv4De/oQx6H2+lekgYOJyYtjiXWfc4MKSDGRrRmRGu5RLm5hVSAI0P1h9hPEivBAt7LgQDBgGaK8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WeHEjPAzdPl1ntiWMAL8hlkKvubzizi7P4jP/3KCTl4=; b=Gr5qpUrqdfYLyAW068PoRyNkRZ6sbVMAqZYKj2RI+m3iZcOb1CKLsdJLgOTYr/FaEO/lZ0hZJRhyLABY1/SD2cVT0gPoTtKwN8eAeRG3HY6o/k/Q97v91kpWN/et/Rbk+l1qMQxJZRDA5ASb1oNq8agz12q8/wOfUiihmKRUl8Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035008209584.922369040463; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.250000.430546 (Exim 4.92) (envelope-from ) id 1mzQ19-0006la-IF; Mon, 20 Dec 2021 21:16:23 +0000 Received: by outflank-mailman (output) from mailman id 250000.430546; Mon, 20 Dec 2021 21:16:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ19-0006jw-7Z; Mon, 20 Dec 2021 21:16:23 +0000 Received: by outflank-mailman (input) for mailman id 250000; Mon, 20 Dec 2021 21:16:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ17-0005IG-Om for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:21 +0000 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [2a00:1450:4864:20::134]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1421b50b-61da-11ec-9e60-abaf8a552007; Mon, 20 Dec 2021 22:16:21 +0100 (CET) Received: by mail-lf1-x134.google.com with SMTP id bt1so24503094lfb.13 for ; Mon, 20 Dec 2021 13:16:21 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:20 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1421b50b-61da-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WeHEjPAzdPl1ntiWMAL8hlkKvubzizi7P4jP/3KCTl4=; b=YjBJFHQOwM4G+wWsfiqU7jf8lspX3+GX5u0wGwI9QDNRrnUG37FpFNMnM1cc6K6rhn XmU7t5q7Nk7JAbqU7CRjCoBcil1ps5xvhznTAjDjEiwLj4zOfKWyfSR1ESeJ9iGnj83+ JEX+wfDmcKHrY4zymy0DHdyH5LIiDKr7UNHvhT3nQ261hO7XmBla8rE5H0xso4xhIJ9x 0dn/xgV0gKpOD6M9uTPWC1f2O2zrqDXRlLjfwhBLv/V0yG4+3sS5YTnEC/7Cz823K4N0 7LHknbZNDIfZViUKwMJ6vSCW9/ZQkROAunoZdOcjHEFvx84l/HfrYCNWrn1tn5aqXgcY TC2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WeHEjPAzdPl1ntiWMAL8hlkKvubzizi7P4jP/3KCTl4=; b=8DQjMwfUpcQg0Peaqjg6kjiKYJvb4xdQLpA1pQ9NMij3Vc84SS80xUu/Bccmq55Ns3 SXR9gaUmDrws8oza/glDC6btlp+gD/B5snDbp7SvTOOsAvStvNYBa64903lmwJqka1fg xN7I1nT0ymvADVXT35GkER1MDC+AYPVBPt4mhh5G8w0GHIY8HzwEVjznsc8wkPfmp5Jq J4/YhVTnUftQo8ttFql1GFnGRConWwhaPauG9sx0vvzR+8ze9cRFF7xT37sTDqxWzQK5 FszMZHYnDz5NkpMqZPA7LUuJlqlHoWCtCsfvx3uWYuCOHcemCoDBAnplnHDHEpv6BpR0 XIwQ== X-Gm-Message-State: AOAM530JHvDNW1yWoN7m0KfE78VT7vQG1kozKfOk601uz9VHiTRtRdVg ltH23VQMWtv6h6uY5Zbq6e1E39c/vmk= X-Google-Smtp-Source: ABdhPJzpSS1SrTorcSVD6F21ky5lwYz7Lq/x4dTSm0jmtZAUI5674vxgWrEY49t/rUCfC3QXJWnRhQ== X-Received: by 2002:a19:8c4b:: with SMTP id i11mr3428387lfj.81.1640034980647; Mon, 20 Dec 2021 13:16:20 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 08/10] iommu/ipmmu-vmsa: Set IPMMU bit IMSCTLR_USE_SECGRP to 0 Date: Mon, 20 Dec 2021 23:15:55 +0200 Message-Id: <1640034957-19764-9-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010245100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Based on the following commits from the Renesas BSP: 8fba83d97cca709a05139c38e29408e81ed4cf62 a8d93bc07da89a7fcf4d85f34d119a030310efa5 located at: https://github.com/renesas-rcar/linux-bsp/tree/v5.10.41/rcar-5.1.3.rc5 Original commit messages: commit 8fba83d97cca709a05139c38e29408e81ed4cf62 Author: Nam Nguyen Date: Wed Apr 28 18:54:44 2021 +0700 iommu/ipmmu-vmsa: Set IPMMU bit IMSCTLR_USE_SECGRP to 0 Need to set bit IMSCTLR_USE_SECGRP to 0 because H/W initial value is unknown, without this dma-transfer cannot be done due to address translation doesn't work. Signed-off-by: Nam Nguyen commit a8d93bc07da89a7fcf4d85f34d119a030310efa5 Author: Nam Nguyen Date: Tue Sep 7 14:46:12 2021 +0700 iommu/ipmmu-vmsa: Update IMSCTLR register offset address for R-Car S4 Update IMSCTLR register offset address to align with R-Car S4 H/W UM. Signed-off-by: Nam Nguyen ********** It is still a question whether this really needs to be done in Xen, rather in firmware, but better to be on the safe side. After all, if firmware already takes care of clearing this bit, nothing bad will happen. Please note the following: 1. I decided to squash both commits since the first commit adds clearing code and only the second one makes it functional on S4. Moreover, this is not a direct port. So it would be better to introduce complete solution by a single patch. 2. Although patch indeed does what it claims in the subject, the implementation is different in comparison with original changes. On Linux the clearing is done at runtime in ipmmu_domain_setup_context(). On Xen the clearing is done at boot time in ipmmu_probe(). The IMSCTLR is not a MMU "context" register at all, so I think there is no point in performing the clearing each time we initialize the context, instead perform the clearing at once during initialization. Also do not abuse ctx_offset_stride_adj field for the register's offset calculation, instead use recently added control_offset_base field. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Volodymyr Babchuk Acked-by: Julien Grall Reviewed-by: Yoshihiro Shimoda --- Changes V1 -> V2: - add R-b - update patch description - replace ctx_offset_stride_adj with control_offset_base for register's offset calculation --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 14848ce..649b9f6 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -222,6 +222,9 @@ static DEFINE_SPINLOCK(ipmmu_devices_lock); #define IMUASID0(n) (0x0308 + ((n) * 16)) #define IMUASID32(n) (0x0608 + (((n) - 32) * 16)) =20 +#define IMSCTLR 0x0500 +#define IMSCTLR_USE_SECGRP (1 << 28) + #define IMSAUXCTLR 0x0504 #define IMSAUXCTLR_S2PTE (1 << 3) =20 @@ -966,6 +969,10 @@ static int ipmmu_probe(struct dt_device_node *node) set_bit(0, mmu->ctx); } =20 + /* Do not use security group function. */ + reg =3D IMSCTLR + mmu->features->control_offset_base; + ipmmu_write(mmu, reg, ipmmu_read(mmu, reg) & ~IMSCTLR_USE_SECGRP); + spin_lock(&ipmmu_devices_lock); list_add(&mmu->list, &ipmmu_devices); spin_unlock(&ipmmu_devices_lock); --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035008; cv=none; d=zohomail.com; s=zohoarc; b=TkKr/H/Y6AtrGHyn00IVm5ntwmIUfbKHUJ1OVQqdpIx3D+59qhbD5mRaKn6X380TZw4eo194Q2vdH7NRF4sK6uadRGPah3eigw+d+VgIZkKpfD9UCxQehgb7aCF3MDssm4bhtzFXJj34F4EXKlvAX8sYbI35wlnTg3EL5njLI48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ruH/ZtUTmX8iN6zofPsz6r1KAf8lKOAgjKOqJDL6kwU=; b=AhJe3nGhr6BsggouiKfMpt2HB9oqGDfhHJJjE8UO2P3WXk21LVmMpBWnhU4MmoQ+gGMTLhYXJSCBVS2+eXid7ZPu1byDWiPwPOlZb6c84/34onYWPhkJE8Yq9KQopTbNSJKhRNHBfbla9B2Yws6ximtOsprSoHUU0ZlwYYW5Q90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 164003500835444.814328135264645; Mon, 20 Dec 2021 13:16:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.250001.430567 (Exim 4.92) (envelope-from ) id 1mzQ1B-0007KU-R4; Mon, 20 Dec 2021 21:16:25 +0000 Received: by outflank-mailman (output) from mailman id 250001.430567; Mon, 20 Dec 2021 21:16:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ1B-0007Gz-FG; Mon, 20 Dec 2021 21:16:25 +0000 Received: by outflank-mailman (input) for mailman id 250001; Mon, 20 Dec 2021 21:16:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ18-0005IB-Ra for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:22 +0000 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [2a00:1450:4864:20::232]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 14a0a55c-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:22 +0100 (CET) Received: by mail-lj1-x232.google.com with SMTP id u22so18047883lju.7 for ; Mon, 20 Dec 2021 13:16:22 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:21 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 14a0a55c-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ruH/ZtUTmX8iN6zofPsz6r1KAf8lKOAgjKOqJDL6kwU=; b=CDMSfqEUyrVBM25MEGIzHLeoHcUFlBF7AVUEDESUE2sPkWXL1Pj7uRg78VNv5JoKuc 54fvBdonm1Nq4ZFPMqV5wAT0Burub2MDNaPv3jjEddM4NEa4TLhHI/nQIAGNranFaIv3 +JXNyPkx9D5HBA/g/4ar7r/RDoZ3Z9N8I6JA/QgJNtlJRziKacOOxL/xiKvpeibC6htM JnUDFzpcJqsHwPYmUrz2IxA+MQSteMNkPsvdiRFcYB9H28gvILoJVOoqN6Cl3MK0ajI3 CfgvX7UrBZdqSEGs4wwbU/zALJm1rUmGQOGszcuDxqlTITemRI+rvjGe9AsDNfT+0ccm HwnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ruH/ZtUTmX8iN6zofPsz6r1KAf8lKOAgjKOqJDL6kwU=; b=zhjPMWyp+8AOBFtbc+e+Z2nfiME/orkJ5Yx2V/kfJ79Rj/M5THNnsDJWidNJ7y+MgO VfqEAujqKsDYqDEBlAWxjsDECF9KvWmFWbpYPx3L/vWWkYWurJ0c8A8DhtHRmkw5nEKg Ahdm62dSqQ7iuDhrylDTJOuBBHi7yAc+jCdzL+SN8QRa4A8xj+Td3lgGill1DZ5ZqvgC 06uWkULJiZ5Ab3m9dABvcfzovdKDe7hLt7XC0AhOQpq2GyiTthGYAI5uMBMeHdhf4Ke3 LvUMZWXlWGWnqNuLvEEykF9Gt1YSRNb13a0tJ97mh9cSgA6FIMnylKAioBbZBEFc9/9V 5RMg== X-Gm-Message-State: AOAM5318VfgoU2m2ST7N8KYvOdK4spF3QC1W4sch8EWFkAx9jtn8QLg8 tJUQtC+6XQDB4crs9pLVetr7Tuf2MvY= X-Google-Smtp-Source: ABdhPJygzn941uf9Tjg3K5YR8Nj0KXaAS2tnW+3lvktFAgQUqXlC3Yrmbyf+ZosfHupnIONO+S2H8g== X-Received: by 2002:a2e:3c17:: with SMTP id j23mr16332638lja.391.1640034981391; Mon, 20 Dec 2021 13:16:21 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 09/10] iommu/ipmmu-vmsa: Use refcount for the micro-TLBs Date: Mon, 20 Dec 2021 23:15:56 +0200 Message-Id: <1640034957-19764-10-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035010328100010 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko Reference-count the micro-TLBs as several bus masters can be connected to the same micro-TLB (and drop TODO comment). This wasn't an issue so far, since the platform devices (this driver deals with) get assigned/deassigned together during domain creation/destruction. But, in order to support PCI devices (which are hot-pluggable) in the near future we will need to take care of. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b - add ASSERT() in ipmmu_utlb_disable() --- xen/drivers/passthrough/arm/ipmmu-vmsa.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 649b9f6..1224ea4 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -127,6 +127,7 @@ struct ipmmu_vmsa_device { spinlock_t lock; /* Protects ctx and domains[] */ DECLARE_BITMAP(ctx, IPMMU_CTX_MAX); struct ipmmu_vmsa_domain *domains[IPMMU_CTX_MAX]; + unsigned int utlb_refcount[IPMMU_UTLB_MAX]; const struct ipmmu_features *features; }; =20 @@ -467,13 +468,12 @@ static int ipmmu_utlb_enable(struct ipmmu_vmsa_domain= *domain, } } =20 - /* - * TODO: Reference-count the micro-TLB as several bus masters can be - * connected to the same micro-TLB. - */ - ipmmu_imuasid_write(mmu, utlb, 0); - ipmmu_imuctr_write(mmu, utlb, imuctr | - IMUCTR_TTSEL_MMU(domain->context_id) | IMUCTR_MMUEN= ); + if ( mmu->utlb_refcount[utlb]++ =3D=3D 0 ) + { + ipmmu_imuasid_write(mmu, utlb, 0); + ipmmu_imuctr_write(mmu, utlb, imuctr | + IMUCTR_TTSEL_MMU(domain->context_id) | IMUCTR_M= MUEN); + } =20 return 0; } @@ -484,7 +484,10 @@ static void ipmmu_utlb_disable(struct ipmmu_vmsa_domai= n *domain, { struct ipmmu_vmsa_device *mmu =3D domain->mmu; =20 - ipmmu_imuctr_write(mmu, utlb, 0); + ASSERT(mmu->utlb_refcount[utlb] > 0); + + if ( --mmu->utlb_refcount[utlb] =3D=3D 0 ) + ipmmu_imuctr_write(mmu, utlb, 0); } =20 /* Domain/Context Management */ --=20 2.7.4 From nobody Mon May 6 20:00:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640035011; cv=none; d=zohomail.com; s=zohoarc; b=lWp+SJTaU73PAFHswkJlISnTXIOF51Ao9dZZY9gb39J9ZqPV9wfbzUuHFf8AqUJfHMr5rIkCG5Z5btvrl1TkviKlBRiT8tarsNont9Z/bWS/qr2Xi3kqao4eIqmQIB+W8lm9B/mWpZ9lPUbkLa4pvPmVeqAxcU3vZWPuS2q1nmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640035011; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=xEJ/as6c2Y3IKG5DtZXdMpOhtzqpglhGl1VKpLommlg=; b=CL3i9/SlxixkAXGY17SjAKHkn44Vcd7zSQe2E8ZTQMKJzPUfhn2wzi901ThLnpQWyIPJLxJBsmT9Myk5O3AQ+ZUAUHz9SpGNiwwazjf2nlE1UCBos55jrcNzVjtlBmkBsL5yXYDnjbilA9Fbrnw2OYs0+abWp+8BiZIimQDt1Uc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1640035011080824.0385255093823; Mon, 20 Dec 2021 13:16:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.250002.430576 (Exim 4.92) (envelope-from ) id 1mzQ1C-0007c8-Nh; Mon, 20 Dec 2021 21:16:26 +0000 Received: by outflank-mailman (output) from mailman id 250002.430576; Mon, 20 Dec 2021 21:16:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ1C-0007Yr-CA; Mon, 20 Dec 2021 21:16:26 +0000 Received: by outflank-mailman (input) for mailman id 250002; Mon, 20 Dec 2021 21:16:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mzQ19-0005IB-CZ for xen-devel@lists.xenproject.org; Mon, 20 Dec 2021 21:16:23 +0000 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [2a00:1450:4864:20::22b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 150591d1-61da-11ec-85d3-df6b77346a89; Mon, 20 Dec 2021 22:16:22 +0100 (CET) Received: by mail-lj1-x22b.google.com with SMTP id k2so18068267lji.4 for ; Mon, 20 Dec 2021 13:16:22 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id b35sm635132lfv.209.2021.12.20.13.16.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Dec 2021 13:16:21 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 150591d1-61da-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xEJ/as6c2Y3IKG5DtZXdMpOhtzqpglhGl1VKpLommlg=; b=bxGK8XoFncudNK8ijCfMDVnV8Ugd3evS/gun5assQK01IdDTTme9eoHJ9hn01SFBFu AglMLMZsDwZF494RmxroKyz+LkoZvL4H3hWk6eHKtXJFBFN9ljmb5FLihHMDLjvK9+zu MLZjTH4KUGfOiiCfUGP59Mi0Z9kvU3jr7wNbq1ltfjVhTSG2J2kMAXLzEhKoFLGl4HhI vuSS+Uvn9aM4f51YSyEZRq+t8bpIPxF+7NZlbqxtu/2gDgIeecz+9T3Gi3u7d9nz1dBY yuZvB7C/HuHIomIzdNWAru9+rn+N4KoZRdPJUKK53zPXIg1NkAm0zmAmEe9iNvSJfmdQ FjcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xEJ/as6c2Y3IKG5DtZXdMpOhtzqpglhGl1VKpLommlg=; b=G99CQAMJF5CAmUSMQ0wbf47w+OgCmyC0EMGmPQVC9R3mDt6RkUVF78kTQwvb2hcgyr Xyh394pKbCoiacuFLRSo9gktKtili9B/XOvoHlpNGI7RXHPR6Gdau3MLGnW5g5BCDze3 7LU2cZvQUHzWmf+QZJsJgwBMfdGTgDrz5vlhpBPQ88RRK6+OAsGzrN19/hfnji7jfK9g hkz0v43GFLI5VmHz2ijuhm1Ht3I8NSXrPFARGyatI70PgRdvIpoeeudUHFzWhYmCia0s nvPmJKwaVVeiWmVjR9ra88HYjxdaIH07byva8sWEIkulCUWzrLttC2Y8NadrQpUYIqfW dGTQ== X-Gm-Message-State: AOAM533xVYwIaVwTYOLS4proYFpqX2t7Qod4jmwUphtQswtt07LRF08R 2M1xR2rB/cRGseX3Emtdn6FMcE55qCE= X-Google-Smtp-Source: ABdhPJyHVZaNSJHo2OIPrA0WgJpGUxpjHQvokrcmd6B6Dh+19rKeup/HjUJRLxpz11VTIqNQv4POKA== X-Received: by 2002:a05:651c:1696:: with SMTP id bd22mr15878925ljb.57.1640034982132; Mon, 20 Dec 2021 13:16:22 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Rahul Singh , Yoshihiro Shimoda , Oleksandr Andrushchenko Subject: [PATCH V2 10/10] iommu/arm: Remove code duplication in all IOMMU drivers Date: Mon, 20 Dec 2021 23:15:57 +0200 Message-Id: <1640034957-19764-11-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> References: <1640034957-19764-1-git-send-email-olekstysh@gmail.com> X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1640035013095100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko All IOMMU drivers on Arm perform almost the same generic actions in hwdom_init callback. Move this code to common arch_iommu_hwdom_init() in order to get rid of code duplication. Signed-off-by: Oleksandr Tyshchenko Reviewed-by: Volodymyr Babchuk Reviewed-by: Yoshihiro Shimoda Acked-by: Julien Grall --- Changes V1 -> V2: - add R-b --- xen/drivers/passthrough/arm/iommu.c | 7 +++++++ xen/drivers/passthrough/arm/ipmmu-vmsa.c | 8 -------- xen/drivers/passthrough/arm/smmu-v3.c | 10 ---------- xen/drivers/passthrough/arm/smmu.c | 10 ---------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/xen/drivers/passthrough/arm/iommu.c b/xen/drivers/passthrough/= arm/iommu.c index ee653a9..fc45318 100644 --- a/xen/drivers/passthrough/arm/iommu.c +++ b/xen/drivers/passthrough/arm/iommu.c @@ -134,6 +134,13 @@ void arch_iommu_domain_destroy(struct domain *d) =20 void __hwdom_init arch_iommu_hwdom_init(struct domain *d) { + /* Set to false options not supported on ARM. */ + if ( iommu_hwdom_inclusive ) + printk(XENLOG_WARNING "map-inclusive dom0-iommu option is not supp= orted on ARM\n"); + iommu_hwdom_inclusive =3D false; + if ( iommu_hwdom_reserved =3D=3D 1 ) + printk(XENLOG_WARNING "map-reserved dom0-iommu option is not suppo= rted on ARM\n"); + iommu_hwdom_reserved =3D 0; } =20 /* diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthr= ough/arm/ipmmu-vmsa.c index 1224ea4..64d8ddc 100644 --- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c +++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c @@ -1325,14 +1325,6 @@ static int ipmmu_iommu_domain_init(struct domain *d) =20 static void __hwdom_init ipmmu_iommu_hwdom_init(struct domain *d) { - /* Set to false options not supported on ARM. */ - if ( iommu_hwdom_inclusive ) - printk(XENLOG_WARNING "ipmmu: map-inclusive dom0-iommu option is n= ot supported on ARM\n"); - iommu_hwdom_inclusive =3D false; - if ( iommu_hwdom_reserved =3D=3D 1 ) - printk(XENLOG_WARNING "ipmmu: map-reserved dom0-iommu option is no= t supported on ARM\n"); - iommu_hwdom_reserved =3D 0; - arch_iommu_hwdom_init(d); } =20 diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthroug= h/arm/smmu-v3.c index d115df7..ca8b5c7 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -3404,16 +3404,6 @@ static int arm_smmu_iommu_xen_domain_init(struct dom= ain *d) =20 static void __hwdom_init arm_smmu_iommu_hwdom_init(struct domain *d) { - /* Set to false options not supported on ARM. */ - if (iommu_hwdom_inclusive) - printk(XENLOG_WARNING - "map-inclusive dom0-iommu option is not supported on ARM\n"); - iommu_hwdom_inclusive =3D false; - if (iommu_hwdom_reserved =3D=3D 1) - printk(XENLOG_WARNING - "map-reserved dom0-iommu option is not supported on ARM\n"); - iommu_hwdom_reserved =3D 0; - arch_iommu_hwdom_init(d); } =20 diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index c9dfc4c..ec18df7 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2851,16 +2851,6 @@ static int arm_smmu_iommu_domain_init(struct domain = *d) =20 static void __hwdom_init arm_smmu_iommu_hwdom_init(struct domain *d) { - /* Set to false options not supported on ARM. */ - if ( iommu_hwdom_inclusive ) - printk(XENLOG_WARNING - "map-inclusive dom0-iommu option is not supported on ARM\n"); - iommu_hwdom_inclusive =3D false; - if ( iommu_hwdom_reserved =3D=3D 1 ) - printk(XENLOG_WARNING - "map-reserved dom0-iommu option is not supported on ARM\n"); - iommu_hwdom_reserved =3D 0; - arch_iommu_hwdom_init(d); } =20 --=20 2.7.4