Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3828387pxj; Mon, 7 Jun 2021 22:53:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy41+W+kDLJw66s1UlGUouvI4IFMPlhDf1mZ1RYPr1NZyrScNVUEG2c2rl9laIhLi1bDFep X-Received: by 2002:a17:906:c293:: with SMTP id r19mr14708592ejz.252.1623131598793; Mon, 07 Jun 2021 22:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623131598; cv=none; d=google.com; s=arc-20160816; b=hM0oG2eoWl42Wvh3ZisD+1ELp2lbDJXdX5ZiZeGMLlM7GU20OqE7FkesUn72WQ/XnT uSqLPMvfbveSJiU1KhHOW3mUc0ZP0vpJ4vVaZeuIpRfVfXJ5TzQd7wgy1qwgHpC+Pzy1 HH9+qEMa8PswyMNXnc2tqfHEdkzIllGlTxZ5o3kZ6A2S00YCLSIJl5BhJJC2fNoKJVct zN5Af6glQSB16Hbr5CsmKcfoyW3j1a54jbcqISFNVv2Ig9nRlU7iGiEKmPxEcOZpA5n4 JI2vP9x0bkzg4xMz/8mPdA5moAgCmCcJOOIJQwgRjU7cD9HXyLtnCD/t2MUT1ddZ5KfV yaJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iNHrhq0IL96XZ0EI6v9hmr0ajyowuoqEGQEPG1rii/A=; b=tQCfo6DstkxIDeZWahBHFckCtM7G8CztNFTCwYZSWnKl9i+ks8a/gCBIci5qBF/bus PSg5tqtSBXL4iUqfiNyarxYMij4UB9vnkomhiVD6ijWN2q2Esqz4GaoNcfS/JB5zFk1k 2WypIBn+7d0e4UAnDeFqsoKqcZLhz+DYisPkQcddr72EupUA6jqQJn8A2u3On2ricDxM QTyxRh0av35Mgdgv4WRkZhG2BKHFrmbTbqpnuC/M7dpd2ZuIVtsWctRQeYqV9jNtMCgp uH/Zn/aKs+jhunPCvJoOWUHjeaNZozl6NYxMI2En6+piFimQxT7N0N9lJSpQ4cIWDHcd OEag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rqBfJaic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si16092001edq.273.2021.06.07.22.52.55; Mon, 07 Jun 2021 22:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rqBfJaic; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbhFHFw2 (ORCPT + 99 others); Tue, 8 Jun 2021 01:52:28 -0400 Received: from mail-ot1-f52.google.com ([209.85.210.52]:33596 "EHLO mail-ot1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbhFHFw0 (ORCPT ); Tue, 8 Jun 2021 01:52:26 -0400 Received: by mail-ot1-f52.google.com with SMTP id o17-20020a9d76510000b02903eabfc221a9so5498721otl.0; Mon, 07 Jun 2021 22:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iNHrhq0IL96XZ0EI6v9hmr0ajyowuoqEGQEPG1rii/A=; b=rqBfJaic00+39Yc0R6kZ1OlmY1TA0B4f0e9Dvt0ly86lrXnPm/NE5j1Rd3h62rxAxq lNexTtLRBT0xJP02vMee/q/SIJOTSpoVt5PMFuzA3a+sx9qCDd53Qnz6jwlrU5o9dRmG BtjLyun9tkzwuXrT65RUwPz4CIznmB6wmDtBbT3gQtWAIZ2oie9v1l5UaPixrqLuH6G7 aI3W8olpV26BGkjnVaPn+7KdGtIdov1RowD5rcNhIYEwjOXJDPLeaEvKEvUGPfMzVHsA mPQSnCQhJwyJkG8O0gzFemZYz3CfSGksLiSE1POQUzpLLOdGpm4EwmEKEtGyBl7/+i5p lVtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iNHrhq0IL96XZ0EI6v9hmr0ajyowuoqEGQEPG1rii/A=; b=PNyaXPOjydrnJVjl5/KqQZFvp5L+bcvI/c5EifHhgz0hgwHZDvvTwvIFUIHDidspJ8 7m+AcIqBng/UupBG3n2or+m5iMDH/gsyz4HeY1Lhj4kluwaF46L5NC2qIvHMOAcAF+Ja QiqwdQ3ycEDyIwSK+r9Nke6VB2mmfvIcp+FfvQQEfQpV6paXEvQ/L0FoD9OsFQvTVqcB 3Gij/Z3UIBPgd+vJkOfTpPCY62LGsttdftFm6jcRy2052fgliP44XBBdAnRhph3kZnes cl7TZqv/isn+M63xfiWfk3FmK3cvWuIRIYvn+R3u15iwCfy8oMPkD8N35Pl8GKSNDa/S MLCw== X-Gm-Message-State: AOAM530ZwF1w0OhpChT0piWZo+x/CErhu9T/CQeG3CpK/x20W/orw3K+ D4EsBvGHKgLhtx7AyECgs4Y= X-Received: by 2002:a9d:5ccc:: with SMTP id r12mr16328130oti.172.1623131374343; Mon, 07 Jun 2021 22:49:34 -0700 (PDT) Received: from localhost.localdomain (static-198-54-128-46.cust.tzulo.com. [198.54.128.46]) by smtp.googlemail.com with ESMTPSA id o2sm2489730oom.26.2021.06.07.22.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 22:49:34 -0700 (PDT) From: Amey Narkhede To: Bjorn Helgaas Cc: alex.williamson@redhat.com, Raphael Norwitz , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kw@linux.com, Shanker Donthineni , Sinan Kaya , Len Brown , "Rafael J . Wysocki" Subject: [PATCH v7 6/8] PCI: Add support for ACPI _RST reset method Date: Tue, 8 Jun 2021 11:18:55 +0530 Message-Id: <20210608054857.18963-7-ameynarkhede03@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210608054857.18963-1-ameynarkhede03@gmail.com> References: <20210608054857.18963-1-ameynarkhede03@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shanker Donthineni The _RST is a standard method specified in the ACPI specification. It provides a function level reset when it is described in the acpi_device context associated with PCI-device. Implement a new reset function pci_dev_acpi_reset() for probing RST method and execute if it is defined in the firmware. The default priority of the ACPI reset is set to below device-specific and above hardware resets. Signed-off-by: Shanker Donthineni Suggested-by: Alex Williamson Reviewed-by: Sinan Kaya --- drivers/pci/pci-acpi.c | 23 +++++++++++++++++++++++ drivers/pci/pci.c | 1 + drivers/pci/pci.h | 6 ++++++ include/linux/pci.h | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index eaddbf701..40dd24cd3 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -941,6 +941,29 @@ void pci_set_acpi_fwnode(struct pci_dev *dev) acpi_pci_find_companion(&dev->dev)); } +/** + * pci_dev_acpi_reset - do a function level reset using _RST method + * @dev: device to reset + * @probe: check if _RST method is included in the acpi_device context. + */ +int pci_dev_acpi_reset(struct pci_dev *dev, int probe) +{ + acpi_handle handle = ACPI_HANDLE(&dev->dev); + + if (!handle || !acpi_has_method(handle, "_RST")) + return -ENOTTY; + + if (probe) + return 0; + + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_RST", NULL, NULL))) { + pci_warn(dev, "ACPI _RST failed\n"); + return -EINVAL; + } + + return 0; +} + static bool acpi_pci_bridge_d3(struct pci_dev *dev) { const struct fwnode_handle *fwnode; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2302aa421..2e7efd7e7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5121,6 +5121,7 @@ static void pci_dev_restore(struct pci_dev *dev) */ const struct pci_reset_fn_method pci_reset_fn_methods[] = { { &pci_dev_specific_reset, .name = "device_specific" }, + { &pci_dev_acpi_reset, .name = "acpi" }, { &pcie_reset_flr, .name = "flr" }, { &pci_af_flr, .name = "af_flr" }, { &pci_pm_reset, .name = "pm" }, diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index d22da6d3c..e9cfb7cd6 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -704,7 +704,13 @@ static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL int pci_acpi_program_hp_params(struct pci_dev *dev); extern const struct attribute_group pci_dev_acpi_attr_group; void pci_set_acpi_fwnode(struct pci_dev *dev); +int pci_dev_acpi_reset(struct pci_dev *dev, int probe); #else +static inline int pci_dev_acpi_reset(struct pci_dev *dev, int probe) +{ + return -ENOTTY; +} + static inline void pci_set_acpi_fwnode(struct pci_dev *dev) {} static inline int pci_acpi_program_hp_params(struct pci_dev *dev) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 6e9bc4f9c..a7f063da2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -49,7 +49,7 @@ PCI_STATUS_SIG_TARGET_ABORT | \ PCI_STATUS_PARITY) -#define PCI_RESET_METHODS_NUM 5 +#define PCI_RESET_METHODS_NUM 6 /* * The PCI interface treats multi-function devices as independent -- 2.31.1