Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2165940rwi; Thu, 3 Nov 2022 13:32:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64ZcBcbLc/Q/7qnLwQSYiGs3RAwP+bJ8FmN8n0BTDH7vkCNe4diBHvN3kP9QtYIttCKDMj X-Received: by 2002:a17:90a:be14:b0:213:c304:1d68 with SMTP id a20-20020a17090abe1400b00213c3041d68mr29040381pjs.80.1667507565180; Thu, 03 Nov 2022 13:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667507565; cv=none; d=google.com; s=arc-20160816; b=qEVlhSEk3SBmi0cOjOlM1qwQ8oBZ3YskwvrAY8q3S2mOPP9xZprzsg2X5d4nfjz1dq RgRyz0hHZQCn+30hSM8oiuOpAP3CSzCDhBbNlqWVsNmi6j2KwOt6v0A4lLZ8SORqD3KV RRn89yntB7XSiGjdXG9r9z4LjlvEfeO2gjX0wY5N2a8YRF+9RzB5wdG0d9diiJcMYFr7 dURDHakmndv8ewSRiFqdo2BH7vQdCUrJpfQuOS1xl5HqF+PJ+dWxpuHDGtUryODUssW0 SdkxiBS51owCNzFydEGxYPSXQSpO6YNltfTZ7yLYt4M8hezKwVCstUGBPRzyo1rqwisI o0IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OS+/+xZt1QdTJvH8RPAr0SDIsAedYTAz4C3sGWMmzrg=; b=fZCSqGHSofZGLRIMykOrjUV9IVfpcFFsPdRkMDH1iNRW8azOruBhtbIQx3oi3n5BjQ KeyxfGDj+gSQh0nXS9yUyYmgnuL0dBNSs1QJph4aspbKXGB67xMBoyimVe3Oe4IHKmED frUHLcqEGXVomdhKorcdHSC1TI5NRHr37nxSM/dvS/8cN3xi2RJCRS4GxZ3zpCJLH53d 6U/soRc8nmXdXKNL/6WkB1E2A4eh2i7QlCF65h/WnUblKDfFx0K4JvwF2pBOFoYtJaLv qEcE7fSMLIg+H+E3DLBWTJfmEKNfk1fqZ8KRR0C3j/rP38kwD9OEFuMtl5OpMWnqfUe/ ej9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=APqBo4kD; 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=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb18-20020a17090b281200b0020291c96b13si914705pjb.121.2022.11.03.13.32.26; Thu, 03 Nov 2022 13:32:45 -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=@quicinc.com header.s=qcdkim header.b=APqBo4kD; 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=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbiKCTpt (ORCPT + 98 others); Thu, 3 Nov 2022 15:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiKCTpr (ORCPT ); Thu, 3 Nov 2022 15:45:47 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 046311F9C5; Thu, 3 Nov 2022 12:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1667504743; x=1699040743; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=OS+/+xZt1QdTJvH8RPAr0SDIsAedYTAz4C3sGWMmzrg=; b=APqBo4kDberOYEAq+cOzShQ+Y024ukW7sz+imBchwAMWU9IzjPdw8ULC uyMONsBPW/xh80JbYcLPqN+azY4s+HquXxFrsUOXAj/DBn+ZjCOO7Ty75 +30ImCndaBLPNwP4KYADl2LSwVoo44hOL+FFr750r1St3as746QAdrx3J 8=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 03 Nov 2022 12:45:42 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 12:45:41 -0700 Received: from [10.110.88.98] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 3 Nov 2022 12:45:40 -0700 Message-ID: <4bf14665-3303-2449-a5d7-5b7cf01ccc29@quicinc.com> Date: Thu, 3 Nov 2022 12:45:39 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v6 02/21] dt-bindings: Add binding for gunyah hypervisor To: Jassi Brar 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 , , "Mark Rutland" , Lorenzo Pieralisi , Sudeep Holla , "Marc Zyngier" , Jonathan Corbet , Will Deacon , Catalin Marinas , Arnd Bergmann , Srinivas Kandagatla , "Amol Maheshwari" , Kalle Valo , , , , 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> Content-Language: en-US From: Elliot Berman In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 11/2/2022 8:21 PM, Jassi Brar wrote: > 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. > Ah -- "message queues" are a generic inter-VM communication mechanism offered by Gunyah. One use case for message queues is to communicate with the resource-manager, but other message queues can exist between other virtual machines. Those other message queues use different TX and RX irq and have different client protocols. In mailbox terminology, we have one known channel at boot-up time (the resource manager). That known channel can inform Linux about other channels at runtime. The client (not the controller) decodes received data from the channel to discover the new channels. One approach we found was coming from pcc.c, which has their own request_channel function (pcc_mbox_request_channel). We could follow this approach as well... >> 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) Yes, this the design I'm aiming for. Also want to highlight that the resource-manager spawns Gunyah virtual devices such as message queue channels. Thanks, Elliot