Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3378044pxv; Mon, 12 Jul 2021 16:10:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHFcl5tMNV5kWeyuDFLnsuMIv2F567vKh7M+zgQCc6eHLucnyUFLBHB0tOfhwBGkFwJ6yJ X-Received: by 2002:a05:6402:16:: with SMTP id d22mr1556855edu.101.1626131452470; Mon, 12 Jul 2021 16:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626131452; cv=none; d=google.com; s=arc-20160816; b=OuFz68rkfUp1o0JRe4p5YBgIUB5GgjL7d1yqlEo2ysYF5VlvnE/6ZK6x3qg978iEuo 8ExjQkPmx2ZsymnkcOcuLWKd9tcgC/6xpqxVHOitlfE4h2EGoofauIt++eodQbsJQZF3 +O69YGAlv4e34j8yJ29yRmNulUZZJvIulurVl2b1/rMfziNv2XBQZUv/TGOVeGMibZWU gdeISSrR/NFCiZRfDYYcBOWSN/cGS0hZsDK9ItKQKBNLSMYnipNfOpoWJtT29+zQKV2I fA0Wt2STizXrtIxVcPrQWzq1JhXe4vyz5f2cMSANrREDvtxn3iKkTTiMkRLxuwqYIBIW RcpA== 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:subject:cc:to:from:date :dkim-signature; bh=pQP+qtN0tfA18/8MgoFuBtUXbYJF/jq+trCW5RaJtbg=; b=pVHWHI+rnAaW5Zv2ok1wlKSaYXhmOMFY/ApQ1NtDQkvaREZroea2aQibtdUqyqZcjs dbrxqOfvmR1+hdSxPzz823Fy/t+3K9yxv1HIJH7CLQeTmi7t5CYkDx8KkW8/yLDNAH4H 7Ea8rtUrEvJYrV8zI6bcL4mcxCfqQZo+BK1w5r7dycwhfVcLj1zxCrxqOvFy937YjHua /DG1QbcxpSdwBNF8JhOWKzUDt94jYLtzLgq4E0WTikwAH+tA8yTrANZe4fRCIMXSUETR l2G4mensLlIJwEXfA+DKi+LkaUQnP7mHeaaUDOChUJK1+FixP98xW2PGDiJXCeRssXF+ LGGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Kd/DaHhd"; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si18364194ejj.516.2021.07.12.16.10.29; Mon, 12 Jul 2021 16:10:52 -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=@redhat.com header.s=mimecast20190719 header.b="Kd/DaHhd"; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231721AbhGLXMP (ORCPT + 99 others); Mon, 12 Jul 2021 19:12:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36611 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbhGLXMN (ORCPT ); Mon, 12 Jul 2021 19:12:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626131364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pQP+qtN0tfA18/8MgoFuBtUXbYJF/jq+trCW5RaJtbg=; b=Kd/DaHhdi9wf75KpEeUYr9tVdWnZ6iC0H9SIlOmiQt9e1BTQQoKtw3U6FQRn6mImM+vr1c LP2HgVlmxj6Q/HaW84HkX3VhTS+xderHGW3MLGbZVoVSLktkhFJztdPLUIFaXWM4wgU+lh IkpyJlLjN5f9BX4vAowdSr9gV7EZdtY= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-cbHYcbhbP4OvH0zREQEV1w-1; Mon, 12 Jul 2021 19:09:23 -0400 X-MC-Unique: cbHYcbhbP4OvH0zREQEV1w-1 Received: by mail-ot1-f72.google.com with SMTP id 42-20020a9d062d0000b02904b7c1fa2d7cso6669082otn.16 for ; Mon, 12 Jul 2021 16:09:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pQP+qtN0tfA18/8MgoFuBtUXbYJF/jq+trCW5RaJtbg=; b=JJsz1u40ZUBty38hLzBRFm5UytNS6Qx9ztQTUIqGbch0MDqCB5Bk92JiFmKcufyTdE ELYpzo90qrEXgleXRiMhenbEwN+6WL61s/OHMxRK5JY9EFgk3IzILEBOu7I5dhp2Vfb1 NFbOF+Y71t5gRCL5leW3MLVPY220/4UOh69YA4rtODetrkyxl0ikaKuKZErA12cM8O7J Qx+FITc7FpbmivxLxgoDA037CrRqNIR2fNiXiFDT5v0+4HESBQ9RXCbHcMLt+Hx/5fNC 93ltsEBx9KRhSwdaeWXcz8kK004Jo52alKPZTv1vt6q85FFol+mlSqjQWUytqER4YjLJ ljYw== X-Gm-Message-State: AOAM5319LClBHC/lPWHS5HYvvqkPYiUwBVoS5pF50ejxoZSRIiqAwrf+ FPlMoYqh13bhVuy5+9p8St/WrBWX8RP4SnzkEaoHKRc8z7z+TovUQPPP4XTPQd72tbL2iQnCVa7 0IQ/zUZ+TShuDv/4BaXetZ+3V X-Received: by 2002:a05:6830:1e8f:: with SMTP id n15mr1057058otr.339.1626131362476; Mon, 12 Jul 2021 16:09:22 -0700 (PDT) X-Received: by 2002:a05:6830:1e8f:: with SMTP id n15mr1057038otr.339.1626131362199; Mon, 12 Jul 2021 16:09:22 -0700 (PDT) Received: from redhat.com ([198.99.80.109]) by smtp.gmail.com with ESMTPSA id g1sm3330802otk.21.2021.07.12.16.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 16:09:21 -0700 (PDT) Date: Mon, 12 Jul 2021 17:09:20 -0600 From: Alex Williamson To: Shanker Donthineni Cc: Amey Narkhede , Bjorn Helgaas , Raphael Norwitz , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kw@linux.com, Sinan Kaya , Len Brown , "Rafael J . Wysocki" Subject: Re: [PATCH v10 7/8] PCI: Add support for ACPI _RST reset method Message-ID: <20210712170920.2a0868ac.alex.williamson@redhat.com> In-Reply-To: <20210709123813.8700-8-ameynarkhede03@gmail.com> References: <20210709123813.8700-1-ameynarkhede03@gmail.com> <20210709123813.8700-8-ameynarkhede03@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Jul 2021 18:08:12 +0530 Amey Narkhede wrote: > 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 dae021322..b6de71d15 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; Should we return -ENOTTY here instead to give a possible secondary reset method a chance? Thanks, Alex > + } > + > + 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 d5c16492c..1e64dbd3e 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -5115,6 +5115,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 990b73e90..2c12017ed 100644 > --- a/drivers/pci/pci.h > +++ b/drivers/pci/pci.h > @@ -705,7 +705,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 f34563831..c3b0d771c 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -50,7 +50,7 @@ > PCI_STATUS_PARITY) > > /* Number of reset methods used in pci_reset_fn_methods array in pci.c */ > -#define PCI_NUM_RESET_METHODS 6 > +#define PCI_NUM_RESET_METHODS 7 > > /* > * The PCI interface treats multi-function devices as independent