From nobody Sat Oct 4 12:48:59 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 246A2270EC1 for ; Mon, 18 Aug 2025 04:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755493112; cv=none; b=qJw6UHQIQFx0ECsP5/TBTzMk2bdhzkN4LvsI+J///RPNmhDllZWQBSXQgbob/5q2qiguDlh5kAgW5O3pO+G4U0XOr7UUqsRXlmr5I+WHdv/Y3uhz3l7FTZiWAjIXw+avs36qw70x3xIiqWbu4RorUYwt88b4Db1ZhanebqeelsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755493112; c=relaxed/simple; bh=wOw6JV14X14ffQE6SMj0By+YxAglNmvsry080ZEuXl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zljhn91+UtnIBuIuJPIxs9YaDIvkaScrdn07/xnmrdC/7nwqA56e1H7seYPtsUKuiWIrdpt4R9r16AonhOv9/i1+SjngnaC9b5Z8uBP/qFCElIfa8jrcOcjJKTtNnM5uCflWTR9h/aYsgJuMfzqx6FZ+OvBx1rtFPFLq8kThlMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Ju2/2KRS; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Ju2/2KRS" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-76e2eb9ae80so2714601b3a.3 for ; Sun, 17 Aug 2025 21:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1755493110; x=1756097910; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NTa6xqW99KKtlVHpIkJtLfUt2l8dIJi8RFcjVe+ZZ0s=; b=Ju2/2KRSAnlsMQsTEpOG97jDqzQc6JWLd1kPDt14HHF+hoT/d8tkfqD7dl2p4wYus5 ObmgXq6ZImKnHvrl4ou9DWqQjb9s5tgeQ9aJZRfPEbMJ26HLMJmcTXbmpq78xnheHhAH wAVXcmXAW+6pLjDmsfmsQZqWAl/S9zSrtfKI146LVJt9S5zkb/ZU2zrd3kOXhDCW1y0Z pce/oeE24sV64ehI8zmDP2q/K6kgI1SYCirXlFBVn8fmxPyaK7gYd1gexocT43F9PZbc LYMLsvLC38rqBFal9+DPOhA68U98iNtGRIXb8RnfOS/tyrlRs9NfU7JQFtpJbMQIRVDE CxNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755493110; x=1756097910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NTa6xqW99KKtlVHpIkJtLfUt2l8dIJi8RFcjVe+ZZ0s=; b=uthOcM3lm6mp/EctGIu6QMfIU+D3+4z+hRosS7waZ0BaCGjsGXRuUk303QOc1ciqmh DUva38mgU1XfUNmQR0VuB83EhCluvfN9sXClY4m2PxqFFb+tGGjk/DRdh/03tiyFmYGO BDLBFu9ZitUpIZxT3sZiApiYtjjawQjh3xhg+w7+zmWLYhbHf4NLHUeN5EZHRebDH/lh sShrQF5cNZkmehs+Jw3w3vhcfRMM/I5rj2Iir4JGsa5S61gR4vDTP6Qb/HCK2ImWanon G75TzGyOL8mhicPL0VimYVa4BezyBx1zcNSVTp+ps9coqVLHqrO+mX1oe3snsf/gBojL 2m9w== X-Gm-Message-State: AOJu0YxT94/sppUOUvvjoiliqrxBz17VYgP8lTSW3qW/+mOL1nSxcsg/ ZvQe/V+FUSdYIAChikS6W785QXC7Qfr3egajuKn3IIbyN8roBeB0Tvt0hNHITPGQoe2iJxz61h3 dbGLxw/8= X-Gm-Gg: ASbGncsElE58681aPu8ijCp7UxffMEXAH6KvTPdGma11RVxXYCAW2OXxMowne2OlcMV 19+VeBtsswo3Fr8IQI5HHIXFUKN9fpdZNEZIp7AAjd1N6lND5iux2Hqx6njYSuQmqlniAJqXv5Z qLFA1P4LiTRaz9hJMB6WZ8dGTt5NeFWekSKWoOq1G2XElGRijBvw10sPeF2DFIfO//Dc0yzRmIW P91+VDQ8QDEnNWVafO3r//S94sYD6rYmjzKQ2Co5wQW6UaIxJPG6rJZLFFR+HkH5pAvM8+IXLPM RikbJm86WNv4/rXWB+ZcRKngF50uFqbWgt4zDrDSzU3/5smZg5mtMDfCTjZc6NeOa/QLQMmDK57 Jcol4K/eQ6DT373pV6YfCJAnVGswF77Rjlbj8FYyo X-Google-Smtp-Source: AGHT+IGBQAQ9QouKj4M7l+2CqoGFg6HgZE82/OKBnQvuZfjFIYQJQta7bAXmxzrYRho/3qFml+C5sQ== X-Received: by 2002:a05:6a20:3ca1:b0:240:265f:4eb0 with SMTP id adf61e73a8af0-240d300688bmr17338262637.4.1755493109991; Sun, 17 Aug 2025 21:58:29 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.199.3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76e4528c264sm6124047b3a.43.2025.08.17.21.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Aug 2025 21:58:29 -0700 (PDT) From: Sunil V L To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux.dev Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , "Rafael J . Wysocki" , Len Brown , Tomasz Jeznach , Joerg Roedel , Will Deacon , Robin Murphy , Sunil V L , Andrew Jones Subject: [PATCH v6 3/3] iommu/riscv: Add ACPI support Date: Mon, 18 Aug 2025 10:28:07 +0530 Message-ID: <20250818045807.763922-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250818045807.763922-1-sunilvl@ventanamicro.com> References: <20250818045807.763922-1-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V IO Mapping Table (RIMT) provides the information about the IOMMU to the OS in ACPI. Add support for ACPI in RISC-V IOMMU drivers by using RIMT data. The changes at high level are, a) Register the IOMMU with RIMT data structures. b) Enable probing of platform IOMMU in ACPI way using the ACPIID defined for the RISC-V IOMMU in the BRS spec [1]. Configure the MSI domain if the platform IOMMU uses MSIs. [1] - https://github.com/riscv-non-isa/riscv-brs/blob/main/acpi-id.adoc Signed-off-by: Sunil V L Reviewed-by: Andrew Jones Acked-by: Will Deacon --- drivers/iommu/riscv/iommu-platform.c | 17 ++++++++++++++++- drivers/iommu/riscv/iommu.c | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/riscv/iommu-platform.c b/drivers/iommu/riscv/iom= mu-platform.c index 725e919b97ef..83a28c83f991 100644 --- a/drivers/iommu/riscv/iommu-platform.c +++ b/drivers/iommu/riscv/iommu-platform.c @@ -10,6 +10,8 @@ * Tomasz Jeznach */ =20 +#include +#include #include #include #include @@ -46,6 +48,7 @@ static int riscv_iommu_platform_probe(struct platform_dev= ice *pdev) enum riscv_iommu_igs_settings igs; struct device *dev =3D &pdev->dev; struct riscv_iommu_device *iommu =3D NULL; + struct irq_domain *msi_domain; struct resource *res =3D NULL; int vec, ret; =20 @@ -76,8 +79,13 @@ static int riscv_iommu_platform_probe(struct platform_de= vice *pdev) switch (igs) { case RISCV_IOMMU_CAPABILITIES_IGS_BOTH: case RISCV_IOMMU_CAPABILITIES_IGS_MSI: - if (is_of_node(dev->fwnode)) + if (is_of_node(dev_fwnode(dev))) { of_msi_configure(dev, to_of_node(dev->fwnode)); + } else { + msi_domain =3D irq_find_matching_fwnode(imsic_acpi_get_fwnode(dev), + DOMAIN_BUS_PLATFORM_MSI); + dev_set_msi_domain(dev, msi_domain); + } =20 if (!dev_get_msi_domain(dev)) { dev_warn(dev, "failed to find an MSI domain\n"); @@ -150,6 +158,12 @@ static const struct of_device_id riscv_iommu_of_match[= ] =3D { {}, }; =20 +static const struct acpi_device_id riscv_iommu_acpi_match[] =3D { + { "RSCV0004", 0 }, + {} +}; +MODULE_DEVICE_TABLE(acpi, riscv_iommu_acpi_match); + static struct platform_driver riscv_iommu_platform_driver =3D { .probe =3D riscv_iommu_platform_probe, .remove =3D riscv_iommu_platform_remove, @@ -158,6 +172,7 @@ static struct platform_driver riscv_iommu_platform_driv= er =3D { .name =3D "riscv,iommu", .of_match_table =3D riscv_iommu_of_match, .suppress_bind_attrs =3D true, + .acpi_match_table =3D riscv_iommu_acpi_match, }, }; =20 diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c index 2d0d31ba2886..7d9370aa58f0 100644 --- a/drivers/iommu/riscv/iommu.c +++ b/drivers/iommu/riscv/iommu.c @@ -12,6 +12,8 @@ =20 #define pr_fmt(fmt) "riscv-iommu: " fmt =20 +#include +#include #include #include #include @@ -1650,6 +1652,14 @@ int riscv_iommu_init(struct riscv_iommu_device *iomm= u) goto err_iodir_off; } =20 + if (!acpi_disabled) { + rc =3D rimt_iommu_register(iommu->dev); + if (rc) { + dev_err_probe(iommu->dev, rc, "cannot register iommu with RIMT\n"); + goto err_remove_sysfs; + } + } + rc =3D iommu_device_register(&iommu->iommu, &riscv_iommu_ops, iommu->dev); if (rc) { dev_err_probe(iommu->dev, rc, "cannot register iommu interface\n"); --=20 2.43.0