Received: by 10.192.165.156 with SMTP id m28csp341350imm; Mon, 16 Apr 2018 00:37:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/iVJck+yWOzNH5PB1jJFgANmDYuZpM1TsqsW9gSjIgednvzexLPQF+VwSNr+RrWA2sr6/ X-Received: by 10.99.95.130 with SMTP id t124mr8684602pgb.150.1523864273540; Mon, 16 Apr 2018 00:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523864273; cv=none; d=google.com; s=arc-20160816; b=bK96hscuKlJrGOJdECPE//HORNqmU0+YHJ56vD91RjItdyTVvvwPOkkcRx9EneCBIO LO/utiBK2lQyOXEDD8qKW1Fmr6bt/4Wm7Ew1fmX+dPFvBgtJuyzeh89gtkPRgZU23/qJ 2AbVwQsJrJgISj12lTtJL48IlCYb+a5X7Sr8dMloSdT973wvXmY/fme/EElbTD0Qf8pC 7HqJLoyt/lyWG2DcmcoNmx9lXvQkhb5HqnkCQsDkZzmDf8H73qNx7BXq/2nYflYotlUq nPxyexO3z56wKJkp8UXJiGADEd/7NsPM9VO6Yb08uVMWn248sc/wpQlf2AN1mFZtPS0W g25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=G57HoDinJJB3uV6GhdAsAyhf+Gd4xXxOsVMwWYByVw0=; b=gOpAhhLF5Ae03hsVLKK5dVDhyTtyBCfXzPyvggC/ggQf+N6usPH2ui3+qd/gT1XLmf azMVz5pgWYX0adKWSsrSpvmbSGkuiwb5qvVicaDDaAGJGBDm1YECekYOQ/7nS6vvWsY2 7gNm0EC8+VwovHu6H89be5YNKusSpv5zPQSjICev78lyCIcLpExHRGLscmkig7S0FgJK JOE2IaNCjGHbF6VOlPQruAmCifT4NvIJIvbf38TniSKkK3EBJyZND0Di3QK5IJGH/i5A 5Uc4qOE48BtYh3L5pxl817jn6fv3X5mX8K932WFENURfrIecfeZz3To1eka7oPR9yalj ogLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TlPDrPOB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si2418489pga.128.2018.04.16.00.37.09; Mon, 16 Apr 2018 00:37:53 -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=@samsung.com header.s=mail20170921 header.b=TlPDrPOB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753956AbeDPHTc (ORCPT + 99 others); Mon, 16 Apr 2018 03:19:32 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:38722 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbeDPHT3 (ORCPT ); Mon, 16 Apr 2018 03:19:29 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180416071927euoutp02a22b0aa90f8957bdef4e76dca3895815~l2XoKF2GU0359703597euoutp02r; Mon, 16 Apr 2018 07:19:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180416071927euoutp02a22b0aa90f8957bdef4e76dca3895815~l2XoKF2GU0359703597euoutp02r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523863167; bh=G57HoDinJJB3uV6GhdAsAyhf+Gd4xXxOsVMwWYByVw0=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=TlPDrPOBNBInGtRLI8nMgq5zRLsnKBuFMrhiZ+ghIc0sELcTmJakjAsMeYP8J5Gao 5nKZbu2jbGFy8agiy11cePktwzw32wZ5/bUw1+kQXI4fwbUL14rCcNWNHzG07K+22Z PJj5qSlKQykouBUw3dlYP/WRSF+JzEIovwhto92w= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180416071926eucas1p27f17a1de3fa509173603bc67d45fa78e~l2XnNT0rP2860328603eucas1p2G; Mon, 16 Apr 2018 07:19:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F8.83.17380.D7E44DA5; Mon, 16 Apr 2018 08:19:25 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180416071925eucas1p20d61ccf3173617be9363716561f93fb3~l2XmOlDp21216312163eucas1p2I; Mon, 16 Apr 2018 07:19:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180416071924eusmtrp1698d23867b6c27d7fa09fc5c12c7edaf~l2Xl84yyg2287422874eusmtrp1h; Mon, 16 Apr 2018 07:19:24 +0000 (GMT) X-AuditID: cbfec7f4-713ff700000043e4-3b-5ad44e7d0728 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C0.10.04178.C7E44DA5; Mon, 16 Apr 2018 08:19:24 +0100 (BST) Received: from [106.120.43.17] (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180416071923eusmtip1f481c0bb1370163d2c1453b3b6737b29~l2XkoZW8R0877708777eusmtip1e; Mon, 16 Apr 2018 07:19:23 +0000 (GMT) Subject: Re: [PATCH v6 24/30] drm/rockchip: Disable PSR on input events To: Enric Balletbo i Serra , architt@codeaurora.org, inki.dae@samsung.com, thierry.reding@gmail.com, hjc@rock-chips.com, seanpaul@chromium.org, airlied@linux.ie, tfiga@chromium.org, heiko@sntech.de Cc: dri-devel@lists.freedesktop.org, dianders@chromium.org, ykk@rock-chips.com, kernel@collabora.com, m.szyprowski@samsung.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, rydberg@bitmath.org, krzk@kernel.org, linux-rockchip@lists.infradead.org, kgene@kernel.org, linux-input@vger.kernel.org, orjan.eide@arm.com, wxt@rock-chips.com, jeffy.chen@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, wzz@rock-chips.com, hl@rock-chips.com, jingoohan1@gmail.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, Laurent.pinchart@ideasonboard.com, kuankuan.y@gmail.com, hshi@chromium.org, "Kristian H. Kristensen" , Dmitry Torokhov , "linux-input@vger.kernel.org" From: Andrzej Hajda Message-ID: <20d2aa03-63e3-0072-5ca7-5f3ca42c3c9e@samsung.com> Date: Mon, 16 Apr 2018 09:19:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180405095000.9756-25-enric.balletbo@collabora.com> Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA02Tf1DTdRjH7/P9ue0YfZzQPlFX14w7rHDN6/K5DO3Ku75lZ51dnoeVLfyG JgxvE8k8gqbxSwEFFTZsehwiR1i0kSw80Ea5lMZkMxVzQUqGrGW3MYqLH7F99eK/1/Pr/X6e Px4ZrRrnUmRbDNtFo0Gfo+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y8PnKiU+bv36dPfRBSc9A WfaWmd90+pmLK6r1Ha+y8wY9ff6uC814/fDr5fkRny1s+26795/eRTWeD7WUkikJq0mzIv0P l2LlGZwDAAA= X-CMS-MailID: 20180416071925eucas1p20d61ccf3173617be9363716561f93fb3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180416071925eucas1p20d61ccf3173617be9363716561f93fb3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180405095330epcas1p33487d73838f08a65ce7935f0d3e8b9e4 X-RootMTR: 20180405095330epcas1p33487d73838f08a65ce7935f0d3e8b9e4 References: <20180405095000.9756-1-enric.balletbo@collabora.com> <20180405095000.9756-25-enric.balletbo@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +CC: linux-input list and maintainer On 05.04.2018 11:49, Enric Balletbo i Serra wrote: > From: "Kristian H. Kristensen" > > To improve PSR exit latency, we speculatively start exiting when we > receive input events. Occasionally, this may lead to false positives, > but most of the time we get a head start on coming out of PSR. Depending > on how userspace takes to produce a new frame in response to the event, > this can completely hide the exit latency. In case of Chrome OS, we > typically get the input notifier 50ms or more before the dirty_fb > triggered exit. As I see from the code below, you just need notification from input subsystem on user activity. Maybe there is some simpler notification mechanism for such things? If not, maybe such helper should be created in input subsystem, I suppose it could be reused in other places as well. Regards Andrzej > > Signed-off-by: Kristian H. Kristensen > Signed-off-by: Thierry Escande > Signed-off-by: Enric Balletbo i Serra > Tested-by: Marek Szyprowski > --- > > drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 134 ++++++++++++++++++++++++++++ > 1 file changed, 134 insertions(+) > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c > index 9376f4396b6b..a107845ba97c 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c > @@ -12,6 +12,8 @@ > * GNU General Public License for more details. > */ > > +#include > + > #include > #include > > @@ -35,6 +37,9 @@ struct psr_drv { > enum psr_state state; > > struct delayed_work flush_work; > + struct work_struct disable_work; > + > + struct input_handler input_handler; > > int (*set)(struct drm_encoder *encoder, bool enable); > }; > @@ -133,6 +138,18 @@ static void psr_flush_handler(struct work_struct *work) > mutex_unlock(&psr->lock); > } > > +static void psr_disable_handler(struct work_struct *work) > +{ > + struct psr_drv *psr = container_of(work, struct psr_drv, disable_work); > + > + /* If the state has changed since we initiated the flush, do nothing */ > + mutex_lock(&psr->lock); > + if (psr->state == PSR_ENABLE) > + psr_set_state_locked(psr, PSR_FLUSH); > + mutex_unlock(&psr->lock); > + mod_delayed_work(system_wq, &psr->flush_work, PSR_FLUSH_TIMEOUT_MS); > +} > + > /** > * rockchip_drm_psr_activate - activate PSR on the given pipe > * @encoder: encoder to obtain the PSR encoder > @@ -173,6 +190,7 @@ int rockchip_drm_psr_deactivate(struct drm_encoder *encoder) > psr->active = false; > mutex_unlock(&psr->lock); > cancel_delayed_work_sync(&psr->flush_work); > + cancel_work_sync(&psr->disable_work); > > return 0; > } > @@ -226,6 +244,95 @@ void rockchip_drm_psr_flush_all(struct drm_device *dev) > } > EXPORT_SYMBOL(rockchip_drm_psr_flush_all); > > +static void psr_input_event(struct input_handle *handle, > + unsigned int type, unsigned int code, > + int value) > +{ > + struct psr_drv *psr = handle->handler->private; > + > + schedule_work(&psr->disable_work); > +} > + > +static int psr_input_connect(struct input_handler *handler, > + struct input_dev *dev, > + const struct input_device_id *id) > +{ > + struct input_handle *handle; > + int error; > + > + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); > + if (!handle) > + return -ENOMEM; > + > + handle->dev = dev; > + handle->handler = handler; > + handle->name = "rockchip-psr"; > + > + error = input_register_handle(handle); > + if (error) > + goto err2; > + > + error = input_open_device(handle); > + if (error) > + goto err1; > + > + return 0; > + > +err1: > + input_unregister_handle(handle); > +err2: > + kfree(handle); > + return error; > +} > + > +static void psr_input_disconnect(struct input_handle *handle) > +{ > + input_close_device(handle); > + input_unregister_handle(handle); > + kfree(handle); > +} > + > +/* Same device ids as cpu-boost */ > +static const struct input_device_id psr_ids[] = { > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT | > + INPUT_DEVICE_ID_MATCH_ABSBIT, > + .evbit = { BIT_MASK(EV_ABS) }, > + .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] = > + BIT_MASK(ABS_MT_POSITION_X) | > + BIT_MASK(ABS_MT_POSITION_Y) }, > + }, /* multi-touch touchscreen */ > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT, > + .evbit = { BIT_MASK(EV_ABS) }, > + .absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) } > + > + }, /* stylus or joystick device */ > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT, > + .evbit = { BIT_MASK(EV_KEY) }, > + .keybit = { [BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) }, > + }, /* pointer (e.g. trackpad, mouse) */ > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT, > + .evbit = { BIT_MASK(EV_KEY) }, > + .keybit = { [BIT_WORD(KEY_ESC)] = BIT_MASK(KEY_ESC) }, > + }, /* keyboard */ > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT | > + INPUT_DEVICE_ID_MATCH_KEYBIT, > + .evbit = { BIT_MASK(EV_KEY) }, > + .keybit = {[BIT_WORD(BTN_JOYSTICK)] = BIT_MASK(BTN_JOYSTICK) }, > + }, /* joysticks not caught by ABS_X above */ > + { > + .flags = INPUT_DEVICE_ID_MATCH_EVBIT | > + INPUT_DEVICE_ID_MATCH_KEYBIT, > + .evbit = { BIT_MASK(EV_KEY) }, > + .keybit = { [BIT_WORD(BTN_GAMEPAD)] = BIT_MASK(BTN_GAMEPAD) }, > + }, /* gamepad */ > + { }, > +}; > + > /** > * rockchip_drm_psr_register - register encoder to psr driver > * @encoder: encoder that obtain the PSR function > @@ -239,6 +346,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, > { > struct rockchip_drm_private *drm_drv = encoder->dev->dev_private; > struct psr_drv *psr; > + int error; > > if (!encoder || !psr_set) > return -EINVAL; > @@ -248,6 +356,7 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, > return -ENOMEM; > > INIT_DELAYED_WORK(&psr->flush_work, psr_flush_handler); > + INIT_WORK(&psr->disable_work, psr_disable_handler); > mutex_init(&psr->lock); > > psr->active = true; > @@ -255,11 +364,33 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, > psr->encoder = encoder; > psr->set = psr_set; > > + psr->input_handler.event = psr_input_event; > + psr->input_handler.connect = psr_input_connect; > + psr->input_handler.disconnect = psr_input_disconnect; > + psr->input_handler.name = > + kasprintf(GFP_KERNEL, "rockchip-psr-%s", encoder->name); > + if (!psr->input_handler.name) { > + error = -ENOMEM; > + goto err2; > + } > + psr->input_handler.id_table = psr_ids; > + psr->input_handler.private = psr; > + > + error = input_register_handler(&psr->input_handler); > + if (error) > + goto err1; > + > mutex_lock(&drm_drv->psr_list_lock); > list_add_tail(&psr->list, &drm_drv->psr_list); > mutex_unlock(&drm_drv->psr_list_lock); > > return 0; > + > + err1: > + kfree(psr->input_handler.name); > + err2: > + kfree(psr); > + return error; > } > EXPORT_SYMBOL(rockchip_drm_psr_register); > > @@ -279,8 +410,11 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder) > mutex_lock(&drm_drv->psr_list_lock); > list_for_each_entry_safe(psr, n, &drm_drv->psr_list, list) { > if (psr->encoder == encoder) { > + input_unregister_handler(&psr->input_handler); > cancel_delayed_work_sync(&psr->flush_work); > + cancel_work_sync(&psr->disable_work); > list_del(&psr->list); > + kfree(psr->input_handler.name); > kfree(psr); > } > }