Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp72380lqm; Tue, 30 Apr 2024 13:09:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmptnC1npBEd7hzXyv+yTb3zeo/66F/zo9KGxAOXiq9kUPn+/pVTaBktFblVQbKgXjgAqKQDoNBTGI80DgV7HSPZmi7zlKR5wGxaYNwA== X-Google-Smtp-Source: AGHT+IHNTl8KACjSzscGOJa2MkShrtCOMWEpzzyugaL0kNRr9jM2R4gIO/h7f/UrdP+3d94W3AOB X-Received: by 2002:a17:902:ee93:b0:1e5:47ac:e760 with SMTP id a19-20020a170902ee9300b001e547ace760mr415455pld.29.1714507761763; Tue, 30 Apr 2024 13:09:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714507761; cv=pass; d=google.com; s=arc-20160816; b=qDIoomdLqXPPx2szHsQga8rjnjl/P8WABgaoirlmNX6mLpEG59zNN7I25075xbe3CT FG2Rzbem1x7xoyLIrinerRL5Ukqr/uoXzuBJLSw9uGytHWaDT5IReon8n9L5T3KlUcg2 76s30ALAhRh5O0lx9i5InzhQtBPiQk9QtV+oyXkoOPlIFcluUGoRIHHItdsXS84IY+Qn OzlfyQYEcQjqi29NBrdgsfNdfc3VjaZGL0iE6YAqg5rUzwv4cXsVGa3opRZ5/aX6kmUs n5+n53L8f6uaGUBBVBeGFGsIpW3ZOid0pdqJldQiMUgzoRR0YB9NAYG4xIJhSlJfPUTn ovLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=woNMMspCQ7rRLAuMwQ/hkraoq5PRvRPYoGmq6YIz3FM=; fh=j+LrrQHvWDhBTOFr7s85W/JDwv+ssRZTmfHI8CWLGbU=; b=OeqTRLvJxhvrbisRGmC8NIDiyHTuEWHYcE2j/VMJxTwMRXYVaAbF5/V8O1AI9FOfh2 pbdXaAuJ5XWuUJsjOoqLV8raN7v06Aoecapcjd0qZiNdwz5+W15sijedqKWFyYeacsWZ KeLTy+lnN7PZNYzaZtgUo8TeRha3QAYX8yN/LeQ1RfMEoQklvgG2DsUp4v2UibGp8lqj J6HVuxDHLMYMA/Spx1QE9iA5ORookgtatdvtppatImgP+SpVesLSWGzh9mxuvwFJBKNg B/y3MexJXXr9f00J/KSdo+yuNh83Y62SCtUi0ge5DVRYDyWUQxhwhjnSxCMkphA4ALq7 l+VA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=OUoKHpna; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-164680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164680-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e11-20020a170902784b00b001e41c8728f2si1982122pln.1.2024.04.30.13.09.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 13:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=OUoKHpna; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-164680-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164680-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 16A33B23B6E for ; Tue, 30 Apr 2024 20:02:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 796991A0AF0; Tue, 30 Apr 2024 20:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="OUoKHpna" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 EC81E199EA9 for ; Tue, 30 Apr 2024 20:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714507362; cv=none; b=Ve9xY7t50aeMf0Lvn/DuDc0ppK7W3wNrBxJg0xzrYKxBk5jLbm4mjd1B4DhNj7RQLjBnXTOeEth4px3j67XblU8QIAU5i0UNjJ9OfsOtP/yLojKoMRv5RA9r5zJnkHv/fwG+i1R7NdkVwJnvGZFY43IukarPi9HmhZmoJgSe5ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714507362; c=relaxed/simple; bh=1EDa52wR7vW6R1hrhW9vs4jIkIJbYACFzLKkb2vfpyY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fqugUAdcbeW3Kg1JkwBlmtBcsf6ouR3ozJioki3h/pnhbGq9Csqn7QiYYOwMg6Hxy5XvbChedHVGAma3CfzgJyeRGRxlVaXYMiX3zMvtKl1ZyIy3ru0XM9+nbg516BVkGjKEgt128oIySpTssmp0L1e4XO0PEKhvuPkTkDdZFWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=OUoKHpna; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1e9320c2ef6so44646305ad.2 for ; Tue, 30 Apr 2024 13:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714507360; x=1715112160; 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=woNMMspCQ7rRLAuMwQ/hkraoq5PRvRPYoGmq6YIz3FM=; b=OUoKHpnahFejwpBFNfd3Ju0r5e1e+P/LGQBOoTytcuEyjxCwaXteO4sfRaEthOh5WS dRqlUlGeUg+Q2hoiP3ai+C+mFiRxMQZFSvOd0jmuM+nsDFAd7p3wTQsI4kQzVoEJ4Q3v QPXgkX9YZdzJz2/adPmd5ngg8LxyfoaHUlr9bOCaKyN9BWRzAtQZFX3WXdAXaQChGJNd b/gD2DZ/l266Yol1Yc9Ukam+MGKqCcof7YcyTxRmsRSl/flhkGOZfGWGVlW482hkw4Oy hjMlopoRgBW3iUnHYsOoyoixdml+WybRqAwOGkgBPt39HizmFZwpUtouKCxYbaVWdMQf m7pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714507360; x=1715112160; 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=woNMMspCQ7rRLAuMwQ/hkraoq5PRvRPYoGmq6YIz3FM=; b=tgwiVpNfbCYIk31OZ03u8OgAjUIO3+qidIn6sWu6Pdx3i05ljJS6U+AXN2zBbPIyqg 4OKZD3eYj34GxfHNftLXPLNOwHRRpHiZR1+4gBb7Mps4fDDuDoUPl7JBgoqvR0bgLcNN g4oZMlAqn+mX4Dlcjw7a5zMUo9idzhhMiwzxwtHEJs7Y9Xvrvk+56aqBh5y75WMmhe6v A8n+iIOwggGSkz6dPhwmVoZCMExVeLPM6rSHqvpkjByvc4yjz/KyL5Ab/Oo1hmyLoTVr GPxLUvISyb2pTXPTtj6byy/enTwXF7fBzyTrr5K3YuLWomuJA8Ce5b77H6sDNgfMaB2n p/ow== X-Forwarded-Encrypted: i=1; AJvYcCUrHXiLo6541f5PEpgDCBUOo+LiKsjr9v5NVPidYEGarlLtMvqfk1P2cs+O4EYoaRxhTE6ocRPgSArfjqW+bVL16B3BGzjQgh+7Xq4u X-Gm-Message-State: AOJu0Yx4if5563v6D9CsyTXessZfYil9FbZS8VJOtuRT12tl+dgNgl/k RN7RZAf3WZ4vHOnDz8dWTiO7z01KVj4+DQ1jOK/2qPLYy2cuRhGc+k3v/v28y4g= X-Received: by 2002:a17:903:2444:b0:1eb:3dad:aced with SMTP id l4-20020a170903244400b001eb3dadacedmr531681pls.11.1714507360233; Tue, 30 Apr 2024 13:02:40 -0700 (PDT) Received: from tjeznach.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id w19-20020a1709027b9300b001e435fa2521sm22809820pll.249.2024.04.30.13.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 13:02:39 -0700 (PDT) From: Tomasz Jeznach To: Joerg Roedel , Will Deacon , Robin Murphy , Paul Walmsley Cc: Palmer Dabbelt , Albert Ou , Anup Patel , Sunil V L , Nick Kossifidis , Sebastien Boeuf , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, iommu@lists.linux.dev, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com, Tomasz Jeznach Subject: [PATCH v3 1/7] dt-bindings: iommu: riscv: Add bindings for RISC-V IOMMU Date: Tue, 30 Apr 2024 13:01:51 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add bindings for the RISC-V IOMMU device drivers. Co-developed-by: Anup Patel Signed-off-by: Anup Patel Signed-off-by: Tomasz Jeznach --- .../bindings/iommu/riscv,iommu.yaml | 150 ++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 157 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/riscv,iommu.yaml diff --git a/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml new file mode 100644 index 000000000000..16817525e157 --- /dev/null +++ b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml @@ -0,0 +1,150 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iommu/riscv,iommu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V IOMMU Architecture Implementation + +maintainers: + - Tomasz Jeznach + +description: | + The RISC-V IOMMU provides memory address translation and isolation for + input and output devices, supporting per-device translation context, + shared process address spaces including the ATS and PRI components of + the PCIe specification, two stage address translation and MSI remapping. + It supports identical translation table format to the RISC-V address + translation tables with page level access and protection attributes. + Hardware uses in-memory command and fault reporting queues with wired + interrupt or MSI notifications. + + Visit https://github.com/riscv-non-isa/riscv-iommu for more details. + + For information on assigning RISC-V IOMMU to its peripheral devices, + see generic IOMMU bindings. + +properties: + # For PCIe IOMMU hardware compatible property should contain the vendor + # and device ID according to the PCI Bus Binding specification. + # Since PCI provides built-in identification methods, compatible is not + # actually required. For non-PCIe hardware implementations 'riscv,iommu' + # should be specified along with 'reg' property providing MMIO location. + compatible: + oneOf: + - items: + - enum: + - qemu,iommu + - const: riscv,iommu + - items: + - enum: + - pci1efd,edf1 + - const: riscv,pci-iommu + + reg: + maxItems: 1 + description: + For non-PCI devices this represents base address and size of for the + IOMMU memory mapped registers interface. + For PCI IOMMU hardware implementation this should represent an address + of the IOMMU, as defined in the PCI Bus Binding reference. The reg + property is a five-cell address encoded as (phys.hi phys.mid phys.lo + size.hi size.lo), where phys.hi should contain the device's BDF as + 0b00000000 bbbbbbbb dddddfff 00000000. The other cells should be zero. + + '#iommu-cells': + const: 1 + description: + Has to be one. The single cell describes the requester id emitted + by a master to the IOMMU. + + interrupts: + minItems: 1 + maxItems: 4 + description: + Wired interrupt vectors available for RISC-V IOMMU to notify the + RISC-V HARTS. The cause to interrupt vector is software defined + using IVEC IOMMU register. + + msi-parent: true + + power-domains: + maxItems: 1 + +required: + - compatible + - reg + - '#iommu-cells' + +additionalProperties: false + +examples: + - |+ + /* Example 1 (IOMMU device with wired interrupts) */ + #include + + iommu1: iommu@1bccd000 { + compatible = "qemu,iommu", "riscv,iommu"; + reg = <0x1bccd000 0x1000>; + interrupt-parent = <&aplic_smode>; + interrupts = <32 IRQ_TYPE_LEVEL_HIGH>, + <33 IRQ_TYPE_LEVEL_HIGH>, + <34 IRQ_TYPE_LEVEL_HIGH>, + <35 IRQ_TYPE_LEVEL_HIGH>; + #iommu-cells = <1>; + }; + + /* Device with two IOMMU device IDs, 0 and 7 */ + master1 { + iommus = <&iommu1 0>, <&iommu1 7>; + }; + + - |+ + /* Example 2 (IOMMU device with shared wired interrupt) */ + #include + + iommu2: iommu@1bccd000 { + compatible = "qemu,iommu", "riscv,iommu"; + reg = <0x1bccd000 0x1000>; + interrupt-parent = <&aplic_smode>; + interrupts = <32 IRQ_TYPE_LEVEL_HIGH>; + #iommu-cells = <1>; + }; + + - |+ + /* Example 3 (IOMMU device with MSIs) */ + iommu3: iommu@1bcdd000 { + compatible = "qemu,iommu", "riscv,iommu"; + reg = <0x1bccd000 0x1000>; + msi-parent = <&imsics_smode>; + #iommu-cells = <1>; + }; + + - |+ + /* Example 4 (IOMMU PCIe device with MSIs) */ + bus { + #address-cells = <2>; + #size-cells = <2>; + + pcie@30000000 { + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + reg = <0x0 0x30000000 0x0 0x1000000>; + ranges = <0x02000000 0x0 0x41000000 0x0 0x41000000 0x0 0x0f000000>; + + /* + * The IOMMU manages all functions in this PCI domain except + * itself. Omit BDF 00:01.0. + */ + iommu-map = <0x0 &iommu0 0x0 0x8 + 0x9 &iommu0 0x9 0xfff7>; + + /* The IOMMU programming interface uses slot 00:01.0 */ + iommu0: iommu@1,0 { + compatible = "pci1efd,edf1", "riscv,pci-iommu"; + reg = <0x800 0 0 0 0>; + #iommu-cells = <1>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index f6dc90559341..7fcf7c27ef6b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18958,6 +18958,13 @@ F: arch/riscv/ N: riscv K: riscv +RISC-V IOMMU +M: Tomasz Jeznach +L: iommu@lists.linux.dev +L: linux-riscv@lists.infradead.org +S: Maintained +F: Documentation/devicetree/bindings/iommu/riscv,iommu.yaml + RISC-V MICROCHIP FPGA SUPPORT M: Conor Dooley M: Daire McNamara -- 2.34.1