From patchwork Tue Jun 2 02:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1302021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bb7d2htzz9sSW; Tue, 2 Jun 2020 12:09:01 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jfwMI-0005Ws-91; Tue, 02 Jun 2020 02:08:54 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwMB-0005QW-JR for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:08:47 +0000 Received: from mail-qv1-f70.google.com ([209.85.219.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwMA-0001z9-3H for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:08:46 +0000 Received: by mail-qv1-f70.google.com with SMTP id t11so2076336qvv.11 for ; Mon, 01 Jun 2020 19:08:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rx58XKayY8ULsTbvVQBsCUn2nPEK/mfrBHo/Yk/dWg0=; b=jxcGVTvWax7hM16buKrREU3WcPGN8JRd5exUksTpiNyXzBo9K8/ppF2xtKvIjMZYLI jul7N9lppAcntsaIb+wi3WPAfp5k8ox5htzz6i3HQacGsrAcf5qxeBSIDeAU1IvBQ79w U5bPLBPa0uPNso6Q+pvFI5myFJngdMnlYRPjU7nQnjyyZiGotxdiH/VsLGAOAxeqGbu/ YQeivxI0Hvk1wLagfR/MUfxvaDDMp4zZ2irE3N9eHLshuoePo+GGpzMxSuPnJjlGRsYV o6TsE1RLLRSJPD1WvYdTckByq40HF/90+/kUskxWPvrK92rhLi5nuOoI3pXsI3crVZGF O+sg== X-Gm-Message-State: AOAM532whC6KQ3HM8viAhCLHAuLt9SLO9qlbsegYw1sL06Ctwg+W6jNe pVwmi5xdRil1xEO7WE2zKYrxiPw3Y+KLuUkBhnlz3n2f82c7vTvhT84+pQhJhScTHFvWEOO39jc HGhhxPkBsjDONLcnnYR/tAaZKCmYL7/GrbRTummnF X-Received: by 2002:a37:2e86:: with SMTP id u128mr20387692qkh.26.1591063724724; Mon, 01 Jun 2020 19:08:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWjHnYSjXuMvg0f4upqoR3rCPnUweDUZUibo+9c+Gxju7d6vsI9VDlwv0ubM2Uof+daNpEjA== X-Received: by 2002:a37:2e86:: with SMTP id u128mr20387673qkh.26.1591063724384; Mon, 01 Jun 2020 19:08:44 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id t13sm1138342qtc.77.2020.06.01.19.08.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 19:08:43 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [focal:linux-azure][PATCH 12/21] Input: hyperv-keyboard: Add the support of hibernation Date: Mon, 1 Jun 2020 23:08:08 -0300 Message-Id: <20200602020817.236422-13-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602020817.236422-1-marcelo.cerri@canonical.com> References: <20200602020817.236422-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1880032 Add suspend() and resume() functions so the Hyper-V virtual keyboard can participate in VM hibernation. Note that the keyboard is a "wakeup" device that could abort an in-progress hibernation if there is keyboard event. No attempt is made to suppress this behavior. If desired, a sysadmin can disable the keyboard as a wakeup device using standard mechanisms such as: echo disabled > /sys/bus/vmbus/drivers/hyperv_keyboard/XXX/power/wakeup (where XXX is the device's GUID) Reviewed-by: Michael Kelley Signed-off-by: Dexuan Cui Signed-off-by: Sasha Levin (cherry picked from commit e2379b30324ca5ba808f16cb3d2504349264912f) Signed-off-by: Marcelo Henrique Cerri --- drivers/input/serio/hyperv-keyboard.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/input/serio/hyperv-keyboard.c b/drivers/input/serio/hyperv-keyboard.c index e486a8a74c40..df4e9f6f4529 100644 --- a/drivers/input/serio/hyperv-keyboard.c +++ b/drivers/input/serio/hyperv-keyboard.c @@ -259,6 +259,8 @@ static int hv_kbd_connect_to_vsp(struct hv_device *hv_dev) u32 proto_status; int error; + reinit_completion(&kbd_dev->wait_event); + request = &kbd_dev->protocol_req; memset(request, 0, sizeof(struct synth_kbd_protocol_request)); request->header.type = __cpu_to_le32(SYNTH_KBD_PROTOCOL_REQUEST); @@ -380,6 +382,29 @@ static int hv_kbd_remove(struct hv_device *hv_dev) return 0; } +static int hv_kbd_suspend(struct hv_device *hv_dev) +{ + vmbus_close(hv_dev->channel); + + return 0; +} + +static int hv_kbd_resume(struct hv_device *hv_dev) +{ + int ret; + + ret = vmbus_open(hv_dev->channel, + KBD_VSC_SEND_RING_BUFFER_SIZE, + KBD_VSC_RECV_RING_BUFFER_SIZE, + NULL, 0, + hv_kbd_on_channel_callback, + hv_dev); + if (ret == 0) + ret = hv_kbd_connect_to_vsp(hv_dev); + + return ret; +} + static const struct hv_vmbus_device_id id_table[] = { /* Keyboard guid */ { HV_KBD_GUID, }, @@ -393,6 +418,8 @@ static struct hv_driver hv_kbd_drv = { .id_table = id_table, .probe = hv_kbd_probe, .remove = hv_kbd_remove, + .suspend = hv_kbd_suspend, + .resume = hv_kbd_resume, .driver = { .probe_type = PROBE_PREFER_ASYNCHRONOUS, },