Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51088C4332F for ; Mon, 20 Dec 2021 21:16:42 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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: 8bit 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öderlund 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 --- 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/passthrough/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_domain *domain, ipmmu_ctx_write_root(domain, reg, data); } +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 */ /* 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 context * bank from being set. */ - imuctr = ipmmu_read(mmu, IMUCTR(utlb)); + imuctr = 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); return 0; } @@ -444,7 +467,7 @@ static void ipmmu_utlb_disable(struct ipmmu_vmsa_domain *domain, { struct ipmmu_vmsa_device *mmu = domain->mmu; - ipmmu_write(mmu, IMUCTR(utlb), 0); + ipmmu_imuctr_write(mmu, utlb, 0); } /* Domain/Context Management */ -- 2.7.4