Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3828965pxj; Mon, 7 Jun 2021 22:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyh7S1m6iSpbFHgZRngIpOTHO2ky5J4m5sIehIkEOs/ufnDq/lyV9Y/6AgCMK6X7L2+cR4 X-Received: by 2002:aa7:d0d4:: with SMTP id u20mr23929731edo.228.1623131674150; Mon, 07 Jun 2021 22:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623131674; cv=none; d=google.com; s=arc-20160816; b=F96M4iGY3B28ZX1/AJs8nhAwYYwDvt81ybVuOU2kc7sqj19Mzc2IcA0/ARFvM7onhS BTATnFlwVmffhwnw+yTzCB08lYQIFttzxcJOMUhWWeFDbFHg7jDNx5vU8elnek/KyTPX +WOUfL7Qp9Z9cEeI0gV0lfaV7aCJziXRmYRbR5zk4GWW5RbUQiRDrRiKzvmR3Is7AgFH Dfccg1U9qKg0/t3J4QK0ahdq9bhrBA7UsPiqP0JmxflE/d7nW2LzhtbGSA1C16FE7/j4 7LkTUSuaPz2Jdjk2+3uxhf8SJvICRGeUDiCix/BP7DcU5dwsIKGjpl/N7/59crg1H+w8 C+xg== 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=fW5wfb8x41zglgHyAcUMAuIIBSAY+Ni+6lOFyDzIdFA=; b=vDRzL3YIQVFJcsCoa5pgJqtEq7ERsGykpWue4q715e/e5QZlHUnwumcMIr0gtUU2nh L6noq3GWdqoMqoFV0fQcSNqBXQY9Pqd5UCS8dGUw+SaiiLS/lC7PcEvm/0ss71vchqZa cOplp3JtWy39OBYOWw3DLr5bXPdFnWfDe44fkdjndpPk8z3fKm7XlWYKvnytHdfAr2Pf 4GaYude+dg6Aujy4rj4FY2f5SBLnMUl7grBLIR9lxtA17YlpEKGH76873z22sTKACWiG y6kcvbqBwn+dkyE+qSwWBXWhFsb8Yxxcs0wLa7WLwwF9UoFsFewwHvicR+PUsToG7tKZ fifg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U9LTh4XC; 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 c14si16245147edr.0.2021.06.07.22.54.11; Mon, 07 Jun 2021 22:54:34 -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=U9LTh4XC; 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 S230392AbhFHFwl (ORCPT + 99 others); Tue, 8 Jun 2021 01:52:41 -0400 Received: from mail-ot1-f46.google.com ([209.85.210.46]:41917 "EHLO mail-ot1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbhFHFwi (ORCPT ); Tue, 8 Jun 2021 01:52:38 -0400 Received: by mail-ot1-f46.google.com with SMTP id 36-20020a9d0ba70000b02902e0a0a8fe36so19218812oth.8; Mon, 07 Jun 2021 22:50:30 -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=fW5wfb8x41zglgHyAcUMAuIIBSAY+Ni+6lOFyDzIdFA=; b=U9LTh4XCT1IWjmtmFLeSM4suqXmmEe/ALoHU9zT9il0Do+8j6r5Ib/HNg0giZJ0/ui SQE4iZwsTAie99pWRhL5UIpd9fSFv1txr0Ud3MY5PjAz1GIaX1lFH3By1fvna95KwB0j Co4x/+qxvVHzUTeKyw96P7SIw8BW/ZhqXhYyJxFRIHZ+UEcNQUlW53JTrBFdMXV1rvBD VRA6k2a++WGIZBjf9nmhvsMWfmkbdcLoa/Q4kQ7OzxIXl3Wwe5iSGvdDpWX99/7iZ7BH vfYVmy7UGjlVfJTQkL1E0Xh80edU4k/QWymk8EvtpaSloFec24npe4T09AV6mHpk3Ku1 9qMw== 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=fW5wfb8x41zglgHyAcUMAuIIBSAY+Ni+6lOFyDzIdFA=; b=Ol5Y9gRF1rzyQ0IztjwUOsEtq1KtG7kjrDuZWo/gHT0KaTKTYKwntmkYvZMGnSqfsY TDBpAu6AZ5wq5bY9xUeZIVpsV9ZeRnKQO/YcXHdGxITCmjOnmYh0rGVj+40rvYINovIE XPZm3BbeCHZlrkpHDw+O/WvJHUcbQC6YaIof4oiHFZxmJdbaIw+s1LuiSjFVHPrxZxaj 8IocP5fc278N9PTqZbBAlpNPMiAqrwn1iSgQoNeafLpyc1QHTZBPbE1lpGtea6JiXqJk Ljy83l/UU0a5gs4ijwBtGEJLgL3LRJBABervvd0/uLEUvr8vcfIhpdfC6IHt9gt5cq2Z vjKA== X-Gm-Message-State: AOAM532Ha92FwqeBNzBwrmKYgJMm0SvuAneUiHuvkFw61QAou+V9kD4N m1rotJuYc6kjo+DdOLNn0B0= X-Received: by 2002:a05:6830:34a7:: with SMTP id c39mr16451469otu.357.1623131370062; Mon, 07 Jun 2021 22:49:30 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 22:49:29 -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 5/8] PCI: Setup ACPI_COMPANION early Date: Tue, 8 Jun 2021 11:18:54 +0530 Message-Id: <20210608054857.18963-6-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 Currently, the ACPI_COMPANION is not available until device_add(). The software features which have dependency on ACPI fwnode properties and needs to be handled before device_add() will not work. One use case, software has to check the existence of _RST method to support ACPI based reset mechanism. This patch adds a new function pci_set_acpi_fwnode() for setting the ACPI_COMPANION, same code which is available in acpi_pci_bridge_d3(). Call pci_set_acpi_fwnode() from pci_scan_device() to fix the issue. Signed-off-by: Shanker Donthineni --- drivers/pci/pci-acpi.c | 12 ++++++++---- drivers/pci/pci.h | 2 ++ drivers/pci/probe.c | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 36bc23e21..eaddbf701 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -934,6 +934,13 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev) static struct acpi_device *acpi_pci_find_companion(struct device *dev); +void pci_set_acpi_fwnode(struct pci_dev *dev) +{ + if (!ACPI_COMPANION(&dev->dev) && !pci_dev_is_added(dev)) + ACPI_COMPANION_SET(&dev->dev, + acpi_pci_find_companion(&dev->dev)); +} + static bool acpi_pci_bridge_d3(struct pci_dev *dev) { const struct fwnode_handle *fwnode; @@ -945,11 +952,8 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev) return false; /* Assume D3 support if the bridge is power-manageable by ACPI. */ + pci_set_acpi_fwnode(dev); adev = ACPI_COMPANION(&dev->dev); - if (!adev && !pci_dev_is_added(dev)) { - adev = acpi_pci_find_companion(&dev->dev); - ACPI_COMPANION_SET(&dev->dev, adev); - } if (adev && acpi_device_power_manageable(adev)) return true; diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 13ec6bd6f..d22da6d3c 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -703,7 +703,9 @@ static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL #ifdef CONFIG_ACPI 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); #else +static inline void pci_set_acpi_fwnode(struct pci_dev *dev) {} static inline int pci_acpi_program_hp_params(struct pci_dev *dev) { return -ENODEV; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 90fd4f61f..dfefa5ed0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2359,6 +2359,8 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) return NULL; } + pci_set_acpi_fwnode(dev); + return dev; } -- 2.31.1