From nobody Mon Feb 9 06:49:00 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=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 --- 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