Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp890987rwi; Wed, 2 Nov 2022 20:45:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5a/GZ4a0m6sUZHURvPEoouX9RGafJ01xtojlSIkrlOnM6Amg5QXtajTGVKYnxKmNnx1YSC X-Received: by 2002:a05:6402:5291:b0:45c:3f6a:d4bc with SMTP id en17-20020a056402529100b0045c3f6ad4bcmr27932958edb.285.1667447113352; Wed, 02 Nov 2022 20:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667447113; cv=none; d=google.com; s=arc-20160816; b=CLyaXa8wPHqOuKzl8it4WzYxYS+H1K/QpvfCShF+lKcXCy6ETWPLVR8XfaIscsD7bs sVf4N5MlZwslo94ZUvmmLgL9fOLUBhZhhvZO867DFVlVZE1T9o9Qj8kc3ozO8rHeqTle nNAK8b0EsxgJRe8QAenSK2sG4bo9ODSJDcmdpzVDTf5lK6bk3ZU/euK+UPlsypgdFAHt VIuapRT4TwXLoXKmijHaKi7+3c5kaO7sOCzUhcG+lyN4zbQqlXgZ2SsL/hGrnHobAPga AX9WvNTSG7tweFxk6h1jkpqnMQa9MqLRcUk6uwKabafnJlusWwOG+4LPzEcYfm1wsqxK j97w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3mJ1M1GCa29hKoerTifDSh6zyzpsImb+52pEFvSJf6k=; b=t2gwp9O4q2+pKPjh7LhAq1oGhG88YFeqcYUaO4grT2mITQr1YJ5ZpTYOHRj3OhfxRW tmM4PC1+eIuGEYlPnoadK04wRj5LFthWdS+cLx+Yc/dSOxMwO+77raSSpLF0bEryDT1W mDTeLR8qaXyRDwJvRrHgPX/HvHOyBWxBPDhlzDr/SxwsBcgrECYNBzjrFvywPpYS10It 5n8rcjEtE+GpPZf6gU9jI9SXuDaLzPSMOTxJp9ke7GywNPg1gky+SlMwj9JbSUhmAh89 9TKuy8hQ4KkPiaL7rpLwwUEHwkvWI/LUG/tZk1IuZRGuHh2BO5L0fbLaspf7RLBINJA1 E2Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SqxPLb37; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a056402518b00b004630d0c280esi17080359edd.539.2022.11.02.20.44.49; Wed, 02 Nov 2022 20:45:13 -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=@gmail.com header.s=20210112 header.b=SqxPLb37; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbiKCDWA (ORCPT + 97 others); Wed, 2 Nov 2022 23:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbiKCDVx (ORCPT ); Wed, 2 Nov 2022 23:21:53 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0D914D2E; Wed, 2 Nov 2022 20:21:51 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id f7so1156648edc.6; Wed, 02 Nov 2022 20:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3mJ1M1GCa29hKoerTifDSh6zyzpsImb+52pEFvSJf6k=; b=SqxPLb37gwUzlh0M2OCmLT3oshNTX2u7ZDnwnsLBGMw+2hzrjm6H6qVneSZ2JRG7ad RKiQCmfVy/LwMrC4GGlPmWe4n1VN+tOdt7Ec/A3lOUs0teu08X0hUfJqw0pqAVWz9a6S OBaBfZQ1F4jdSUk1XyQfZegrANC4EX4EGTs+tpsRpkxPDI6zneQs5wrsCrlFnMV9tcIe O62MGSmazs952yy/io8OtJPPORD4inDvrc8dFCzFjPezL8uKfHbEJuZsEYTcX5oAeDsK wQCIFJ6DdBY6dhNV+e4msBR4tYEJvv6NUHbumbMH596G34oFlWLJbM/bmStZk3954W2g H7lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3mJ1M1GCa29hKoerTifDSh6zyzpsImb+52pEFvSJf6k=; b=7nsxTNaFvprYu2zh1StnMYIQJUnMedGE+UUoCgCSUdjSoRsnFWlWihUXELN1KTVHPV DAReOtiPHKzGBIsfAMkva1JUdTEUy8vzoJUJNVyY9NmrqJiSJuv4CwCaY3aU0RN0Kx3j gi/2YNHW3IULGkojpNxmcOJRFeK7O5nsfBMaVZjFVMIU3viu/EtEwVbR/6VWzSqJUW26 gPA24Zy2x2o8eO5KnhJCcZyMe4C1Rza0jCyR1MiPKTuIiGJup6jBZEJR5miViXxaUCw4 P5+PAGgvioOLyq+KVK17UZhTLZuKKYqBo82+bmTCHNDYKTQBHfDPbyHUwqU7jOeX7fWH Lxow== X-Gm-Message-State: ACrzQf3a1g69PfJl4cEcYxTozNNyF/P8fZkAqk0rRkGjlVGqoitNJbDS t08bBwPK+w1ZySUjNwRMc+0BQJlrZbfPTUP2e8A= X-Received: by 2002:a05:6402:1d4e:b0:461:c7bd:7d9c with SMTP id dz14-20020a0564021d4e00b00461c7bd7d9cmr27654272edb.284.1667445710302; Wed, 02 Nov 2022 20:21:50 -0700 (PDT) MIME-Version: 1.0 References: <20221026185846.3983888-1-quic_eberman@quicinc.com> <20221026185846.3983888-3-quic_eberman@quicinc.com> <4cb58489-cd42-1868-9add-0c360065de23@quicinc.com> <62f7402d-f0e7-8e8a-e1a4-958ddbcf8d8b@quicinc.com> <840d876c-6a09-59cf-fc66-c5752ad22d7e@quicinc.com> <10525d0d-b887-6960-5fbc-933b91e2e97c@quicinc.com> In-Reply-To: <10525d0d-b887-6960-5fbc-933b91e2e97c@quicinc.com> From: Jassi Brar Date: Wed, 2 Nov 2022 22:21:38 -0500 Message-ID: Subject: Re: [PATCH v6 02/21] dt-bindings: Add binding for gunyah hypervisor To: Elliot Berman Cc: Bjorn Andersson , Murali Nalajala , Greg Kroah-Hartman , Krzysztof Kozlowski , Rob Herring , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Prakruthi Deepak Heragu , Andy Gross , Dmitry Baryshkov , linux-arm-kernel@lists.infradead.org, Mark Rutland , Lorenzo Pieralisi , Sudeep Holla , Marc Zyngier , Jonathan Corbet , Will Deacon , Catalin Marinas , Arnd Bergmann , Srinivas Kandagatla , Amol Maheshwari , Kalle Valo , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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, Nov 2, 2022 at 6:23 PM Elliot Berman wrote: > > > > On 11/2/2022 11:24 AM, Jassi Brar wrote: > > On Wed, Nov 2, 2022 at 1:06 PM Elliot Berman wrote: > >> > >> Hi Jassi, > >> > >> On 11/1/2022 7:01 PM, Jassi Brar wrote: > >>> On Tue, Nov 1, 2022 at 7:12 PM Elliot Berman wrote: > >>>> > >>>> > >>>> > >>>> On 11/1/2022 2:58 PM, Jassi Brar wrote: > >>>>> On Tue, Nov 1, 2022 at 3:35 PM Elliot Berman wrote: > >>>>>> > >>>>>> > >>>>>> > >>>>>> On 11/1/2022 9:23 AM, Jassi Brar wrote: > >>>>>>> On Mon, Oct 31, 2022 at 10:20 PM Elliot Berman wrote: > >>>>>>>> > >>>>>>>> Hi Jassi, > >>>>>>>> > >>>>>>>> On 10/27/2022 7:33 PM, Jassi Brar wrote: > >>>>>>>> > On Wed, Oct 26, 2022 at 1:59 PM Elliot Berman > >>>>>>>> wrote: > >>>>>>>> > ..... > >>>>>>>> >> + > >>>>>>>> >> + gunyah-resource-mgr@0 { > >>>>>>>> >> + compatible = "gunyah-resource-manager-1-0", > >>>>>>>> "gunyah-resource-manager"; > >>>>>>>> >> + interrupts = , /* TX > >>>>>>>> full IRQ */ > >>>>>>>> >> + ; /* RX > >>>>>>>> empty IRQ */ > >>>>>>>> >> + reg = <0x00000000 0x00000000>, <0x00000000 0x00000001>; > >>>>>>>> >> + /* TX, RX cap ids */ > >>>>>>>> >> + }; > >>>>>>>> >> > >>>>>>>> > All these resources are used only by the mailbox controller driver. > >>>>>>>> > So, this should be the mailbox controller node, rather than the > >>>>>>>> > mailbox user.> One option is to load gunyah-resource-manager as a > >>>>>>>> module that relies > >>>>>>>> > on the gunyah-mailbox provider. That would also avoid the "Allow > >>>>>>>> > direct registration to a channel" hack patch. > >>>>>>>> > >>>>>>>> A message queue to another guest VM wouldn't be known at boot time and > >>>>>>>> thus couldn't be described on the devicetree. > >>>>>>>> > >>>>>>> I think you need to implement of_xlate() ... or please tell me what > >>>>>>> exactly you need to specify in the dt. > >>>>>> > >>>>>> Dynamically created virtual machines can't be known on the dt, so there > >>>>>> is nothing to specify in the DT. There couldn't be a devicetree node for > >>>>>> the message queue client because that client is only exists once the VM > >>>>>> is created by userspace. > >>>>>> > >>>>> The underlying "physical channel" is the synchronous SMC instruction, > >>>>> which remains 1 irrespective of the number of mailbox instances > >>>>> created. > >>>> > >>>> I disagree that the physical channel is the SMC instruction. Regardless > >>>> though, there are num_online_cpus() "physical channels" with this > >>>> perspective. > >>>> > >>>>> So basically you are sharing one resource among users. Why doesn't the > >>>>> RM request the "smc instruction" channel once and share it among > >>>>> users? > >>>> > >>>> I suppose in this scenario, a single mailbox channel would represent all > >>>> message queues? This would cause Linux to serialize *all* message queue > >>>> hypercalls. Sorry, I can only think negative implications. > >>>> > >>>> Error handling needs to move into clients: if a TX message queue becomes > >>>> full or an RX message queue becomes empty, then we'll need to return > >>>> error back to the client right away. The clients would need to register > >>>> for the RTS/RTR interrupts to know when to send/receive messages and > >>>> have retry error handling. If the mailbox controller retried for the > >>>> clients as currently proposed, then we could get into a scenario where a > >>>> message queue could never be ready to send/receive and thus stuck > >>>> forever trying to process that message. The effect here would be that > >>>> the mailbox controller becomes a wrapper to some SMC instructions that > >>>> aren't related at the SMC instruction level. > >>>> > >>>> A single channel would limit performance of SMP systems because only one > >>>> core could send/receive a message. There is no such limitation for > >>>> message queues to behave like this. > >>>> > >>> This is just an illusion. If Gunyah can handle multiple calls from a > >>> VM parallely, even with the "bind-client-to-channel" hack you can't > >>> make sure different channels run on different cpu cores. If you are > >>> ok with that, you could simply populate a mailbox controller with N > >>> channels and allocate them in any order the clients ask. > >> > >> I wanted to make sure I understood the ask here completely. On what > >> basis is N chosen? Who would be the mailbox clients? > >> > > A channel structure is cheap, so any number that is not likely to run > > out. Say you have 10 possible users in a VM, set N=16. I know ideally > > it should be precise and flexible but the gain in simplicity makes the > > trade-off very acceptable. > > I think I get the direction you are thinking now. N is chosen based off > of how many clients there might be. One mailbox controller will > represent all message queues and each channel will be one message queue. > There are some limitations that might make it more complex to implement > than having 1 message queue per controller like I have now. > > My interpretation is that mailbox controller knows the configuration of > its channels before being bound to a client. For dynamically created > message queues, the client would need tell the controller about the > message queue configuration. I didn't find example where client is > providing information about a channel to the controller. > > 1. need a mechanism to allow the client to provide the > gunyah_resources for the channel (i.e. the irqs and cap ids). > IIUC there is exactly one resource-manager in a VM. Right? Looking at your code, TX and RX irq are used only by the mailbox driver and are the same for all clients/users. So that should be a property under the mailbox controller node. Not sure what cap ids are. > 2. Still need to have bind-client-to-channel patch since clients > aren't real devices and so shouldn't be on DT. > the clients may be virtual (serial, gpio etc) but the resource-manager requires some mailbox hardware to communicate, so the resource-manager should be the mailbox client (that further spawns virtual devices) thnx.