From patchwork Thu Jul 7 12:53:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 588403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 723ABC433EF for ; Thu, 7 Jul 2022 12:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235910AbiGGM5B (ORCPT ); Thu, 7 Jul 2022 08:57:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbiGGM4r (ORCPT ); Thu, 7 Jul 2022 08:56:47 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A63731901 for ; Thu, 7 Jul 2022 05:56:15 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id e20so2199680lfq.11 for ; Thu, 07 Jul 2022 05:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H6677ejFNXKglyi/84+y7ULfVLWnlMQ6vEtVbRnv+vI=; b=Mh7gtpR4GcdX4WcgpOC+AbgtdPP6eO6z1dw11i6JBWeX1ULeCBz+lpRR3pORehirTa 86zxMqdsM7RuDU6w8EOL+0bNM0etAC2TTxfd4rjD2DVTQzvN0l2yN2NkcKW/SOItDMpU dFVvBoNMbXV0ILGAfklsAmdtRatKiwTaUIozP2JEbk7/qALXd9p+qfz20kNNYlYV1qWV WsTlyC+6KzVBm4GRcpUC6E5dhO3jWsgT93LvIVR6DWK6RLgMWU6M7UZiEttdlYL7cA14 1HDKQnyd1ly1tq5a3Tn/QJaBOUD1v1VUs2HOlRK7LDuaJp9FoGvesu5Aen5x1orm1k3l DQtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=H6677ejFNXKglyi/84+y7ULfVLWnlMQ6vEtVbRnv+vI=; b=FnoH76eWBQBOmZEJHFAUv/aDq91G22o6r2d1VCmjMzt5Hjoacxi1S8C2UcKsSeT6kv vzm+SiHVPw42pxRb5T1pKzFWCs079UCdHeY3XobBI6ZUXiWTJDxhDhxiEHOX3kp9nbaj lGzpYYVwafJXe6el6wxIfCA0LHgOmpq98955InFahE8HcR4LVMq59EH0Me+p1ksVVNYD hLMjiHk1ZkzWwrUw1t0Zb6QFQPF78HgQJtz5cU8Iki6RcrahPl0rk7qnoUe46SiwSlSI L48q6hx2gbNP3e+U07Kyb0fynN/ZSRQ0PiAXr5tbDbfLcVDs3E++MtnPYmVWXRb9EMuw ZaBw== X-Gm-Message-State: AJIora9tulqht4v/F8cQ5T6qq0ExwrjKVCFRgyAkQkTaltaORBKJkOa2 FUlEESEaIFQMANzYIGiWzjMd1Q== X-Google-Smtp-Source: AGRyM1tJ3jCvJ5a/DkRtsTuF+6ZetmEjN6/i+Wqc17/EryWUTrJPKEaxdDE3XdzFq4E7wl3HyOZznw== X-Received: by 2002:a05:6512:3d89:b0:47f:c089:1c7f with SMTP id k9-20020a0565123d8900b0047fc0891c7fmr31065785lfv.72.1657198573447; Thu, 07 Jul 2022 05:56:13 -0700 (PDT) Received: from jazctssd.c.googlers.com.com (138.58.228.35.bc.googleusercontent.com. [35.228.58.138]) by smtp.gmail.com with ESMTPSA id d7-20020a05651221c700b0047255d2111csm6810361lft.75.2022.07.07.05.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 05:56:12 -0700 (PDT) From: Grzegorz Jaszczyk To: linux-kernel@vger.kernel.org Cc: jaz@semihalf.com, dmy@semihalf.com, mario.limonciello@amd.com, seanjc@google.com, dbehr@google.com, upstream@semihalf.com, zide.chen@intel.corp-partner.google.com, "Rafael J. Wysocki" , Len Brown , Hans de Goede , Mark Gross , Pavel Machek , Mika Westerberg , Sachi King , linux-acpi@vger.kernel.org (open list:ACPI), platform-driver-x86@vger.kernel.org (open list:X86 PLATFORM DRIVERS), linux-pm@vger.kernel.org (open list:HIBERNATION (aka Software Suspend, aka swsusp)) Subject: [RFC PATCH 0/2] x86: allow to notify host about guest entering s2idle Date: Thu, 7 Jul 2022 12:53:22 +0000 Message-Id: <20220707125329.378277-1-jaz@semihalf.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org According to the mailing list discussion [1] about the preferred approach for notifying hypervisor/VMM about guest entering s2idle state this RFC was implemented. Instead of original hypercall based approach, which involves KVM change [2] and makes it hypervisor specific, implement different mechanism, which takes advantage of MMIO/PIO trapping and makes it hypervisor independent. Patch #1 extends S2Idle ops by new notify handler which will be invoked as a very last command before system actually enters S2Idle states. It also allows to register and use driver specific notification hook which is used in patch #2. Patch #2 introduces new driver for virtual PMC, which registers acpi_s2idle_dev_ops's notify handler. Its implementation is based on an ACPI _DSM evaluation, which in turn can perform MMIO access and allow to trap and therefore notify the VMM about guest entering S2Idle state. Please see individual patches and commit logs for more verbose description. This patchset is marked as RFC since patch #2 implements driver for non existing device "HYPE0001", which ACPI ID was not registered yet. Furthermore the required registration process [3] will not be started before getting positive feedback about this patchset. [1] https://patchwork.kernel.org/project/linux-pm/patch/20220609110337.1238762-2-jaz@semihalf.com/ [2] https://patchwork.kernel.org/project/linux-pm/patch/20220609110337.1238762-3-jaz@semihalf.com/ [3] https://uefi.org/PNP_ACPI_Registry Grzegorz Jaszczyk (2): suspend: extend S2Idle ops by new notify handler platform/x86: Add virtual PMC driver used for S2Idle drivers/acpi/x86/s2idle.c | 11 +++++ drivers/platform/x86/Kconfig | 7 ++++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/virt_pmc.c | 73 +++++++++++++++++++++++++++++++++ include/linux/acpi.h | 1 + include/linux/suspend.h | 1 + kernel/power/suspend.c | 4 ++ 7 files changed, 98 insertions(+) create mode 100644 drivers/platform/x86/virt_pmc.c