From patchwork Wed Mar 1 20:33:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 63090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3855821wrd; Wed, 1 Mar 2023 12:37:19 -0800 (PST) X-Google-Smtp-Source: AK7set8ce5FM84x69zpGLngCpCwcvqyCO3PBNZkj/ZuO0S4R2RNGESOI9rrkzNr7+2KPd9bmr5tt X-Received: by 2002:a17:903:41c8:b0:19e:699e:9b64 with SMTP id u8-20020a17090341c800b0019e699e9b64mr238492ple.65.1677703036139; Wed, 01 Mar 2023 12:37:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677703036; cv=pass; d=google.com; s=arc-20160816; b=pf1jkLw3GESKO3/QzysIJyl90wgwWVZ4538FNZZNivZEEXvEPyXm/CUyWnQG9vEBHv E97UBPdRz+9EEs0llg7RzZCJZX5+YowP3Hx2XnfRCGXSb5nlf4OVvyu222BiS2ku6Fy8 H6IqDZvNuHiIp4YR+AWCMMiBwy4vY442o4ysgKxOIu+b+vYunEYWlvf3EhNReDxrI2dj ATfZrKZXx7dkuqOPmIMZXts4N4csCsh91OweOOY3aHNAT59UD5USfPnXAQHR1i3e1wJC pU6POWwxsbSbH5ys2SdaXOptv6WaMX8EWP9LR43VUuetTJf2wgmPvcA3rv5tA31VWcap FG+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cCfva3MZF3+TDCGiaCDAXYi239+FjG5FfTY5/Hw5c5c=; b=uNxO5w8pFMQcVIinOtVMwEWnVN8Cm5ktLfj6dPrelR9l5XEKn9JsHg6pF1ivZqi8b1 z+k66Eri5a1jWSHMOK3kEQF4mHvduvL8f7xymKcER0nzT//nF2tvEbMm07hZDTPSFSMs ourNhPRTGrtYtq4SyT69GOSJh8lko/vYBHoKiRi6PNl4kI6y83J+SRlTtt9K36Q7PDXW rQS2Ckf3TOHOC2xneV7vV9B8761BJ2lYqTaTQ2vihbktNpjBUaBzhO9OVwY+UcM5IwCV c+V7ka5RkSsdSZ8nboUayhnVxQDQFfctKllLw21sW8P/kd7xW6eX52o42glZ4oolbaSW KHTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="km/vG0Yo"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v24-20020a1709028d9800b00198c1bc4067si13285691plo.102.2023.03.01.12.37.02; Wed, 01 Mar 2023 12:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="km/vG0Yo"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229589AbjCAUdc (ORCPT + 99 others); Wed, 1 Mar 2023 15:33:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjCAUda (ORCPT ); Wed, 1 Mar 2023 15:33:30 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7614AE04A for ; Wed, 1 Mar 2023 12:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XUB/2ONoGnZGo7XpDrj6C2PPzfz6XfJ3vNdzymon2T7HBy9tzuh7gEqf0lop7hAE4fpdOZL30nghAMFucIa0dFsGJ/2AUkK9cjf35r/q16lz87xms85s2Zp9Q/ErwFJNuqN1CmsUh8ng0VKI89UxNFSfkKQCSzFQevTHO2LPF/d7P2UusDgxgYz1uuQ0lVRLP9vNqJfzo1CXuoTiwgBHhQ2iUec2XQzn22q+D9g7EQvlDMGYQq8k9KIbT/Jc6gXnTwNzFlvxys/hpuZoxxDKQnq3lBaaA6R2QxBWLyL/enRcvV34+gzmFq9/xN7XV2qJz1fJZ48IOESsq4+7Q2iz8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cCfva3MZF3+TDCGiaCDAXYi239+FjG5FfTY5/Hw5c5c=; b=HIGP1Mi++kT10pvjctNDorzN4iTz5LDJmvCHjOSzQiqGWFTsjQF8aa23KFs/k59EG/HDye94OtsURs8u38A0pftnReMiiIstDl6BGa/4uP5T/yq2hopiTaPGw7lcGx01fRWWmCCL8gsBXGcy+tuTzJKAsa9dvzJhDbsv82ZnZkPqWIAMqqDuAk6BtBaYRivL3cRLpnArG7A6fWh013Duy4AGbiyh8/CtkiANu5WyxAugqwblvRG9pd+gPDh3upJXwzLyVLat9riWIKw0Aer/OIA5nbjifwlNzcnEU5z1HTZG2QvibbOEUThesf6tJf0DFM5WnMTtmsJUvbwP/ANiyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cCfva3MZF3+TDCGiaCDAXYi239+FjG5FfTY5/Hw5c5c=; b=km/vG0Yobst76TTtXqZcNINH/CJckSUNfv92dO8pUmJati590IFIYjcUXMxKPOED+Xz67l+UmGABlMt9XKKsp5tMG7MhSaM5nw/eKdQ80mIJhz5AgEI184pLzInivsjk1OaOmpjCJAkvIQqMM7Q7l+Z7NGThdN3bu089k6Zdd+Q= Received: from MW2PR16CA0026.namprd16.prod.outlook.com (2603:10b6:907::39) by CY5PR12MB6526.namprd12.prod.outlook.com (2603:10b6:930:31::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Wed, 1 Mar 2023 20:33:26 +0000 Received: from CO1NAM11FT108.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::5) by MW2PR16CA0026.outlook.office365.com (2603:10b6:907::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18 via Frontend Transport; Wed, 1 Mar 2023 20:33:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT108.mail.protection.outlook.com (10.13.175.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.18 via Frontend Transport; Wed, 1 Mar 2023 20:33:26 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 1 Mar 2023 14:33:24 -0600 From: Mario Limonciello To: Keith Busch , Jens Axboe , "Christoph Hellwig" , Sagi Grimberg CC: Mario Limonciello , , , Subject: [PATCH v2] nvme: Add a module parameter for users to force simple suspend Date: Wed, 1 Mar 2023 14:33:01 -0600 Message-ID: <20230301203302.28889-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT108:EE_|CY5PR12MB6526:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c818466-2501-480a-7dea-08db1a9435cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pm/dK7w0u8kIDpRpOe/O/W+k9SpqeneRkuvIn5aKfw3suXzm82ZLqjCu/RJQMCJDjHUntdnOnpS1lOaHbT4CDZGr8YCdR60QirQ5NJVoGZZoDjP3a5oZqNN2Sw+oYiGIk82Ra/zaCec0K10JGFEPt4wj29iGTOFs9Ko+KHGlHpnQIytBMNSKArkEGScjI8i1Egv03E2bGUeDUQ1EYaCOPZvDzqIIxXxXlukQDrsXc9yQMntpIehjnnxzVLFvUFk/Y6FVRwsKg3TgPX3zIhYoD7+8R0pF4NxuvKjrUmPynAU+XNf7ze91+OOBD9EKdoZAdS7qf8h3oStUIOLMLEwPoU9cQd8/ZSWgj6l9q2WxWtQwMZTMSG2ch99Ht6TlKmjVnXAubdy3jPwMTWphuH6ijtLyhcXwBUya+WcG+IcxN3LoWMFSreVqF6m26CGSzWOgAFccHGwsaSTUUZaimZZZvAZfqpCNt3Pa/pCCdzevmeywm+AZzH4LCGAoHd4gvbwKMqRXRoFQlCxe+I5MkSayaYBbYHg7RiaOCVRcBn/SXYG6FfbT6Bdw1r8SookfjiJVCc+0oTsbjQt4wbptPT1TD3v93QjaQHqLlrv3CJpVty0gLISFwPsyrlUJircVAEjOSwL8cftWv7p2mgbNgLmPT/SjoraIPWcE8/+wQU3ZAJAE39l0c7SwS+HjG3Gs6sHV0E3tUbiXeTT+XpvHnsc7p20Dy7DsSewkES9khsggMJALGgdupSUYpu4ZnFL/Szf7TDylm92jAXSOP2cacQ6eew== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(110136005)(81166007)(54906003)(8936002)(82740400003)(36756003)(316002)(16526019)(8676002)(40460700003)(478600001)(82310400005)(186003)(26005)(7696005)(44832011)(86362001)(356005)(40480700001)(966005)(6666004)(1076003)(15650500001)(2616005)(5660300002)(2906002)(336012)(4326008)(70206006)(83380400001)(70586007)(47076005)(66899018)(426003)(41300700001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2023 20:33:26.1505 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c818466-2501-480a-7dea-08db1a9435cb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT108.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6526 X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URI_TRY_3LD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759199139087519754?= X-GMAIL-MSGID: =?utf-8?q?1759199139087519754?= Elvis Angelaccio reports that his HP laptop that has two SSDs takes a long time to resume from suspend to idle and has low hardware sleep residency. In analyzing the logs and acpidump from the BIOS it's clear that BIOS does set the StorageD3Enable _DSD property but it's only set on one of the SSDs. Double checking the behavior in Windows there is no problem with resume time or hardware sleep residency. It appears that Windows offers a configuration setting for OEMs to utilize in their factory images and end users to set to force allowing D3 to be used for sleep. The preference would be that OEMs fix this in the BIOS by adding the StorageD3Enable _DSD to both disks, but as this works on Windows by such a policy we should offer something similar that users can utilize in Linux too. Remove the module parameter noacpi which could only be used to ignore StorageD3Enable and instead add a new module parameter for the NVME module that will let users force simple suspend to be enabled or disabled universally. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216773#c19 Link: https://learn.microsoft.com/en-us/windows/configuration/wcd/wcd-storaged3inmodernstandby Reported-by: elvis.angelaccio@kde.org Signed-off-by: Mario Limonciello --- v1->v2: * Rebase on nvme/nvme-6.3 * Replace noacpi parameter * Clear the quirk if set by driver and user set simple_suspend=0 --- drivers/nvme/host/pci.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index d68e2db00d0d..93dcd9dc8df9 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -102,9 +102,9 @@ static unsigned int poll_queues; module_param_cb(poll_queues, &io_queue_count_ops, &poll_queues, 0644); MODULE_PARM_DESC(poll_queues, "Number of queues to use for polled IO."); -static bool noacpi; -module_param(noacpi, bool, 0444); -MODULE_PARM_DESC(noacpi, "disable acpi bios quirks"); +static int simple_suspend = -1; +module_param(simple_suspend, int, 0444); +MODULE_PARM_DESC(simple_suspend, "use simple suspend for disks (0 = never, 1 = always, -1 = auto";) struct nvme_dev; struct nvme_queue; @@ -2898,7 +2898,30 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev) */ if ((dmi_match(DMI_BOARD_VENDOR, "LENOVO")) && dmi_match(DMI_BOARD_NAME, "LNVNB161216")) - return NVME_QUIRK_SIMPLE_SUSPEND; + return simple_suspend ? NVME_QUIRK_SIMPLE_SUSPEND : 0; + } + + return 0; +} + +/* + * Some systems include a BIOS _DSD property to ask for D3 + * or users may explicitly request it enabled. + */ +static unsigned long check_simple_suspend(struct pci_dev *pdev) +{ + switch (simple_suspend) { + case 0: + return 0; + case 1: + return NVME_QUIRK_SIMPLE_SUSPEND; + default: + break; + } + if (acpi_storage_d3(&pdev->dev)) { + dev_info(&pdev->dev, + "platform quirk: setting simple suspend\n"); + return NVME_QUIRK_SIMPLE_SUSPEND; } return 0; @@ -2932,15 +2955,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, dev->dev = get_device(&pdev->dev); quirks |= check_vendor_combination_bug(pdev); - if (!noacpi && acpi_storage_d3(&pdev->dev)) { - /* - * Some systems use a bios work around to ask for D3 on - * platforms that support kernel managed suspend. - */ - dev_info(&pdev->dev, - "platform quirk: setting simple suspend\n"); - quirks |= NVME_QUIRK_SIMPLE_SUSPEND; - } + quirks |= check_simple_suspend(pdev); ret = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops, quirks); if (ret)