Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp145029iob; Tue, 17 May 2022 21:46:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGkRUOkwYRiSPTyVY9cTCncB0ciOfS8G/C5Hbzc/dH1RDFwvBWiavetNe528rhpk8zoCID X-Received: by 2002:a05:6a00:14cf:b0:510:5549:ad8a with SMTP id w15-20020a056a0014cf00b005105549ad8amr25654352pfu.24.1652849188257; Tue, 17 May 2022 21:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652849188; cv=none; d=google.com; s=arc-20160816; b=NOaldGN5RT5r9jn9eNW7dwhtW3v0t7t4qTIxSUnWxOsypKDu7fHEimyts0MriIueB1 qYIQ6X/7LhqV+HsRImSeJMGlnh+WjV1WjEBmixhaz4x4c2QWTXG7YvvaHbi/tmMASKkd 8Pl7EjQ04LqUS72/QakYPclI0Azba3tQEx6Wi022tzuYHicOuB6bTUduLTGD8atfPk2W JEb7qYP/5ColWzK7IOM1kLPDdDmxt4bJAWhMwc3CbL+RkHbGcukc1JeLZAfA5/ESraYW 5XP4E1ODpObLf18LC2iFhrKONHFdUVmG+X5uxUMKX06NkMfNhmLFm9gGYYAtD+VzxDcL PB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=X9rd48IcOQMlJI4fL1LiOmaxrjRg+Q4uXQPcsoEgV+k=; b=wFNCCMLvGJYncpC5n8xtlhscRrV/eCuu7VXyebZlaFnQKbNIZRDFfNWbwJHUyevbNq h7M+zeANA8F/YUzbGQV4O/aUv4kbeuxOCHVKlzo9Py4/ewqdn3+ia3HBEqnk/tt3GQ3k Oheu7XTJRyyfgdJ1qZt+WnzV/xSicWFdw7J18nJgRmtXi08LChbkQodYI57tFG2/NzqS pWZ8LaWUFEzxYLJ9zqS/Ja4A33TaZ1jseqoxAYIrS/te4/8SmBFs5HT+YCcnrW6WA4nh WyUHPK8Zlt2dHHxitbVaM4jlZd9/kUbStSybotcXET+JDNjPYL2MRTc4rgAPhFciFKIC u9Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FlPd4Ema; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q34-20020a635c22000000b003c64af6e01dsi1183402pgb.123.2022.05.17.21.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:46:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FlPd4Ema; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D51D4F749A; Tue, 17 May 2022 20:58:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230097AbiEQWI1 (ORCPT + 99 others); Tue, 17 May 2022 18:08:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbiEQWIY (ORCPT ); Tue, 17 May 2022 18:08:24 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B645377FA for ; Tue, 17 May 2022 15:08:23 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2fede3f229cso4575417b3.8 for ; Tue, 17 May 2022 15:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=X9rd48IcOQMlJI4fL1LiOmaxrjRg+Q4uXQPcsoEgV+k=; b=FlPd4Ema1RTlqOmUDneIdv1KEKzfvy5j81NCIQeDPZybHktJlCFTbLL4ZkCjfGPLVC nMHR9eGulo22rP5seemivgemqbsWdMosN/8jIZz+5WRGX7iR97kNyjmLjJacDnOJnsdn L+Rhi1RJ/5Vk2i2KnaG7WO10vJsTNBLaN4eITTnEPWFkpEzMB8yYbbm8Q3GEMOzVP5MQ 3HSQqqhUCeOpRHu4aKeQ6HDtK32bZIUNT2zL/+Kj+9UEztN8TtaM/gqYK841nJ9TcN5g GMI5o9E8QNXP+KkedPoVP3OeQsAjzD9IDLkczE0Iu+oj9bEqvQO47sCQW8NfvLUrFFVE NZ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=X9rd48IcOQMlJI4fL1LiOmaxrjRg+Q4uXQPcsoEgV+k=; b=7YuknLu1Skfdsae56zpV1glFmixxNYMSM85FTGiwJbdDtGgdn2pB+SD9wqKwQDSUqS qCV9GImRi4Xozny3d1wtoHCGqAvP+2h7qS+x9mlifNjlqCTkEhJw1JfUFE9umm1Ss56+ 3COzmh5o9n3Ro5/F8gEYteZxyEhzGVpZbHsqh2f7nOXjHfzl3/0lDoZH8TFfHXk42Bkc 1g+EenIGC4GxBK5mMXwDohIB4p7+6L0q1OX7dFFvl1Gc/idhLBFR9JGvmFwO2wwOLW+4 HH14xZZui/EyhwWUDcE7aGomHgzCKoDcVUwmovZCydbbIK4x4N9uWxUaDAGXooNmblHe ZY0Q== X-Gm-Message-State: AOAM532gxPwuZOf/ELxKgw/sVA0bLNyVbL49WAifmSNV0YyUIe2XIACz F88Le6BsUBt8yWOvMCP3chYoGC1i7CUgy48= X-Received: from tansuresh.svl.corp.google.com ([2620:15c:2c5:13:3c9b:5345:708:1378]) (user=tansuresh job=sendgmr) by 2002:a05:6902:84:b0:63d:4a3d:eb5 with SMTP id h4-20020a056902008400b0063d4a3d0eb5mr24596845ybs.145.1652825302496; Tue, 17 May 2022 15:08:22 -0700 (PDT) Date: Tue, 17 May 2022 15:08:13 -0700 Message-Id: <20220517220816.1635044-1-tansuresh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.550.gb090851708-goog Subject: [PATCH v3 0/3] Asynchronous shutdown interface and example implementation From: Tanjore Suresh To: Greg Kroah-Hartman , "Rafael J . Wysocki" , Christoph Hellwig , Sagi Grimberg , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, Tanjore Suresh Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 Problem: Some of our machines are configured with many NVMe devices and are validated for strict shutdown time requirements. Each NVMe device plugged into the system, typicaly takes about 4.5 secs to shutdown. A system with 16 such NVMe devices will takes approximately 80 secs to shutdown and go through reboot. The current shutdown APIs as defined at bus level is defined to be synchronous. Therefore, more devices are in the system the greater the time it takes to shutdown. This shutdown time significantly contributes the machine reboot time. Solution: This patch set proposes an asynchronous shutdown interface at bus level, modifies the core driver, device shutdown routine to exploit the new interface while maintaining backward compatibility with synchronous implementation already existing (Patch 1 of 3) and exploits new interface to enable all PCI-E based devices to use asynchronous interface semantics if necessary (Patch 2 of 3). The implementation at PCI-E level also works in a backward compatible way, to allow exiting device implementation to work with current synchronous semantics. Only show cases an example implementation for NVMe device to exploit this asynchronous shutdown interface. (Patch 3 of 3). Changelog: v2: - Replaced the shutdown_pre & shutdown_post entry point names with the recommended names (async_shutdown_start and asynch_shutdown_end). - Comment about ordering requirements between bridge shutdown versus leaf/endpoint shutdown was agreed to be different when calling async_shutdown_start and async_shutdown_end. Now this implements the same order of calling both start and end entry points. v3: - This notes clarifies why power management framework was not considered for implementing this shutdown optimization. There is no code change done. This change notes clarfies the reasoning only. This patch is only for shutdown of the system. The shutdown entry points are traditionally have different requirement where all devices are brought to a quiescent state and then system power may be removed (power down request scenarios) and also the same entry point is used to shutdown all devices and re-initialized and restarted (soft shutdown/reboot scenarios). Whereas, the device power management (dpm) allows the device to bring down any device configured in the system that may be idle to various low power states that the device may support in a selective manner and based on transitions that device implementation allows. The power state transitions initiated by the system can be achieved using 'dpm' interfaces already specified. Therefore the request to use the 'dpm' interface to achieve this shutdown optimization is not the right approach as the suggested interface is meant to solve an orthogonal requirement and have historically been kept separate from the shutdown entry points defined and its associated semantics. Tanjore Suresh (3): driver core: Support asynchronous driver shutdown PCI: Support asynchronous shutdown nvme: Add async shutdown support drivers/base/core.c | 38 +++++++++++++++++- drivers/nvme/host/core.c | 28 +++++++++---- drivers/nvme/host/nvme.h | 8 ++++ drivers/nvme/host/pci.c | 80 ++++++++++++++++++++++++-------------- drivers/pci/pci-driver.c | 20 ++++++++-- include/linux/device/bus.h | 12 ++++++ include/linux/pci.h | 4 ++ 7 files changed, 149 insertions(+), 41 deletions(-) -- 2.36.0.550.gb090851708-goog