From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49E0FC433FE for ; Wed, 9 Dec 2020 20:40:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EC7123D1C for ; Wed, 9 Dec 2020 20:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbgLIUja (ORCPT ); Wed, 9 Dec 2020 15:39:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:46082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728508AbgLIUjU (ORCPT ); Wed, 9 Dec 2020 15:39:20 -0500 X-Gm-Message-State: AOAM531bf7FqyU+G1r0+QRPNn5r+N6GGPsQjCork7EQrw+7LiU09Or1Q zfLboIJKOT9iklMBouZqK14YMUvw1jLNlVBgvcI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607546320; bh=Ha7lLzOpXQ1X99veTNG7S+85hi9hDdUnwFrOdFxJkFY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=m2wotAQGycNW3fNMRpvScONvUE+gNQJa/7UXeuv/E5/eArPXRVUCPnYQLNrImG/mi EJQV7WMwocrOB73rk8fCLhZCKjNIIiR/bzljek61mxBTwLpxZP82Xn6jRhlnEUKATY iEBAwk/CSGD9Xo47fY9oJGPZG78DcYthsCzyjY+hsWhf7D9e50RNKkGKje4//M6lnX 86DGjo+2ZTer6Q7yhGH0UvyBu2prkduSQAGOLKN5qBU3EyEyp7I4BzaQZcPiejMXMM 6hNi9fuj/ykVQO5y8Oy4vK4OaddGLZhWOG0zHrOv8NhJ1xIkzjm0yvECImZOpff6AX yJ8H5FndHMpDA== X-Google-Smtp-Source: ABdhPJx9b5wUc4ET8rElWbclWiQSLM9K0iZJ/2Q/ZLrhCrcYkZDXsayj9l5KMwDCDCiFnl6/qW8E7Vk6lrA60XCvUYc= X-Received: by 2002:a9d:6317:: with SMTP id q23mr3381889otk.251.1607546319268; Wed, 09 Dec 2020 12:38:39 -0800 (PST) MIME-Version: 1.0 References: <20201203191135.21576-1-info@metux.net> <20201203191135.21576-2-info@metux.net> <0080d492-2f07-d1c6-d18c-73d4204a5d40@metux.net> <51d3efb7-b7eb-83d7-673a-308dd51616d3@metux.net> <2827855a-dc4f-2e17-aca3-4b1b9f0d5084@ti.com> In-Reply-To: <2827855a-dc4f-2e17-aca3-4b1b9f0d5084@ti.com> From: Arnd Bergmann Date: Wed, 9 Dec 2020 21:38:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Howto listen to/handle gpio state changes ? Re: [PATCH v2 2/2] drivers: gpio: add virtio-gpio guest driver To: Grygorii Strashko Cc: Linus Walleij , "Enrico Weigelt, metux IT consult" , "Michael S. Tsirkin" , Jason Wang , Jonathan Corbet , Linux Doc Mailing List , "linux-kernel@vger.kernel.org" , virtualization@lists.linux-foundation.org, Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , linux-riscv , "Enrico Weigelt, metux IT consult" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Wed, Dec 9, 2020 at 9:22 PM Grygorii Strashko wrote: > On 09/12/2020 14:53, Linus Walleij wrote: > > On Wed, Dec 9, 2020 at 12:19 PM Arnd Bergmann wrote: > >> On Wed, Dec 9, 2020 at 9:51 AM Linus Walleij wrote: > >>> On Tue, Dec 8, 2020 at 3:07 PM Enrico Weigelt, metux IT consult wrote: > >> > >>> What we need to understand is if your new usecase is an outlier > >>> so it is simplest modeled by a "mock" irq_chip or we have to design > >>> something new altogether like notifications on changes. I suspect > >>> irq_chip would be best because all drivers using GPIOs for interrupts > >>> are expecting interrupts, and it would be an enormous task to > >>> change them all and really annoying to create a new mechanism > >>> on the side. > >> > >> I would expect the platform abstraction to actually be close enough > >> to a chained irqchip that it actually works: the notification should > >> come in via vring_interrupt(), which is a normal interrupt handler > >> that calls vq->vq.callback(), calling generic_handle_irq() (and > >> possibly chained_irq_enter()/chained_irq_exit() around it) like the > >> other gpio drivers do should just work here I think, and if it did > >> not, then I would expect this to be just a bug in the driver rather > >> than something missing in the gpio framework. > > > > Performance/latency-wise that would also be strongly encouraged. > > > > Tglx isn't super-happy about the chained interrupts at times, as they > > can create really nasty bugs, but a pure IRQ in fastpath of some > > kinde is preferable and intuitive either way. > > In my opinion the problem here is that proposed patch somehow describes Front end, but > says nothing about Backend and overall design. > > What is expected to be virtualized? whole GPIO chip? or set of GPIOs from different GPIO chips? > Most often nobody want to give Guest access to the whole GPIO chip, so, most probably, smth. similar to > GPIO Aggregator will be needed. I would argue that it does not matter, the virtual GPIO chip could really be anything. Certain functions such as a gpio based keyboard require interrupts, so it sounds useful to make them work. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF73FC4361B for ; Wed, 9 Dec 2020 20:38:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B15B23BAC for ; Wed, 9 Dec 2020 20:38:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B15B23BAC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=je2JM3BhUxEfkSMNS2/FLYYHUsRMLtdV1zhO61zVg+E=; b=hCKcVOVQc2KNy72H4C3S/YyRB KyLKV2NiiDESAvu+ta2uNMOArNfWdxJk/KJb6KVdS52+yltwnrF5kL0UYW5Pvqxr+ML7MNSoLXht1 kwrpgHoGbV8vYywWszvKZNON81dQteeA2L5TVSiwYz2mG+0ZpvUKQrmGMlMvuIGhoXNqiRxJLk10P 2nCgL32LBmNjB+4H9keLI50+YfXPbzNnQJ+Xy1YDK1/z5sOotdMKnMZFS5iA64khl8sdPqTBAy5SH ghDh83yPtJamY3HQ1JZUuZ/T5dPSZaQXIpfiL+Z5RyZX8TqIfRO6NuLcCCH/e5GXJlAANrvv5YLeh dtBjpcndw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn6EW-0007M5-QT; Wed, 09 Dec 2020 20:38:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn6ET-0007LX-U8 for linux-riscv@lists.infradead.org; Wed, 09 Dec 2020 20:38:42 +0000 X-Gm-Message-State: AOAM530QHKE11dCHU1xuk7jWg30RU9PZAWyDfx2M2E1C3khN6yjYnLmN IE/1Ej3etlQC7qfZEwttPSbyQYGZgGByDpXwgks= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607546320; bh=Ha7lLzOpXQ1X99veTNG7S+85hi9hDdUnwFrOdFxJkFY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=m2wotAQGycNW3fNMRpvScONvUE+gNQJa/7UXeuv/E5/eArPXRVUCPnYQLNrImG/mi EJQV7WMwocrOB73rk8fCLhZCKjNIIiR/bzljek61mxBTwLpxZP82Xn6jRhlnEUKATY iEBAwk/CSGD9Xo47fY9oJGPZG78DcYthsCzyjY+hsWhf7D9e50RNKkGKje4//M6lnX 86DGjo+2ZTer6Q7yhGH0UvyBu2prkduSQAGOLKN5qBU3EyEyp7I4BzaQZcPiejMXMM 6hNi9fuj/ykVQO5y8Oy4vK4OaddGLZhWOG0zHrOv8NhJ1xIkzjm0yvECImZOpff6AX yJ8H5FndHMpDA== X-Google-Smtp-Source: ABdhPJx9b5wUc4ET8rElWbclWiQSLM9K0iZJ/2Q/ZLrhCrcYkZDXsayj9l5KMwDCDCiFnl6/qW8E7Vk6lrA60XCvUYc= X-Received: by 2002:a9d:6317:: with SMTP id q23mr3381889otk.251.1607546319268; Wed, 09 Dec 2020 12:38:39 -0800 (PST) MIME-Version: 1.0 References: <20201203191135.21576-1-info@metux.net> <20201203191135.21576-2-info@metux.net> <0080d492-2f07-d1c6-d18c-73d4204a5d40@metux.net> <51d3efb7-b7eb-83d7-673a-308dd51616d3@metux.net> <2827855a-dc4f-2e17-aca3-4b1b9f0d5084@ti.com> In-Reply-To: <2827855a-dc4f-2e17-aca3-4b1b9f0d5084@ti.com> From: Arnd Bergmann Date: Wed, 9 Dec 2020 21:38:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Howto listen to/handle gpio state changes ? Re: [PATCH v2 2/2] drivers: gpio: add virtio-gpio guest driver To: Grygorii Strashko X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201209_153842_112533_5DBC5D9A X-CRM114-Status: GOOD ( 19.38 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Jonathan Corbet , Linus Walleij , Linux Doc Mailing List , "linux-kernel@vger.kernel.org" , virtualization@lists.linux-foundation.org, Bartosz Golaszewski , "Enrico Weigelt, metux IT consult" , "open list:GPIO SUBSYSTEM" , linux-riscv , "Enrico Weigelt, metux IT consult" , Jason Wang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Dec 9, 2020 at 9:22 PM Grygorii Strashko wrote: > On 09/12/2020 14:53, Linus Walleij wrote: > > On Wed, Dec 9, 2020 at 12:19 PM Arnd Bergmann wrote: > >> On Wed, Dec 9, 2020 at 9:51 AM Linus Walleij wrote: > >>> On Tue, Dec 8, 2020 at 3:07 PM Enrico Weigelt, metux IT consult wrote: > >> > >>> What we need to understand is if your new usecase is an outlier > >>> so it is simplest modeled by a "mock" irq_chip or we have to design > >>> something new altogether like notifications on changes. I suspect > >>> irq_chip would be best because all drivers using GPIOs for interrupts > >>> are expecting interrupts, and it would be an enormous task to > >>> change them all and really annoying to create a new mechanism > >>> on the side. > >> > >> I would expect the platform abstraction to actually be close enough > >> to a chained irqchip that it actually works: the notification should > >> come in via vring_interrupt(), which is a normal interrupt handler > >> that calls vq->vq.callback(), calling generic_handle_irq() (and > >> possibly chained_irq_enter()/chained_irq_exit() around it) like the > >> other gpio drivers do should just work here I think, and if it did > >> not, then I would expect this to be just a bug in the driver rather > >> than something missing in the gpio framework. > > > > Performance/latency-wise that would also be strongly encouraged. > > > > Tglx isn't super-happy about the chained interrupts at times, as they > > can create really nasty bugs, but a pure IRQ in fastpath of some > > kinde is preferable and intuitive either way. > > In my opinion the problem here is that proposed patch somehow describes Front end, but > says nothing about Backend and overall design. > > What is expected to be virtualized? whole GPIO chip? or set of GPIOs from different GPIO chips? > Most often nobody want to give Guest access to the whole GPIO chip, so, most probably, smth. similar to > GPIO Aggregator will be needed. I would argue that it does not matter, the virtual GPIO chip could really be anything. Certain functions such as a gpio based keyboard require interrupts, so it sounds useful to make them work. Arnd _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv