Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp652974ybi; Fri, 12 Jul 2019 02:28:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyg1SYWPFI37d4Jgt49WYiUfHsb74eJk4nbe9WeiH9VBDYrWEZIZwHgG8yuaWq7alfV92kf X-Received: by 2002:a17:90a:220a:: with SMTP id c10mr10678458pje.33.1562923708134; Fri, 12 Jul 2019 02:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562923708; cv=none; d=google.com; s=arc-20160816; b=co4xCHpXMxTcBiBPlNu7wopSA0h2v/tyBXRBBBE8WW6ih+V0tv7g02EEsg0709EIIu TVCm9HdmWe4HiO1km9Qz7qyFiViO2h4wcE0xD8EvErWWbD55pOxvuvgLvIkg1btfLiDc xSVETUHcDip14XCAadvfxt0QUnN/T3dcprEnasGGkMc8vTVLC/sdJ+8+GNOx/3r1dSU8 F2ZTYYzCW+ketDnPS9VkxGnmlAsYkdloGQRsyqsZpDTATFkFLmDOv0DffiaqbsxmFvWi GnhYzinSnbA0AbauTfrXP1d0oUD3+AuBrYnndy2dzzi6A6f5OpkkH2ik8YsyZinGKyGx 4dPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jYy0XP6ethrem4b19nt43P11ZiYCCwivtW53JRcikeE=; b=DmJp2n/8ZDzXbWfzf1uHj75I5oVAaV00Y7unbuavnkNUtLLQUy/ldAOtfRq/28rFZN QCvbdShPeoX7CyLLkSY6h5X0KV1OSbFgDm6elh4K9Tsfy/P/5m5L0IP6HiLlS6iPKWrg DNMfmOTlYNzi2bClAQ0rv75pMHJLV+N3fZR9jRIv/SogsX4+1fT51MCooH2Dba/xUv30 6eAhhAS2QigWG8Bv/JpODQnPfy21IHxIvjliLl0lKfpJL68KP4k5JNb2GTnJZJOOvSiT der/Q3D6esEHH2wWIzS+qf7zVh6I1bLjdjUIkTXKx6UFjVSNoaEEpxN4QotqhEeNJIUV DI5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=X22GS1wk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13si7081016pgv.398.2019.07.12.02.28.12; Fri, 12 Jul 2019 02:28:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=X22GS1wk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbfGLJ14 (ORCPT + 99 others); Fri, 12 Jul 2019 05:27:56 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34480 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbfGLJ14 (ORCPT ); Fri, 12 Jul 2019 05:27:56 -0400 Received: by mail-ot1-f65.google.com with SMTP id n5so8841755otk.1 for ; Fri, 12 Jul 2019 02:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jYy0XP6ethrem4b19nt43P11ZiYCCwivtW53JRcikeE=; b=X22GS1wk91UjPm6+zhjoIjTp6TANbMdrUt6PVMNOW9CW/5FPKoxIlUCGugAB+NRfRQ monlxmvfGjdkXHE0ZXj5TSesu/oigagcXG+j6OYS3f9S8e/jIh/2BrFN70n632G8bJlr ArRi2NabuE5PXCf2lJC1fyNzO3ZGV7RMpfSmQmT5SJv8S0yYl8b5duVEmdRMT9zOjLV6 MMlp4NQ2biV1cCjV+lAXpJShoHW000qTR2iSqk+SzD7uaPhNExUrMOch2dzqjkDkaiI0 Wi1yENBcScRkf2Hq1RIw7hwJWljm7CgJxis3HKB0cvCOtLD888T6G++Uniy7ZJtM3XzJ hhIg== 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:content-transfer-encoding; bh=jYy0XP6ethrem4b19nt43P11ZiYCCwivtW53JRcikeE=; b=DUiEqgBsad3XI5KrroGaoDdykg6D0UMlJcyfMwIhUOzTrRKKgK7m2isQIgT+2p05y3 g25XVAiw28kyQYXMKecxXWG2nsrOpIhy29XHqS36OtHzspuFPF3aYd7J4gnTu0hAht6R pdSQi9ZaC6+U2KQ134794+FhfU8GZU8bYKaLwPAA/Aqv97tt0utDh15e7rptnSgdT5G3 Bh5rgIJbzadfbyIO7eAeXegq1xOia9A2+0sxLC63sRrFLCOUzDkWFzvsSg7gBQBpBJaJ E2i/Y5AsAl7LUQVKwAhVDXXtpMZre3SWr9kflNlioV3w64Cl23TNWvap+/65F/3F7Wh+ 31/g== X-Gm-Message-State: APjAAAVBdHB8VHWAISMgUwyJh6O3Zrw50rXFxAUegIkjUbgwIgLzNXRf YR5LFsHQ/xIj0+Zna7ze+zBiMCLvA8vCCYy0LYMXECxh X-Received: by 2002:a9d:7352:: with SMTP id l18mr2470502otk.292.1562923674988; Fri, 12 Jul 2019 02:27:54 -0700 (PDT) MIME-Version: 1.0 References: <20190705160536.12047-1-geert+renesas@glider.be> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 12 Jul 2019 11:27:43 +0200 Message-ID: Subject: Re: [PATCH RFC] gpio: Add Virtual Aggregator GPIO Driver To: Geert Uytterhoeven Cc: Geert Uytterhoeven , Linus Walleij , Alexander Graf , Peter Maydell , Paolo Bonzini , Magnus Damm , linux-gpio , QEMU Developers , Linux-Renesas , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 9 lip 2019 o 17:59 Geert Uytterhoeven napisa=C5= =82(a): > > Hi Bartosz, > > On Tue, Jul 9, 2019 at 4:59 PM Bartosz Golaszewski > wrote: > > pon., 8 lip 2019 o 12:24 Geert Uytterhoeven napi= sa=C5=82(a): > > > On Mon, Jul 8, 2019 at 11:45 AM Bartosz Golaszewski > > > wrote: > > > > pt., 5 lip 2019 o 18:05 Geert Uytterhoeven napisa=C5=82(a): > > > > > GPIO controllers are exported to userspace using /dev/gpiochip* > > > > > character devices. Access control to these devices is provided b= y > > > > > standard UNIX file system permissions, on an all-or-nothing basis= : > > > > > either a GPIO controller is accessible for a user, or it is not. > > > > > Currently no mechanism exists to control access to individual GPI= Os. > > > > > > > > > > Hence add a virtual GPIO driver to aggregate existing GPIOs (up t= o 32), > > > > > and expose them as a new gpiochip. This is useful for implementi= ng > > > > > access control, and assigning a set of GPIOs to a specific user. > > > > > Furthermore, it would simplify and harden exporting GPIOs to a vi= rtual > > > > > machine, as the VM can just grab the full virtual GPIO controller= , and > > > > > no longer needs to care about which GPIOs to grab and which not, > > > > > reducing the attack surface. > > > > > > > > > > Virtual GPIO controllers are instantiated by writing to the "new_= device" > > > > > attribute file in sysfs: > > > > > > > > > > $ echo " [ ...]" > > > > > "[, [ ...]] ...]" > > > > > > /sys/bus/platform/drivers/gpio-virt-agg/new_device > > > > > > > > > > Likewise, virtual GPIO controllers can be destroyed after use: > > > > > > > > > > $ echo gpio-virt-agg. \ > > > > > > /sys/bus/platform/drivers/gpio-virt-agg/delete_devi= ce > > > Am I doing it right? I'm trying to create a device and am only getting = this: > > > > # echo gpiochip2 23 > new_device > > [ 707.507039] gpio-virt-agg gpio-virt-agg.0: Cannot find gpiochip gpio= chip2 > > > > gpiochip2 *does* exist in the system. > > Please try the name of the platform device instead. > I.e. for my koelsch (R-Car M2-W), it needs "e6052000.gpio" instead > of "gpiochip2". > > Probably the driver should match on both. > > > I see. I'll try to review it more thoroughly once I get to play with > > it. So far I'm stuck on creating the virtual chip. > > Thanks, good luck! > This is not a show-stopper but one thing that's bothering me in this is that lines used by the aggregator are considered 'used' in regard to the original chip. I'm wondering how much effort would it take to have them be 'muxed' into two (real and virtual) chips at once. Other than that - seems to works pretty nice other than the matching by chip name and by line names. Bart > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m6= 8k.org > > In personal conversations with technical people, I call myself a hacker. = But > when I'm talking to journalists I just say "programmer" or something like= that. > -- Linus Torvalds