From nobody Sun Feb 8 22:22:12 2026 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=1638035560; cv=none; d=zohomail.com; s=zohoarc; b=TeuSRbs13LatojIjn4cCa0aaMjXBLQW2vvnMpPG5wYTMn5ACkBMY/XLQUfyY6NzDAYEEaW+rhvk7ZCQKsYuxuNuh8FN9ImE4sSUpmlukXsEKHFJyYzNO94rA61We/sEfv3gDTvFq/mYXuZyXH6OA2gXnw2ViZuRXnftY+OBFxtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638035560; 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=I496Z+swiWyAchqbkA9TA+qXRaefRbc6db3siiLMLlI=; b=Pj7o3v1VNxGtt8/7LN+YiF/xnmedqNwNCqBNA35ZcMpFm/lPnpa3idkpOp5AIM/ugjjXdvB9VPtdUuJBjWMGDzCvZdbQnxhQaOQPDIYT03WN9n7xO5AZplmZ+cgDgmxndNNPI4LH3l3Sk6s7wv4ETaJ7r4GQyMayYjAEzb3Tsq8= 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 1638035560012764.7148808026129; Sat, 27 Nov 2021 09:52:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.234019.406195 (Exim 4.92) (envelope-from ) id 1mr1ri-0004gx-F6; Sat, 27 Nov 2021 17:51:58 +0000 Received: by outflank-mailman (output) from mailman id 234019.406195; Sat, 27 Nov 2021 17:51:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mr1ri-0004cq-42; Sat, 27 Nov 2021 17:51:58 +0000 Received: by outflank-mailman (input) for mailman id 234019; Sat, 27 Nov 2021 17:51:56 +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 1mr1rg-0004Ig-76 for xen-devel@lists.xenproject.org; Sat, 27 Nov 2021 17:51:56 +0000 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [2a00:1450:4864:20::22a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b4aae86a-4faa-11ec-b941-1df2895da90e; Sat, 27 Nov 2021 18:51:54 +0100 (CET) Received: by mail-lj1-x22a.google.com with SMTP id k23so25480764lje.1 for ; Sat, 27 Nov 2021 09:51:54 -0800 (PST) Received: from otyshchenko.router ([212.22.223.21]) by smtp.gmail.com with ESMTPSA id f18sm827075ljc.104.2021.11.27.09.51.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Nov 2021 09:51:52 -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: b4aae86a-4faa-11ec-b941-1df2895da90e 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=I496Z+swiWyAchqbkA9TA+qXRaefRbc6db3siiLMLlI=; b=ab2NL+08Ekqzqf/v9FO9StivTv/vi/Xk9zCd6Ja59vmCjRrhLwCGPvVhDYzk16riJM XAKyNIoaus6fnFuPkL2CE06ST3OkI/bn4L2RNH/DqlD6A+K3bQ9deBeDNzeLjkDQ+Xf1 dqpek9pUF6Rrvno17DsFivKeleYFoYyQugd1EUNXqUrL8weR+tJ1JLFVgV2/b434AcPu VS5OUVyfUEQ0W0N88/caso1XhyyEydcQICUEtghNVAUYRxAnTbuZx3y2MuReI6b+sd7T dzJLwJjEX+obkspGYR5GUrmLmNt1lJuicvmgVV0yNrLRwJyn+yiLJ2XFZOJ6i6OYGngC Z/rQ== 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=I496Z+swiWyAchqbkA9TA+qXRaefRbc6db3siiLMLlI=; b=b8VpjUknwvekozD/NS+uxEsWnuD+3X1ZfVPRfJKZMRQVgMeDBu5Qu+hSLao7jSW3B8 7op/3jIGrd/YaL/yUuPYHXQtyVJy13VVVP9F+imWkQaWPB56zmLZEgyLxm+HDQSnX8+l 6TyQ+dFm6vszp649fscGbWthNIBYbR2K2CBeq8KTCEusp+vUM7WVmm7LXWBD2mAq3bB/ mfFY4Kg5TYa1TOrcdnHQEyG3UopYk6Ot2OLgVkZReOEj2lKg1RmHGKwxVvanMEJKCHdc opQRcLLPdqe4y8sFkLIg/lRGdhw+LmenaQ+FojL1fIoF1K1X2xISRauGYNPf7Z4ISCFs S6+A== X-Gm-Message-State: AOAM530xOLrpNPlJPznlTSwxfkWIqHblJWZ92rdKjYy53YxJRrIYUZzr 3JMZRyfVLynVMtVBxUcWxaIXhJZxx/8= X-Google-Smtp-Source: ABdhPJx9ZItP/jmf1Mc3AFgG0Q7hrJ+0biPwpDlU/DbtkxUet5+vtuy5UDixp9AFkPzx+JPv2msi/A== X-Received: by 2002:a05:651c:106b:: with SMTP id y11mr38555280ljm.504.1638035513198; Sat, 27 Nov 2021 09:51:53 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Yoshihiro Shimoda Subject: [PATCH 02/10] iommu/ipmmu-vmsa: Add helper functions for MMU "context" registers Date: Sat, 27 Nov 2021 19:51:37 +0200 Message-Id: <1638035505-16931-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1638035505-16931-1-git-send-email-olekstysh@gmail.com> References: <1638035505-16931-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: 1638035562191100005 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 --- 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