Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp528507lqr; Wed, 5 Jun 2024 12:58:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1l4T3u9EQBEAcolA4D+35IqT5HVFraslUIMwygxFyPsxnZlLjMpL76RTAuLBmuxvFy+F9yuVDiCbXr4E10e+cf8551nnspMLjspfbPg== X-Google-Smtp-Source: AGHT+IHvID+30VSDlGu6sCEC0RKrcDKqRF0DcVEHizfBoVAa88FK8QNqqPhLkl8I9yOpSv5spC3M X-Received: by 2002:a05:6902:248e:b0:df7:9773:4571 with SMTP id 3f1490d57ef6-dfacab2c213mr3940946276.11.1717617501795; Wed, 05 Jun 2024 12:58:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717617501; cv=pass; d=google.com; s=arc-20160816; b=eUfIulZ8vnsAxbuN93Nd9iBclaLXryY+s3QLp9mJONjFXvTfaeQwfscRz597NXaULe nbQS7OFssVF+UduHj5ZteuWJlwP3ZmoBz9ZvHSbE1w2pLoMFzWnb6k/wliqsz8/Dneds o6vY5Lr0+To0rh1f3Fyt7yLgxvtx6RLUfsie3OH2zT3GGxJrjSgE3hCAqFoP6fz/xiMo 5xytvaUO+/EgUN1sRq1EQMCp3/oMp0aTOVBfuUFei4rwl546l4e5U7sJPqvALimkdhdq ssBJV2qX2RXpmgzhqVTuYmREvoNNIXhdS5jJb9JdVUNJEnaCK8dEaDomwabFjD6imXy+ tDnA== 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=I3OdnqJm+rXYztcxY0Ww1DG6j2yyBo/otAAAbxVMihM=; fh=MiOajZ8Qb6PdfuvYHIsnd/dMkqqNkH55abELQ+yCdIU=; b=0EaHKMcz94AdHw67NlcRpDiaV4dE1+iO6YCd1EtDrFQCdijf6TraqXC6AmLhvJb2Wd ZGuASUuDkJcpPtZw9GqyKEApcWTvVR0czoXkRPRJfjjbEbJ4aG+HR8dXUXYjCAeIkrtJ AMe/O1myY9wWw8lvzUshjr2fT6A5IyR1CpnilGEllVAzAZkG63IYl39n/spXCC+emdub gGjGC4FE7uALlTQUkPuBWYuVgS2GH0tnupxAh2Vy7dUn2JJ3yJQjJYr/ZbDwXuDqouGB FoQgv9gaueYiEOv8/MoQGxfrUqXpdtdu5AEuBiuSCg/+vnJAWKp/5Y1ww3poRrgIk+4F WyXA==; 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="wYoLKR9/"; 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-203132-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203132-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b401319si6207756d6.309.2024.06.05.12.58.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 12:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203132-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="wYoLKR9/"; 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-203132-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203132-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7329D1C20FC1 for ; Wed, 5 Jun 2024 19:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95F8D15534D; Wed, 5 Jun 2024 19:58:01 +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="wYoLKR9/" Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 E1924155355 for ; Wed, 5 Jun 2024 19:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717617480; cv=none; b=MOLW+k/o0rMmsYpzKiVroRi3/CTyeH7tq7zQc9mpozGaNu146phpFfMB0dNPXtOHPlcOwkqs16sQiosI2NKdlBtao2zt20F2nlrunlxwn41ujm9A+4BudEnH/13rpLX7gQ5EZn2JzyDn9iMr5NJFbP3AOwtfRPvFp0BVX4u9Yl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717617480; c=relaxed/simple; bh=u/8EhdvDift/4PjJIMaVhEkEwfsBYE1N//dIYQ3iqKE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CrgLiHHUNUdJ1YQ9rHEwh7Dqfy2l+7s6D7a+T1FMGxMBlDecurRoKudZlrZlvijXFfM3MY+iwfhNRt2na9XJx3M4FYvxdYihLsMSetX5siB+wi++Lcd0rmcSVxX8oAfBtiX/hz2eL40Q7DCTHeAiNJi6m5EmSY9vQ1UWgO49NTM= 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=wYoLKR9/; arc=none smtp.client-ip=209.85.210.170 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-pf1-f170.google.com with SMTP id d2e1a72fcca58-70255d5ddc7so153983b3a.3 for ; Wed, 05 Jun 2024 12:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1717617478; x=1718222278; 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=I3OdnqJm+rXYztcxY0Ww1DG6j2yyBo/otAAAbxVMihM=; b=wYoLKR9/utkMExtRMZVUiNE5ZIwiWXeqMuBPRV3s22UGi5+gg/lO1FuL+r+PQc2ixp P4oxxtlGA/undhIF90U2drLAXbkK83s6WEvpSBYlrUZxZuYsvECKlWO3Fu/OKlRtgQXu HuLDj2WN2uBjLuAZnEbbIWOc4fH6XcIYKccXaKFF+ehZzXBnOLgqoKV30UFLOIiL/Sla md/0oxkpboNRYVMe2y7db0lzdV4/PH+E2SZgdr/zQmol5ZgKkS6CXiXvu5lR2xbDAYNe QTS5XyYHYHwsMHF+29/JgjUUUFvF/XQdAO8r/K7ch5QCpN0DRBget9PkkRxHkdzEmNxR FQGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717617478; x=1718222278; 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=I3OdnqJm+rXYztcxY0Ww1DG6j2yyBo/otAAAbxVMihM=; b=HctpornXRJp1Jz2XCbcfpedG+kp26hGf7buQDGoPlT1PRaBJ1wj3bG53/PH0CAsaxn PcjVZy4CohzcqYvI32E0fQ5Kt074idfHar3Www5u4t1+rmUTj8RDgKXNqN+zoQlPmaSk BUO/TCNIBJl4AU0+DQGgj6Wu125BK0avQb5BhrrJyKmUWEcEwgsiMhPlIwrjRuA/kKqN mJUH8vT+2Q8zf4S/RGBD2ogIHOYu5l1X6SJ/WW8R8h7sdnkj9AsJBD/6NOq6Ilf9NnXz 5nKH0Dw/kGCzOY7YPitdgP27/8DPZqXZ6QmzsUUcVjENQujcWGsvqYvxQfbcHaJ0lRPj BsHw== X-Forwarded-Encrypted: i=1; AJvYcCWdjP6qWu2E3v56svHj3NP6p1bpBGw2NnYtRCLqPKKca+pB+NbM67sBknFIxzErYKbjr56hqyMc3w3raSgbqrzW28ppRfE21WwohOgD X-Gm-Message-State: AOJu0YylaUq0uuTNyurSh9em/Kdc03Dq/gINBQV0ufv3AHK7yovCV9rq S76e5gLNYMIjvkh10SdGm4Pe602f7gZYKYGgG2c0fV0TEs0qvT6qB8wzK8rPZLw= X-Received: by 2002:a05:6a00:301b:b0:702:4b69:5bca with SMTP id d2e1a72fcca58-703e597aa87mr3589048b3a.18.1717617478132; Wed, 05 Jun 2024 12:57:58 -0700 (PDT) Received: from tjeznach.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70244900ee9sm8664209b3a.124.2024.06.05.12.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 12:57:57 -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 , Conor Dooley , Rob Herring Subject: [PATCH v7 1/7] dt-bindings: iommu: riscv: Add bindings for RISC-V IOMMU Date: Wed, 5 Jun 2024 12:57:43 -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 Reviewed-by: Conor Dooley Reviewed-by: Rob Herring (Arm) Signed-off-by: Tomasz Jeznach --- .../bindings/iommu/riscv,iommu.yaml | 147 ++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 154 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..5d015eeb06d0 --- /dev/null +++ b/Documentation/devicetree/bindings/iommu/riscv,iommu.yaml @@ -0,0 +1,147 @@ +# 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,riscv-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. + + '#iommu-cells': + const: 1 + description: + 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,riscv-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,riscv-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,riscv-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 8754ac2c259d..a20748224545 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19264,6 +19264,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