From patchwork Mon Mar 20 00:22:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9632951 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 421A960249 for ; Mon, 20 Mar 2017 00:24:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 351F327FAC for ; Mon, 20 Mar 2017 00:24:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 272EB2807E; Mon, 20 Mar 2017 00:24:37 +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 C7F2C27FAC for ; Mon, 20 Mar 2017 00:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbdCTAWk (ORCPT ); Sun, 19 Mar 2017 20:22:40 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36379 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752718AbdCTAWg (ORCPT ); Sun, 19 Mar 2017 20:22:36 -0400 Received: by mail-pg0-f67.google.com with SMTP id 81so9109839pgh.3; Sun, 19 Mar 2017 17:22:36 -0700 (PDT) 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=KlOhK4ElPpDrCRSD0vuRoB7M9FSiPBeS1Ew17N4WKf4=; b=q9uHrOP2uugdFOqYNGT47VsPGqkc+M2JtWWE/uPvxYPfgrmP69wLhhf3ucbjfM6awC MSR/gh2s5ekaRTAju/M3n7UtrotwxvpM9PTU0cWNblMFU9k8tYOT3D279z0B1jmQZKUR 3oRuB3lrACtstcHz7ygCYwh0sTHnYNDps1LR7IUjoCWCrxxsu+CKm/k07/jB9ZoUDg63 UJ+jBsy2H1NmITKFE/Lgv3cz1mVKEoAdl9hK/WgfdI79l48TZCOQZ9eUsyvdvsawmLT2 c0Va/iO9LhCh7BHYmcZ66jQj4Ogxq31NNdB9FD7GUKrOW6G9rYxZVI7FBtalsgxT5skV o/EQ== 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=KlOhK4ElPpDrCRSD0vuRoB7M9FSiPBeS1Ew17N4WKf4=; b=E0Ipuol5qFRpXTzaC/5EHMfsmdXjZlpryExaJLWsVQnnInNnydYsYGbzOpWiOiQlNl sqyxx1k6mm/B4i4sgEXSOQBm18PBUMzVn2ZUMxFvZLLU2KaZ/7p8oxFtIkaNRXrHfF1u 6RPv1eSF0zotpqe/DafgKmL8hdiRzwhjsuuQnpxGNKlbHo51XMo3IxHgbjGxyD8PRh6A jNq/qcS6LjLZ41v1VSHZMhBicRLB/bUOA5RvowhO9vA14nYHwRvbpN5ZmL63z/Ff6zwu YN552wukVYC9fAEYYzZBXkWIg+gudqUf5tpvch4imProuipwUNRulLfupXlbPjNrEZFi Hj1w== X-Gm-Message-State: AFeK/H10qXeZvEIrGkTIX1zyjCIOrzpwbOq0+qvhC7KAq04GRn9By6evFLqhvfslq5DadA== X-Received: by 10.84.236.2 with SMTP id q2mr11520314plk.157.1489969355593; Sun, 19 Mar 2017 17:22:35 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id n185sm29134460pga.9.2017.03.19.17.22.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Mar 2017 17:22:35 -0700 (PDT) From: Dmitry Torokhov To: Benjamin Tissoires Cc: Andrew Duggan , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 2/9] Input: serio - add fast reconnect option Date: Sun, 19 Mar 2017 17:22:24 -0700 Message-Id: <20170320002231.31152-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.0.367.g23dc2f6d3c-goog In-Reply-To: <20170320002231.31152-1-dmitry.torokhov@gmail.com> References: <20170320002231.31152-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". Reviewed-by: Benjamin Tissoires 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 048ae748c4d1..30d6230d48f7 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 *);