Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2724638pxj; Mon, 14 Jun 2021 05:52:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyfrVvTd02o7OeaOppS13/11qBlJcteijzhcg8fmXD1ibak7G7+V78er/uZE7MQsemyZGy X-Received: by 2002:a17:906:fcb4:: with SMTP id qw20mr15325107ejb.344.1623675157674; Mon, 14 Jun 2021 05:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623675157; cv=none; d=google.com; s=arc-20160816; b=uM2YqPVXCp03Y3WT8P/NHJTb/jkmB9alXA5RWi+jBVDv6JCkXzR1Xz597LFJ6lU5xo oIDXwHCLyt/rLoTQ2uo3/PcU40L4mIF9ORr7KY3dhpiOXkHLAmIMk2NbHdmhCPVApxia AN/0qzCfrVjDERx7VGKKKAF/mEVR77UHmzNJVjBXkQc1kHHXDBZnvk9k/8YTUBCIq0SP KlGU7Rcx0sxL1KbCGpuNbT867zg3Z4JFS2u89tX0Qf/t+vxVltcl4dqNxM9tNs/XN8mk 6EoNa7d4Tl/Dpdy9QGH0NXohE+FZp7HWaAFOSFaE0PhD8EMouwNNXuGqFrNZfKcKoAcv aITg== 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=nzgH/7Iv6iyxaTVlqwmoCQllTxzdAPS+ij+2D3qFMC8=; b=jsSwdDg+KZt5lWweTJqBjEZlXe5Dxf35ek0IAfn2gMdcNWjkS309yCV7DUwc7Kep1d Vb5LGzfZXsjls5qG0ZEX+IPadH9dyUHGTBYNn8p7guoaQgEnrwDbdbwvAQaXC7mySpaW nrJ9h82a1BMkcqmtTHInN6Di1M0tG3sR5BUs+ENIIAT+2fChfbhifJz+NGrx23sh6AVY 4eqEDYUBvlvPabPbnaBGVhBwMZdl96T7JO6Q/AAcRaXxGa290wimFSMUSyLPdfJsHl2K d8910NKPfwnaqB4CswF7nTrmPRC5ESf8Txfu2skyicc87toOSDayht+ckHmhbkvpZ7lv l/ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MN3G10KS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si12800488ejj.523.2021.06.14.05.52.14; Mon, 14 Jun 2021 05:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MN3G10KS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233139AbhFNMwC (ORCPT + 99 others); Mon, 14 Jun 2021 08:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbhFNMwC (ORCPT ); Mon, 14 Jun 2021 08:52:02 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB28C061574 for ; Mon, 14 Jun 2021 05:49:59 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id x14so19986706ljp.7 for ; Mon, 14 Jun 2021 05:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nzgH/7Iv6iyxaTVlqwmoCQllTxzdAPS+ij+2D3qFMC8=; b=MN3G10KS8zT9A3PhB5Whd+ylxP7qd2wucfj/5keASzzuwCyM4ftUcJHBgukcPd4Pbi M2sT9MXbnDkO9scWr2I3T528lXZnloLOK1R53oNHTI0JVx54U5c1yTOf4uax87g7oFG1 PY/Wn2e/Jup0aTF0CuE3x3gdEb8yG3Kkf2YS+pSv0E/7cDpcfSnUO+o4gZlH7no8wL0b ANynTpBGzjNcn22NpH7+l2UqT/b0nm0eKwhq6DDUFLY6ou1PNlLUyuVplSvh0jJ3NxK5 p1W5biqA2S8Vtimkdz9r7CO6lLavrfXQCKCxPWMUnSQ622Abr26sv3nFyaLvvja4JjyN C6vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nzgH/7Iv6iyxaTVlqwmoCQllTxzdAPS+ij+2D3qFMC8=; b=Fwo4BikW4n7b+CIWa4zn6yZ3OtqUSZgmPOSxSZKoCQxVB0sitPIGkP5VXFaMgDLFVF ExNaOh2JElUwNpUFV7suwWDYNUK+D4sKnnKeXYjCWjv43CI6VMyjKZqPeJ4nVNM0Buy+ mGjq2mPVDnozOUjMEsqAyvFMm6A1flhAREa7oaIRb2MbIJG1TIA97AsktzRNDcTAhApj pS1pRCBw06STzmju7AY86gBus+fCxuBNAJOqchnJ0TGNopG+zZWrjUghYanwNS0WYCoC hD3CCQk8r+PraZCpjCEjjtH5hUaZaFSSeCUkOIYK/0b1WPTDm1wvdbkEaVAV84XfJYYL bf2w== X-Gm-Message-State: AOAM53034qN9IVZ5rxqIfi2XF7y+9oVctosqDb03FAucDSUyIseCdZJQ ZplLeU2gqPXdccEl7kiYJdFOVBFHTCrK2f6kLBZ3UQ== X-Received: by 2002:a2e:858a:: with SMTP id b10mr13186671lji.445.1623674997438; Mon, 14 Jun 2021 05:49:57 -0700 (PDT) MIME-Version: 1.0 References: <10442926ae8a65f716bfc23f32339a6b35e51d5a.1623326176.git.viresh.kumar@linaro.org> <20210614102119.qifm5sj7fpg54iqo@vireshk-i7> In-Reply-To: From: Vincent Guittot Date: Mon, 14 Jun 2021 14:49:45 +0200 Message-ID: Subject: Re: [PATCH V3 1/3] gpio: Add virtio-gpio driver To: Arnd Bergmann Cc: Viresh Kumar , Bartosz Golaszewski , Linus Walleij , "Enrico Weigelt, metux IT consult" , Viresh Kumar , "Michael S. Tsirkin" , Jason Wang , Bill Mills , =?UTF-8?B?QWxleCBCZW5uw6ll?= , Stratos Mailing List , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Stefan Hajnoczi , "Stefano Garzarella --cc virtualization @ lists . linux-foundation . org" , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Jun 2021 at 14:33, Arnd Bergmann wrote: > > On Mon, Jun 14, 2021 at 12:23 PM Viresh Kumar wrote: > > On 10-06-21, 15:22, Arnd Bergmann wrote: > > > Can you give an example of how this would be hooked up to other drivers > > > using those gpios. Can you give an example of how using the "gpio-keys" or > > > "gpio-leds" drivers in combination with virtio-gpio looks like in the DT? > > > > > > Would qemu simply add the required DT properties to the device node that > > > corresponds to the virtio device in this case? > > > > > > From what I can tell, both the mmio and pci variants of virtio can have their > > > dev->of_node populated, but I don't see the logic in register_virtio_device() > > > that looks up the of_node of the virtio_device that the of_gpio code then > > > tries to refer to. > > > > To be honest, I haven't tried this yet and I was expecting it to be > > already taken care of. I was relying on the DTB automatically > > generated by Qemu to get the driver probed and didn't have a look at > > it as well. > > > > I now understand that it won't be that straight forward. The same must > > be true for adding an i2c device to an i2c bus over virtio (The way I > > tested that earlier was by using the sysfs file to add a device to a > > bus). > > Yes, correct, we had the same discussion about i2c. Again, this is > relatively straightforward when the controller and the device attached > to it (i2c controller/client or gpio controller/function) are both emulated > by qemu, but a lot harder when the controller and device are > implemented in different programs. > > > This may be something lacking generally for virtio-pci thing, not > > sure though. > > I think most importantly we need a DT binding to describe what device > nodes are supposed to look like underneath a virtio-mmio or > virtio-pci device in order for a hypervisor to pass down the > information to a guest OS in a generic way. We can probably borrow > the USB naming, and replace compatible="usbVID,PID" with > compatible="virtioDID", with the device ID in hexadecimal digits, > such as "virtio22" for I2C (virtio device ID 34 == 0x22) if we decide > to have a sub-node under the device, or we just point dev->of_node > of the virtio device to the platform/pci device that is its parent > in Linux. > > Adding the Linux guest code to the virtio layer should be fairly > straightforward, and I suppose it could be mostly copied from the > corresponding code that added this for mmc in commit 25185f3f31c9 > ("mmc: Add SDIO function devicetree subnode parsing") and for USB > in commit 69bec7259853 ("USB: core: let USB device know device > node") and 1a7e3948cb9f ("USB: add device-tree support for > interfaces"). And something similar is also done with SCMI protocols which are defined in a SCMI node. A typical example: cpu@0 { ... clocks = <&scmi_dvfs 0>; ... }; deviceX: deviceX@YYYYYYY { ... clocks = <&scmi_clk 0>; ... }; scmi: scmi { compatible = "arm,scmi-virtio"; #address-cells = <1>; #size-cells = <0>; scmi_devpd: protocol@11 { reg = <0x11>; #power-domain-cells = <1>; }; scmi_clk: protocol@14 { reg = <0x14>; #clock-cells = <1>; }; scmi_sensors: protocol@15 { reg = <0x15>; #thermal-sensor-cells = <1>; }; scmi_dvfs: protocol@13 { reg = <0x13>; #clock-cells = <1>; }; }; > > Arnd