Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp344512rwb; Wed, 21 Sep 2022 23:44:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DKLYdoptjgl5HlXAaCkqgRPlRxkj25gc59Wb1+umTi0MlSjAew20J5ehsBygS2hj1m5GN X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr1743124edb.410.1663829048668; Wed, 21 Sep 2022 23:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663829048; cv=none; d=google.com; s=arc-20160816; b=nIuANI69Itry769kbDfiP7xSgr61C8mdTr6PV9wKH7LBUKopR/tGyfJGTSx898AAtQ YF8eP9dUosItRzQaSFTeRylkRBZyX0oyi7vdJITBYNT+7YNLvWgT1jXbFdZi7lSunVif KJMcSeSN3C5NWolBCvCx8M1H9Mm3HH1LUL0YSkIBoKSif0lDjXxQID0U0Lr1uZmrCULx jpnbcyTP0iFSgAeKDPjbZim5okvFDmf7xkFw3rCccMpUZVyGI4ea8L9TilmG9JBT3x3Q vhdy03QK+13YhpPu7RY/ibjW24fqnPCCXrhkWPfd1+tg5zHga/QS4t/MWG0UYs8brRPi US3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=pc9XPISpbSGrSKClTsjUCQ3s2OvkC6s9yKH7w3Lu38w=; b=yUVkZQ7u4Fw26GPVJ9oabQMJ4Cnl6E9hctSq3VJ6pj3GdM2xOPJs+ZfF37O9lrCnq9 afwj4JKWbDiDQRDPhZe/v8A7eHllQ/ZREFYh2Q8FCy99N/9nYZ1LBjXz1tZ/URVoKYFG JvzpShvVdeknOhnfE0xmdsdzqe1kX2EVYW9QM3zz3o3vQzhPXxDuXOaRfvhh9VLK37tc LhFNGUJe7xBzi/1UwMRb5nw3cCqPpZ/fU6Lip1u6g34M/H7aRLLS1uew0VxF0O4Vy2zm wZwwlCS7csD6QvRMZz9+l4/g40yITV68hm0HGUfisMS0aDKMjFgVkLe4u43cQwUxH7mf zxgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=miw7MxLG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="guIp/zmw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg14-20020a170907320e00b0077e29d27c39si6746124ejb.5.2022.09.21.23.43.40; Wed, 21 Sep 2022 23:44:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=miw7MxLG; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="guIp/zmw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbiIVGay (ORCPT + 99 others); Thu, 22 Sep 2022 02:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiIVGav (ORCPT ); Thu, 22 Sep 2022 02:30:51 -0400 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D70B028D; Wed, 21 Sep 2022 23:30:51 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 3C5BD2B05A35; Thu, 22 Sep 2022 02:30:49 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 02:30:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1663828248; x=1663831848; bh=pc9XPISpbS GrSKClTsjUCQ3s2OvkC6s9yKH7w3Lu38w=; b=miw7MxLGEJQDH02KamYjGaBbiA emyhzmC2EjDpet3ByxNekE7xindVb/WHDb3wTpbOC9YIZR7qEarMip0ihFkqsWNU 8HSI7RyowUNdY9FsYjflIHm9DkmYuY/BK/fHDxkisX/5iBedQh3en2LmJl2WUY5f U+c7Z6A2DhcC5OJ9/EP+Xh/Pm3/Sd6x2x6/tjzlPWR1CAb/DyhUaKYnGx5A0N5LD NvH9Z+TREmWr3XKKM8SHxd50nGe++IEy/zDh41rK5HhuTAFDo5P+ZMm6KhGkVhOD +7rlumViEP5y/M4IbNs9nppV1sc2UyFHRs7PLXswCr1vsYlvn1aXzCmWplJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1663828248; x=1663831848; bh=pc9XPISpbSGrSKClTsjUCQ3s2Ovk C6s9yKH7w3Lu38w=; b=guIp/zmwVEwZGVF57nii8FIBbPPPFdH0hWSewC8RF/GD CfBFXRipj5CPq+WVz7t/UNjtpHKOExLG30qkdYRjV02SW43mlzZIEbvPOscHjVzt XXIYsiNQgMjk1yTf5WNfwH5Zqqewa2LbK1JJKIenSG+A1l3ARsFr5AViqPlmJg77 XkGoaxF4MhDOxHW3WZiaPQCiBapN0vKkcR5fnkRxDzdNnIvFEKCxrT8NEXRJiWVe niHVCMyuV0xwkBaWwND+hrc1rOQV3LD6SYhUQoVlX4WSZFw2pauqMqho8EVpW7xX 6BMGD5rDz9w9ERVZpZeGDigIU46MeZq/tEu9Sjfi/w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefvddguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedt keetffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C0B47B60086; Thu, 22 Sep 2022 02:30:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-935-ge4ccd4c47b-fm-20220914.001-ge4ccd4c4 Mime-Version: 1.0 Message-Id: <0603b2a5-6253-4c4b-8b30-aa0253ed0480@www.fastmail.com> In-Reply-To: <45d2e6c2-3b4b-5720-0431-002c74b1f9cc@arm.com> References: <45d2e6c2-3b4b-5720-0431-002c74b1f9cc@arm.com> Date: Thu, 22 Sep 2022 08:30:26 +0200 From: "Arnd Bergmann" To: "Robin Murphy" , "Geert Uytterhoeven" , "Rob Herring" , "Krzysztof Kozlowski" Cc: "Andre Przywara" , "Conor.Dooley" , "Samuel Holland" , "Biju Das" , "Chris Paterson" , "Atish Patra" , "Lad, Prabhakar" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-riscv , "Linux ARM" , Linux-Renesas , "Linux Kernel Mailing List" Subject: Re: Similar SoCs with different CPUs and interrupt bindings Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 21, 2022, at 11:20 AM, Robin Murphy wrote: > On 2022-09-21 08:46, Geert Uytterhoeven wrote: >> Hi Rob, Krzysztof, >> >> This is a topic that came up at the RISC-V BoF at Plumbers, and it was >> suggested to bring it up with you. >> >> The same SoC may be available with either RISC-V or other (e.g. ARM) CPU >> cores (an example of this are the Renesas RZ/Five and RZ/G2UL SoCs). >> To avoid duplication, we would like to have: >> - .dtsi includes .dtsi, >> - .dtsi includes .dtsi. >> >> Unfortunately RISC-V and ARM typically use different types of interrupt >> controllers, using different bindings (e.g. 2-cell vs. 3-cell), and >> possibly using different interrupt numbers. Hence the interrupt-parent >> and interrupts{-extended} properties should be different, too. >> >> Possible solutions[1]: >> 1. interrupt-map >> >> 2. Use a SOC_PERIPHERAL_IRQ() macro in interrupts properties in >> .dtsi, with >> - #define SOC_PERIPHERAL_IRQ(nr, na) nr // RISC-V >> - #define SOC_PERIPHERAL_IRQ(nr, na) GIC_SPI na // ARM >> Note that the cpp/dtc combo does not support arithmetic, so even >> the simple case where nr = 32 + na cannot be simplified. >> >> 3. Wrap inside RISCV() and ARM() macros, e.g.: >> >> RISCV(interrupts = <412 IRQ_TYPE_LEVEL_HIGH>;) >> ARM(interrupts = ;) >> >> Cfr. ARM() and THUMB() in arch/arm/include/asm/unified.h, as used >> to express the same operation using plain ARM or ARM Thumb >> instructions. > > 4. Put all the "interrupts" properties in the SoC-specific DTSI at the > same level as the interrupt controller to which they correspond. Works > out of the box with no horrible mystery macros, and is really no more or > less error-prone than any other approach. Yes, it means replicating a > bit of structure and/or having labels for everything (many of which may > be wanted anyway), but that's not necessarily a bad thing for > readability anyway. Hierarchical definitions are standard FDT practice > and should be well understood, so this is arguably the simplest and > least surprising approach :) FWIW, approaches 1, 2 and 4 all seem reasonable to me, but I don't like number 3 if this is only about the IRQ definitions. It sounds like we're already converging on #2, so just one more idea from me: we could fold the IRQ type into the macro, and make it just take a single argument for extra flexibility: #define SOC_PERIPHERAL_IRQ_LEVEL_HIGH(nr) \ GIC_SPI (nr + offset) IRQ_TYPE_LEVEL_HIGH If all the irqs on the chip have the same type, the name can be shorter of course. Either way, some variation of the macro sounds like a good enough approach to me. Arnd