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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F04BC433F5 for ; Thu, 25 Nov 2021 15:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H/0DejC05MiK138mn8qxYUJt1/8FO/etBKm+3+CVe5M=; b=vCgVCJ3y0ORZd9 BHTVMJC2kcmjB/Qr1b1V5BogTMS4K8nYf02LwN/0nGjdvz4YsLubOUcO+su9Xnvra8kT7I8QdSMCo fuii8yyx5XFHold1k3NUaUaxDZ2qdDDnMlPII7pFPDxNqQfFfzhTG4KQIribzyJWUCTdx6LaW01mu nUIoOfPb5usQvojXyobWbmUzAQAexsDKfllpzsHac9sPH4rBuL0NPAJjmsgmKql3U3cbibnSiVFJO EZkNKONJBfoGc8jI5tJDJ/LChVHErlRCizZo2LvGiLh0GQCpU2Q+dVtKmb0cezo1z4tWvQnyGWY86 Ip4RRApVfqI9dj2oGqqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqGhm-0081gX-Vp; Thu, 25 Nov 2021 15:30:34 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqGhj-0081fS-Jb for linux-rockchip@lists.infradead.org; Thu, 25 Nov 2021 15:30:33 +0000 Received: by mail-wm1-x329.google.com with SMTP id 137so5942153wma.1 for ; Thu, 25 Nov 2021 07:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=PEQF6bMcJoShAAAQZkOF5BkWuiwr/n8dHKen+aLofuFtfwvoi1JRGleq7frRxwDwPz dnnd09H6YI8fqa/4VFmNOCorgx79h5Kb8CTaEQBFTgi9u06DecieiPFcyxaALI3u/tie nIGrxVpEgmrjxTTqEkl42sXE71D31J1/kYVeo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=C0Wk0R8jvh4Ek2V6N//rBrGULRtzU1DFS9IkUC8F2DeWELFSW6E/7SSwb0Kxvzlkn3 YSThRNDBhm0JfU7zWBLr1vnZLMo8Vn/1/kOVMWai21xx5lQHTscwC7Q1iJltFk5RjqlX xS1e5+AzgdYLogcHXWU7eSZkOW6isIcK/TahyLmZABaHeFilZWx+JoZRuJdQOLn7wKQq mJJ914UeVm6Ih3l6wDzPZMVesGBj5334vhh84Uh+kQ6RSrCI2e2QpR8ODOjKKiz3wP0Z /OsqtpAKZHbYSJMdeJKRuMNm27n+1UenZysVUkN0wHQcddWtwmjQA8kcM1NUIT0/Dbmc Qe9g== X-Gm-Message-State: AOAM533dmeQmKV3h3dD0TQuPOL4y4vFtEjoNBdVSQiLUgAp7MZlW4Fxc XreqDq+Zos92JKzfIgoL4gi+iw== X-Google-Smtp-Source: ABdhPJxhA/VhsuDIAS0OWxUiI3i8TAhLLHvv9SkU+3wJwc/Kf9vwByE1Bdg0iWstOjaQzCy5lMbUTQ== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr8313877wmc.58.1637854229881; Thu, 25 Nov 2021 07:30:29 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id p27sm3220547wmi.28.2021.11.25.07.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:30:29 -0800 (PST) Date: Thu, 25 Nov 2021 16:30:27 +0100 From: Daniel Vetter To: Pekka Paalanen Cc: Daniel Vetter , Simon Ser , Rob Clark , Brian Norris , Andrzej Hajda , David Airlie , Dmitry Torokhov , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Thomas Zimmermann , linux-input@vger.kernel.org Subject: Re: [PATCH v2 1/2] drm/input_helper: Add new input-handling helper Message-ID: Mail-Followup-To: Pekka Paalanen , Simon Ser , Rob Clark , Brian Norris , Andrzej Hajda , David Airlie , Dmitry Torokhov , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Thomas Zimmermann , linux-input@vger.kernel.org References: <20211117224841.3442482-1-briannorris@chromium.org> <20211117144807.v2.1.I09b516eff75ead160a6582dd557e7e7e900c9e8e@changeid> <20211118123928.545dec8a@eldfell> <20211119115419.505155b5@eldfell> <98236dpcx39iOz8xAYrwGLfiLdwgUlljrbBgHL3wd8A0Wz4KzRk3PR8s_tb5Rxu4eScKI4483kB6Vhv-T64CJYOeQqwXlqo2c-64HvoS5cg=@emersion.fr> <20211122114342.0d23890f@eldfell> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211122114342.0d23890f@eldfell> X-Operating-System: Linux phenom 5.10.0-8-amd64 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_073031_683026_70A07D34 X-CRM114-Status: GOOD ( 42.47 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org On Mon, Nov 22, 2021 at 11:43:42AM +0200, Pekka Paalanen wrote: > On Fri, 19 Nov 2021 17:11:07 +0100 > Daniel Vetter wrote: > > > On Fri, Nov 19, 2021 at 04:04:28PM +0000, Simon Ser wrote: > > > On Friday, November 19th, 2021 at 16:53, Daniel Vetter wrote: > > > > > > > Random idea ... should we perhaps let userspace connect the boosting? I.e. > > > > we do a bunch of standardized boost targets (render clocks, display sr > > > > exit), and userspace can then connect it to whichever input device it > > > > wants to? > > > > > > On IRC we discussed having user-space hand over a FD to the kernel. When the FD > > > becomes readable, the kernel triggers the boost. > > > > > > This would let user-space use e.g. an input device, an eventfd, or an epoll FD > > > with any combination of these as the boost signal. > > > > Can userspace filter eventfd appropriately like we do here? And can they > > get at that maybe 2nd eventfd from logind or whatever there is on distros > > where /dev access is locked down for compositors/users. > > (Mind, eventfd is a specific thing, see 'man eventfd', and evdev/input > device fd is different.) Yeah I was a bit sloppy, but I knew. > I don't think any of that is any problem when userspace prepares an > epoll fd to be given to the boosting machinery. The boosting machinery > could have several different targets as well, PSR vs. GPU clocks and > whatnot. > > I envision a compositor to maintain an epoll fd for boosting by > adding/removing the same device fds to it that it already uses in its > operations. I don't see any need to open new device fds just for > boosting. It's only the epoll fd given to the kernel and after that the > epoll set can still be changed, right? > > The boosting machinery would never actually read or write the > registered fd(s), so it would not interfere with the normal operations. > But it also means the fd will remain readable until userspace services > it. Userspace may need to set up that epoll set very carefully to have > it work right (e.g. edge-triggered?). > > If your input handling is in a different process than the DRM poking > for some reason, the epoll fd should still work if: > - it is possible to use SCM_RIGHTS to pass the epollfd from the > input process to the DRM process, and > - you cannot extract the watched fds from an epoll fd. > > Do we have those assumptions today? > > Then the attack surface in the DRM process is limited to changing the > epoll set of which fds can trigger boosting, but the DRM process can do > that anyway. I also presume the input process can still add and remove > fds from the epoll set even afterwards. > > > I do agree that if we can do this generically maybe we should, but also > > the use-case for input boosting is pretty well defined. I think it's just > > about making sure that compositors is in control, and that we don't make > > it worse (e.g. with the sr exit adding latency when the compositor can > > redraw quickly enough). > > The epollfd design sounds very good to me. One can register an > arbitrary set of fds with it, and use even eventfds in the set to have > purely software triggers. Yeah I think just allowing to internall poll on any arbitrary fd sounds like a neat interface. Userspace should then be able to do whatever it wants to. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip 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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53209C433EF for ; Thu, 25 Nov 2021 15:30:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 486296E86B; Thu, 25 Nov 2021 15:30:33 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DB8A6E86B for ; Thu, 25 Nov 2021 15:30:31 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id o29so5919232wms.2 for ; Thu, 25 Nov 2021 07:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=PEQF6bMcJoShAAAQZkOF5BkWuiwr/n8dHKen+aLofuFtfwvoi1JRGleq7frRxwDwPz dnnd09H6YI8fqa/4VFmNOCorgx79h5Kb8CTaEQBFTgi9u06DecieiPFcyxaALI3u/tie nIGrxVpEgmrjxTTqEkl42sXE71D31J1/kYVeo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=3cuNcRUG8PzQ+50U4e+zXZBAFQ9J5YVVWT3cESWu6+qeDJvpl/o3EiEr2a6XIu1ekz 9TgkFTth7kU4qeEpQ1tx0kjxaXAg7aQ0bfbeYZc6GP9Deb/ALD985b33MmhRwstmjJXE cJ2hbQgQWSgCJ2N/F9X0IMFaWukq73lNUovm/CE3AcJ4e+VlHL2wwkq16aEoYTTJy/FI 6VOf3Pz34aF/RTbiTmYzD2dIG7a/WtcWCjJQTSvva3rk41J4xQ7mN7wgufCXJ/CqH80O T+zKbmt9yZjLBjEfZcYoz92wPM2lpI2HQcrkAJCzvA3oocG1gej7AOIYbPMz2WXxT+Ze qrSA== X-Gm-Message-State: AOAM530HoGXjszCce3IBmhiR8VSWFkFe2Ltr8E6DS1+hIxTIr4pes/Mv LBaguCwElt2jxEFMtTk3E2cwP5A3CdG5tw== X-Google-Smtp-Source: ABdhPJxhA/VhsuDIAS0OWxUiI3i8TAhLLHvv9SkU+3wJwc/Kf9vwByE1Bdg0iWstOjaQzCy5lMbUTQ== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr8313877wmc.58.1637854229881; Thu, 25 Nov 2021 07:30:29 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id p27sm3220547wmi.28.2021.11.25.07.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:30:29 -0800 (PST) Date: Thu, 25 Nov 2021 16:30:27 +0100 From: Daniel Vetter To: Pekka Paalanen Subject: Re: [PATCH v2 1/2] drm/input_helper: Add new input-handling helper Message-ID: Mail-Followup-To: Pekka Paalanen , Simon Ser , Rob Clark , Brian Norris , Andrzej Hajda , David Airlie , Dmitry Torokhov , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Thomas Zimmermann , linux-input@vger.kernel.org References: <20211117224841.3442482-1-briannorris@chromium.org> <20211117144807.v2.1.I09b516eff75ead160a6582dd557e7e7e900c9e8e@changeid> <20211118123928.545dec8a@eldfell> <20211119115419.505155b5@eldfell> <98236dpcx39iOz8xAYrwGLfiLdwgUlljrbBgHL3wd8A0Wz4KzRk3PR8s_tb5Rxu4eScKI4483kB6Vhv-T64CJYOeQqwXlqo2c-64HvoS5cg=@emersion.fr> <20211122114342.0d23890f@eldfell> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211122114342.0d23890f@eldfell> X-Operating-System: Linux phenom 5.10.0-8-amd64 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Dmitry Torokhov , Thomas Zimmermann , David Airlie , Brian Norris , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Andrzej Hajda , linux-input@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Nov 22, 2021 at 11:43:42AM +0200, Pekka Paalanen wrote: > On Fri, 19 Nov 2021 17:11:07 +0100 > Daniel Vetter wrote: > > > On Fri, Nov 19, 2021 at 04:04:28PM +0000, Simon Ser wrote: > > > On Friday, November 19th, 2021 at 16:53, Daniel Vetter wrote: > > > > > > > Random idea ... should we perhaps let userspace connect the boosting? I.e. > > > > we do a bunch of standardized boost targets (render clocks, display sr > > > > exit), and userspace can then connect it to whichever input device it > > > > wants to? > > > > > > On IRC we discussed having user-space hand over a FD to the kernel. When the FD > > > becomes readable, the kernel triggers the boost. > > > > > > This would let user-space use e.g. an input device, an eventfd, or an epoll FD > > > with any combination of these as the boost signal. > > > > Can userspace filter eventfd appropriately like we do here? And can they > > get at that maybe 2nd eventfd from logind or whatever there is on distros > > where /dev access is locked down for compositors/users. > > (Mind, eventfd is a specific thing, see 'man eventfd', and evdev/input > device fd is different.) Yeah I was a bit sloppy, but I knew. > I don't think any of that is any problem when userspace prepares an > epoll fd to be given to the boosting machinery. The boosting machinery > could have several different targets as well, PSR vs. GPU clocks and > whatnot. > > I envision a compositor to maintain an epoll fd for boosting by > adding/removing the same device fds to it that it already uses in its > operations. I don't see any need to open new device fds just for > boosting. It's only the epoll fd given to the kernel and after that the > epoll set can still be changed, right? > > The boosting machinery would never actually read or write the > registered fd(s), so it would not interfere with the normal operations. > But it also means the fd will remain readable until userspace services > it. Userspace may need to set up that epoll set very carefully to have > it work right (e.g. edge-triggered?). > > If your input handling is in a different process than the DRM poking > for some reason, the epoll fd should still work if: > - it is possible to use SCM_RIGHTS to pass the epollfd from the > input process to the DRM process, and > - you cannot extract the watched fds from an epoll fd. > > Do we have those assumptions today? > > Then the attack surface in the DRM process is limited to changing the > epoll set of which fds can trigger boosting, but the DRM process can do > that anyway. I also presume the input process can still add and remove > fds from the epoll set even afterwards. > > > I do agree that if we can do this generically maybe we should, but also > > the use-case for input boosting is pretty well defined. I think it's just > > about making sure that compositors is in control, and that we don't make > > it worse (e.g. with the sr exit adding latency when the compositor can > > redraw quickly enough). > > The epollfd design sounds very good to me. One can register an > arbitrary set of fds with it, and use even eventfds in the set to have > purely software triggers. Yeah I think just allowing to internall poll on any arbitrary fd sounds like a neat interface. Userspace should then be able to do whatever it wants to. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 749DBC433F5 for ; Thu, 25 Nov 2021 15:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241817AbhKYPmz (ORCPT ); Thu, 25 Nov 2021 10:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235890AbhKYPky (ORCPT ); Thu, 25 Nov 2021 10:40:54 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D136C0619E0 for ; Thu, 25 Nov 2021 07:30:31 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id m25-20020a7bcb99000000b0033aa12cdd33so1139884wmi.1 for ; Thu, 25 Nov 2021 07:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=PEQF6bMcJoShAAAQZkOF5BkWuiwr/n8dHKen+aLofuFtfwvoi1JRGleq7frRxwDwPz dnnd09H6YI8fqa/4VFmNOCorgx79h5Kb8CTaEQBFTgi9u06DecieiPFcyxaALI3u/tie nIGrxVpEgmrjxTTqEkl42sXE71D31J1/kYVeo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=mT5CztXXGEVtVu2lf/CwV1g7OPVgRExJfPGlfmMywm0=; b=zyouYSuPOAB7OdyBlYZHnMJQlwpDE/AacUIJ1njmlyb6kmw5L3nrKWUyTW6L+80NH7 JBjuhiSsOxyKizvw+2R06T58a4Q/SNG3v2PjJ1ilcsknSx2mrpoIuJ1+pMxle9MzR6Le eifxKwZ/2XerrXMzIM7PYq+yMemdPe4R1CyWpnspL95Bf6h8Mxhz2xEDJIIVG/T43svd ljmsNSukdXvRjIYixImL73lTa688dBMVVKAPHR4mEbw1aO0r7sKWDt7TVsjVXSF59DMv aXT46/qMYpmOvf/su3GVrbZ/phQN/Dfcj9E2DOdmH4hmja5eLCtvLyfRIO0X79r4C4nV 5/SQ== X-Gm-Message-State: AOAM531ml2FNVFBE6J8Mo8gZA3WdwdmGsYC7gauIv9BEDO3bIVBaeQuz D/OYOf+X3G4l+3Wvw2p3yPy3EQ== X-Google-Smtp-Source: ABdhPJxhA/VhsuDIAS0OWxUiI3i8TAhLLHvv9SkU+3wJwc/Kf9vwByE1Bdg0iWstOjaQzCy5lMbUTQ== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr8313877wmc.58.1637854229881; Thu, 25 Nov 2021 07:30:29 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id p27sm3220547wmi.28.2021.11.25.07.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:30:29 -0800 (PST) Date: Thu, 25 Nov 2021 16:30:27 +0100 From: Daniel Vetter To: Pekka Paalanen Cc: Daniel Vetter , Simon Ser , Rob Clark , Brian Norris , Andrzej Hajda , David Airlie , Dmitry Torokhov , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Thomas Zimmermann , linux-input@vger.kernel.org Subject: Re: [PATCH v2 1/2] drm/input_helper: Add new input-handling helper Message-ID: Mail-Followup-To: Pekka Paalanen , Simon Ser , Rob Clark , Brian Norris , Andrzej Hajda , David Airlie , Dmitry Torokhov , Linux Kernel Mailing List , dri-devel , Doug Anderson , "open list:ARM/Rockchip SoC..." , "Kristian H . Kristensen" , Thomas Zimmermann , linux-input@vger.kernel.org References: <20211117224841.3442482-1-briannorris@chromium.org> <20211117144807.v2.1.I09b516eff75ead160a6582dd557e7e7e900c9e8e@changeid> <20211118123928.545dec8a@eldfell> <20211119115419.505155b5@eldfell> <98236dpcx39iOz8xAYrwGLfiLdwgUlljrbBgHL3wd8A0Wz4KzRk3PR8s_tb5Rxu4eScKI4483kB6Vhv-T64CJYOeQqwXlqo2c-64HvoS5cg=@emersion.fr> <20211122114342.0d23890f@eldfell> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211122114342.0d23890f@eldfell> X-Operating-System: Linux phenom 5.10.0-8-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 22, 2021 at 11:43:42AM +0200, Pekka Paalanen wrote: > On Fri, 19 Nov 2021 17:11:07 +0100 > Daniel Vetter wrote: > > > On Fri, Nov 19, 2021 at 04:04:28PM +0000, Simon Ser wrote: > > > On Friday, November 19th, 2021 at 16:53, Daniel Vetter wrote: > > > > > > > Random idea ... should we perhaps let userspace connect the boosting? I.e. > > > > we do a bunch of standardized boost targets (render clocks, display sr > > > > exit), and userspace can then connect it to whichever input device it > > > > wants to? > > > > > > On IRC we discussed having user-space hand over a FD to the kernel. When the FD > > > becomes readable, the kernel triggers the boost. > > > > > > This would let user-space use e.g. an input device, an eventfd, or an epoll FD > > > with any combination of these as the boost signal. > > > > Can userspace filter eventfd appropriately like we do here? And can they > > get at that maybe 2nd eventfd from logind or whatever there is on distros > > where /dev access is locked down for compositors/users. > > (Mind, eventfd is a specific thing, see 'man eventfd', and evdev/input > device fd is different.) Yeah I was a bit sloppy, but I knew. > I don't think any of that is any problem when userspace prepares an > epoll fd to be given to the boosting machinery. The boosting machinery > could have several different targets as well, PSR vs. GPU clocks and > whatnot. > > I envision a compositor to maintain an epoll fd for boosting by > adding/removing the same device fds to it that it already uses in its > operations. I don't see any need to open new device fds just for > boosting. It's only the epoll fd given to the kernel and after that the > epoll set can still be changed, right? > > The boosting machinery would never actually read or write the > registered fd(s), so it would not interfere with the normal operations. > But it also means the fd will remain readable until userspace services > it. Userspace may need to set up that epoll set very carefully to have > it work right (e.g. edge-triggered?). > > If your input handling is in a different process than the DRM poking > for some reason, the epoll fd should still work if: > - it is possible to use SCM_RIGHTS to pass the epollfd from the > input process to the DRM process, and > - you cannot extract the watched fds from an epoll fd. > > Do we have those assumptions today? > > Then the attack surface in the DRM process is limited to changing the > epoll set of which fds can trigger boosting, but the DRM process can do > that anyway. I also presume the input process can still add and remove > fds from the epoll set even afterwards. > > > I do agree that if we can do this generically maybe we should, but also > > the use-case for input boosting is pretty well defined. I think it's just > > about making sure that compositors is in control, and that we don't make > > it worse (e.g. with the sr exit adding latency when the compositor can > > redraw quickly enough). > > The epollfd design sounds very good to me. One can register an > arbitrary set of fds with it, and use even eventfds in the set to have > purely software triggers. Yeah I think just allowing to internall poll on any arbitrary fd sounds like a neat interface. Userspace should then be able to do whatever it wants to. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch