From patchwork Fri Dec 11 07:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11967369 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=-8.9 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 B0B8CC433FE for ; Fri, 11 Dec 2020 07:11:18 +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 566F523F2A for ; Fri, 11 Dec 2020 07:11:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 566F523F2A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=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:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=Altj4Nq/JhITRL/8TbfT9gSNLb32WWryrvhOdodSP8A=; b=H6WNvWoI/hj37tKHryQfeO78M 2bSuQGGm96GxFLsu/qJp0PCl3emcDKfn/KMLciGfHvXr9w6geDPil6/KTblvD9ERcoFP4hMff4n5D 95uWCjJDQjfqTW1MRaGU4ZGfluQPoXWeO62cG7zkmOP765ztklBaVw284N7hzJiV9WFdZE2j4FW3S 1I5NTuYrvT4znrbOmM988l3aV0O3sz09f5dlSjIDDX2z4jkKE9f7BTVKhGOgjtbZpw7HL+VTaZhmh tgmTCoP70bNlAAzEF+6KFMpUGS8Qd20B8Ew5gW2CIjx4snphTrBFwLk3HIsB4OYUuEbqwzRJa74GO dSlU/C9XA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kncYn-0002Gg-F4; Fri, 11 Dec 2020 07:09:49 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kncYl-0002Ft-Ar for linux-arm-kernel@lists.infradead.org; Fri, 11 Dec 2020 07:09:48 +0000 Received: by mail-pg1-x544.google.com with SMTP id 143so418104pge.10 for ; Thu, 10 Dec 2020 23:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=agSZMQdvaCGV7hdnrq9aTuJTFu3GU2xvnWahrOKp2Jc=; b=iaCwlxTDrUkLZaR2IE70DXZlzMvfp14eegDu7lsHhJVqA94v1rPO5Tw4Re0cXWzUs5 tTdmMAeE833iUuG2ImjX+nRar2krQmwfag0rFEsw5K4ZZDSsw9fPPIUx1J2XQU6rwbnH Kz55ev9L7xh0UTnBPP41ch7Fo9bpfKhtijuuRjlbCoQIPm6fHPuAydEfkg/7WaDcnUw2 KrX/PojTaAYfFOJojhEJH0JOWh5+06NYveWE7iDEGwTmJRic5BIrac7SqUas4AAAIZYJ M0gohUFiRGvu59MmoW09LRLN4qrmmTOMEwyEoyc9qQHocn+A30QS9pv/UEmoXPeSjRD6 JYkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=agSZMQdvaCGV7hdnrq9aTuJTFu3GU2xvnWahrOKp2Jc=; b=k9g8X3o+W27dZUD20snLVX0kUtAzS/NGJ7/aV0nSEpmUXBJRrsVxEoi2VLkg9rOjR4 iZqsFj9YYTNXOmqFPzg9mzVs54wAZ6meTZ59/bcYQeWB/0bmbZMflcOe/d7+tWr1LEfW pjYsDq06aXUALGD8AEXzydQf6TKhyrGaoqjsYE6QrQft6rp2jI+hqrsv0tV8pFhuWwoN N3V+VR1+dXHUJdzlVIbUfpxF3PBAFJidhYYMh7MqDX5T6azC5HaugipSb67NFOT8rWUX xF2PbMlQgoHU5XQnk0gXfgYtzB60zC6Iv5YzfCAaTN2dVWyO8UY53FufhMp5ObQbQSH/ zc6Q== X-Gm-Message-State: AOAM530dqdowqIxtS+rOUDo1nQjkHim0wo20yOEg6Cvbk91ncHIPKKdH 5APDn/xjT6Hxsyj/W1MZ+A4= X-Google-Smtp-Source: ABdhPJxv8+WMAsqzX+/A7wLGk5FIrmzTZ6C65bUsZXxoEOBEVQ55NlCjhr48qYKwqGs7+RH4FmPorQ== X-Received: by 2002:a63:4d5c:: with SMTP id n28mr10516947pgl.88.1607670583820; Thu, 10 Dec 2020 23:09:43 -0800 (PST) Received: from google.com ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id j3sm8846830pjs.50.2020.12.10.23.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 23:09:43 -0800 (PST) Date: Thu, 10 Dec 2020 23:09:38 -0800 From: Dmitry Torokhov To: Marek Szyprowski Subject: [PATCH] Input: cyapa - do not call input_device_enabled from power mode handler Message-ID: References: <2336e15d-ff4b-bbb6-c701-dbf3aa110fcd@redhat.com> <20200608112211.12125-1-andrzej.p@collabora.com> <20200608112211.12125-3-andrzej.p@collabora.com> <27ce1176-6318-45aa-4e22-3dec9f3df15d@samsung.com> <9c784a23-eade-eacd-3e67-d344a5758b83@collabora.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201211_020947_430701_509AB8D6 X-CRM114-Status: GOOD ( 19.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@collabora.com, Nick Dyer , linux-iio@vger.kernel.org, platform-driver-x86@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, Laxman Dewangan , Peter Meerwald-Stadler , Peter Hutterer , Fabio Estevam , linux-samsung-soc@vger.kernel.org, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Jonathan Hunter , linux-acpi@vger.kernel.org, Kukjin Kim , NXP Linux Team , linux-input@vger.kernel.org, Len Brown , Michael Hennerich , linux-pm@vger.kernel.org, Sascha Hauer , Sylvain Lemieux , Henrique de Moraes Holschuh , Vladimir Zapolskiy , Hans de Goede , Lars-Peter Clausen , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Barry Song , Ferruh Yigit , patches@opensource.cirrus.com, "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Andrzej Pietrasiewicz , Thierry Reding , Sangwon Jee , Pengutronix Kernel Team , Hartmut Knaack , Shawn Guo , Jonathan Cameron Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Input device's user counter is supposed to be accessed only while holding input->mutex. Commit d69f0a43c677 ("Input: use input_device_enabled()") recently switched cyapa to using the dedicated API and it uncovered the fact that cyapa driver violated this constraint. This patch removes checks whether the input device is open when clearing device queues when changing device's power mode as there is no harm in sending input events through closed input device - the events will simply be dropped by the input core. Note that there are more places in cyapa driver that call input_device_enabled() without holding input->mutex, those are left unfixed for now. Reported-by: Marek Szyprowski Signed-off-by: Dmitry Torokhov --- Marek, could you please try this one? drivers/input/mouse/cyapa_gen3.c | 5 +---- drivers/input/mouse/cyapa_gen5.c | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c index a97f4acb6452..4a9022faf945 100644 --- a/drivers/input/mouse/cyapa_gen3.c +++ b/drivers/input/mouse/cyapa_gen3.c @@ -907,7 +907,6 @@ static u16 cyapa_get_wait_time_for_pwr_cmd(u8 pwr_mode) static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, u16 always_unused, enum cyapa_pm_stage pm_stage) { - struct input_dev *input = cyapa->input; u8 power; int tries; int sleep_time; @@ -953,7 +952,6 @@ static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, * depending on the command's content. */ if (cyapa->operational && - input && input_device_enabled(input) && (pm_stage == CYAPA_PM_RUNTIME_SUSPEND || pm_stage == CYAPA_PM_RUNTIME_RESUME)) { /* Try to polling in 120Hz, read may fail, just ignore it. */ @@ -1223,8 +1221,7 @@ static int cyapa_gen3_try_poll_handler(struct cyapa *cyapa) (data.finger_btn & OP_DATA_VALID) != OP_DATA_VALID) return -EINVAL; - return cyapa_gen3_event_process(cyapa, &data); - + return cyapa->input ? cyapa_gen3_event_process(cyapa, &data) : 0; } static int cyapa_gen3_initialize(struct cyapa *cyapa) { return 0; } diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c index abf42f77b4c5..afc5aa4dcf47 100644 --- a/drivers/input/mouse/cyapa_gen5.c +++ b/drivers/input/mouse/cyapa_gen5.c @@ -518,8 +518,7 @@ int cyapa_empty_pip_output_data(struct cyapa *cyapa, *len = length; /* Response found, success. */ return 0; - } else if (cyapa->operational && - input && input_device_enabled(input) && + } else if (cyapa->operational && input && (pm_stage == CYAPA_PM_RUNTIME_RESUME || pm_stage == CYAPA_PM_RUNTIME_SUSPEND)) { /* Parse the data and report it if it's valid. */