Message ID | 20230707151044.1311544-1-alex.williamson@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3363213vqx; Fri, 7 Jul 2023 08:52:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGuAfJ3Y18S/PlUEV5wcGHBPs7xfeNPQVhQdaGKKbERPjxpLHNhacHDJjCNoFG5yuKaZ6HF X-Received: by 2002:a17:906:72d9:b0:993:7594:99ae with SMTP id m25-20020a17090672d900b00993759499aemr4693487ejl.0.1688745121848; Fri, 07 Jul 2023 08:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688745121; cv=none; d=google.com; s=arc-20160816; b=V1zYjXRG0dajt61AIi5aLnIPr8C5zCCXDXipFj40+Blem3NfWZBGtaoJbdsY5Lt8Ee JBIkVb1BBYjJzUlKjGIwxz6PCLcmlOM1QSc6bXxgP04rNCQrugs7dd6DWDrygMsyrqMv BcbGBL+NoUA5zupt/pNCVEEPePp37DETJwRRGtY8ovHveROABktxsQbRQWH7enxxcrKU DBJVHekZEhMXLjZvQ0pEHlqLVANiV6UoVC6ThybfOllpmvWYmukH9niyrfLu66aRcGPv 67hjXKuKUAmQaIxdJErLtbaUbLhRJ947GaWQMjcAY7VBsAGdvbZhgIvbsG8W+BAK6Sgu 392g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/vpgghRxsUnXsE3t1IVpXcHF3Kir76KUPEpQodsytdc=; fh=EkXd9mulaEwhN/gYQbLN171OqS+TkA74SfbkC4a6Z8Y=; b=xL0R0qYXrvnLm3xp635iACMkkSBaRtV863jBu0JjIbgM2Ms3aeqhFIae+v5oK12Hc7 15lAS8RWtu8bxvw/hX/1AIBA9Jp4bq4f9DeUA/zdMCj8esh6q/6aSVBzP7ow5tSvWD5d iTMut6PViykJdQSS9nRtZykiyHV67EpcxKgCKDK7JW2rAUXNg+wqqH4zZczQvdrrfzI/ KAVM6Xks9sbJwY/JHRpW09KBxy8pDqiA/RH8dZb1F6KXBIpxovJcGa8ScO7LTWTsXRHm tqiLzL3gul3TzOFywRYqYV2ddJaSNDqPAoG8J/QrfQAQayWDlMR4hzTNVtdjicy9fgQy 6uYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c+nLXn4O; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a1709061c0900b0099327546526si883091ejg.506.2023.07.07.08.51.38; Fri, 07 Jul 2023 08:52:01 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=c+nLXn4O; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233364AbjGGPMZ (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Fri, 7 Jul 2023 11:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjGGPMT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 7 Jul 2023 11:12:19 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8199A212C for <linux-kernel@vger.kernel.org>; Fri, 7 Jul 2023 08:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688742688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/vpgghRxsUnXsE3t1IVpXcHF3Kir76KUPEpQodsytdc=; b=c+nLXn4OZLR9JopyYhq/kLKcu5hVDcMJgVZSqqvUmMU9sSkNL6kfZhp26EcF8NDrZIe0wi l0MWnOpFXfPNaOUuB2C1NUvJ3AZ1VW6xwfD6/Ztxvn7VL05I1e2pmxNXbXFZ9qB83+YAgF sD5KsFJ5eqPjy9XcVtxU7Ied6RcbTIU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-huiRPxb7MyqWJbXufgI7Jw-1; Fri, 07 Jul 2023 11:11:27 -0400 X-MC-Unique: huiRPxb7MyqWJbXufgI7Jw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D28691C060C9; Fri, 7 Jul 2023 15:11:26 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.17.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70FCAC09A09; Fri, 7 Jul 2023 15:11:26 +0000 (UTC) From: Alex Williamson <alex.williamson@redhat.com> To: bhelgaas@google.com Cc: Alex Williamson <alex.williamson@redhat.com>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, eric.auger@redhat.com Subject: [PATCH] PCI/VPD: Add runtime power management to sysfs interface Date: Fri, 7 Jul 2023 09:10:44 -0600 Message-Id: <20230707151044.1311544-1-alex.williamson@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770777604928309301?= X-GMAIL-MSGID: =?utf-8?q?1770777604928309301?= |
Series |
PCI/VPD: Add runtime power management to sysfs interface
|
|
Commit Message
Alex Williamson
July 7, 2023, 3:10 p.m. UTC
Unlike default access to config space through sysfs, the vpd read and
write function don't actively manage the runtime power management state
of the device during access. Since commit 7ab5e10eda02 ("vfio/pci: Move
the unused device into low power state with runtime PM"), the vfio-pci
driver will use runtime power management and release unused devices to
make use of low power states. Attempting to access VPD information in
this low power state can result in incorrect information or kernel
crashes depending on the system behavior.
Wrap the vpd read/write bin attribute handlers in runtime PM and take
into account the potential quirk to select the correct device to wake.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/pci/vpd.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
Comments
Hi Alex, On 7/7/23 17:10, Alex Williamson wrote: > Unlike default access to config space through sysfs, the vpd read and > write function don't actively manage the runtime power management state > of the device during access. Since commit 7ab5e10eda02 ("vfio/pci: Move > the unused device into low power state with runtime PM"), the vfio-pci > driver will use runtime power management and release unused devices to > make use of low power states. Attempting to access VPD information in > this low power state can result in incorrect information or kernel > crashes depending on the system behavior. > > Wrap the vpd read/write bin attribute handlers in runtime PM and take > into account the potential quirk to select the correct device to wake. This much improved the situation as it is more difficult to hit the issue. Unfortunately after tens of attempts I was still able to hit a kernel crash. The console output does not mention the VPD anymore but PCI power management events (PME). [ 168.616700] CPU: 0 PID: 1409 Comm: kworker/0:5 Not tainted 6.4.0-vpd-upstream+ #56 [ 168.624257] Hardware name: GIGABYTE R181-T90-00/MT91-FS1-00, BIOS F34 08/13/2020 [ 168.631639] Workqueue: events_freezable pci_pme_list_scan [ 168.637032] pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 168.643982] pc : pci_generic_config_read+0x64/0xd8 [ 168.648763] lr : pci_generic_config_read+0x28/0xd8 [ 168.653542] sp : ffff80008caebcb0 [ 168.656844] x29: ffff80008caebcb0 x28: 0000000000000000 x27: 0000000000000000 [ 168.663969] x26: 0000000000000000 x25: 0000000000000000 x24: ffff80008caebd76 [ 168.671094] x23: ffff0008063fd800 x22: 0000000000000044 x21: ffff80008232d4c8 [ 168.678218] x20: ffff80008caebd24 x19: 0000000000000002 x18: 00000000000040fc [ 168.685342] x17: 00000000000040f8 x16: 0000000000000000 x15: 0000000000000001 [ 168.692466] x14: ffffffffffffffff x13: 0000000000000000 x12: 0101010101010101 [ 168.699590] x11: 7f7f7f7f7f7f7f7f x10: fefefefefefefeff x9 : ffff8000807b3938 [ 168.706714] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : 000000000000007f [ 168.713838] x5 : 0000000000000000 x4 : ffff800090000000 x3 : 0000000000000000 [ 168.720962] x2 : 0000000000000044 x1 : 0000000000c00044 x0 : ffff800090c00044 [ 168.728086] Call trace: [ 168.730520] pci_generic_config_read+0x64/0xd8 [ 168.734953] pci_bus_read_config_word+0x84/0xe8 [ 168.739471] pci_read_config_word+0x30/0x50 [ 168.743642] pci_check_pme_status+0x70/0xa8 [ 168.747813] pci_pme_list_scan+0x84/0x158 [ 168.751811] process_one_work+0x1ec/0x488 [ 168.755810] worker_thread+0x48/0x400 [ 168.759461] kthread+0x10c/0x120 [ 168.762678] ret_from_fork+0x10/0x20 [ 168.766245] Code: 52800000 a94153f3 a8c27bfd d65f03c0 (79400000) [ 168.772326] ---[ end trace 0000000000000000 ]--- [ 168.776931] Kernel panic - not syncing: synchronous external abort: Fatal exception [ 168.784574] SMP: stopping secondary CPUs [ 169.831001] SMP: failed to stop secondary CPUs 0,199 [ 169.835955] Kernel Offset: 0x190000 from 0xffff800080000000 Thanks Eric > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com> > --- > drivers/pci/vpd.c | 34 ++++++++++++++++++++++++++++++++-- > 1 file changed, 32 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c > index a4fc4d0690fe..81217dd4789f 100644 > --- a/drivers/pci/vpd.c > +++ b/drivers/pci/vpd.c > @@ -275,8 +275,23 @@ static ssize_t vpd_read(struct file *filp, struct kobject *kobj, > size_t count) > { > struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); > + struct pci_dev *vpd_dev = dev; > + ssize_t ret; > + > + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { > + vpd_dev = pci_get_func0_dev(dev); > + if (!vpd_dev) > + return -ENODEV; > + } > + > + pci_config_pm_runtime_get(vpd_dev); > + ret = pci_read_vpd(vpd_dev, off, count, buf); > + pci_config_pm_runtime_put(vpd_dev); > + > + if (dev != vpd_dev) > + pci_dev_put(vpd_dev); > > - return pci_read_vpd(dev, off, count, buf); > + return ret; > } > > static ssize_t vpd_write(struct file *filp, struct kobject *kobj, > @@ -284,8 +299,23 @@ static ssize_t vpd_write(struct file *filp, struct kobject *kobj, > size_t count) > { > struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); > + struct pci_dev *vpd_dev = dev; > + ssize_t ret; > + > + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { > + vpd_dev = pci_get_func0_dev(dev); > + if (!vpd_dev) > + return -ENODEV; > + } > + > + pci_config_pm_runtime_get(vpd_dev); > + ret = pci_write_vpd(vpd_dev, off, count, buf); > + pci_config_pm_runtime_put(vpd_dev); > + > + if (dev != vpd_dev) > + pci_dev_put(vpd_dev); > > - return pci_write_vpd(dev, off, count, buf); > + return ret; > } > static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0); >
On Sun, 9 Jul 2023 13:50:35 +0200 Eric Auger <eric.auger@redhat.com> wrote: > Hi Alex, > > On 7/7/23 17:10, Alex Williamson wrote: > > Unlike default access to config space through sysfs, the vpd read and > > write function don't actively manage the runtime power management state > > of the device during access. Since commit 7ab5e10eda02 ("vfio/pci: Move > > the unused device into low power state with runtime PM"), the vfio-pci > > driver will use runtime power management and release unused devices to > > make use of low power states. Attempting to access VPD information in > > this low power state can result in incorrect information or kernel > > crashes depending on the system behavior. > > > > Wrap the vpd read/write bin attribute handlers in runtime PM and take > > into account the potential quirk to select the correct device to wake. > > This much improved the situation as it is more difficult to hit the > issue. Unfortunately after tens of attempts I was still able to hit a > kernel crash. The console output does not mention the VPD anymore but > PCI power management events (PME). Does combining this with an extended D3hot wakeup for the device make any difference, such as a5a6dd262469 ("PCI/PM: Extend D3hot delay for NVIDIA HDA controllers")? Thanks, Alex > [ 168.616700] CPU: 0 PID: 1409 Comm: kworker/0:5 Not tainted > 6.4.0-vpd-upstream+ #56 > [ 168.624257] Hardware name: GIGABYTE R181-T90-00/MT91-FS1-00, BIOS F34 > 08/13/2020 > [ 168.631639] Workqueue: events_freezable pci_pme_list_scan > [ 168.637032] pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS > BTYPE=--) > [ 168.643982] pc : pci_generic_config_read+0x64/0xd8 > [ 168.648763] lr : pci_generic_config_read+0x28/0xd8 > [ 168.653542] sp : ffff80008caebcb0 > [ 168.656844] x29: ffff80008caebcb0 x28: 0000000000000000 x27: > 0000000000000000 > [ 168.663969] x26: 0000000000000000 x25: 0000000000000000 x24: > ffff80008caebd76 > [ 168.671094] x23: ffff0008063fd800 x22: 0000000000000044 x21: > ffff80008232d4c8 > [ 168.678218] x20: ffff80008caebd24 x19: 0000000000000002 x18: > 00000000000040fc > [ 168.685342] x17: 00000000000040f8 x16: 0000000000000000 x15: > 0000000000000001 > [ 168.692466] x14: ffffffffffffffff x13: 0000000000000000 x12: > 0101010101010101 > [ 168.699590] x11: 7f7f7f7f7f7f7f7f x10: fefefefefefefeff x9 : > ffff8000807b3938 > [ 168.706714] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : > 000000000000007f > [ 168.713838] x5 : 0000000000000000 x4 : ffff800090000000 x3 : > 0000000000000000 > [ 168.720962] x2 : 0000000000000044 x1 : 0000000000c00044 x0 : > ffff800090c00044 > [ 168.728086] Call trace: > [ 168.730520] pci_generic_config_read+0x64/0xd8 > [ 168.734953] pci_bus_read_config_word+0x84/0xe8 > [ 168.739471] pci_read_config_word+0x30/0x50 > [ 168.743642] pci_check_pme_status+0x70/0xa8 > [ 168.747813] pci_pme_list_scan+0x84/0x158 > [ 168.751811] process_one_work+0x1ec/0x488 > [ 168.755810] worker_thread+0x48/0x400 > [ 168.759461] kthread+0x10c/0x120 > [ 168.762678] ret_from_fork+0x10/0x20 > [ 168.766245] Code: 52800000 a94153f3 a8c27bfd d65f03c0 (79400000) > [ 168.772326] ---[ end trace 0000000000000000 ]--- > [ 168.776931] Kernel panic - not syncing: synchronous external abort: > Fatal exception > [ 168.784574] SMP: stopping secondary CPUs > [ 169.831001] SMP: failed to stop secondary CPUs 0,199 > [ 169.835955] Kernel Offset: 0x190000 from 0xffff800080000000 > > > Thanks > > Eric > > > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com> > > --- > > drivers/pci/vpd.c | 34 ++++++++++++++++++++++++++++++++-- > > 1 file changed, 32 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c > > index a4fc4d0690fe..81217dd4789f 100644 > > --- a/drivers/pci/vpd.c > > +++ b/drivers/pci/vpd.c > > @@ -275,8 +275,23 @@ static ssize_t vpd_read(struct file *filp, struct kobject *kobj, > > size_t count) > > { > > struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); > > + struct pci_dev *vpd_dev = dev; > > + ssize_t ret; > > + > > + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { > > + vpd_dev = pci_get_func0_dev(dev); > > + if (!vpd_dev) > > + return -ENODEV; > > + } > > + > > + pci_config_pm_runtime_get(vpd_dev); > > + ret = pci_read_vpd(vpd_dev, off, count, buf); > > + pci_config_pm_runtime_put(vpd_dev); > > + > > + if (dev != vpd_dev) > > + pci_dev_put(vpd_dev); > > > > - return pci_read_vpd(dev, off, count, buf); > > + return ret; > > } > > > > static ssize_t vpd_write(struct file *filp, struct kobject *kobj, > > @@ -284,8 +299,23 @@ static ssize_t vpd_write(struct file *filp, struct kobject *kobj, > > size_t count) > > { > > struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); > > + struct pci_dev *vpd_dev = dev; > > + ssize_t ret; > > + > > + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { > > + vpd_dev = pci_get_func0_dev(dev); > > + if (!vpd_dev) > > + return -ENODEV; > > + } > > + > > + pci_config_pm_runtime_get(vpd_dev); > > + ret = pci_write_vpd(vpd_dev, off, count, buf); > > + pci_config_pm_runtime_put(vpd_dev); > > + > > + if (dev != vpd_dev) > > + pci_dev_put(vpd_dev); > > > > - return pci_write_vpd(dev, off, count, buf); > > + return ret; > > } > > static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0); > > >
Hi Alex, On 7/9/23 15:26, Alex Williamson wrote: > On Sun, 9 Jul 2023 13:50:35 +0200 > Eric Auger <eric.auger@redhat.com> wrote: > >> Hi Alex, >> >> On 7/7/23 17:10, Alex Williamson wrote: >>> Unlike default access to config space through sysfs, the vpd read and >>> write function don't actively manage the runtime power management state >>> of the device during access. Since commit 7ab5e10eda02 ("vfio/pci: Move >>> the unused device into low power state with runtime PM"), the vfio-pci >>> driver will use runtime power management and release unused devices to >>> make use of low power states. Attempting to access VPD information in >>> this low power state can result in incorrect information or kernel >>> crashes depending on the system behavior. >>> >>> Wrap the vpd read/write bin attribute handlers in runtime PM and take >>> into account the potential quirk to select the correct device to wake. >> This much improved the situation as it is more difficult to hit the >> issue. Unfortunately after tens of attempts I was still able to hit a >> kernel crash. The console output does not mention the VPD anymore but >> PCI power management events (PME). > Does combining this with an extended D3hot wakeup for the device make > any difference, such as a5a6dd262469 ("PCI/PM: Extend D3hot delay for > NVIDIA HDA controllers")? Thanks, I added static void quirk_qlogic_nic_pm(struct pci_dev *dev) { dev_info(&dev->dev, "****** %s", __func__); quirk_d3hot_delay(dev, 20); } DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_QLOGIC, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET, 8, quirk_qlogic_nic_pm) and checked it was called, but I can still hit after 10's of iterations [ 152.788557] Modules linked in: xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 nft_compat nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf _tables nfnetlink rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache netfs bridge stp llc rfkill vfat fat qedr ib_uverbs vfio_pci ib_core vfio_pci_core vfio_iommu_type1 crct10dif_c e ghash_ce vfio i2c_smbus sha1_ce ipmi_ssif ipmi_devintf nfsd ipmi_msghandler thunderx2_pmu auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c sg ixgbevf ast drm_km s_helper qede i2c_algo_bit drm_shmem_helper qed drm ixgbe e1000e mpt3sas nvme nvme_core sha2_ce sha256_arm64 raid_class scsi_transport_sas nvme_common crc8 mdio gpio_xlp i2c_xl p9xx dm_mirror dm_region_hash dm_log dm_mod fuse [ 152.854119] CPU: 112 PID: 1416 Comm: kworker/112:7 Not tainted 6.4.0-vpd-upstream+ #57 [ 152.862024] Hardware name: GIGABYTE R181-T90-00/MT91-FS1-00, BIOS F34 08/13/2020 [ 152.869406] Workqueue: events_freezable pci_pme_list_scan [ 152.874810] pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 152.881760] pc : pci_generic_config_read+0x64/0xd8 [ 152.886549] lr : pci_generic_config_read+0x28/0xd8 [ 152.891328] sp : ffff80008cb23cb0 [ 152.894630] x29: ffff80008cb23cb0 x28: 0000000000000000 x27: 0000000000000000 [ 152.901756] x26: 0000000000000000 x25: 0000000000000001 x24: ffff80008cb23d76 [ 152.908881] x23: ffff000806331800 x22: 0000000000000044 x21: ffff80008232d4c8 [ 152.916006] x20: ffff80008cb23d24 x19: 0000000000000002 x18: 0000000000000000 [ 152.923130] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000001 [ 152.930255] x14: ffffffffffffffff x13: 0000000000000000 x12: 0101010101010101 [ 152.937379] x11: 7f7f7f7f7f7f7f7f x10: fefefefefefefeff x9 : ffff8000807b3938 [ 152.944504] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : 000000000000007f [ 152.951628] x5 : 0000000000000000 x4 : ffff800090000000 x3 : 0000000000000000 [ 152.958752] x2 : 0000000000000044 x1 : 0000000000c01044 x0 : ffff800090c01044 [ 152.965878] Call trace: [ 152.968312] pci_generic_config_read+0x64/0xd8 [ 152.972745] pci_bus_read_config_word+0x84/0xe8 [ 152.977264] pci_read_config_word+0x30/0x50 [ 152.981435] pci_check_pme_status+0x70/0xa8 [ 152.985606] pci_pme_list_scan+0x84/0x158 [ 152.989604] process_one_work+0x1ec/0x488 [ 152.993616] worker_thread+0x48/0x400 [ 152.997267] kthread+0x10c/0x120 [ 153.000492] ret_from_fork+0x10/0x20 [ 153.004063] Code: 52800000 a94153f3 a8c27bfd d65f03c0 (79400000) [ 153.010146] ---[ end trace 0000000000000000 ]--- [ 153.014751] Kernel panic - not syncing: synchronous external abort: Fatal exception [ 153.022395] SMP: stopping secondary CPUs [ 154.081107] SMP: failed to stop secondary CPUs 112,194 [ 154.086236] Kernel Offset: 0x190000 from 0xffff800080000000 [ 154.091796] PHYS_OFFSET: 0x80000000 [ 154.095272] CPU features: 0x01800000,0a0140a1,08004203 [ 154.100398] Memory Limit: none [ 154.103440] ---[ end Kernel panic - not syncing: synchronous external abort: Fatal exception ]--- Eric > > Alex > > >> [ 168.616700] CPU: 0 PID: 1409 Comm: kworker/0:5 Not tainted >> 6.4.0-vpd-upstream+ #56 >> [ 168.624257] Hardware name: GIGABYTE R181-T90-00/MT91-FS1-00, BIOS F34 >> 08/13/2020 >> [ 168.631639] Workqueue: events_freezable pci_pme_list_scan >> [ 168.637032] pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS >> BTYPE=--) >> [ 168.643982] pc : pci_generic_config_read+0x64/0xd8 >> [ 168.648763] lr : pci_generic_config_read+0x28/0xd8 >> [ 168.653542] sp : ffff80008caebcb0 >> [ 168.656844] x29: ffff80008caebcb0 x28: 0000000000000000 x27: >> 0000000000000000 >> [ 168.663969] x26: 0000000000000000 x25: 0000000000000000 x24: >> ffff80008caebd76 >> [ 168.671094] x23: ffff0008063fd800 x22: 0000000000000044 x21: >> ffff80008232d4c8 >> [ 168.678218] x20: ffff80008caebd24 x19: 0000000000000002 x18: >> 00000000000040fc >> [ 168.685342] x17: 00000000000040f8 x16: 0000000000000000 x15: >> 0000000000000001 >> [ 168.692466] x14: ffffffffffffffff x13: 0000000000000000 x12: >> 0101010101010101 >> [ 168.699590] x11: 7f7f7f7f7f7f7f7f x10: fefefefefefefeff x9 : >> ffff8000807b3938 >> [ 168.706714] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : >> 000000000000007f >> [ 168.713838] x5 : 0000000000000000 x4 : ffff800090000000 x3 : >> 0000000000000000 >> [ 168.720962] x2 : 0000000000000044 x1 : 0000000000c00044 x0 : >> ffff800090c00044 >> [ 168.728086] Call trace: >> [ 168.730520] pci_generic_config_read+0x64/0xd8 >> [ 168.734953] pci_bus_read_config_word+0x84/0xe8 >> [ 168.739471] pci_read_config_word+0x30/0x50 >> [ 168.743642] pci_check_pme_status+0x70/0xa8 >> [ 168.747813] pci_pme_list_scan+0x84/0x158 >> [ 168.751811] process_one_work+0x1ec/0x488 >> [ 168.755810] worker_thread+0x48/0x400 >> [ 168.759461] kthread+0x10c/0x120 >> [ 168.762678] ret_from_fork+0x10/0x20 >> [ 168.766245] Code: 52800000 a94153f3 a8c27bfd d65f03c0 (79400000) >> [ 168.772326] ---[ end trace 0000000000000000 ]--- >> [ 168.776931] Kernel panic - not syncing: synchronous external abort: >> Fatal exception >> [ 168.784574] SMP: stopping secondary CPUs >> [ 169.831001] SMP: failed to stop secondary CPUs 0,199 >> [ 169.835955] Kernel Offset: 0x190000 from 0xffff800080000000 >> >> >> Thanks >> >> Eric >>> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> >>> --- >>> drivers/pci/vpd.c | 34 ++++++++++++++++++++++++++++++++-- >>> 1 file changed, 32 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c >>> index a4fc4d0690fe..81217dd4789f 100644 >>> --- a/drivers/pci/vpd.c >>> +++ b/drivers/pci/vpd.c >>> @@ -275,8 +275,23 @@ static ssize_t vpd_read(struct file *filp, struct kobject *kobj, >>> size_t count) >>> { >>> struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); >>> + struct pci_dev *vpd_dev = dev; >>> + ssize_t ret; >>> + >>> + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { >>> + vpd_dev = pci_get_func0_dev(dev); >>> + if (!vpd_dev) >>> + return -ENODEV; >>> + } >>> + >>> + pci_config_pm_runtime_get(vpd_dev); >>> + ret = pci_read_vpd(vpd_dev, off, count, buf); >>> + pci_config_pm_runtime_put(vpd_dev); >>> + >>> + if (dev != vpd_dev) >>> + pci_dev_put(vpd_dev); >>> >>> - return pci_read_vpd(dev, off, count, buf); >>> + return ret; >>> } >>> >>> static ssize_t vpd_write(struct file *filp, struct kobject *kobj, >>> @@ -284,8 +299,23 @@ static ssize_t vpd_write(struct file *filp, struct kobject *kobj, >>> size_t count) >>> { >>> struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); >>> + struct pci_dev *vpd_dev = dev; >>> + ssize_t ret; >>> + >>> + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { >>> + vpd_dev = pci_get_func0_dev(dev); >>> + if (!vpd_dev) >>> + return -ENODEV; >>> + } >>> + >>> + pci_config_pm_runtime_get(vpd_dev); >>> + ret = pci_write_vpd(vpd_dev, off, count, buf); >>> + pci_config_pm_runtime_put(vpd_dev); >>> + >>> + if (dev != vpd_dev) >>> + pci_dev_put(vpd_dev); >>> >>> - return pci_write_vpd(dev, off, count, buf); >>> + return ret; >>> } >>> static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0); >>>
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index a4fc4d0690fe..81217dd4789f 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -275,8 +275,23 @@ static ssize_t vpd_read(struct file *filp, struct kobject *kobj, size_t count) { struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); + struct pci_dev *vpd_dev = dev; + ssize_t ret; + + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { + vpd_dev = pci_get_func0_dev(dev); + if (!vpd_dev) + return -ENODEV; + } + + pci_config_pm_runtime_get(vpd_dev); + ret = pci_read_vpd(vpd_dev, off, count, buf); + pci_config_pm_runtime_put(vpd_dev); + + if (dev != vpd_dev) + pci_dev_put(vpd_dev); - return pci_read_vpd(dev, off, count, buf); + return ret; } static ssize_t vpd_write(struct file *filp, struct kobject *kobj, @@ -284,8 +299,23 @@ static ssize_t vpd_write(struct file *filp, struct kobject *kobj, size_t count) { struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); + struct pci_dev *vpd_dev = dev; + ssize_t ret; + + if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) { + vpd_dev = pci_get_func0_dev(dev); + if (!vpd_dev) + return -ENODEV; + } + + pci_config_pm_runtime_get(vpd_dev); + ret = pci_write_vpd(vpd_dev, off, count, buf); + pci_config_pm_runtime_put(vpd_dev); + + if (dev != vpd_dev) + pci_dev_put(vpd_dev); - return pci_write_vpd(dev, off, count, buf); + return ret; } static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0);