From patchwork Thu Mar 9 22:16:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9614253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A361B60417 for ; Thu, 9 Mar 2017 22:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92288286D7 for ; Thu, 9 Mar 2017 22:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8736B286DC; Thu, 9 Mar 2017 22:19:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40177286D7 for ; Thu, 9 Mar 2017 22:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753848AbdCIWSq (ORCPT ); Thu, 9 Mar 2017 17:18:46 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33129 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753110AbdCIWRF (ORCPT ); Thu, 9 Mar 2017 17:17:05 -0500 Received: by mail-pf0-f194.google.com with SMTP id v190so8593055pfb.0; Thu, 09 Mar 2017 14:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NP7acrtQ2Y/IdY3BCbVeA12NPLfoAs+tahyuJtvSLlw=; b=nRp4zjeJ16uiUh+F1GbIguswE2MBqHVxZk8ixx42Fmx2c7+Awo+UUZToSKD4INsMTy LC1RM2xfptk6yWys3uyvwv2pNvfvn8BxPF1G5FNnb85wVnP4Y4XK5jNNEIPvVfOLb7+p wfl0IEht/oAlHDmdxADpfFJMj+fhxj5KbzbZc+SB18EhjzlIQA9/jMGm6MVxxqec6W1J J+hDGMyCm/uye4spFEGAV5NNAxqw/JlQe28daCUkZHJ6V0BWhdgWkYx03AC+lp7YlU9M k0YqcCt0hlNt9kZBSIzMvs1zASzewN2I4S+OWY/+Kr6zcxf1rgzDXbISjF3Rwk9h9vSN RGow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NP7acrtQ2Y/IdY3BCbVeA12NPLfoAs+tahyuJtvSLlw=; b=lUjiCLoij98OdsWspmyWDRpmiBJut/tZKH01n87/gyMlwxeH92N4Ov5fGaHxe1hoVz AEFM9arKP7uAlJgZkrl5nEVIeA2M0sXSXfCbZHCPmex9dpHcT4iFfNNC9CmUwOe6o0/G S21dui54+U+hnZmXjshsRI/0dZ6A6tgRwDAqP412POqEKNSR9BEFT7B3S+UIKNzG8IFs h0IdHo5oZBNasrA/A0fSj/Q/K2N8QkJ+5ATe4BBRPunXyVecHDeeHJey3APdqPReLpfZ PysnJwTa0v6sCgM6VcwCTp2XWq3gppTO8yimCovtipezGm+/TQVTE7RBWbAgdeS3ZFuL 745Q== X-Gm-Message-State: AMke39myn4bBpCHm0fs4f1GJm2ZqO2/hRo/2tI9kNUkmFkIkuT+ubqErRXEyxQWypdHQgQ== X-Received: by 10.99.9.65 with SMTP id 62mr16428887pgj.22.1489097808883; Thu, 09 Mar 2017 14:16:48 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id 15sm14439676pgh.21.2017.03.09.14.16.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 14:16:48 -0800 (PST) From: Dmitry Torokhov To: Benjamin Tissoires Cc: Andrew Duggan , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH 2/8] Input: serio - add fast reconnect option Date: Thu, 9 Mar 2017 14:16:38 -0800 Message-Id: <20170309221644.17035-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170309221644.17035-1-dmitry.torokhov@gmail.com> References: <20170309221644.17035-1-dmitry.torokhov@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Devices connected to serio bus are quite slow, and to improve apparent speed of resume process, serio core resumes (reconnects) its devices asynchronously, by posting port reconnect requests to a workqueue. Unfortunately this means that if there is a dependent device of a given serio port (for example SMBus part of touchpad connected via both PS/2 and SMBus), we do not have a good way of ensuring resume order. This change allows drivers to define "fast reconnect" handlers that would be called in-line during system resume. Drivers need to ensure that these handlers are truly "fast". Signed-off-by: Dmitry Torokhov --- drivers/input/serio/serio.c | 22 +++++++++++++++++----- include/linux/serio.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 1ca7f551e2da..34793ce2df91 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -953,12 +953,24 @@ static int serio_suspend(struct device *dev) static int serio_resume(struct device *dev) { struct serio *serio = to_serio_port(dev); + int error = -ENOENT; - /* - * Driver reconnect can take a while, so better let kseriod - * deal with it. - */ - serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); + mutex_lock(&serio->drv_mutex); + if (serio->drv && serio->drv->fast_reconnect) { + error = serio->drv->fast_reconnect(serio); + if (error && error != -ENOENT) + dev_warn(dev, "fast reconnect failed with error %d\n", + error); + } + mutex_unlock(&serio->drv_mutex); + + if (error) { + /* + * Driver reconnect can take a while, so better let + * kseriod deal with it. + */ + serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); + } return 0; } diff --git a/include/linux/serio.h b/include/linux/serio.h index c733cff44e18..138a5efe863a 100644 --- a/include/linux/serio.h +++ b/include/linux/serio.h @@ -77,6 +77,7 @@ struct serio_driver { irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int); int (*connect)(struct serio *, struct serio_driver *drv); int (*reconnect)(struct serio *); + int (*fast_reconnect)(struct serio *); void (*disconnect)(struct serio *); void (*cleanup)(struct serio *);