From patchwork Wed Aug 17 08:51:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=hPiMWC/K; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71wx615Cz1ygg for ; Wed, 17 Aug 2022 18:52:16 +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 1oOEmR-0000Lu-Hu; Wed, 17 Aug 2022 08:52:03 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmM-0000K8-Ta for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:51:58 +0000 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6D0173FBA1 for ; Wed, 17 Aug 2022 08:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726318; bh=XWSX6PSGmLemeA83Vblhx7g43vrVJPth/jBHwmHNEMk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hPiMWC/KXKr4so1iISlIW7fwspw4u/SrcDz3j/WjahDgG+S54dD/GeQvJ6kRmkUOI m25hKGUXwm5lJzUS83rhbm8rqaqWkTHF0kTxwTMXpFM5NhR7J6day/63k7mmiiOiNe 5bK53jOh8gjlOhnEymiYuQit4kUywVkssURMKWW59VlUoy4bgQQRf365RpVZkVwZ5J pkdV0mnDbvNyInj80wpEeQO5I6XarzW6m5F942FCF1v5gfZ8S3rco1zDukfjYuEQ9t IKs7xojDma9jZ1+YWWZX8AnxBV20LWFhQzKk8LoIGzn9L4xi7cGiL/zPDFRdfEhJ1L o/zW8u4dAUQwA== Received: by mail-pj1-f70.google.com with SMTP id o18-20020a17090aac1200b001f3252af009so853338pjq.7 for ; Wed, 17 Aug 2022 01:51:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=XWSX6PSGmLemeA83Vblhx7g43vrVJPth/jBHwmHNEMk=; b=YduBrDf4yX1y6slAsltey40AU8uznm0vfAOrpzSYoQJRinNHyhUu5m4pZthIV10Qa8 VQBbxpehSaIGxNcJbK/5quoOqrgiMxcX6vc+beXUxHcg2Lf2oe7S5NcjsdnRq4xdjewB CacQIqDh2FST9C/WEdRPjCrfceATDDYDRVBjJh9+19FtSpRgt6sXrtCa1rf5AvC9gCUI czMmncSk4suKwtUIabWvlRDtkH+Iod3wFJ/vnCiBgB2g5VLQaaE7ciLSqoSykx2Pigz2 ss2ylNtEADAp6sKnzoxU8c85uZ2KMvuDGF+0K90q5/IpVBvobMrQ3ER1QCoTy/elsPw3 ihoQ== X-Gm-Message-State: ACgBeo3b/Mw2Df/8csXCYwEXh5VZ5wqeWQcKT4uyQbKkRlXt9T9pTrZj eI2ThzF9E3rQStzeNqmr1Gyqyqs5Xj2zss0zAhiFX4JANbNOb4xkgvP4Uh2JeGeZk+p8QUWnStG FT3aKEHeBJ9HOTCN0sHiOcnuO2w9inXEPekHoY3pU+Q== X-Received: by 2002:a63:904b:0:b0:41c:227d:3781 with SMTP id a72-20020a63904b000000b0041c227d3781mr20813782pge.368.1660726316663; Wed, 17 Aug 2022 01:51:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Mc/7s9MCQUbWzoXyVOrMTujyh3LscgxcEn/axrouJfEOlJulXCZlKpsSol2I7iShSJspzeQ== X-Received: by 2002:a63:904b:0:b0:41c:227d:3781 with SMTP id a72-20020a63904b000000b0041c227d3781mr20813758pge.368.1660726316208; Wed, 17 Aug 2022 01:51:56 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.51.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:51:55 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 01/20] UBUNTU: SAUCE: xen/manage: keep track of the on-going suspend mode Date: Wed, 17 Aug 2022 16:51:27 +0800 Message-Id: <20220817085150.2078055-2-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 To differentiate between Xen suspend, PM suspend and PM hibernation, keep track of the on-going suspend mode by mainly using a new PM notifier. Since Xen suspend doesn't have corresponding PM event, its main logic is modfied to acquire pm_mutex and set the current mode. Note that we may see deadlock if PM suspend/hibernation is interrupted by Xen suspend. PM suspend/hibernation depends on xenwatch thread to process xenbus state transactions, but the thread will sleep to wait pm_mutex which is already held by PM suspend/hibernation context in the scenario. Though, acquirng pm_mutex is still right thing to do, and we would need to modify Xen shutdown code to avoid the issue. This will be fixed by a separate patch. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Sebastian Biemueller Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273194/ (cherry picked from commit cd6c8a67a4767b174210d41b4c6c7cc28dd23849 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/manage.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 374d36de7f5a..63abb3ab09af 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,16 @@ enum shutdown_state { /* Ignore multiple shutdown requests. */ static enum shutdown_state shutting_down = SHUTDOWN_INVALID; +enum suspend_modes { + NO_SUSPEND = 0, + XEN_SUSPEND, + PM_SUSPEND, + PM_HIBERNATION, +}; + +/* Protected by pm_mutex */ +static enum suspend_modes suspend_mode = NO_SUSPEND; + struct suspend_info { int cancelled; }; @@ -99,6 +110,10 @@ static void do_suspend(void) int err; struct suspend_info si; + lock_system_sleep(); + + suspend_mode = XEN_SUSPEND; + shutting_down = SHUTDOWN_SUSPEND; err = freeze_processes(); @@ -162,6 +177,10 @@ static void do_suspend(void) thaw_processes(); out: shutting_down = SHUTDOWN_INVALID; + + suspend_mode = NO_SUSPEND; + + unlock_system_sleep(); } #endif /* CONFIG_HIBERNATE_CALLBACKS */ @@ -388,3 +407,42 @@ int xen_setup_shutdown_event(void) EXPORT_SYMBOL_GPL(xen_setup_shutdown_event); subsys_initcall(xen_setup_shutdown_event); + +static int xen_pm_notifier(struct notifier_block *notifier, + unsigned long pm_event, void *unused) +{ + switch (pm_event) { + case PM_SUSPEND_PREPARE: + suspend_mode = PM_SUSPEND; + break; + case PM_HIBERNATION_PREPARE: + case PM_RESTORE_PREPARE: + suspend_mode = PM_HIBERNATION; + break; + case PM_POST_SUSPEND: + case PM_POST_RESTORE: + case PM_POST_HIBERNATION: + /* Set back to the default */ + suspend_mode = NO_SUSPEND; + break; + default: + pr_warn("Receive unknown PM event 0x%lx\n", pm_event); + return -EINVAL; + } + + return 0; +}; + +static struct notifier_block xen_pm_notifier_block = { + .notifier_call = xen_pm_notifier +}; + +static int xen_setup_pm_notifier(void) +{ + if (!xen_hvm_domain()) + return -ENODEV; + + return register_pm_notifier(&xen_pm_notifier_block); +} + +subsys_initcall(xen_setup_pm_notifier); From patchwork Wed Aug 17 08:51:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OYGZhWht; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71wy0VCSz1ygh for ; Wed, 17 Aug 2022 18:52:17 +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 1oOEmQ-0000LT-AD; Wed, 17 Aug 2022 08:52:02 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmO-0000KS-KK for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:00 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 57EFB3FB94 for ; Wed, 17 Aug 2022 08:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726320; bh=r3BEiPbrJJ1N0xQ3NMCHgclyjQmPAQDUd8I7WMm3U2E=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OYGZhWhtUQx6U6DmdRivOzU7yxvqWhCeO7WKwJdIryShRdlz2IhpDEYRyVsMgIm/j yYmd88iiPPgF4HKkKDvcNw8OmfjigYUjgb6AtVyfG7IEhNLWSuX1dobr2Sebaa3mz9 Y9hnoc6GAUP42ohoYg6K/MkvdLAp+1GjnsiFDOG5LxtrjXmTv2fweRHSZFKAx6gUa5 szkrQtwBPugtzk5Qt+PiXcvJ/6Iw1cGNGxSLzl0qfH8rnsfJ0xkjzvnXrYIlxdtZyY hvOb0vE9MjN4JU00MNspX1oxzFJAxjiNMArOlIBknyB2KX06rrUZOvDcKA852nAS/F I2fLM1zmjVcbA== Received: by mail-pj1-f72.google.com with SMTP id u2-20020a17090a2b8200b001f74f05c1a7so5208821pjd.2 for ; Wed, 17 Aug 2022 01:52:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=r3BEiPbrJJ1N0xQ3NMCHgclyjQmPAQDUd8I7WMm3U2E=; b=M825HNZCsr+4M2gwFj1dwmJS1fTJdO1yuTlILmhc37qdHcokOzgTxk3VfuJYgAftqx udO3mONZQQhe+cb6CtxK1MyAjZXLUAznZBJe52K2fTbU2Syw5M8bVfPx5UAF4DmH1Jc6 MeWnO4wnhTU8W0NMWCN4/CJm6amAI6SRnmkh7IfCutpQMY8OwwL3NDxSbVdU2V8oLcxa RkX4wAuwzQo/cq0JsMtktsd0osjy8TnVDQjIva6kCIjcJXUc4+4tjeNDh96ZvFaYkK5N HxC9WuleNQTAlFL69N3Ifa533JcjMnivslSuoLku+E7Y1KmKr6OTwgcnvNi3UPoN5DlY ugAA== X-Gm-Message-State: ACgBeo2n9mGvdzQ5scq5Mq3JQ2YbQQ0ltu+jqUCqyUvBOhRUSkeeqyaF 3nZSJIizx384UuAjJOtnZIu4+1Aluo10L7gVmtFc3L+LpGYPOCgm+BJz5YmrM+orzEy2ClD4hqB tRguKkN8iaH50mtxO48K3kB2MxAX7USYiBKDInZCC1g== X-Received: by 2002:a63:8848:0:b0:41c:45da:2db9 with SMTP id l69-20020a638848000000b0041c45da2db9mr20569921pgd.206.1660726318769; Wed, 17 Aug 2022 01:51:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR763RPysMUWr/SIjQ2qWvy3QBKRNSJXqT9FMo5GHKmQPqybwYViT0WbVQvB/E4Vkbekz+rZLQ== X-Received: by 2002:a63:8848:0:b0:41c:45da:2db9 with SMTP id l69-20020a638848000000b0041c45da2db9mr20569913pgd.206.1660726318404; Wed, 17 Aug 2022 01:51:58 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.51.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:51:58 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][kinetic/linux-aws][PATCH 02/20] UBUNTU: SAUCE: xen/manage: introduce helper function to know the on-going suspend mode Date: Wed, 17 Aug 2022 16:51:29 +0800 Message-Id: <20220817085150.2078055-4-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Introduce simple functions which help to know the on-going suspend mode so that other Xen-related code can behave differently according to the current suspend mode. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Alakesh Haloi Reviewed-by: Sebastian Biemueller Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273190/ (cherry picked from commit 7d04745f53231fcfc934cea2b5ef3cf4f80fb7d4 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/manage.c | 15 +++++++++++++++ include/xen/xen-ops.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 5e5bf218f9a7..82e46ff87699 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -51,6 +51,21 @@ enum suspend_modes { /* Protected by pm_mutex */ static enum suspend_modes suspend_mode = NO_SUSPEND; +bool xen_suspend_mode_is_xen_suspend(void) +{ + return suspend_mode == XEN_SUSPEND; +} + +bool xen_suspend_mode_is_pm_suspend(void) +{ + return suspend_mode == PM_SUSPEND; +} + +bool xen_suspend_mode_is_pm_hibernation(void) +{ + return suspend_mode == PM_HIBERNATION; +} + struct suspend_info { int cancelled; }; diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index 80546960f8b7..d37328f2af0f 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -40,6 +40,10 @@ u64 xen_steal_clock(int cpu); int xen_setup_shutdown_event(void); +bool xen_suspend_mode_is_xen_suspend(void); +bool xen_suspend_mode_is_pm_suspend(void); +bool xen_suspend_mode_is_pm_hibernation(void); + extern unsigned long *xen_contiguous_bitmap; #if defined(CONFIG_XEN_PV) From patchwork Wed Aug 17 08:51:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=KzaUfZGj; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71wy2vngz1ygj for ; Wed, 17 Aug 2022 18:52:18 +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 1oOEmS-0000MQ-Pr; Wed, 17 Aug 2022 08:52:04 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmP-0000L8-OC for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:01 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 7E7D93F46B for ; Wed, 17 Aug 2022 08:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726321; bh=OSh6RBx2UPdYrPu+pLx83OWcHN+3ihEUeQxogZBZYnI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KzaUfZGjheWnbRS1ody/jaTiSgKZ1Nw4XV0tbzPihqA5EOAknNzjBeJd9l9FQ39eZ /nvv3+MQazZh5vXL7ynkPZraJxieURC/hpoNBpWOoxW0hcG5feWVipov2Zyn9pGIlm f/oGO804CPV+cwGz9XLDlmgtMmOFZGP70+ArgWLgl9U+bE/tz0E7Z1g5GEt719Nei3 bwitc30ztQiVr8DW+gxvPlctkGeFoOjvrnvW/cOkAffU9p0tqz57Jsg0J5+iCmyXp0 xOaj4SZmxV+ie6dV/i+Pjrtm91Q53ZqofNnz9LHQeSThR5gd8YjTyDsVNGdbPrqday OTyICUUH9KYKQ== Received: by mail-pj1-f71.google.com with SMTP id ng1-20020a17090b1a8100b001f4f9f69d48so858800pjb.4 for ; Wed, 17 Aug 2022 01:52:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=OSh6RBx2UPdYrPu+pLx83OWcHN+3ihEUeQxogZBZYnI=; b=B2Tr74lC8Y/+ApNuKICiiRSQSxI/8FQbBpZwoFZFFavhONqHyOTbzGVqJPv87X2QT5 dVNNwJbhYErg4MSJz36qzjIfq5+eggET11uU/Kebxo10JSJbDKJtZKuO0b7widOQ3gYO fkjvunOJMBoofdYsNcK3LisSwJfJUWTgkaDawhvW09aReDt2+KBPw4icTE4ysOmy766w 08ju9wbJSGf9JkI0jsIahk+9EJimmYQLFKgyJNkCFTBTGFgOS9PYPmQZS/ao1O/kHceo tM9m9evIaFLecqwrvWv0SbpJpyt8yyxGIxcPAQzU9G4qSA2LpRmSUoYcBaQ4wXQLWSfk 4PNQ== X-Gm-Message-State: ACgBeo3XjebY/kmfEpfbTEErsa/R5oySC+dxn7gbJ2m5xTGUM27pQBz1 ++XpIBLickoFU/KxsYhRZXEbUYka5GWdjKUg6SfT9NL27yigSEDyR6kNx/2e23C681ri/cRsmKp Ip5RT+d0T8nrQFSDAudpcDaiAnZjreDu9oI7tvZVgng== X-Received: by 2002:a65:4bc6:0:b0:428:90d4:b410 with SMTP id p6-20020a654bc6000000b0042890d4b410mr11956444pgr.529.1660726319935; Wed, 17 Aug 2022 01:51:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6elUEGuFaqDrP7BjZwe4MHuEEz8DOiFo2JcU8nCv0N+/zaLZRwa99F8HMQWrv1lLYOJQDvlQ== X-Received: by 2002:a65:4bc6:0:b0:428:90d4:b410 with SMTP id p6-20020a654bc6000000b0042890d4b410mr11956432pgr.529.1660726319497; Wed, 17 Aug 2022 01:51:59 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.51.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:51:59 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 03/20] UBUNTU: SAUCE: xenbus: add freeze/thaw/restore callbacks support Date: Wed, 17 Aug 2022 16:51:30 +0800 Message-Id: <20220817085150.2078055-5-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Since commit b3e96c0c7562 ("xen: use freeze/restore/thaw PM events for suspend/resume/chkpt"), xenbus uses PMSG_FREEZE, PMSG_THAW and PMSG_RESTORE events for Xen suspend. However, they're actually assigned to xenbus_dev_suspend(), xenbus_dev_cancel() and xenbus_dev_resume() respectively, and only suspend and resume callbacks are supported at driver level. To support PM suspend and PM hibernation, modify the bus level PM callbacks to invoke not only device driver's suspend/resume but also freeze/thaw/restore. Note that we'll use freeze/restore callbacks even for PM suspend whereas suspend/resume callbacks are normally used in the case, becausae the existing xenbus device drivers already have suspend/resume callbacks specifically designed for Xen suspend. So we can allow the device drivers to keep the existing callbacks wihtout modification. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273200/ (cherry picked from commit 4f60b62df39c3a7f5cddf7b7a24f168af665d877 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/xenbus/xenbus_probe.c | 99 ++++++++++++++++++++++++++----- include/xen/xenbus.h | 3 + 2 files changed, 86 insertions(+), 16 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index fe360c33ce71..5b0eba3b44fe 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -663,26 +664,47 @@ int xenbus_dev_suspend(struct device *dev) struct xenbus_driver *drv; struct xenbus_device *xdev = container_of(dev, struct xenbus_device, dev); + int (*cb)(struct xenbus_device *) = NULL; + bool xen_suspend = xen_suspend_mode_is_xen_suspend(); DPRINTK("%s", xdev->nodename); if (dev->driver == NULL) return 0; drv = to_xenbus_driver(dev->driver); - if (drv->suspend) - err = drv->suspend(xdev); - if (err) - dev_warn(dev, "suspend failed: %i\n", err); + + if (xen_suspend) + cb = drv->suspend; + else + cb = drv->freeze; + + if (cb) + err = cb(xdev); + + if (err) { + dev_warn(dev, "%s failed: %i\n", xen_suspend ? + "suspend" : "freeze", err); + return err; + } + + if (!xen_suspend) { + /* Forget otherend since this can become stale after restore */ + free_otherend_watch(xdev); + free_otherend_details(xdev); + } + return 0; } EXPORT_SYMBOL_GPL(xenbus_dev_suspend); int xenbus_dev_resume(struct device *dev) { - int err; + int err = 0; struct xenbus_driver *drv; struct xenbus_device *xdev = container_of(dev, struct xenbus_device, dev); + int (*cb)(struct xenbus_device *) = NULL; + bool xen_suspend = xen_suspend_mode_is_xen_suspend(); DPRINTK("%s", xdev->nodename); @@ -691,23 +713,32 @@ int xenbus_dev_resume(struct device *dev) drv = to_xenbus_driver(dev->driver); err = talk_to_otherend(xdev); if (err) { - dev_warn(dev, "resume (talk_to_otherend) failed: %i\n", err); + dev_warn(dev, "%s (talk_to_otherend) failed: %i\n", + xen_suspend ? "resume" : "restore", err); return err; } - xdev->state = XenbusStateInitialising; + if (xen_suspend) + xdev->state = XenbusStateInitialising; - if (drv->resume) { - err = drv->resume(xdev); - if (err) { - dev_warn(dev, "resume failed: %i\n", err); - return err; - } + if (xen_suspend) + cb = drv->resume; + else + cb = drv->restore; + + if (cb) + err = cb(xdev); + + if (err) { + dev_warn(dev, "%s failed: %i\n", + xen_suspend ? "resume" : "restore", err); + return err; } err = watch_otherend(xdev); if (err) { - dev_warn(dev, "resume (watch_otherend) failed: %d\n", err); + dev_warn(dev, "%s (watch_otherend) failed: %d.\n", + xen_suspend ? "resume" : "restore", err); return err; } @@ -717,8 +748,44 @@ EXPORT_SYMBOL_GPL(xenbus_dev_resume); int xenbus_dev_cancel(struct device *dev) { - /* Do nothing */ - DPRINTK("cancel"); + int err = 0; + struct xenbus_driver *drv; + struct xenbus_device *xdev + = container_of(dev, struct xenbus_device, dev); + bool xen_suspend = xen_suspend_mode_is_xen_suspend(); + + if (xen_suspend) { + /* Do nothing */ + DPRINTK("cancel"); + return 0; + } + + DPRINTK("%s", xdev->nodename); + + if (dev->driver == NULL) + return 0; + drv = to_xenbus_driver(dev->driver); + + err = talk_to_otherend(xdev); + if (err) { + dev_warn(dev, "thaw (talk_to_otherend) failed: %d.\n", err); + return err; + } + + if (drv->thaw) { + err = drv->thaw(xdev); + if (err) { + dev_warn(dev, "thaw failed: %i\n", err); + return err; + } + } + + err = watch_otherend(xdev); + if (err) { + dev_warn(dev, "thaw (watch_otherend) failed: %d.\n", err); + return err; + } + return 0; } EXPORT_SYMBOL_GPL(xenbus_dev_cancel); diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b94074c82772..99c8c7d167e5 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -119,6 +119,9 @@ struct xenbus_driver { int (*remove)(struct xenbus_device *dev); int (*suspend)(struct xenbus_device *dev); int (*resume)(struct xenbus_device *dev); + int (*freeze)(struct xenbus_device *dev); + int (*thaw)(struct xenbus_device *dev); + int (*restore)(struct xenbus_device *dev); int (*uevent)(struct xenbus_device *, struct kobj_uevent_env *); struct device_driver driver; int (*read_otherend_details)(struct xenbus_device *dev); From patchwork Wed Aug 17 08:51:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=iWI0eT3+; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71wz6L8fz1ygF for ; Wed, 17 Aug 2022 18:52:19 +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 1oOEmX-0000Qw-6c; Wed, 17 Aug 2022 08:52:09 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmR-0000Lj-CZ for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:03 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A0C083F46B for ; Wed, 17 Aug 2022 08:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726322; bh=JCh7Uqx3pL2x6SaRQnscDcay0Gae0E8eMwz+67b8LIY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iWI0eT3+AMi6pDLe6El9QoGIaJOR/xqZbCbha+jJf4FRgXaTyk2hdlX+WSngn6AZp /Fm6oOmwYY95thliz99MupBHforvkM6dBX7vgWz+MdEiu5GbFqf3NuCAZaMsIQUrp9 +bzrAMZbNG1MHSjSYXa8Tm+tjK+EaQBU0nOjrNLDtiZn5BtSOoV6twA7nvO3HDlbXA /zGNBzlcm+AeK1Z7TzAS32yjsxxllOSMSh8eadT5o6c8aRX9QjFLHov8QrSCantrZH hsfsiXz4/FvtQqLqerLlzOQSvf+s+69p1Y0bHfcw21vDzBDBjiWS6QoN/JakcJ5dAs mW0oQ8Ymvk+EQ== Received: by mail-pl1-f199.google.com with SMTP id m5-20020a170902f64500b0016d313f3ce7so8064340plg.23 for ; Wed, 17 Aug 2022 01:52:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=JCh7Uqx3pL2x6SaRQnscDcay0Gae0E8eMwz+67b8LIY=; b=xRj67Q44XoB600zwhMVinaXqF3GULVUeH0oDFF1YntLbW1W9amjzw79Hy31mVCMS0i 21N9AlkfiwhC2GocS6FrGXQNB0n7gFAMhp+IFe3hu3dCJQVUbho4bvGQKW0K7ECmuJbK 1GJh1KjsjaSRXxMY4JxzySHtKOVIZtOJnzWt2Tz9BUlVg/JLxvxLcSERPq8G7vGPUAMf L/NHS7UznwQRmNUSM5HzOW+rvqo2Ne87zMprcKAjS0sr8yVtNzJuHT+phr2kkXDehaGY cQX3gyRdLTn94z79HQjGhao3gjV0TCAuHAFrUuHGSDKkptUQQSfS0O9nl+7xaZuEOEk/ dlXw== X-Gm-Message-State: ACgBeo1XFnDzpiswlHzzAFm6utgJ6XmaOsi2k8Ftsl4kr5omEH8T011a 5Udbl8N5jGVleu8s3eZ5lbWFyAulZghcW6d2UDD6VDDg6VU6Q3b2H4mZUQSif97o0+nguOEZNi2 In9egYzvIL1uuf7kIYe4WhE/9uVjIxLyiusNiyi+BSg== X-Received: by 2002:a05:6a00:4298:b0:52e:722f:5f1e with SMTP id bx24-20020a056a00429800b0052e722f5f1emr25377123pfb.85.1660726320990; Wed, 17 Aug 2022 01:52:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5rR84CwZxTVriko+0fhQBnZ+giJEYedub+936UwHAdXcWXVtqKZYvlFtYwj7onCg/OgxnwSA== X-Received: by 2002:a05:6a00:4298:b0:52e:722f:5f1e with SMTP id bx24-20020a056a00429800b0052e722f5f1emr25377106pfb.85.1660726320639; Wed, 17 Aug 2022 01:52:00 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.51.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:00 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 04/20] UBUNTU: SAUCE: x86/xen: Introduce new function to map HYPERVISOR_shared_info on Resume Date: Wed, 17 Aug 2022 16:51:31 +0800 Message-Id: <20220817085150.2078055-6-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Anchal Agarwal BugLink: https://bugs.launchpad.net/bugs/1968062 Introduce a small function which re-uses shared page's PA allocated during guest initialization time in reserve_shared_info() and not allocate new page during resume flow. It also does the mapping of shared_info_page by calling xen_hvm_init_shared_info() to use the function. Backport Notes: We don't need this commit 8d5ce0dad4ab2a4c8c8a3c36f6fb8c46b695b053 ("x86/xen: decouple shared_info mapping from xen_hvm_init_shared_info()") here since xen_hvm_init_shared_info changed in 4.14 kernel just to do the mapping and allocation of shared page is done in a separate function. We don't need to decouple this kernel API anymore Signed-off-by: Anchal Agarwal Reviewed-by: Sebastian Biemueller Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273203/ (cherry picked from commit 9970545c4f2f4f3d8ab77730bf67ed3accf1eab8 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/enlighten_hvm.c | 7 +++++++ arch/x86/xen/xen-ops.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index e68ea5f4ad1c..660114498316 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -29,6 +29,13 @@ static unsigned long shared_info_pfn; +void xen_hvm_map_shared_info(void) +{ + xen_hvm_init_shared_info(); + if(shared_info_pfn) + HYPERVISOR_shared_info = __va(PFN_PHYS(shared_info_pfn)); +} + void xen_hvm_init_shared_info(void) { struct xen_add_to_physmap xatp; diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 16aed4b12129..5582845c5ab1 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -56,6 +56,8 @@ void xen_enable_sysenter(void); void xen_enable_syscall(void); void xen_vcpu_restore(void); +void xen_callback_vector(void); +void xen_hvm_map_shared_info(void); void xen_hvm_init_shared_info(void); void xen_unplug_emulated_devices(void); From patchwork Wed Aug 17 08:51:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=VvAUz7g5; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71x13M0Xz1ygg for ; Wed, 17 Aug 2022 18:52:21 +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 1oOEmY-0000SU-HY; Wed, 17 Aug 2022 08:52:10 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmT-0000Mx-8X for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:05 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id F17333FB94 for ; Wed, 17 Aug 2022 08:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726325; bh=MTKOvl9iShw/Xcwg0ZJO5QiRkozHYPDiS/He5/uBwt0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VvAUz7g5EksxjBkn1XUmRFX48V9pM64lx5iN1gJnDdCA3X1r6q82qfEP0RH80atkp pR2HgIBc9fD0zDf45q9S7iHQ6is3/N7cYqELuHZo/SAlHq01qWB11T56jyNSU7IlRP Tbaubq0w0obr8bH9/awS7aht363YGY9NoKaOWuGKl3jJaQgf36qQsoaeTCUjFnhyMA 0s6XO8GtIQDbxSSPWE5sqcs7cYTxeNgQ7h+ls1CFlMNsrk3aQI3rpk1ky7YMVRCgHd MwX6VbRq60n+wRs/XnLtaxU1R5R81ows6KtKxiNCc4MGzPUjQtVs073tZARTm3xkFH 5/wTN7X7DNaVA== Received: by mail-pg1-f197.google.com with SMTP id z32-20020a631920000000b0042903cb8dfcso3320510pgl.5 for ; Wed, 17 Aug 2022 01:52:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=MTKOvl9iShw/Xcwg0ZJO5QiRkozHYPDiS/He5/uBwt0=; b=O5uSxe0ayEhzRxP/knpKLhjiPrtI+tXu8W2aq1swMUiOdIafbwTVt46LrcDDdw51fo QHw6SOY8elwTDGYYuHHT+YfdaIB9/ipb69VU4LDCyf9Ul2y71i2eyeZS3IoTfFUQlph4 FD20MZfLzqVnu15kS4V0KnvhgIX+UtbuXfJlqDPwraJBXZEIreWFzB2Qz9JevbzgrDag q6CnksZolbUGQMX34WAUhTdeBpngdCP4dvs8Wug4kViicwhElIxdqlZLMV8JJSfNHAfS 5ksFyoS2wT1/m2wZPlO/z0wtHGEdG1cdJyXgVJAQTZhoQSAMWJhFVfHhoK+RFMg9Twm2 4fgg== X-Gm-Message-State: ACgBeo2WoiCcPk++aStH3E2cvOBfFuvogKXgcBsUKObAV+hGWxgx1LfA 3T5umA5F7cW277L04KAuhk9sRdrf+SRCNPlTFJ5+vwEYxidC/K58J73pN0RsurkM0e/QkaZsvfs 5Wo3pzMrVj/ygPel+y/Z6y58IZ/Vy9BsHKK3ptkllnA== X-Received: by 2002:a62:1c81:0:b0:52f:ccb5:9de1 with SMTP id c123-20020a621c81000000b0052fccb59de1mr24785985pfc.45.1660726323428; Wed, 17 Aug 2022 01:52:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR76FsJlz6xj2AS5a5wrw3fNY1tRzDmvbDWEIOVhGpjDrUhm7yA9lgXVU0NJW7A1KS99M0elIg== X-Received: by 2002:a62:1c81:0:b0:52f:ccb5:9de1 with SMTP id c123-20020a621c81000000b0052fccb59de1mr24785972pfc.45.1660726323079; Wed, 17 Aug 2022 01:52:03 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:02 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][kinetic/linux-aws][PATCH 05/20] UBUNTU: SAUCE: x86/xen: add system core suspend and resume callbacks Date: Wed, 17 Aug 2022 16:51:33 +0800 Message-Id: <20220817085150.2078055-8-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Add Xen PVHVM specific system core callbacks for PM suspend and hibernation support. The callbacks suspend and resume Xen primitives, like shared_info, pvclock and grant table. Note that Xen suspend can handle them in a different manner, but system core callbacks are called from the context. So if the callbacks are called from Xen suspend context, return immediately. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273204/ (cherry picked from commit bcb1b39880df2f69ec45652a88367861f96de60c amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/enlighten_hvm.c | 1 + arch/x86/xen/suspend.c | 53 ++++++++++++++++++++++++++++++++++++ include/xen/xen-ops.h | 2 ++ 3 files changed, 56 insertions(+) diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index 0d6c38c767aa..ebe29d6834f6 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -221,6 +221,7 @@ static void __init xen_hvm_guest_init(void) if (!no_vector_callback && xen_feature(XENFEAT_hvm_callback_vector)) xen_have_vector_callback = 1; + xen_setup_syscore_ops(); xen_hvm_smp_init(); WARN_ON(xen_cpuhp_setup(xen_cpu_up_prepare_hvm, xen_cpu_dead_hvm)); xen_unplug_emulated_devices(); diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index 1d83152c761b..784c4484100b 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -2,17 +2,22 @@ #include #include #include +#include +#include #include #include +#include #include #include +#include #include #include #include #include #include +#include #include "xen-ops.h" #include "mmu.h" @@ -82,3 +87,51 @@ void xen_arch_suspend(void) on_each_cpu(xen_vcpu_notify_suspend, NULL, 1); } + +static int xen_syscore_suspend(void) +{ + struct xen_remove_from_physmap xrfp; + int ret; + + /* Xen suspend does similar stuffs in its own logic */ + if (xen_suspend_mode_is_xen_suspend()) + return 0; + + xrfp.domid = DOMID_SELF; + xrfp.gpfn = __pa(HYPERVISOR_shared_info) >> PAGE_SHIFT; + + ret = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrfp); + if (!ret) + HYPERVISOR_shared_info = &xen_dummy_shared_info; + + return ret; +} + +static void xen_syscore_resume(void) +{ + /* Xen suspend does similar stuffs in its own logic */ + if (xen_suspend_mode_is_xen_suspend()) + return; + + /* No need to setup vcpu_info as it's already moved off */ + xen_hvm_map_shared_info(); + + pvclock_resume(); + + gnttab_resume(); +} + +/* + * These callbacks will be called with interrupts disabled and when having only + * one CPU online. + */ +static struct syscore_ops xen_hvm_syscore_ops = { + .suspend = xen_syscore_suspend, + .resume = xen_syscore_resume +}; + +void __init xen_setup_syscore_ops(void) +{ + if (xen_hvm_domain()) + register_syscore_ops(&xen_hvm_syscore_ops); +} diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index d37328f2af0f..59bc4417385e 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -44,6 +44,8 @@ bool xen_suspend_mode_is_xen_suspend(void); bool xen_suspend_mode_is_pm_suspend(void); bool xen_suspend_mode_is_pm_hibernation(void); +void xen_setup_syscore_ops(void); + extern unsigned long *xen_contiguous_bitmap; #if defined(CONFIG_XEN_PV) From patchwork Wed Aug 17 08:51:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=EaaaxIem; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71x669h7z1ygF for ; Wed, 17 Aug 2022 18:52:26 +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 1oOEmb-0000Ux-9o; Wed, 17 Aug 2022 08:52:13 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmU-0000Nl-Nj for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:06 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4BF8F3F46B for ; Wed, 17 Aug 2022 08:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726326; bh=nId7+ctMTDlURp2QwwPpAWqcKpUgu0Lq+e+WQkrLg30=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EaaaxIemI52MuA/XECG99j/cEmbOjlCNAQ7GRKwaIGHyYMueefDSbHLfiYvlKw9xp hP+2LZTiwixAfXmvWTcnMxc9DJoja6R/8WY6QHyI8DRT3dJbnS5hzM6bCaXpsRihD9 NuoKATBtQJMrGUMQyIfjXmn6Ch0/CUpPGsrqTicc5gk4c57l7DFcDZN15KbB+WV9pH d0kMCLHErMDkdCMZ8alvelKDibQwBx0YjhNduBtjSlnEhGJJDc+bEk6MfB6ajns256 5UC7T0H67EflhtyASpJqD8NeT06cIyywXg5psQUHHgLvqZg6M7WyV+ToglB0lMboqp kRDrhwkrDUNrA== Received: by mail-pj1-f69.google.com with SMTP id 92-20020a17090a09e500b001d917022847so5209005pjo.1 for ; Wed, 17 Aug 2022 01:52:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=nId7+ctMTDlURp2QwwPpAWqcKpUgu0Lq+e+WQkrLg30=; b=cPpK53ckSzMEYLEqel4MfoX9eSOAZneseECdsyGlNbJVES+zBN7rzaigcxBc+6TxyN cKjMiw8xPS9zB/klhQhVUFpC8+GvHRglfkP5WE5qsl0uGnliKcOA/CJHxCeeJtZyZZ1D WQo2/PrRlC3hpHtsvfROu6OzvwkCcx93Q4V4+HNonXAnwNHjLwIOG77gNbho8fMx8Qvr y+vR2jVKAaomRDKk2sTujOHcNfKGJDPSHh3WpmXDo9Dj7GMarE3N/wl5R4NShkDMJ+TK a2525O4Lz/OcSM8QD//UvPr3W8aCj08tibYbii6zrh4l7BRLZyVJTWaZ57lnf992k+4C Tv0Q== X-Gm-Message-State: ACgBeo3JJWxN6Om4R3Gcf9t374WvecxYBO360ndkeKVQxHIQ7g+xdjwO Sv+d1PjbSHk39QkjOpT9iFLa6DB0MsjZsdKsly76y81+Yz/jbYtdCXXPb3ABtH5gRFQlMbSUVyu rsAqzYj1AD+M1/AUqXSqw6xrFnHXo0GgiS6Eo/SQT+w== X-Received: by 2002:a17:902:e884:b0:170:2845:986a with SMTP id w4-20020a170902e88400b001702845986amr24928124plg.43.1660726324650; Wed, 17 Aug 2022 01:52:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR78Rq/Hu/8vPgHkqgQ3e052j8ggkTYKItUmz2Ypky8Zu98ER2kqA1TD4pKeugIO0wP9gCNInQ== X-Received: by 2002:a17:902:e884:b0:170:2845:986a with SMTP id w4-20020a170902e88400b001702845986amr24928101plg.43.1660726324182; Wed, 17 Aug 2022 01:52:04 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:03 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 06/20] UBUNTU: SAUCE: xen-blkfront: add callbacks for PM suspend and hibernation Date: Wed, 17 Aug 2022 16:51:34 +0800 Message-Id: <20220817085150.2078055-9-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Add freeze and restore callbacks for PM suspend and hibernation support. The freeze handler stops a block-layer queue and disconnect the frontend from the backend while freeing ring_info and associated resources. The restore handler re-allocates ring_info and re-connect to the backedend, so the rest of the kernel can continue to use the block device transparently.Also, the handlers are used for both PM suspend and hibernation so that we can keep the existing suspend/resume callbacks for Xen suspend without modification. If a backend doesn't have commit 12ea729645ac ("xen/blkback: unmap all persistent grants when frontend gets disconnected"), the frontend may see massive amount of grant table warning when freeing resources. [ 36.852659] deferring g.e. 0xf9 (pfn 0xffffffffffffffff) [ 36.855089] xen:grant_table: WARNING: g.e. 0x112 still in use! In this case, persistent grants would need to be disabled. Ensure no reqs/rsps in rings before disconnecting. When disconnecting the frontend from the backend in blkfront_freeze(), there still may be unconsumed requests or responses in the rings, especially when the backend is backed by network-based device. If the frontend gets disconnected with such reqs/rsps remaining there, it can cause grant warnings and/or losing reqs/rsps by freeing pages afterward. This can lead resumed kernel into unrecoverable state like unexpected freeing of grant page and/or hung task due to the lost reqs or rsps. Therefore we have to ensure that there is no unconsumed requests or responses before disconnecting. Actually, the frontend just needs to wait for some amount of time so that the backend can process the requests, put responses and notify the frontend back. Timeout used here is based on some heuristic. If we somehow hit the timeout, it would mean something serious happens in the backend, the frontend will just return an error to PM core and PM suspend/hibernation will be aborted. This may be something should be fixed by the backend side, but a frontend side fix is probably still worth doing to work with broader backends. Backport Note: Unlike 4.9 kernel, blk-mq is default for 4.14 kernel and request-based mode cod eis not included in this frontend driver. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8297625/ (cherry picked from commit e516934f6a0e1b1a641b3a62edd9345e6d222bc8 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/block/xen-blkfront.c | 163 +++++++++++++++++++++++++++++++++-- 1 file changed, 155 insertions(+), 8 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 390817cf1221..1efa83e11c85 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include @@ -82,6 +84,8 @@ enum blkif_state { BLKIF_STATE_CONNECTED, BLKIF_STATE_SUSPENDED, BLKIF_STATE_ERROR, + BLKIF_STATE_FREEZING, + BLKIF_STATE_FROZEN }; struct grant { @@ -222,6 +226,7 @@ struct blkfront_info struct list_head requests; struct bio_list bio_list; struct list_head info_list; + struct completion wait_backend_disconnected; }; static unsigned int nr_minors; @@ -263,6 +268,16 @@ static DEFINE_SPINLOCK(minor_lock); static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo); static void blkfront_gather_backend_features(struct blkfront_info *info); static int negotiate_mq(struct blkfront_info *info); +static void __blkif_free(struct blkfront_info *info); + +static inline bool blkfront_ring_is_busy(struct blkif_front_ring *ring) +{ + if (RING_SIZE(ring) > RING_FREE_REQUESTS(ring) || + RING_HAS_UNCONSUMED_RESPONSES(ring)) + return true; + else + return false; +} #define for_each_rinfo(info, ptr, idx) \ for ((ptr) = (info)->rinfo, (idx) = 0; \ @@ -1154,6 +1169,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, info->sector_size = sector_size; info->physical_sector_size = physical_sector_size; blkif_set_queue_limits(info); + init_completion(&info->wait_backend_disconnected); xlvbd_flush(info); @@ -1178,6 +1194,8 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, /* Already hold rinfo->ring_lock. */ static inline void kick_pending_request_queues_locked(struct blkfront_ring_info *rinfo) { + if (unlikely(rinfo->dev_info->connected == BLKIF_STATE_FREEZING)) + return; if (!RING_FULL(&rinfo->ring)) blk_mq_start_stopped_hw_queues(rinfo->dev_info->rq, true); } @@ -1302,9 +1320,6 @@ static void blkif_free_ring(struct blkfront_ring_info *rinfo) static void blkif_free(struct blkfront_info *info, int suspend) { - unsigned int i; - struct blkfront_ring_info *rinfo; - /* Prevent new requests being issued until we fix things up. */ info->connected = suspend ? BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED; @@ -1312,6 +1327,14 @@ static void blkif_free(struct blkfront_info *info, int suspend) if (info->rq) blk_mq_stop_hw_queues(info->rq); + __blkif_free(info); +} + +static void __blkif_free(struct blkfront_info *info) +{ + unsigned int i; + struct blkfront_ring_info *rinfo; + for_each_rinfo(info, rinfo, i) blkif_free_ring(rinfo); @@ -1523,8 +1546,10 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) unsigned int eoiflag = XEN_EOI_FLAG_SPURIOUS; if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) { - xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); - return IRQ_HANDLED; + if (info->connected != BLKIF_STATE_FREEZING) { + xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); + return IRQ_HANDLED; + } } spin_lock_irqsave(&rinfo->ring_lock, flags); @@ -2026,6 +2051,7 @@ static int blkif_recover(struct blkfront_info *info) unsigned int segs; struct blkfront_ring_info *rinfo; + bool frozen = info->connected == BLKIF_STATE_FROZEN; blkfront_gather_backend_features(info); /* Reset limits changed by blk_mq_update_nr_hw_queues(). */ blkif_set_queue_limits(info); @@ -2047,6 +2073,9 @@ static int blkif_recover(struct blkfront_info *info) kick_pending_request_queues(rinfo); } + if (frozen) + return 0; + list_for_each_entry_safe(req, n, &info->requests, queuelist) { /* Requeue pending requests (flush or discard) */ list_del_init(&req->queuelist); @@ -2345,6 +2374,7 @@ static void blkfront_connect(struct blkfront_info *info) return; case BLKIF_STATE_SUSPENDED: + case BLKIF_STATE_FROZEN: /* * If we are recovering from suspension, we need to wait * for the backend to announce it's features before @@ -2463,12 +2493,36 @@ static void blkback_changed(struct xenbus_device *dev, break; case XenbusStateClosed: - if (dev->state == XenbusStateClosed) + if (dev->state == XenbusStateClosed) { + if (info->connected == BLKIF_STATE_FREEZING) { + __blkif_free(info); + info->connected = BLKIF_STATE_FROZEN; + complete(&info->wait_backend_disconnected); + break; + } + + break; + } + + /* + * We may somehow receive backend's Closed again while thawing + * or restoring and it causes thawing or restoring to fail. + * Ignore such unexpected state anyway. + */ + if (info->connected == BLKIF_STATE_FROZEN && + dev->state == XenbusStateInitialised) { + dev_dbg(&dev->dev, + "ignore the backend's Closed state: %s", + dev->nodename); break; + } fallthrough; case XenbusStateClosing: - blkfront_closing(info); - break; + if (info->connected == BLKIF_STATE_FREEZING) + xenbus_frontend_closed(dev); + else + blkfront_closing(info); + break; } } @@ -2500,6 +2554,96 @@ static int blkfront_is_ready(struct xenbus_device *dev) return info->is_ready && info->xbdev; } +static int blkfront_freeze(struct xenbus_device *dev) +{ + unsigned int i; + struct blkfront_info *info = dev_get_drvdata(&dev->dev); + struct blkfront_ring_info *rinfo; + struct blkif_front_ring *ring; + /* This would be reasonable timeout as used in xenbus_dev_shutdown() */ + unsigned int timeout = 5 * HZ; + int err = 0; + + info->connected = BLKIF_STATE_FREEZING; + + blk_mq_stop_hw_queues(info->rq); + + for (i = 0; i < info->nr_rings; i++) { + rinfo = &info->rinfo[i]; + + gnttab_cancel_free_callback(&rinfo->callback); + flush_work(&rinfo->work); + } + + for (i = 0; i < info->nr_rings; i++) { + spinlock_t *lock; + bool busy; + unsigned long req_timeout_ms = 25; + unsigned long ring_timeout; + + rinfo = &info->rinfo[i]; + ring = &rinfo->ring; + + lock = &rinfo->ring_lock; + + ring_timeout = jiffies + + msecs_to_jiffies(req_timeout_ms * RING_SIZE(ring)); + + do { + spin_lock_irq(lock); + busy = blkfront_ring_is_busy(ring); + spin_unlock_irq(lock); + + if (busy) + msleep(req_timeout_ms); + else + break; + } while (time_is_after_jiffies(ring_timeout)); + + /* Timed out */ + if (busy) { + xenbus_dev_error(dev, err, "the ring is still busy"); + info->connected = BLKIF_STATE_CONNECTED; + return -EBUSY; + } + } + + /* Kick the backend to disconnect */ + xenbus_switch_state(dev, XenbusStateClosing); + + /* + * We don't want to move forward before the frontend is diconnected + * from the backend cleanly. + */ + timeout = wait_for_completion_timeout(&info->wait_backend_disconnected, + timeout); + if (!timeout) { + err = -EBUSY; + xenbus_dev_error(dev, err, "Freezing timed out;" + "the device may become inconsistent state"); + } + + return err; +} + +static int blkfront_restore(struct xenbus_device *dev) +{ + struct blkfront_info *info = dev_get_drvdata(&dev->dev); + int err = 0; + + err = negotiate_mq(info); + if (err) + goto out; + + err = talk_to_blkback(dev, info); + if (err) + goto out; + blk_mq_update_nr_hw_queues(&info->tag_set, info->nr_rings); + +out: + return err; +} + static const struct block_device_operations xlvbd_block_fops = { .owner = THIS_MODULE, @@ -2521,6 +2665,9 @@ static struct xenbus_driver blkfront_driver = { .resume = blkfront_resume, .otherend_changed = blkback_changed, .is_ready = blkfront_is_ready, + .freeze = blkfront_freeze, + .thaw = blkfront_restore, + .restore = blkfront_restore }; static void purge_persistent_grants(struct blkfront_info *info) From patchwork Wed Aug 17 08:51:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=MWLny4ZR; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xH6ZhBz1ygF for ; Wed, 17 Aug 2022 18:52:35 +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 1oOEmm-0000ku-E7; Wed, 17 Aug 2022 08:52:24 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmX-0000Or-Hw for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:09 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 652313F46B for ; Wed, 17 Aug 2022 08:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726327; bh=UcGTP2GKqSjG53nObBxMBrKZPQ2F0MzRYmNASivPigw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MWLny4ZRxlwJU+PS6f5pkHR5MdeA53ME0n03KHaC0mYf60vhZhjnotdyiBKGhHBFC dFsdvuMgtsJEaZaNvCuA3H2xFYnoO7kajFRFEMfEWi5INmwabPBTtUNotd30g9Yeq2 oMq329lp4b+VPFM4qJj/UC6kmRxYCsGVjKwhjjW4Z/amzCsfNX2gKz6MnsHKmAWbIZ sJuFbeP3Jq6Xut4OovcK7jbb+VOwnsZVwR1JEpXAyrPs2fSZrX2ye5fUSRQetcnuUd cx9iMbLdrpihMv5nBzn2U5Y7qqVfCVJjs8BQhOZDgManMimfsUuCFpPElH1W4c+mXx yGFuoljkNMHJQ== Received: by mail-pf1-f199.google.com with SMTP id y8-20020aa79428000000b0052f17a0627cso4733325pfo.1 for ; Wed, 17 Aug 2022 01:52:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=UcGTP2GKqSjG53nObBxMBrKZPQ2F0MzRYmNASivPigw=; b=Kg20teeh8N8B8cvhFJddof4iJmtXkVCt9qALM2PneFI02EbBAAwLbGiAZqR/f2A8Fq 3oZ5vLH/mli4qCZZvj1Choyiy/y/W2I4asbgBb6xv35GNav25+K3vTHC5aJavVTmKYCr N2ViOvd/ysa1hFlBJXIZXjqUHhNAedXnOPxmiU5AiwOwiX/SV4paGNmCxvjGV4a/xlBR tjIC1U1yxH06/ehlXMxKBhYEPFS0KDIqFnXmhGV86xtbosC4VKV6xfcFjOOk4BxKA6ck ISXSVaHkaEt4O6nbmBOI/kaTGa04oHGE9itgfYyPl/rwt7UWBXnResTIyblbSUMhtkln 7fFg== X-Gm-Message-State: ACgBeo02igiqirEzk1Z7eMfCxGohivmeDZaqK1r3vmPiy6gpuz+BgNBO Q6DvgCgZrY24APT52+Oucc0F/i1pyxdmybapc96HlITcOafFtPivipLk7RgW1+NiiIFORlPqdQ+ SjoJmBhK1JPWTTDyDL97J2/dxma/7zYd9xVSX2AzHSg== X-Received: by 2002:a17:902:ce11:b0:172:6f2c:a910 with SMTP id k17-20020a170902ce1100b001726f2ca910mr13920398plg.156.1660726325665; Wed, 17 Aug 2022 01:52:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6RFXJEUSkVyr1BrQhC5hAO9xW+FtO2d5Yn2lOqI98ge93KgTDs96S7w96zzFkmJ6l3lJTXpw== X-Received: by 2002:a17:902:ce11:b0:172:6f2c:a910 with SMTP id k17-20020a170902ce1100b001726f2ca910mr13920371plg.156.1660726325158; Wed, 17 Aug 2022 01:52:05 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:04 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][PATCH 07/20] UBUNTU: SAUCE: xen-netfront: add callbacks for PM suspend and hibernation support Date: Wed, 17 Aug 2022 16:51:35 +0800 Message-Id: <20220817085150.2078055-10-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Add freeze and restore callbacks for PM suspend and hibernation support. The freeze handler simply disconnects the frotnend from the backend and frees resources associated with queues after disabling the net_device from the system. The restore handler just changes the frontend state and let the xenbus handler to re-allocate the resources and re-connect to the backend. This can be performed transparently to the rest of the system. The handlers are used for both PM suspend and hibernation so that we can keep the existing suspend/resume callbacks for Xen suspend without modification. Freezing netfront devices is normally expected to finish within a few hundred milliseconds, but it can rarely take more than 5 seconds and hit the hard coded timeout, it would depend on backend state which may be congested and/or have complex configuration. While it's rare case, longer default timeout seems a bit more reasonable here to avoid hitting the timeout. Also, make it configurable via module parameter so that we can cover broader setups than what we know currently. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Eduardo Valentin Reviewed-by: Munehisa Kamata CR: https://cr.amazon.com/r/8297632 (cherry picked from commit 78b1b3b4dc215e8046806de5e8e1fa4e7ffe5fd2 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/net/xen-netfront.c | 97 +++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 2492a27467b4..0304fa9f40dc 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,12 @@ #include #include +enum netif_freeze_state { + NETIF_FREEZE_STATE_UNFROZEN, + NETIF_FREEZE_STATE_FREEZING, + NETIF_FREEZE_STATE_FROZEN, +}; + /* Module parameters */ #define MAX_QUEUES_DEFAULT 8 static unsigned int xennet_max_queues; @@ -68,6 +75,12 @@ MODULE_PARM_DESC(max_queues, #define XENNET_TIMEOUT (5 * HZ) +static unsigned int netfront_freeze_timeout_secs = 10; +module_param_named(freeze_timeout_secs, + netfront_freeze_timeout_secs, uint, 0644); +MODULE_PARM_DESC(freeze_timeout_secs, + "timeout when freezing netfront device in seconds"); + static const struct ethtool_ops xennet_ethtool_ops; struct netfront_cb { @@ -176,6 +189,10 @@ struct netfront_info { bool broken; atomic_t rx_gso_checksum_fixup; + + int freeze_state; + + struct completion wait_backend_disconnected; }; struct netfront_rx_info { @@ -872,6 +889,21 @@ static void xennet_set_rx_rsp_cons(struct netfront_queue *queue, RING_IDX val) spin_unlock_irqrestore(&queue->rx_cons_lock, flags); } +static int xennet_disable_interrupts(struct net_device *dev) +{ + struct netfront_info *np = netdev_priv(dev); + unsigned int num_queues = dev->real_num_tx_queues; + unsigned int i; + struct netfront_queue *queue; + + for (i = 0; i < num_queues; ++i) { + queue = &np->queues[i]; + disable_irq(queue->tx_irq); + disable_irq(queue->rx_irq); + } + return 0; +} + static void xennet_move_rx_slot(struct netfront_queue *queue, struct sk_buff *skb, grant_ref_t ref) { @@ -1681,6 +1713,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) np->queues = NULL; + init_completion(&np->wait_backend_disconnected); + err = -ENOMEM; np->rx_stats = netdev_alloc_pcpu_stats(struct netfront_stats); if (np->rx_stats == NULL) @@ -2231,6 +2265,50 @@ static int xennet_create_queues(struct netfront_info *info, return 0; } +static int netfront_freeze(struct xenbus_device *dev) +{ + struct netfront_info *info = dev_get_drvdata(&dev->dev); + unsigned long timeout = netfront_freeze_timeout_secs * HZ; + int err = 0; + + xennet_disable_interrupts(info->netdev); + + netif_device_detach(info->netdev); + + info->freeze_state = NETIF_FREEZE_STATE_FREEZING; + + /* Kick the backend to disconnect */ + xenbus_switch_state(dev, XenbusStateClosing); + + /* We don't want to move forward before the frontend is diconnected + * from the backend cleanly. + */ + timeout = wait_for_completion_timeout(&info->wait_backend_disconnected, + timeout); + if (!timeout) { + err = -EBUSY; + xenbus_dev_error(dev, err, "Freezing timed out;" + "the device may become inconsistent state"); + return err; + } + + /* Tear down queues */ + xennet_disconnect_backend(info); + xennet_destroy_queues(info); + + info->freeze_state = NETIF_FREEZE_STATE_FROZEN; + + return err; +} + +static int netfront_restore(struct xenbus_device *dev) +{ + /* Kick the backend to re-connect */ + xenbus_switch_state(dev, XenbusStateInitialising); + + return 0; +} + /* Common code used when first setting up, and when resuming. */ static int talk_to_netback(struct xenbus_device *dev, struct netfront_info *info) @@ -2456,6 +2534,8 @@ static int xennet_connect(struct net_device *dev) spin_unlock_bh(&queue->rx_lock); } + np->freeze_state = NETIF_FREEZE_STATE_UNFROZEN; + return 0; } @@ -2493,10 +2573,22 @@ static void netback_changed(struct xenbus_device *dev, break; case XenbusStateClosed: - if (dev->state == XenbusStateClosed) + if (dev->state == XenbusStateClosed) { + /* dpm context is waiting for the backend */ + if (np->freeze_state == NETIF_FREEZE_STATE_FREEZING) + complete(&np->wait_backend_disconnected); break; + } fallthrough; /* Missed the backend's CLOSING state */ case XenbusStateClosing: + /* We may see unexpected Closed or Closing from the backend. + * Just ignore it not to prevent the frontend from being + * re-connected in the case of PM suspend or hibernation. + */ + if (np->freeze_state == NETIF_FREEZE_STATE_FROZEN && + dev->state == XenbusStateInitialising) { + break; + } xenbus_frontend_closed(dev); break; } @@ -2658,6 +2750,9 @@ static struct xenbus_driver netfront_driver = { .probe = netfront_probe, .remove = xennet_remove, .resume = netfront_resume, + .freeze = netfront_freeze, + .thaw = netfront_restore, + .restore = netfront_restore, .otherend_changed = netback_changed, }; From patchwork Wed Aug 17 08:51:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=TmUy3rkb; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xQ07mrz1ygF for ; Wed, 17 Aug 2022 18:52:42 +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 1oOEmt-0000xa-DJ; Wed, 17 Aug 2022 08:52:31 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmY-0000Ru-PA for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:10 +0000 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 5B2BD3FB94 for ; Wed, 17 Aug 2022 08:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726329; bh=7rqBGZgkKCPWTbp255zbWWiq3ePWTX5K5C7JCgVBCrI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TmUy3rkbKZsmHgllyf/t/x8GHGsrg09aK/gO3cvJTg3TKk2OdWCM5Er4X0hEomWoa T8+k26o6cPIPKVGR/QXWUFEcG+C60eb2x2A1Eno+GS1/cdrrcBNMO7G0/xc0MRM3TJ NGUf950TzARA/rJTu8wCMBQx8k6VCCazQFEp8O7H4yrqcgDxBkrnL3jSbTKn2JWeXB QRZYcqe9kmUReKgbbUUgv+lylFq8pcDxeP1ePg6xJS9+KkyvEEZwZVtJV6reIEnEvJ +fanUswaL4B0gJCOsMacE4DH3AId6hF6dWSCYf9tQbE/m6wMlUO1tyCDCqhA8lJ0vf c1PrmboddAC8w== Received: by mail-pj1-f70.google.com with SMTP id q6-20020a17090a1b0600b001f558bbb924so646244pjq.3 for ; Wed, 17 Aug 2022 01:52:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=7rqBGZgkKCPWTbp255zbWWiq3ePWTX5K5C7JCgVBCrI=; b=vWcxux3tMb/4nT7VPC7S6uX/4BsWRxz/BAwnpvfPq/tHp+Ux8CbPFwkG8LAwZMALl+ g8GjVbTjuGRZy6XoTLZEC0sMbAUF2XPLekg488mLnr/1vzl+QYlawXeXIl1RlqW6zdu+ MYxoVHfKUcqjmwpiDIL5ZkPbF/VQmbI3/CW7uYI/P8dpiVpwztueXX+4SnjrZYttAUzt p6G9yH6VBfDp+Wrvg22YcwOIZfkC9BjjszZ40K09FL1N6uGc/eFWxllMoCARBFNN4lGJ vhZT2X1PFfjn9h9VI1Udnvt2/WKDFeF7NnJBtRo4oNgy2QvUFUZrU8QyDB+GOtQ8XrZF glGg== X-Gm-Message-State: ACgBeo02sY5aSFXRWF6COG3u5UoKR09luZAPbNtZrNqsq/p1BiU+3V9h iyfyCXP6BCG+JrZ1kCU8IDIywqWOYX3AcEsoJoDvzE5Il1L86L6GLu6ykZ7NdgcXp0iZgNitvtn BqVk+kB29wFx4AIjXJBQHEu9zPhJvROD/PNOEuMNhxw== X-Received: by 2002:a17:903:285:b0:16e:dcb7:937a with SMTP id j5-20020a170903028500b0016edcb7937amr25018734plr.4.1660726327793; Wed, 17 Aug 2022 01:52:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4d7vU/k9MM6w+6vOTEVEeOoVZm9tKBIjn+Hd91TSkuZMGvsyIrwKhLsiuOHtEOXtQ+mjZR3A== X-Received: by 2002:a17:903:285:b0:16e:dcb7:937a with SMTP id j5-20020a170903028500b0016edcb7937amr25018712plr.4.1660726327369; Wed, 17 Aug 2022 01:52:07 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:07 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 08/20] UBUNTU: SAUCE: xen/time: introduce xen_{save, restore}_steal_clock Date: Wed, 17 Aug 2022 16:51:37 +0800 Message-Id: <20220817085150.2078055-12-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Currently, steal time accounting code in scheduler expects steal clock callback to provide monotonically increasing value. If the accounting code receives a smaller value than previous one, it uses a negative value to calculate steal time and results in incorrectly updated idle and steal time accounting. This breaks userspace tools which read /proc/stat. top - 08:05:35 up 2:12, 3 users, load average: 0.00, 0.07, 0.23 Tasks: 80 total, 1 running, 79 sleeping, 0 stopped, 0 zombie Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,30100.0%id, 0.0%wa, 0.0%hi, 0.0%si,-1253874204672.0%st This can actually happen when a Xen PVHVM guest gets restored from hibernation, because such a restored guest is just a fresh domain from Xen perspective and the time information in runstate info starts over from scratch. This patch introduces xen_save_steal_clock() which saves current values in runstate info into per-cpu variables. Its couterpart, xen_restore_steal_clock(), sets offset if it found the current values in runstate info are smaller than previous ones. xen_steal_clock() is also modified to use the offset to ensure that scheduler only sees monotonically increasing number. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273209/ (cherry picked from commit 7a4398155fdabe4e9ad27561e44fb6f6bc9d595e amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/time.c | 29 ++++++++++++++++++++++++++++- include/xen/xen-ops.h | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/xen/time.c b/drivers/xen/time.c index 152dd33bb223..bf41e5cf1332 100644 --- a/drivers/xen/time.c +++ b/drivers/xen/time.c @@ -24,6 +24,9 @@ static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate); static DEFINE_PER_CPU(u64[4], old_runstate_time); +static DEFINE_PER_CPU(u64, xen_prev_steal_clock); +static DEFINE_PER_CPU(u64, xen_steal_clock_offset); + /* return an consistent snapshot of 64-bit time/counter value */ static u64 get64(const u64 *p) { @@ -150,7 +153,7 @@ bool xen_vcpu_stolen(int vcpu) return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable; } -u64 xen_steal_clock(int cpu) +static u64 __xen_steal_clock(int cpu) { struct vcpu_runstate_info state; @@ -158,6 +161,30 @@ u64 xen_steal_clock(int cpu) return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline]; } +u64 xen_steal_clock(int cpu) +{ + return __xen_steal_clock(cpu) + per_cpu(xen_steal_clock_offset, cpu); +} + +void xen_save_steal_clock(int cpu) +{ + per_cpu(xen_prev_steal_clock, cpu) = xen_steal_clock(cpu); +} + +void xen_restore_steal_clock(int cpu) +{ + u64 steal_clock = __xen_steal_clock(cpu); + + if (per_cpu(xen_prev_steal_clock, cpu) > steal_clock) { + /* Need to update the offset */ + per_cpu(xen_steal_clock_offset, cpu) = + per_cpu(xen_prev_steal_clock, cpu) - steal_clock; + } else { + /* Avoid unnecessary steal clock warp */ + per_cpu(xen_steal_clock_offset, cpu) = 0; + } +} + void xen_setup_runstate_info(int cpu) { struct vcpu_register_runstate_memory_area area; diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h index 86b773f32ecd..5ec79b720aef 100644 --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -37,6 +37,8 @@ void xen_time_setup_guest(void); void xen_manage_runstate_time(int action); void xen_get_runstate_snapshot(struct vcpu_runstate_info *res); u64 xen_steal_clock(int cpu); +void xen_save_steal_clock(int cpu); +void xen_restore_steal_clock(int cpu); int xen_setup_shutdown_event(void); From patchwork Wed Aug 17 08:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667159 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=wajoh6k9; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xm3DLXz1ygF for ; Wed, 17 Aug 2022 18:53:00 +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 1oOEnB-0001QM-Hc; Wed, 17 Aug 2022 08:52:49 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmc-0000U7-My for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:14 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8BDDC3F46F for ; Wed, 17 Aug 2022 08:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726330; bh=WwuxZmuauDyi289dQ/n375lDUKvlKSsYJKoz/3JuGGQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wajoh6k9dKobWAzfgrDf9dLuSwuhQ59iDbo2CqSYvcxL2OQ1OH9gNXHOOHE5CxozJ LaSOXuoUNvkpOwrM/AJx5f5oCw7a4cwLItx5RZFStqhD1rHUTWv9Z09draH/bpqHfE 5JDU2h5FzEUNc41aLpz99F2DlbTc7C+8xTdAz0s0EkVKMaPQMwpCRKONntoC3Qm5+Y ke6fJwXN36hKzzX7iYkn7zdV5DEgNUCFVih4KRWzyufaqkyZS2MBXF2EXId8+Y2rlx PwrmBoD6cJxVXWIFe93B18nlqRuvmL2D1+oi5ZYvM7Lf0EPKk0KY/JeoCB1UorVfLa 1tfJKbwHqbukQ== Received: by mail-pl1-f200.google.com with SMTP id u10-20020a170902e5ca00b0016f091c4b6bso8037803plf.10 for ; Wed, 17 Aug 2022 01:52:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=WwuxZmuauDyi289dQ/n375lDUKvlKSsYJKoz/3JuGGQ=; b=VUuODDjDeu7rBvbm9vzouzleMGj3oi5b8grdud5vw1WX4MZbHSZvbSGyg7Ks8p7U5s L9++DYEXgpFMn08IfoUBEPKgDrwUhLn/M7fKVpFPfzyGLrh+a0k5Lt38/OdRNfj5UaDU PJkSH6LsRfny1mh8s6F2XgXal+ZQHNCXtLRl3fQuRBNchL7b3mrLmIH3rKgyj5xkTN/q +1VWZlC3yEvW+e9QCVpc5ZPx92g+eIAa9lnXkUWa93tav/9W+mXaQZ7x0DoHZmkveVFc z+aj/1dSxepmdYwB+Ne/cALubz6a70i1A9Q5yqN26U7CjnmvwQfpBvgLVt8zZ3nBbNAp xdhw== X-Gm-Message-State: ACgBeo1qKGprwLQpObHGRudrwMXmcdIyow/pD4R8eom5cLV5qFLX67jQ qUfRj84vRRM+YKUvPlrfL/zDNj5jmK7njra1pZ5gUsRgWT4GxC+Y9ROu2E5SHakpZWEYpM1UaYM w51/n5zsL0TJFTjdibMKzXk/CBsrD/k+CrLix/pKHAw== X-Received: by 2002:a17:90b:3b8a:b0:1f5:1df2:1fff with SMTP id pc10-20020a17090b3b8a00b001f51df21fffmr2741175pjb.169.1660726328953; Wed, 17 Aug 2022 01:52:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Ou//x2M35ldgfRU75JTXZ2PvWxofy7796cPSX5nHn0ADkmGnGRjO5bSX8xBowc5uaF5ktuQ== X-Received: by 2002:a17:90b:3b8a:b0:1f5:1df2:1fff with SMTP id pc10-20020a17090b3b8a00b001f51df21fffmr2741159pjb.169.1660726328644; Wed, 17 Aug 2022 01:52:08 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:08 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 09/20] UBUNTU: SAUCE: x86/xen: save and restore steal clock Date: Wed, 17 Aug 2022 16:51:38 +0800 Message-Id: <20220817085150.2078055-13-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Save steal clock values of all present CPUs in the system core ops suspend callbacks. Also, restore a boot CPU's steal clock in the system core resume callback. For non-boot CPUs, restore after they're brought up, because runstate info for non-boot CPUs are not active until then. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273212/ (cherry picked from commit f38e01e8076c5185c3ca62ce3836ec0511cb2fd7 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/suspend.c | 13 ++++++++++++- arch/x86/xen/time.c | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index 784c4484100b..dae0f74f5390 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -91,12 +91,20 @@ void xen_arch_suspend(void) static int xen_syscore_suspend(void) { struct xen_remove_from_physmap xrfp; - int ret; + int cpu, ret; /* Xen suspend does similar stuffs in its own logic */ if (xen_suspend_mode_is_xen_suspend()) return 0; + for_each_present_cpu(cpu) { + /* + * Nonboot CPUs are already offline, but the last copy of + * runstate info is still accessible. + */ + xen_save_steal_clock(cpu); + } + xrfp.domid = DOMID_SELF; xrfp.gpfn = __pa(HYPERVISOR_shared_info) >> PAGE_SHIFT; @@ -118,6 +126,9 @@ static void xen_syscore_resume(void) pvclock_resume(); + /* Nonboot CPUs will be resumed when they're brought up */ + xen_restore_steal_clock(smp_processor_id()); + gnttab_resume(); } diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 9ef0a5cca96e..cc11dd2e2f48 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -548,6 +548,9 @@ static void xen_hvm_setup_cpu_clockevents(void) { int cpu = smp_processor_id(); xen_setup_runstate_info(cpu); + if (cpu) + xen_restore_steal_clock(cpu); + /* * xen_setup_timer(cpu) - snprintf is bad in atomic context. Hence * doing it xen_hvm_cpu_notify (which gets called by smp_init during From patchwork Wed Aug 17 08:51:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=i33SVASN; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xW0QHNz1ygF for ; Wed, 17 Aug 2022 18:52:47 +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 1oOEmy-00014l-QD; Wed, 17 Aug 2022 08:52:36 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmd-0000VG-Ja for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:15 +0000 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 3EA1D3F46B for ; Wed, 17 Aug 2022 08:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726332; bh=XtgNIIadsr/v1ORur+hQaY0gHvae8nF/qbdguWCNmGs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i33SVASN/r46ERFNjbxp3d/6n1AzWLrxuoj1sJz0TvRrmWqqEwdHlbTzy9N0TXGju PdGUWZTFfjVwHuKzWc/DvV5J0eo1JmnnICPI/LfqQ9exOSe4zlooaXMSMaNntrov/7 lCpnTHzISUiKuUDMPvZ43GD4a+D7DEN46fyng08ghiYcIrfjHSmhRFsWxobXl7Ht1A JzzNtLFd8V22oOcaaECNdoxMnswhe1jeiOglw2OanHk5Hb0k/Ac+MwcfwZGRIgf/Zt yS1EbQulWq6LrjWWUOiOKf1tx9WXvv2qlramU9cGxt84WXg3xYJX65cEqCFvwOn0rO JNeWxd1DhCftg== Received: by mail-pf1-f200.google.com with SMTP id c142-20020a621c94000000b005324991c5b8so4797303pfc.15 for ; Wed, 17 Aug 2022 01:52:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=XtgNIIadsr/v1ORur+hQaY0gHvae8nF/qbdguWCNmGs=; b=WnSNvtiJx6rAvyYOn9doT3LDOkSIo+Kyz5O8jrtOZf4r/aIVXp7Af2CpdB52IL6jUw TFJcG+NfpRPljJP9rOU5xk5Cy7ZzbgcqeVucbBd+3a5l3O71RUWGefIMMfew30Wq7Hpu U/SVBoLRhJcnuAFceF9IJ+0Z86ljc4Ci4jdofJr9Ghzbp/6fRC+YNuPa7C+EcfSS2SsG 7p/kVmx8CbuxLwdRVL/JL0GX42CbxCHsFegtJY+2ld339RaO1FqKmD+37PwYAKvXE4xl GCoWqlialxtVlCK2RjAERxgTjD/js5iw5lvdRDIi2CkYApEfBM1oU4WqCmGt8ZjrYwlm QoOw== X-Gm-Message-State: ACgBeo3HRYhXSZLueTR30vcwY6LhIVcLEi5b9y4uxJGMIgYrfuCFsZfH gWkftvDvct/d0/16oJXbO438UY5qbTI3ffw9d6o56ML35swpKnzwIRs36gwpDT7Wx5I9W1FgBeV 3hSvsGEy3jRD5ylrpJeKgcueCV01rDlMTKZ0hYZSC5w== X-Received: by 2002:a65:5688:0:b0:3c2:1015:988e with SMTP id v8-20020a655688000000b003c21015988emr20876490pgs.280.1660726330016; Wed, 17 Aug 2022 01:52:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CKathIRagcRVJRBMUI+MVK2o5k6ECSEjJ7KMdFs7jQuBalNm5qIfXs0mB+NmxMnGKGo1hRA== X-Received: by 2002:a65:5688:0:b0:3c2:1015:988e with SMTP id v8-20020a655688000000b003c21015988emr20876476pgs.280.1660726329649; Wed, 17 Aug 2022 01:52:09 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:09 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 10/20] UBUNTU: SAUCE: xen/events: add xen_shutdown_pirqs helper function Date: Wed, 17 Aug 2022 16:51:39 +0800 Message-Id: <20220817085150.2078055-14-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Add a simple helper function to "shutdown" active PIRQs, which actually closes event channels but keeps related IRQ structures intact. PM suspend/hibernation code will rely on this. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273214/ (cherry picked from commit 5d311aa62b86e7ef655895c973e1422395b2d3fa amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/events/events_base.c | 12 ++++++++++++ include/xen/events.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 46d9295d9a6e..36c683aee9d4 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -2124,6 +2124,18 @@ void xen_irq_resume(void) restore_pirqs(); } +void xen_shutdown_pirqs(void) +{ + struct irq_info *info; + + list_for_each_entry(info, &xen_irq_list_head, list) { + if (info->type != IRQT_PIRQ || !VALID_EVTCHN(info->evtchn)) + continue; + + shutdown_pirq(irq_get_irq_data(info->irq)); + } +} + static struct irq_chip xen_dynamic_chip __read_mostly = { .name = "xen-dyn", diff --git a/include/xen/events.h b/include/xen/events.h index 344081e71584..7f30459489d7 100644 --- a/include/xen/events.h +++ b/include/xen/events.h @@ -86,6 +86,7 @@ static inline void notify_remote_via_evtchn(evtchn_port_t port) void notify_remote_via_irq(int irq); void xen_irq_resume(void); +void xen_shutdown_pirqs(void); /* Clear an irq's pending state, in preparation for polling on it */ void xen_clear_irq_pending(int irq); From patchwork Wed Aug 17 08:51:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=BtTQxCXd; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xc6jHNz1ygF for ; Wed, 17 Aug 2022 18:52:52 +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 1oOEn3-0001BZ-Np; Wed, 17 Aug 2022 08:52:41 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmd-0000Vj-4R for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:15 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D48733FB94 for ; Wed, 17 Aug 2022 08:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726332; bh=ktEGjgQ2/GBQmayyYgmMOsxe/9J/tcFMDjZVgEXSLrY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BtTQxCXdnTBvSaUjnVJug99hBXaW3ad73ZA1B0qQey9XpsZaPEwQNYKWtFxU2QTSs mdZ9fD2qLOn+WxWG0jzn9lbUFFgre78/ISllPYGM6Q+EfnweWjQla1TC/2oLEK2Oec oLuYcgMEWEy7n4fCHktujONXEyWwjDaYJvpPg1NfLioHnwmD/N7CgM7M5X91ncs6Wm zlr/uuc5FUEBBlmuEUjZPM/1XpdegSAZwaV//jVRAKlIg5i7rlYvmgDzc7AxKYo7x/ o9W+c9VWvxk23VKCrCRZ6efOLOCi2iXPhX0i0KZFPh+ZiqvN7/2YCT025JJd4YWr0S p++PsGpo0uiTw== Received: by mail-pl1-f200.google.com with SMTP id l2-20020a170902f68200b00171590ddc3bso7955287plg.2 for ; Wed, 17 Aug 2022 01:52:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=ktEGjgQ2/GBQmayyYgmMOsxe/9J/tcFMDjZVgEXSLrY=; b=B2zB4SaMV56k17PHwUuq1akqSbQ40Ez/p+wKRbHlER3ktvYcmnxQtNyuKyVrijjN+O SRP3jF07bUAS0tzN12kne6Ipv+3e+2H8WTQoDy/LbnxINZv3HGn01Ec6ig5ZHihyhVcC brtDALIhp4Qj8nQm+NTZNcdPejKVtYzD0Ij1WBt7y8dHsirv5o5k7R6ckHEoePoYGPKm 5QQ788WSUqoJpZn0Uw45cGikL9A7KqYjeYoXLcFSQe9OWEgxjkK7uhWxxX+SVe9QwlS7 9vsDjnfLlBptHh7RcULAchVKjZYw9mf9AB49mUPV0IE/+FdY3vlQhpuihL0ClRRPlH2v XrMA== X-Gm-Message-State: ACgBeo0ZnupUmc8TVx+sDLBt8LRWSCh6DYhTRTg/CirjwsFZf2lvR/lF 2M7uXVxTl/yOj6OXjujOg6uhb8r+Yo6cTV0ko58DXCsvLcjtX5RasGrH5pHvZNiJYjLXp7hZNXM /rvbkwJiiVjfWeHHFR+TcCgHru0e2wf0ygIbIfZ9EAw== X-Received: by 2002:a65:5504:0:b0:41d:271:4929 with SMTP id f4-20020a655504000000b0041d02714929mr20969083pgr.606.1660726331245; Wed, 17 Aug 2022 01:52:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5VtOTZou+A8N+HI8xC/b253xYV0wQmRb/kIMsEv4RgLF0q/FsXylwuU+ZNr2hUPRq6yEcoug== X-Received: by 2002:a65:5504:0:b0:41d:271:4929 with SMTP id f4-20020a655504000000b0041d02714929mr20969065pgr.606.1660726330741; Wed, 17 Aug 2022 01:52:10 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:10 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 11/20] UBUNTU: SAUCE: x86/xen: close event channels for PIRQs in system core suspend callback Date: Wed, 17 Aug 2022 16:51:40 +0800 Message-Id: <20220817085150.2078055-15-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Munehisa Kamata BugLink: https://bugs.launchpad.net/bugs/1968062 Close event channels allocated for devices which are backed by PIRQ and still active when suspending the system core. Normally, the devices are emulated legacy devices, e.g. PS/2 keyboard, floppy controller and etc. Without this, in PM hibernation, information about the event channel remains in hibernation image, but there is no guarantee that the same event channel numbers are assigned to the devices when restoring the system. This may cause conflict like the following and prevent some devices from being restored correctly. [ 102.330821] ------------[ cut here ]------------ [ 102.333264] WARNING: CPU: 0 PID: 2324 at drivers/xen/events/events_base.c:878 bind_evtchn_to_irq+0x88/0xf0 ... [ 102.348057] Call Trace: [ 102.348057] [] dump_stack+0x63/0x84 [ 102.348057] [] __warn+0xd1/0xf0 [ 102.348057] [] warn_slowpath_null+0x1d/0x20 [ 102.348057] [] bind_evtchn_to_irq+0x88/0xf0 [ 102.348057] [] ? blkif_copy_from_grant+0xb0/0xb0 [xen_blkfront] [ 102.348057] [] bind_evtchn_to_irqhandler+0x27/0x80 [ 102.348057] [] talk_to_blkback+0x425/0xcd0 [xen_blkfront] [ 102.348057] [] ? __kmalloc+0x1ea/0x200 [ 102.348057] [] blkfront_restore+0x2d/0x60 [xen_blkfront] [ 102.348057] [] xenbus_dev_restore+0x58/0x100 [ 102.348057] [] ? xenbus_frontend_delayed_resume+0x20/0x20 [ 102.348057] [] xenbus_dev_cond_restore+0x1e/0x30 [ 102.348057] [] dpm_run_callback+0x4e/0x130 [ 102.348057] [] device_resume+0xe7/0x210 [ 102.348057] [] ? pm_dev_dbg+0x80/0x80 [ 102.348057] [] dpm_resume+0x114/0x2f0 [ 102.348057] [] hibernation_snapshot+0x15f/0x380 [ 102.348057] [] hibernate+0x183/0x290 [ 102.348057] [] state_store+0xcf/0xe0 [ 102.348057] [] kobj_attr_store+0xf/0x20 [ 102.348057] [] sysfs_kf_write+0x3a/0x50 [ 102.348057] [] kernfs_fop_write+0x10b/0x190 [ 102.348057] [] __vfs_write+0x28/0x120 [ 102.348057] [] ? rw_verify_area+0x49/0xb0 [ 102.348057] [] vfs_write+0xb2/0x1b0 [ 102.348057] [] SyS_write+0x46/0xa0 [ 102.348057] [] entry_SYSCALL_64_fastpath+0x1a/0xa9 [ 102.423005] ---[ end trace b8d6718e22e2b107 ]--- [ 102.425031] genirq: Flags mismatch irq 6. 00000000 (blkif) vs. 00000000 (floppy) Note that we don't explicitly re-allocate event channels for such devices in the resume callback. Re-allocation will occur when PM core re-enable IRQs for the devices at later point. Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8273217/ (cherry picked from commit 46bd378646b79f762eae1ad124694302fe1aa2f9 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/suspend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index dae0f74f5390..affa63d4b6bd 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -105,6 +105,8 @@ static int xen_syscore_suspend(void) xen_save_steal_clock(cpu); } + xen_shutdown_pirqs(); + xrfp.domid = DOMID_SELF; xrfp.gpfn = __pa(HYPERVISOR_shared_info) >> PAGE_SHIFT; From patchwork Wed Aug 17 08:51:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=B3h9mXD9; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xr2ZmTz1ygF for ; Wed, 17 Aug 2022 18:53:04 +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 1oOEnE-0001cO-LS; Wed, 17 Aug 2022 08:52:52 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEme-0000XN-2Q for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:16 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D7FA63FBA1 for ; Wed, 17 Aug 2022 08:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726333; bh=Sk/LJrt0K7abio5L1k2YEh52W0+e4OVvf61DhS/6ByI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B3h9mXD9vA+jnK57ImQOAXR+ippEpvWuaPPKwr9iXNDlq7s+MGQHj4IPMhnpYHcd+ 5uOes8R4HAUQu+TM0N4Q8Q1s9vfw08jkUAXoWDfOv6YmVewPomYqYEy9O+PZ2564GS +lObLDbT7MOwF/oQA3/j7AqRIghXqzHw86mx5OggmUPAMewP+AmJfEllrujpVpui2i qHWQav5TO81z10vt8r/JPIi+Kc/m/iuH5sqP2WQ42Kdc8t2UPfgEsZ0kLFa61L1rW6 9rTSmntnSf0JIAk9627FlHD4F70y9Bd+cNoT+KmnDO7RfM4KfyGTucWIjRBKC2/+Ut Br/AhzIrsfR+A== Received: by mail-pg1-f198.google.com with SMTP id 130-20020a630088000000b004276c4c600fso4121528pga.9 for ; Wed, 17 Aug 2022 01:52:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=Sk/LJrt0K7abio5L1k2YEh52W0+e4OVvf61DhS/6ByI=; b=kPtWXpK2kMbn89O54dO3XK98fAFC8RdFJKEBqbe7j83Rtx7UYH1YgbZG41fjyF2G8k SABxdSYahPgSpAz8lY0hyMsnWKZhXCyI6OCEbhulAbrKZ89pUWzCxohj5XYjR9mb8Be0 hTtPi5rraaSY5oLl0sRNoFLdq2l44Mc1MXLzdKFhbmv//XGrMReSb9N9berEhXUjGvQo bSyjGQr6kcmGGjAwb/AH0jkBcFulOvceOq99Chb72h2bfmRwGO3+HoroVv96JvcFSHsI yW/ZYhRxuu6xkPiEmgMSPK5mwq/L8aoTvg6rRtvDv2BAQs3timugE1/gEA2tc1KYS+D5 bkCw== X-Gm-Message-State: ACgBeo0yr5NLxDxk6lTx/n2wAMj0b0Zfk8rMcJSVjQrV+vEqplH+YN9A mc4HdRybehv+11u0m1NtXVuXUOSWinlAVynTxC3HhABMzhVh8lQQX6Dk26vACyN2xUfQOri4aTZ stILeMF2K8JyMNl6tFkJYkQEuaT/v/HNq+otJB8OSTQ== X-Received: by 2002:a63:6848:0:b0:421:9052:1ac9 with SMTP id d69-20020a636848000000b0042190521ac9mr20530522pgc.183.1660726332288; Wed, 17 Aug 2022 01:52:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR4DUSFFN14Tb8fKSZwbzLlM1hLXP0yYO/kd6zhJFAVNvdlsIVl27nLBQAGCqYFfxpA4Fv7HDQ== X-Received: by 2002:a63:6848:0:b0:421:9052:1ac9 with SMTP id d69-20020a636848000000b0042190521ac9mr20530512pgc.183.1660726331956; Wed, 17 Aug 2022 01:52:11 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:11 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 12/20] UBUNTU: SAUCE: PM / hibernate: update the resume offset on SNAPSHOT_SET_SWAP_AREA Date: Wed, 17 Aug 2022 16:51:41 +0800 Message-Id: <20220817085150.2078055-16-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Aleksei Besogonov BugLink: https://bugs.launchpad.net/bugs/1968062 The SNAPSHOT_SET_SWAP_AREA is supposed to be used to set the hibernation offset on a running kernel to enable hibernating to a swap file. However, it doesn't actually update the swsusp_resume_block variable. As a result, the hibernation fails at the last step (after all the data is written out) in the validation of the swap signature in mark_swapfiles(). Before this patch, the command line processing was the only place where swsusp_resume_block was set. Signed-off-by: Aleksei Besogonov Signed-off-by: Munehisa Kamata Signed-off-by: Anchal Agarwal Reviewed-by: Munehisa Kamata Reviewed-by: Eduardo Valentin CR: https://cr.amazon.com/r/8297650/ (cherry picked from commit af7ba9de0abd9cbf761e8c3feb5377c5ddf51a29 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- kernel/power/user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/power/user.c b/kernel/power/user.c index 740723bb3885..ba7a6431acff 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -233,6 +233,10 @@ static int snapshot_set_swap_area(struct snapshot_data *data, if (data->swap < 0) return swdev ? -ENODEV : -EINVAL; data->dev = swdev; + + swsusp_resume_device = swdev; + swsusp_resume_block = offset; + return 0; } From patchwork Wed Aug 17 08:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=WObe++5u; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71xz0Sr7z1ygF for ; Wed, 17 Aug 2022 18:53:11 +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 1oOEnI-0001rJ-QG; Wed, 17 Aug 2022 08:52:57 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmf-0000Yk-Kd for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:17 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E9A863FBA6 for ; Wed, 17 Aug 2022 08:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726334; bh=7zO9O8Fmyh/++nhTEoAdJek98Vu4Qd+sdEF1/Ka4J78=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WObe++5uYQkiD5VWpaD47KXbx/Yy68p9oEgjfC5Yf2Yvv1qRwKaYMeTaoEVYGbfoT 7PNHN8RIVpavdn1rDjiiEZSmNjRNIxsniV0+9UMuHWo4+Y1bMvrU5OowmsXl7XgVP2 MXLr5zJaw0EIBnrImeI9502hCWsEYvhNBLCmBcPHvl5Fth7fGfucYpdFjRqucyA0x5 IfMKBN1zWWD7vzw7xvAz0w1WoKVCwYs5WSrhTouqq06Q1hFNVQpSxVrjoa1ZKZlGmz pk63IdjkKGrtPuHJpP3G2wZexud4SKadWAWJhpNr2mIxoCGujiVqm/n/GH90MAdGCO AWKOPkuLHzduw== Received: by mail-pg1-f197.google.com with SMTP id k16-20020a635a50000000b0042986056df6so2735262pgm.2 for ; Wed, 17 Aug 2022 01:52:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=7zO9O8Fmyh/++nhTEoAdJek98Vu4Qd+sdEF1/Ka4J78=; b=6GW0TcKG46+JGcHOltHKnd8ZcReR2NilEHJY2JLlPapdMlxBqcDRWausOJKuL3aPBz 6f/iK10LvprhK8ug8xJWXXDJGhoBpBifKOmfK6D2u/Sv0OegBITHY6xALfzhptVr+K1e K5DDsSM/yQy6D3Nkj7wc3oU5eU46AIFrPLzNISCTYImcS63RDzGGulBVJnD3LFDLoiz8 E3KM8WDYoSnIbwpqgwBH3K0vlEAGezWhKM0Cn97oPrJa9EbYxSZhqFKfFfL22D9oKloZ R/VmlqmjkSY7XweNXyoWBX27t8o1pEXmrlN7mCC7ujnpCDaHF9nXi4Jpu0yD98cb5StX gRxA== X-Gm-Message-State: ACgBeo0dm4zKmOsfZObSed8gxvcaY0vBuMkIh04UQds6vbsA9vqqwRbS ny45RZNunv8kmoMU/E7+OwRrl/ysHtinx+9KIIvtAqfB+y9DDNgESrGsQEfpflZzDrwNO0dBJ0f MPLxf7AqkjZAr4heh5JOOiiLbZgoQ46VlErosbodmRg== X-Received: by 2002:a63:83c2:0:b0:429:a2aa:b651 with SMTP id h185-20020a6383c2000000b00429a2aab651mr5932556pge.500.1660726333424; Wed, 17 Aug 2022 01:52:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR6P50pImei4PxplQlCByMC6mNsnyzJswuewxSPKakZgNeELwaPzqKk11dwydzmH744bEKFhDQ== X-Received: by 2002:a63:83c2:0:b0:429:a2aa:b651 with SMTP id h185-20020a6383c2000000b00429a2aab651mr5932544pge.500.1660726333030; Wed, 17 Aug 2022 01:52:13 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:12 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 13/20] UBUNTU: SAUCE: Revert "xen: dont fiddle with event channel masking in suspend/resume" Date: Wed, 17 Aug 2022 16:51:42 +0800 Message-Id: <20220817085150.2078055-17-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Anchal Agarwal BugLink: https://bugs.launchpad.net/bugs/1968062 This reverts commit e91b2b1194335ca83d8a40fa4e0efd480bf2babe. evtchn are supposed to be masked during resume however they are not which causes special interrupts like PV spinlock to cause kernel BUG() as its expects the IRQ to be masked. This causes instances that are live migrated successfully to crash after few minutes. Signed-off--by: Anchal Agarwal Signed-off--by: Eduardo Valentin Reviewed-by: Frank van der Linden Reviewed-by: Alakesh Haloi Reviewed-by: Vallish Vaidyeshwara CR: https://cr.amazon.com/r/8361544/ (cherry picked from commit 79435eaffd1695c8379e70e2f41ee41e4ad84ba9 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/events/events_base.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 36c683aee9d4..5883320002d0 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -540,6 +540,14 @@ static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu, channels_on_cpu_inc(info); } +static void xen_evtchn_mask_all(void) +{ + evtchn_port_t evtchn; + + for (evtchn = 0; evtchn < xen_evtchn_nr_channels(); evtchn++) + mask_evtchn(evtchn); +} + /** * notify_remote_via_irq - send event to remote end of event channel via irq * @irq: irq of event channel to send event to @@ -2104,6 +2112,7 @@ void xen_irq_resume(void) struct irq_info *info; /* New event-channel space is not 'live' yet. */ + xen_evtchn_mask_all(); xen_evtchn_resume(); /* No IRQ <-> event-channel mappings. */ @@ -2253,7 +2262,6 @@ static int xen_evtchn_cpu_dead(unsigned int cpu) void __init xen_init_IRQ(void) { int ret = -EINVAL; - evtchn_port_t evtchn; if (xen_fifo_events) ret = xen_evtchn_fifo_init(); @@ -2273,8 +2281,7 @@ void __init xen_init_IRQ(void) BUG_ON(!evtchn_to_irq); /* No event channels are 'live' right now. */ - for (evtchn = 0; evtchn < xen_evtchn_nr_channels(); evtchn++) - mask_evtchn(evtchn); + xen_evtchn_mask_all(); pirq_needs_eoi = pirq_needs_eoi_flag; From patchwork Wed Aug 17 08:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ZAwjurgo; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yF1FTQz1ygF for ; Wed, 17 Aug 2022 18:53:25 +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 1oOEnc-0002qY-HH; Wed, 17 Aug 2022 08:53:16 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmi-0000cV-KI for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:20 +0000 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 35E363FB94 for ; Wed, 17 Aug 2022 08:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726336; bh=jKlQG++X0Epmn5PLiXbHMmuuK9yJTxcynaOew6rwNDU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZAwjurgoSIxmv4gvHH+jGnwOZY7g6VkWDiAfJYFzge8K/wUKW3nrLNUjvQeRW19C4 jeeVcj9Ve2Lc/3aR0hiShkxZqi7GQ3m1l4UWDiM/KaxKpltpfO6h97O1vhWnElctO5 uO8hCAn+1+j7yQDLv4YBDy7RN5FSieas67Wc9GJUsi4WkFo4JO4d/XUZPUcF6LFU/h 2My14Mgrn4lG0/Ivxv7zLWnJAp8C2DpUxiwY6sgxSi8WOgy2mVgPfRvifKUWVIs5Ai BtWUSRDuOP6fGlu+ze1J68Hzrka4GnrOSPy55ynGPogR/GekCAqZVwn1VjE6L6rprP 9Pwtxj1i8YjIw== Received: by mail-pg1-f200.google.com with SMTP id p9-20020a63c149000000b00420f9b67f0bso5026258pgi.19 for ; Wed, 17 Aug 2022 01:52:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=jKlQG++X0Epmn5PLiXbHMmuuK9yJTxcynaOew6rwNDU=; b=I5cLy2eCNg5kqA2XaZyLuR3FpFpY5HeXIkZGsjFIf4/3tscDrFY1WpF/a/UPCme1DE grniQZPAIuJzg1g3Qz56BnlUYDyKAnLOdZvfdU49leSfz4XcWaUHF/ka/FfgnLaZe3RY Da1M7k9WqLpnng42ANnkonNb9h9bX1XQT8EME2on75DXuiYc+sOEouEqDDHXHRGLBYj6 wpW4P0WRk+wu4W00Wl/96jIoENkeERKVIZxeO8zJ0OHCU0dvNLpSQy7UifIrUDsfhdor qRj7foLAiNXdONmbzfpPbt1RKoIi4+EjGsUzthWIGpEwoSrIQwXUHq4K42lixjWK6G9n C7NQ== X-Gm-Message-State: ACgBeo0+rY+XpnL09WvuJeOqCTObhnVb2ab74tHkqJGnp6jvoVtl/GK5 Tw32x6Jp/0Z5uCpnLYtHnmRuIt7b+CO/BSoqEfOEp3ICw+msvgJy/xDukyCWvxf995Pnz4SI8O0 WP/7aqbJtWw+pGJgmLn+i82oadU6a0+MRF+304VKlyA== X-Received: by 2002:a17:903:1c7:b0:171:3ba4:9bb8 with SMTP id e7-20020a17090301c700b001713ba49bb8mr25397337plh.105.1660726334571; Wed, 17 Aug 2022 01:52:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZVszNzdWfPrkVTg/Xg1j3VdHzxQ3vI7i6iTwiKaP20hQA1C2IYPE2LmPESLdUQh2QEM8e9Q== X-Received: by 2002:a17:903:1c7:b0:171:3ba4:9bb8 with SMTP id e7-20020a17090301c700b001713ba49bb8mr25397310plh.105.1660726334111; Wed, 17 Aug 2022 01:52:14 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:13 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 14/20] UBUNTU: SAUCE: xen-blkfront: Fixed blkfront_restore to remove a call to negotiate_mq Date: Wed, 17 Aug 2022 16:51:43 +0800 Message-Id: <20220817085150.2078055-18-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Anchal Agarwal BugLink: https://bugs.launchpad.net/bugs/1968062 The code for talk_to_blkback API changed in kernel-4.14.45 to include a call to negotiate_mq. Subsequent calls causes kernel panic [ 84.440105] Call Trace: [ 84.443707] talk_to_blkback+0x6d/0x8b0 [xen_blkfront] [ 84.449147] blkfront_restore+0x33/0x60 [xen_blkfront] [ 84.453336] ? xenbus_read_otherend_details+0x50/0xb0 [ 84.457804] xenbus_dev_cancel+0x5f/0x160 [ 84.463286] ? xenbus_dev_resume+0x170/0x170 [ 84.466891] dpm_run_callback+0x3b/0x100 [ 84.470516] device_resume+0x10d/0x420 [ 84.473844] dpm_resume+0xfd/0x2f0 [ 84.476984] hibernation_snapshot+0x218/0x410 [ 84.480794] hibernate+0x14b/0x270 [ 84.484030] state_store+0x50/0x60 [ 84.487443] kernfs_fop_write+0x105/0x180 [ 84.492695] __vfs_write+0x36/0x160 [ 84.496672] ? __audit_syscall_entry+0xbc/0x110 [ 84.502123] vfs_write+0xad/0x1a0 [ 84.506857] SyS_write+0x52/0xc0 [ 84.511420] do_syscall_64+0x67/0x100 [ 84.516365] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 [ 84.522571] RIP: 0033:0x7f44a03407e4 [ 84.526210] RSP: 002b:00007ffd5e0ec3c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 84.534041] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f44a03407e4 [ 84.542571] RDX: 0000000000000004 RSI: 0000000001e94990 RDI: 0000000000000001 [ 84.549142] RBP: 0000000001e94990 R08: 00007f44a060c8c0 R09: 00007f44a0c57740 [ 84.554658] R10: 00007f44a03cd320 R11: 0000000000000246 R12: 0000000000000004 [ 84.560411] R13: 0000000000000001 R14: 00007f44a060b760 R15: 0000000000000004 [ 84.565744] Code: 39 ab e8 00 00 00 77 8a 31 c0 5b 5d c3 44 8b 05 50 57 00 00 45 85 c0 0f 84 2f ff ff ff 89 c0 48 69 f8 e0 40 01 00 e9 30 ff ff ff <0f> 0b 48 8b 7b 28 48 c7 c2 78 58 16 a0 be f4 ff ff ff e8 7e 37 [ 84.580594] RIP: negotiate_mq+0x12b/0x150 [xen_blkfront] RSP: ffffc90000ebbc70 Signed-off-by: Anchal Agarwal Reviewed-by: Frank van der Linden Reviewed-by: Vallish Vaidyeshwara (cherry picked from commit 5458460569d5b9b7a93481f0967c123e5d8fc62d amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/block/xen-blkfront.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 1efa83e11c85..3ebff999ca70 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2630,11 +2630,6 @@ static int blkfront_restore(struct xenbus_device *dev) { struct blkfront_info *info = dev_get_drvdata(&dev->dev); int err = 0; - - err = negotiate_mq(info); - if (err) - goto out; - err = talk_to_blkback(dev, info); if (err) goto out; From patchwork Wed Aug 17 08:51:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=BQ3n1Xxg; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71y63WJ1z1ygF for ; Wed, 17 Aug 2022 18:53:18 +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 1oOEnU-0002Q9-FW; Wed, 17 Aug 2022 08:53:08 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmh-0000cA-5Z for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:19 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4C80F3F46B for ; Wed, 17 Aug 2022 08:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726337; bh=A4l8gW4qXp/DhvLcbtj81P0LtVTzTJGJYt3b3DjRwJ0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BQ3n1XxgptcxSzrn6qLE/mbLW0uL00y/Q/3Itv3/wvU2VZB09YnqfROcIs7vUdQWu 8eiQjoq3/BX3717pfAi6pB6fN8REiQkegqLHEHfV0QdIRAXQd5eCXKh89q/eJn4htX WoWaTFOysnTFpQFNcJE+O8jrGw5eT81B5LAQAScNOyk5zbaLtHh5UZ429Pxt94TjUV L9KlaLVjk3Hkhgw7be1JYE7ZDfTp7PMBeTdaT+gwDILTJaYghjCMdRhFixlM3Y7DSz d90MhhvgNHEQABApfrqyJnWKAfhxrNZHkf/8OYkybdsiGbHpdUpiznkJc/lNezJR3T I7/E+GXmGMXiw== Received: by mail-pg1-f197.google.com with SMTP id f128-20020a636a86000000b004291bf13aa8so3308255pgc.18 for ; Wed, 17 Aug 2022 01:52:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=A4l8gW4qXp/DhvLcbtj81P0LtVTzTJGJYt3b3DjRwJ0=; b=t0FnqnPoGgw11ULvRFQWn+8DcOFVBOwxsIXw+Z/xNeRv+HkOmc/VYhTr+GXTOVc93G LwG3QIG4gHLicAD+4a8q06+lNQnrmwGulhtY4UIfeY3iSU8vIAKEZ7d7JxTwL5hf4pLA +G5x7kRwlVHfeoN7+mFlu760IatrAU4woQia8Jcm5BbV85BWAseqjSXXy1qiOJWP/Idg arsRNZ0UKEBfscM2zb/0SiTGRtlFTdPlFGq3pYWkdPVxvtzQ8yaRcibVAwXIZLfzKX2E 5fsUzLFi0HfM08c1x8MBuBcHCf7yiVWB5tLowcj+IB/TPVEY7jlp9pN6XeNWQDQyDfO0 sW+Q== X-Gm-Message-State: ACgBeo2oatp82fL1R2YjIQW/H3uN76KGBZJnLyZs1KGZhcltSHxqIhbe PfSv1fHNPJ3/ggkeESy/U7CaP/TD/gBR53Kym2DBTnTXsjBRlfAjUlOMnUeoqslNC6lYDWN9LHN ksmqNvUD/2SEb/YmmKSqj3Z4my9DsfeHzVQ842rS1iw== X-Received: by 2002:a17:90b:4b8e:b0:1f5:49bd:8b0e with SMTP id lr14-20020a17090b4b8e00b001f549bd8b0emr2724315pjb.86.1660726335762; Wed, 17 Aug 2022 01:52:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Z/8NpUuVs1YQbDcU6JlYevSDXoGtq+d+FhlukBW8epx+A4NVH8Mwv4bYm1WxY5ILwq7el7g== X-Received: by 2002:a17:90b:4b8e:b0:1f5:49bd:8b0e with SMTP id lr14-20020a17090b4b8e00b001f549bd8b0emr2724294pjb.86.1660726335351; Wed, 17 Aug 2022 01:52:15 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:14 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][PATCH 15/20] UBUNTU: SAUCE: x86: tsc: avoid system instability in hibernation Date: Wed, 17 Aug 2022 16:51:44 +0800 Message-Id: <20220817085150.2078055-19-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Eduardo Valentin BugLink: https://bugs.launchpad.net/bugs/1968062 System instability are seen during resume from hibernation when system is under heavy CPU load. This is due to the lack of update of sched clock data, and the scheduler would then think that heavy CPU hog tasks need more time in CPU, causing the system to freeze during the unfreezing of tasks. For example, threaded irqs, and kernel processes servicing network interface may be delayed for several tens of seconds, causing the system to be unreachable. Situation like this can be reported by using lockup detectors such as workqueue lockup detectors: [root@ip-172-31-67-114 ec2-user]# echo disk > /sys/power/state Message from syslogd@ip-172-31-67-114 at May 7 18:23:21 ... kernel:BUG: workqueue lockup - pool cpus=0 node=0 flags=0x0 nice=0 stuck for 57s! Message from syslogd@ip-172-31-67-114 at May 7 18:23:21 ... kernel:BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0 nice=0 stuck for 57s! Message from syslogd@ip-172-31-67-114 at May 7 18:23:21 ... kernel:BUG: workqueue lockup - pool cpus=3 node=0 flags=0x1 nice=0 stuck for 57s! Message from syslogd@ip-172-31-67-114 at May 7 18:29:06 ... kernel:BUG: workqueue lockup - pool cpus=3 node=0 flags=0x1 nice=0 stuck for 403s! The fix for this situation is to mark the sched clock as unstable as early as possible in the resume path, leaving it unstable for the duration of the resume process. This will force the scheduler to attempt to align the sched clock across CPUs using the delta with time of day, updating sched clock data. In a post hibernation event, we can then mark the sched clock as stable again, avoiding unnecessary syncs with time of day on systems in which TSC is reliable. Reviewed-by: Erik Quanstrom Reviewed-by: Frank van der Linden Reviewed-by: Balbir Singh Reviewed-by: Munehisa Kamata Tested-by: Anchal Agarwal Signed-off-by: Eduardo Valentin CR: https://cr.amazon.com/r/8440112/ (cherry picked from commit 885c53db2a97468e0e9af8b4a4b034034f9c182b amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/kernel/tsc.c | 29 +++++++++++++++++++++++++++++ include/linux/sched/clock.h | 5 +++++ kernel/sched/clock.c | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index a698196377be..597b35ae7197 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -1575,3 +1576,31 @@ unsigned long calibrate_delay_is_known(void) return 0; } #endif + +static int tsc_pm_notifier(struct notifier_block *notifier, + unsigned long pm_event, void *unused) +{ + switch (pm_event) { + case PM_HIBERNATION_PREPARE: + clear_sched_clock_stable(); + break; + case PM_POST_HIBERNATION: + /* Set back to the default */ + if (!check_tsc_unstable()) + set_sched_clock_stable(); + break; + } + + return 0; +}; + +static struct notifier_block tsc_pm_notifier_block = { + .notifier_call = tsc_pm_notifier, +}; + +static int tsc_setup_pm_notifier(void) +{ + return register_pm_notifier(&tsc_pm_notifier_block); +} + +subsys_initcall(tsc_setup_pm_notifier); diff --git a/include/linux/sched/clock.h b/include/linux/sched/clock.h index 867d588314e0..902654ac5f7e 100644 --- a/include/linux/sched/clock.h +++ b/include/linux/sched/clock.h @@ -32,6 +32,10 @@ static inline void clear_sched_clock_stable(void) { } +static inline void set_sched_clock_stable(void) +{ +} + static inline void sched_clock_idle_sleep_event(void) { } @@ -51,6 +55,7 @@ static inline u64 local_clock(void) } #else extern int sched_clock_stable(void); +extern void set_sched_clock_stable(void); extern void clear_sched_clock_stable(void); /* diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index c2b2859ddd82..98003d1e8f5a 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -116,7 +116,7 @@ static void __scd_stamp(struct sched_clock_data *scd) scd->tick_raw = sched_clock(); } -static void __set_sched_clock_stable(void) +void set_sched_clock_stable(void) { struct sched_clock_data *scd; @@ -236,7 +236,7 @@ static int __init sched_clock_init_late(void) smp_mb(); /* matches {set,clear}_sched_clock_stable() */ if (__sched_clock_stable_early) - __set_sched_clock_stable(); + set_sched_clock_stable(); return 0; } From patchwork Wed Aug 17 08:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=vEEC+Imb; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yH58RKz1ygF for ; Wed, 17 Aug 2022 18:53:27 +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 1oOEnf-0002ys-3Y; Wed, 17 Aug 2022 08:53:19 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmk-0000fi-Gj for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:22 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id AFB5B3F46B for ; Wed, 17 Aug 2022 08:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726339; bh=h+O60z4V7rOWvrlvA6dyR5xApd1/MsOBgT8bGn9plFg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vEEC+ImbXtoLi3qV5cNLADppPKnGJzsexJKzIc9ert2yYxABLEwMDgCCWFMxQM4Sk rckCMErJp4JyP5FKd+FxMvhyf33nk/gqaNMdjlBo8vNz/bt+723y01mDvH5hDv39/X UqXPi/o3p9UoBhc5I7iSe6CiqOdTIoPgw+tVQY0x64zb7sVN91Z8876XSk0/qjjkTe 49p1S2s90i4dxGCyeIpvjN2dl7ahTQwms+hPEMT9rUL1k8oVSVopz2cTqpNI3GKpAx nq0kj/lsPekoIsEjYOaWXa1AaXymqtvFdeYUIqehnjSd9wfPGt0Fq3gqDt3iX0dJ4w MPQ+jE7i9++QA== Received: by mail-pj1-f69.google.com with SMTP id q10-20020a17090a2dca00b001f89ba05a54so644923pjm.8 for ; Wed, 17 Aug 2022 01:52:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=h+O60z4V7rOWvrlvA6dyR5xApd1/MsOBgT8bGn9plFg=; b=BlCAyQHucEK8ar4+cmv2F7suy+zA221AcPkEd4wFK8ei857DEDyChlLZTq40yrw9Or dQjMbYrUAVr9EXXVwbVWlufiYuzdSS4jJcbleTqj3nMo/IGaJ0ZWzNcxI7oqd8ZJ8vGt gTPHD4qWKqIBF/cGKf7d+X4EexzcsVqfpZUGjqjSHJ0q3AGeNcg3N6Fppg1CyWoPMSQ+ 7KkAux6ozybgRubl9Gf7BckL1IxgGCp1bASPIRklRQ6BsBd0FCvO4vZtQ5dslF7nCMMO you2GXa4Ekk9ebiPSl6xTKOzoWYDj+sf9ZzBKnq/emiDs+JmzZWKoH1ZVfpZe34OEe6H ggHA== X-Gm-Message-State: ACgBeo0o31ghge1ltd85XqQOwiXlGkPQdO2wrOFwXkSROc6HNzY+RQql 8wEm6tw7jvZSzfEM7uIS/j+ry0afx8cn3gBlk30wTdSBMlVc3ni4/hL0ffeJEkW1RI5DwJeV4Dm iaiRreS9TCGxcXFSb+VCYhxOQv8yg+wnhY19xlZRG/g== X-Received: by 2002:a17:903:31c9:b0:16c:3024:69c4 with SMTP id v9-20020a17090331c900b0016c302469c4mr25586574ple.81.1660726338155; Wed, 17 Aug 2022 01:52:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VuPG11yIZZxckLhIQN4R0sLmQJ5+lgemIHCprZ/fiNrkwEaitn09vSYHSjCjF7hQDUYpgrQ== X-Received: by 2002:a17:903:31c9:b0:16c:3024:69c4 with SMTP id v9-20020a17090331c900b0016c302469c4mr25586547ple.81.1660726337764; Wed, 17 Aug 2022 01:52:17 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:17 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 16/20] UBUNTU: SAUCE: block: xen-blkfront: consider new dom0 features on restore Date: Wed, 17 Aug 2022 16:51:46 +0800 Message-Id: <20220817085150.2078055-21-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Eduardo Valentin BugLink: https://bugs.launchpad.net/bugs/1968062 On regular start, the instance will perform a regular boot, in which rootfs is mounted accordingly to the xen-blkback features (in particular feature-barrier and feature-flush-cache). That will setup the journal accordingly to the provided features on SB. On a start from hibernation, the instance boots, detects that a hibernation image is present, push the image to memory and jumps back where it was. There is no regular mount of the rootfs, it uses the data structures already in the previous saved memory image. Now, When the instance hibernates, it may move from its original dom0 to a new dom0 when it is restarted. So, given the above, if the xen-blkback features change then the guest can be in trouble. And I see the original assumption was that the dom0 environment would be preserved. I did a couple of experiments, and I confirm that these particular features change quite a lot across hibernation attempts: [ 2343.157903] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 2444.712339] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 2537.105884] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 2636.641298] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 2729.868349] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 2827.118979] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 2924.812599] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 3018.063399] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 3116.685040] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 3209.164475] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 3317.981362] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 3415.939725] blkfront: xvda: flush diskcache: enabled; persistent grants: disabled; indirect descriptors: enabled; [ 3514.202478] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; [ 3619.355791] blkfront: xvda: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled; Now, considering the above, this patch fixes the following scenario: a. Instance boots and sets up bio queue on a dom0 A with softbarrier supported. b. hibernates c. When asked to restore, the instance is back on dom0 B with unsupported softbarrier. d. Restoration goes well until next journal commit is issued. Remember that it is still using the previous image rootfs data structures, therefore is gonna request a softbarrier. e. The bio will error out and throw a "operation not supported" message and cause the journal to fail, and it will decide to remount the rootfs as RO. [ 1138.909290] print_req_error: operation not supported error, dev xvda, sector 4470400, flags 6008 [ 1139.025685] Aborting journal on device xvda1-8. [ 1139.029758] print_req_error: operation not supported error, dev xvda, sector 4460544, flags 26008 [ 1139.326119] Buffer I/O error on dev xvda1, logical block 0, lost sync page write [ 1139.331398] EXT4-fs error (device xvda1): ext4_journal_check_start:61: Detected aborted journal [ 1139.337296] EXT4-fs (xvda1): Remounting filesystem read-only [ 1139.341006] EXT4-fs (xvda1): previous I/O error to superblock detected [ 1139.345704] print_req_error: operation not supported error, dev xvda, sector 4096, flags 26008 The fix is essentially to read xenbus to query the new xen blkback capabilities and update them into the request queue. Reviewed-by: Balbir Singh Reviewed-by: Vallish Vaidyeshwara Signed-off-by: Eduardo Valentin (cherry picked from commit 740afde3ef282dfdd4a3c179f3de0ae33162e85c amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/block/xen-blkfront.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 3ebff999ca70..d607823c7934 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -2630,6 +2630,9 @@ static int blkfront_restore(struct xenbus_device *dev) { struct blkfront_info *info = dev_get_drvdata(&dev->dev); int err = 0; + + blkfront_gather_backend_features(info); + xlvbd_flush(info); err = talk_to_blkback(dev, info); if (err) goto out; From patchwork Wed Aug 17 08:51:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=J1BNX6mS; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yP4fDYz1ygF for ; Wed, 17 Aug 2022 18:53:33 +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 1oOEnk-0003Dn-22; Wed, 17 Aug 2022 08:53:24 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmk-0000hd-Ou for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:22 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E11423F46E for ; Wed, 17 Aug 2022 08:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726340; bh=l/kx0lSfJD9eMwwj4yc80tN7ysNfdky4bMaajWn2qPw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J1BNX6mSwWPnXTkj9xOR54EXWEyBQ25dfZjNeLuQZKdWIzn3IsIlSycB2coMfnihJ Y7HT2TKMEPkRk/8y9MTaWPffPO25R7sP4MbuqXHTYDWHAHvt/TnVILW7FgQVFBrXAl 4pe8O0Qv0LW3kJ1070tXc2Xk3uoNHV5mygy3RTQsMNPupst0dnM9QMKhseRhsFKE66 hQsVSxfpTOSFbKAfmEGkuuBRFN6+YAAUniGus6H3ZpWSbeutzEwcNBx4zvCKBpnKni +gE2btVwK8DLzv0J266mUExmITIp4tPJ940Z7BWaTREpuS3lwKB5BlCLfuThRF1ZNn bP3vkaGZL1X2A== Received: by mail-pj1-f71.google.com with SMTP id t10-20020a17090a4e4a00b001fab2c791dcso646442pjl.5 for ; Wed, 17 Aug 2022 01:52:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=l/kx0lSfJD9eMwwj4yc80tN7ysNfdky4bMaajWn2qPw=; b=Iuc4BvCUaG/gnbQQnFQPl7byd28LntYbPPpNAwU6V3ZA+QG4NnO4NjEVSnvnRcKDcS anlxa9d9MSt5Y17JvYelTZDRtNl8ii+cb+OMMtWSjKLRuiMFHcYCZPf1IHJYx25mPwXr zS3JuDPF+8qGcrT/X5T+StB8QI4IXQQGJ6nt0fGSODZsKzhi2nfwJR8hBxujt4Rbh0uG MGwftD+q4olym4aZuxfhVI1r0ur+GMFiJgc1J3MsN9J4Im757lZsbdLanezqpVBwQA5x EjygE3GD1x39jGiLe6GSWuvifwM359v1bEaLegTIOJHv08x1klCL5SCD4LaMQygopu4x 5TeQ== X-Gm-Message-State: ACgBeo2Cf26VoKb1qMmz07Y0AdzUiO+Iu1l3qJoDfI87EFbB7aAjFu8F nsCLRmTrLbw4DmN+swZXoFAGtsOKAlWUTzn5lhdisT0pl/M1BeTsY71Rg1vuQPAKC3L0wCbmC7T Cez3bNTFt9eIfBSlN2TQSmFFoctensyY4ecTZ8it00A== X-Received: by 2002:a17:90a:f411:b0:1f7:620c:4a83 with SMTP id ch17-20020a17090af41100b001f7620c4a83mr2743213pjb.43.1660726339316; Wed, 17 Aug 2022 01:52:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR5KqUn2ZjySIKYKbSrG0ifObTAxdvh4YVeSRJXM6ezaoMH18mWYnISMV+3miS9UV5rfX7StDQ== X-Received: by 2002:a17:90a:f411:b0:1f7:620c:4a83 with SMTP id ch17-20020a17090af41100b001f7620c4a83mr2743199pjb.43.1660726339005; Wed, 17 Aug 2022 01:52:19 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:18 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 17/20] UBUNTU: SAUCE: xen: restore pirqs on resume from hibernation. Date: Wed, 17 Aug 2022 16:51:47 +0800 Message-Id: <20220817085150.2078055-22-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Frank van der Linden BugLink: https://bugs.launchpad.net/bugs/1968062 The hibernation code unlinks event channels from these (legacy) IRQs, so they must be reinitialized on wakeup, much like in the Xen suspend/resume case. Signed-off-by: Frank van der Linden Reviewed-by: Cristian Gafton Reviewed-by: Anchal Agarwal Reviewed-by: Alakesh Haloi CR: https://code.amazon.com/reviews/CR-3702953/ (cherry picked from commit 5ac2dbdedcf419c726f323cd4c2f93ff652b46b4 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/suspend.c | 2 ++ drivers/xen/events/events_base.c | 5 +++++ include/xen/events.h | 1 + 3 files changed, 8 insertions(+) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index affa63d4b6bd..39644923b623 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -132,6 +132,8 @@ static void xen_syscore_resume(void) xen_restore_steal_clock(smp_processor_id()); gnttab_resume(); + + xen_restore_pirqs(); } /* diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 5883320002d0..0249e34104ac 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -2145,6 +2145,11 @@ void xen_shutdown_pirqs(void) } } +void xen_restore_pirqs(void) +{ + restore_pirqs(); +} + static struct irq_chip xen_dynamic_chip __read_mostly = { .name = "xen-dyn", diff --git a/include/xen/events.h b/include/xen/events.h index 7f30459489d7..72fb0167eb2e 100644 --- a/include/xen/events.h +++ b/include/xen/events.h @@ -87,6 +87,7 @@ void notify_remote_via_irq(int irq); void xen_irq_resume(void); void xen_shutdown_pirqs(void); +void xen_restore_pirqs(void); /* Clear an irq's pending state, in preparation for polling on it */ void xen_clear_irq_pending(int irq); From patchwork Wed Aug 17 08:51:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=uISAyYAE; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yL3Bhmz1ygF for ; Wed, 17 Aug 2022 18:53:30 +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 1oOEnh-00036E-QX; Wed, 17 Aug 2022 08:53:21 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmk-0000hw-Ci for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:22 +0000 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 099EB3FB94 for ; Wed, 17 Aug 2022 08:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726341; bh=kRph3bJSEdXYNiQemR+sknPvrv9/7AozHYxBl3ArvjU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uISAyYAElbg4p7pFIBQ29+nKwCSfC0UPaSOhW+JhQEMz4iPdylYfTsPzBfm7hWs1Q Vj9rHWurDxb2LnYT01kv85MRI1JZHJFt+SbDwp3ULk71bti4P3nmOaOoeiebhdnN9x nW20ngUid8mjCHwwyjqTAPjLjb+tldkMzkY1UfrbAYkFESJphLMiNh+Hejvlu0MCs/ 13wVNDxrqV/hGscIg367YK2N6661YO1UV+rGfmcmCAE5N5KSm1WT9hlDdGgvd7oGUp V8ZlVzHvLfLSA1jC3MpKrncm59K+NCiNtDP/3pxcznuDQR11tqHBY9BFaqYU3NAQmz 0a4b7y3QtpNZQ== Received: by mail-pj1-f71.google.com with SMTP id o18-20020a17090aac1200b001f3252af009so853857pjq.7 for ; Wed, 17 Aug 2022 01:52:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=kRph3bJSEdXYNiQemR+sknPvrv9/7AozHYxBl3ArvjU=; b=shraTrhQdvDboPIkVzcX0pIJ6rXX258KMnDljlGZw392Gt79mGO85F/ewQZc62jf7c cyLoNUlkh1/cpGKWg3hjNqPk29r3EbM+aBRX0w5O9zzAUGL/Yn814GW4JkzTS6g6OCu3 fIum72aXyv9GrJgRrn2JsLtetf8iC3wn2mzTADQ+EC0+96QCrvgjmSCPpMVyWR+D8iCu N158p8lOBfhfni3+pLJ4LoyfQYUxM7u+zwzIwpUOA2O7DePmteH2mYQRdBY2ZKx/Ndh/ duDyN7LAeshAjYzf4bIqnu8PmAgE8mxMERzTfz0zqlr65Hz7kK5jjQDpoVQSL8N01Oe0 zNFw== X-Gm-Message-State: ACgBeo3dAxsfAXdhvXeWvZG/w8hEL01t1Sgz2iv/W7hof9KFKgJUE5y1 YK4MNBqh/JO+MbrTX5ZxF+HvR6WdoMeSDdshgiHjsWtYV7FGdyDXj9NTfqzBb7lyV1mksmFBAac RNaiq7YPniokiSLpuzeQ0ExkLmw3pCBpY3W5OBROSOw== X-Received: by 2002:a17:90b:4b91:b0:1f4:e116:8f1 with SMTP id lr17-20020a17090b4b9100b001f4e11608f1mr2745639pjb.121.1660726340399; Wed, 17 Aug 2022 01:52:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IrnqoT4sRK6SRL2d/NcWEmSGHP31x6/jMujZYvZLHOIXI8YpWL8dEbQB8wrGVej5Lflsspw== X-Received: by 2002:a17:90b:4b91:b0:1f4:e116:8f1 with SMTP id lr17-20020a17090b4b9100b001f4e11608f1mr2745606pjb.121.1660726340008; Wed, 17 Aug 2022 01:52:20 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:19 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 18/20] UBUNTU: SAUCE: xen: Only restore the ACPI SCI interrupt in xen_restore_pirqs. Date: Wed, 17 Aug 2022 16:51:48 +0800 Message-Id: <20220817085150.2078055-23-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Frank van der Linden BugLink: https://bugs.launchpad.net/bugs/1968062 Restoring all PIRQs, which is the right thing to do, was causing problems on larger instances. This is a horrible workaround until this issue is fully understood. Signed-off-by: Frank van der Linden Reviewed-by: Alakesh Haloi Reviewed-by: Anchal Agarwal Reviewed-by: Qian Lu (cherry picked from commit 6eaed73fd397db40f80ee36abcfdf77dca0ca20a amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/xen/events/events_base.c | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 0249e34104ac..775af2aa6dc8 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -66,6 +66,10 @@ #include #include +#ifdef CONFIG_ACPI +#include +#endif + #include "events_internal.h" #undef MODULE_PARAM_PREFIX @@ -2145,9 +2149,45 @@ void xen_shutdown_pirqs(void) } } +/* + * For now, only restore the ACPI SCI pirq. + */ void xen_restore_pirqs(void) { - restore_pirqs(); +#ifdef CONFIG_ACPI + int pirq, rc, irq, gsi; + struct physdev_map_pirq map_irq; + struct irq_info *info; + + list_for_each_entry(info, &xen_irq_list_head, list) { + if (info->type != IRQT_PIRQ) + continue; + + pirq = info->u.pirq.pirq; + gsi = info->u.pirq.gsi; + irq = info->irq; + + if (gsi != acpi_gbl_FADT.sci_interrupt) + continue; + + map_irq.domid = DOMID_SELF; + map_irq.type = MAP_PIRQ_TYPE_GSI; + map_irq.index = gsi; + map_irq.pirq = pirq; + + rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); + if (rc) { + pr_warn("xen: ACPI SCI interrupt map failed, rc=%d\n", + rc); + xen_free_irq(irq); + continue; + } + + printk(KERN_DEBUG "xen: restored ACPI SCI interrupt\n"); + + __startup_pirq(irq); + } +#endif } static struct irq_chip xen_dynamic_chip __read_mostly = { From patchwork Wed Aug 17 08:51:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=ABI1VcIl; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yR4Tkkz1ygF for ; Wed, 17 Aug 2022 18:53:35 +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 1oOEnl-0003KE-V3; Wed, 17 Aug 2022 08:53:25 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmn-0000lN-Ut for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:26 +0000 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 36C763F46B for ; Wed, 17 Aug 2022 08:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726343; bh=0zIjbsIDOOdPW8LRTb6q+6Xg2YPta4KM/gblbZTUX4s=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ABI1VcIl0NyR1wMcya3lnrHoIJzS91B6qIEpPTAJTpnGV3kmjP97wY7nOdF00NwKr uuuO39S9RtvA+NgkxsRlyxcuY11+BbYCL/KmaI5LRIZVqfkNAcF0iokTJWplJlVU3E 5abXCmJaOMqno4Txd3mYsfy4CN7Zqh58uuBl27tZVeFbAGZldN+cMx4+g9H58Nlo7W EMosw8Vyb3qDCkrNJs4sPT5wkWUUz6rpmlZQGcB3hcuofIghRS29XYdUdOUMYXG14s QT7nv7xHkjoTLei25dEPw9TA5GI2UNjgcJS/guC+ObArMy7xxdrVkG2UDLtw5SDLsx 9f9sesz7IcbiA== Received: by mail-pf1-f197.google.com with SMTP id s22-20020a056a00195600b0052ece6c829fso4744663pfk.6 for ; Wed, 17 Aug 2022 01:52:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=0zIjbsIDOOdPW8LRTb6q+6Xg2YPta4KM/gblbZTUX4s=; b=17Ng6/hKdbfRZggWaw7wCsHS/KvkZTAjlo6SBVDyggiij3BDBbtMuWW323O6X1Cm7K 2mmYE1z40ylGpzneDdFFz9xR+WH9y+eRAy0SEMIw6LSXpjAO3NHtVhApELUryxbwealJ PrLmP6skm+Psk1J/6JQoZp9VDSazTAMJpCNjle5T54Mq/LnpkxZtwrxTOtEwb5kH7V4o crunTx9cj4wyzazEni0WzeP1wKXrrgZqT5H6xiOCy6ju/NtIWT5FGtvDM8f+fAWPxfnC BNV1z7tLdEw3UDvJAfLVptz8Y15C58XWEgJVtzWBlCqYa8rBbNVo7bzxdDoH5Y00eTXe NT1A== X-Gm-Message-State: ACgBeo3KXYpif7F8Oa7aQmsFcPAzylHq3fPyai3dKWiuD1VCoos1Njyz QAbYChLBePATrpxPccJqtv6lCYObnrULnoXmERQIXm8opzTrS0SQKw+utcCpKH1iSePPZ1w0cyk l8oy15XLmwP+6/9+XCvEUuvb2Uv4SuoSvjs1jWk66Gg== X-Received: by 2002:a17:90b:4c07:b0:1f5:40a:8040 with SMTP id na7-20020a17090b4c0700b001f5040a8040mr2692973pjb.121.1660726341428; Wed, 17 Aug 2022 01:52:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR60OuqUfcdMUAjKQNkIRMeO6zps0Pzo1e88Wj8ZpU0MvTE6+p/luzrjcLUo9Qhp7byj+UBNNw== X-Received: by 2002:a17:90b:4c07:b0:1f5:40a:8040 with SMTP id na7-20020a17090b4c0700b001f5040a8040mr2692958pjb.121.1660726341048; Wed, 17 Aug 2022 01:52:21 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:20 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 19/20] UBUNTU: SAUCE: xen-netfront: call netif_device_attach on resume Date: Wed, 17 Aug 2022 16:51:49 +0800 Message-Id: <20220817085150.2078055-24-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Frank van der Linden BugLink: https://bugs.launchpad.net/bugs/1968062 When xennet_connect is called in the resume path, it needs to re-attach the netif, otherwise it will no longer be found by various operations (such as ethtool ioctls, etc). Signed-off-by: Frank van der Linden Reviewed-by: Alakesh Haloi Reviewed-by: Vallish Vaidyeshwara (cherry picked from commit d1b942fd87e869b26a5aa1abac29347dbff6ba43 amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- drivers/net/xen-netfront.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 0304fa9f40dc..8a0829aee3af 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -2501,6 +2501,13 @@ static int xennet_connect(struct net_device *dev) device_unregister(&np->xbdev->dev); return err; } + } else { + /* + * In the resume / thaw case, the netif needs to be + * reattached, as it was detached in netfront_freeze(). + */ + if (np->freeze_state == NETIF_FREEZE_STATE_FROZEN) + netif_device_attach(dev); } rtnl_lock(); From patchwork Wed Aug 17 08:51:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Yang X-Patchwork-Id: 1667169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=U2BNT6Je; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M71yV27RQz1ygF for ; Wed, 17 Aug 2022 18:53:38 +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 1oOEnn-0003Q9-R3; Wed, 17 Aug 2022 08:53:27 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oOEmo-0000my-Qe for kernel-team@lists.ubuntu.com; Wed, 17 Aug 2022 08:52:27 +0000 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1FBD53F46E for ; Wed, 17 Aug 2022 08:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660726344; bh=fJQ/i2Wt2dEeWNvEdbDOL8nnOZifugISRN9mykymTco=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U2BNT6JeJw0cvs8kNSzKL3k1ktfyfvs0cu/FG4nNb7MTlllpxCyabUTCwfyR4YxZO N+OYQesHisSJUCd58AHLxSTdI3SlY5wggKQ/EirGDZnDdVc0lxjZnG5cQlKmF0ghBf tMIqyigzm9oQW+WWQ9uIyADjgpIpG8/RFU2cfqB+KiWacEsgh3aJVqEyhWowUv3M7l gqlDXetoGNmhqRl1ygqP5wZt6iS/2+12rj+rkSOv8/UmEGH1SwVJzqAC3VsCGEOde6 0IBHW8uBnpsTbEKlG/eY0HXoDI4Q66lNA6YPG/TQ383e6MuxyUJs8zaEj6IYSIMkFX AgucnQ72bnIWw== Received: by mail-pl1-f197.google.com with SMTP id n8-20020a170902e54800b001729df300d7so604494plf.18 for ; Wed, 17 Aug 2022 01:52:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=fJQ/i2Wt2dEeWNvEdbDOL8nnOZifugISRN9mykymTco=; b=OwpH1EEPAnR4WY+MEYr9hjqMeNhbKQd6Nbw66/Bc7Zh2cEhyuDfI3CaFzuqUVWF71z n4YbLiVR3zRGt698wg7w7x5ABnJ65z4ZmtXByXsDDwZ7rnKnAbiGhnvjk3RXgvIDZ1N6 WHiP8uZh0vuaoyKTialDhtWhlCLDu3v9BnnAz9JeeyVgiUjFvJvqfZqftKPezsOwZk8S Zb8yPGUl7bGXfo0dmjfzEBqX78xWv1nQ8UnNqsWtxl0Hrwun3xH8KxuVbq22tmerqaAK pvPsulpCKkcHrtIL4/r2D9YqJn0N82cjEYN4kVEw/l35Qo3sLXsvrpKbOrHWq0lKQ7gv FCEw== X-Gm-Message-State: ACgBeo2ylk4AcEksw0qPBn1MI3LAK12JTJnqrICs7f/9LtAa9MUlb1z4 rWvT1gX8cH9o1zc/Gx90rNEY4k4bc4gpnE/3YxAA4/ewr7PyWz6t9hvv5KY18qulC6pbZ6x5y7I b2WlRMv3EyrOxPGgvKsDhUZHRKsPyO+VQC2pKwg4w/g== X-Received: by 2002:a17:90b:4d91:b0:1f5:24a:ff7e with SMTP id oj17-20020a17090b4d9100b001f5024aff7emr2736955pjb.194.1660726342581; Wed, 17 Aug 2022 01:52:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vGeHOtq0eJ+1hX96+hludE+6jvjZlC+HGSLZt+0FpX0ltdafgXX1KJqqdmQ3RCKBlFEBRlA== X-Received: by 2002:a17:90b:4d91:b0:1f5:24a:ff7e with SMTP id oj17-20020a17090b4d9100b001f5024aff7emr2736939pjb.194.1660726342103; Wed, 17 Aug 2022 01:52:22 -0700 (PDT) Received: from localhost.localdomain (220-135-31-21.hinet-ip.hinet.net. [220.135.31.21]) by smtp.gmail.com with ESMTPSA id s90-20020a17090a69e300b001f522180d46sm1001033pjj.8.2022.08.17.01.52.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 01:52:21 -0700 (PDT) From: Gerald Yang To: kernel-team@lists.ubuntu.com Subject: [SRU][jammy/linux-aws][kinetic/linux-aws][PATCH 20/20] UBUNTU: SAUCE: xen: Restore xen-pirqs on resume from hibernation Date: Wed, 17 Aug 2022 16:51:50 +0800 Message-Id: <20220817085150.2078055-25-gerald.yang@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220817085150.2078055-1-gerald.yang@canonical.com> References: <20220817085150.2078055-1-gerald.yang@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: Anchal Agarwal BugLink: https://bugs.launchpad.net/bugs/1968062 shutdown_pirq is invoked during hibernation path and hence PIRQs should be restarted during resume. [Commit: xen: Only restore the ACPI SCI interrupt in xen_restore_pirqs] restores only ACPI SCI interrupt however, that is not the right thing to do as all pirqs should be enabled as a part of resume_device_irqs during suspend/resume device interrupts. Apparently, chip->irq_startup is called only if IRQD_IRQ_STARTED is unset during irq_startup on resume. This flag gets cleared by free_irq->irq_shutdown during suspend. free_irq() never gets explicitly called for ioapic-edge and ioapic-level interrupts as respective drivers do nothing during suspend/resume. So we shut them down explicitly in the first place in syscore_suspend path to clear IRQ<>event channel mapping. shutdown_pirq being called explicitly during suspend does not clear this flags, hence .irq_enable is called in irq_startup during resume instead and pirq's never start up. This commit exports irq_state_clr_started API to clear the flag during shutdown_pirq. Also, following the order in which ipis/virqs/pirqs are restored during xen resume, the same order should be followed for hibernation path. As per the flow of hibernation_platform_enter, we should not restore pirqs explicitly in syscore_resume ops and it should be done in resume devices path. Signed-off-by: Anchal Agarwal (cherry picked from commit f6dd31829fa706ecbcd3ccaa4b5eaab25fe7bf6d amazon-5.15.y/mainline) Signed-off-by: Gerald Yang Signed-off-by: Matthew Ruffell --- arch/x86/xen/suspend.c | 1 - drivers/xen/events/events_base.c | 42 +------------------------------- include/linux/irq.h | 2 ++ kernel/irq/chip.c | 4 +-- 4 files changed, 5 insertions(+), 44 deletions(-) diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index 39644923b623..8be6ffa6bfbe 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c @@ -133,7 +133,6 @@ static void xen_syscore_resume(void) gnttab_resume(); - xen_restore_pirqs(); } /* diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 775af2aa6dc8..7beb5c658ef2 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -2146,50 +2146,10 @@ void xen_shutdown_pirqs(void) continue; shutdown_pirq(irq_get_irq_data(info->irq)); + irq_state_clr_started(irq_to_desc(info->irq)); } } -/* - * For now, only restore the ACPI SCI pirq. - */ -void xen_restore_pirqs(void) -{ -#ifdef CONFIG_ACPI - int pirq, rc, irq, gsi; - struct physdev_map_pirq map_irq; - struct irq_info *info; - - list_for_each_entry(info, &xen_irq_list_head, list) { - if (info->type != IRQT_PIRQ) - continue; - - pirq = info->u.pirq.pirq; - gsi = info->u.pirq.gsi; - irq = info->irq; - - if (gsi != acpi_gbl_FADT.sci_interrupt) - continue; - - map_irq.domid = DOMID_SELF; - map_irq.type = MAP_PIRQ_TYPE_GSI; - map_irq.index = gsi; - map_irq.pirq = pirq; - - rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); - if (rc) { - pr_warn("xen: ACPI SCI interrupt map failed, rc=%d\n", - rc); - xen_free_irq(irq); - continue; - } - - printk(KERN_DEBUG "xen: restored ACPI SCI interrupt\n"); - - __startup_pirq(irq); - } -#endif -} - static struct irq_chip xen_dynamic_chip __read_mostly = { .name = "xen-dyn", diff --git a/include/linux/irq.h b/include/linux/irq.h index c8293c817646..bb28da5d370c 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -811,6 +811,8 @@ extern int irq_set_msi_desc_off(unsigned int irq_base, unsigned int irq_offset, struct msi_desc *entry); extern struct irq_data *irq_get_irq_data(unsigned int irq); +extern void irq_state_clr_started(struct irq_desc *desc); + static inline struct irq_chip *irq_get_chip(unsigned int irq) { struct irq_data *d = irq_get_irq_data(irq); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index a98bcfc4be7b..1b1cd3ac5380 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -173,11 +173,11 @@ static void irq_state_clr_masked(struct irq_desc *desc) irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED); } -static void irq_state_clr_started(struct irq_desc *desc) +void irq_state_clr_started(struct irq_desc *desc) { irqd_clear(&desc->irq_data, IRQD_IRQ_STARTED); } - +EXPORT_SYMBOL_GPL(irq_state_clr_started); static void irq_state_set_started(struct irq_desc *desc) { irqd_set(&desc->irq_data, IRQD_IRQ_STARTED);