linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex G <mr.nuke.me@gmail.com>
To: Alex Williamson <alex.williamson@redhat.com>, Alex_Gagniuc@Dellteam.com
Cc: bhelgaas@google.com, helgaas@kernel.org,
	linux-pci@vger.kernel.org, Austin.Bolen@dell.com,
	keith.busch@intel.com, Shyam.Iyer@dell.com, lukas@wunner.de,
	okaya@kernel.org, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: Add link_change error handler and vfio-pci user
Date: Wed, 24 Apr 2019 12:35:51 -0500	[thread overview]
Message-ID: <1ee5f50e-a34b-5e15-e6d8-c32f1e1e73ea@gmail.com> (raw)
In-Reply-To: <20190424111943.376d7d24@x1.home>

On 4/24/19 12:19 PM, Alex Williamson wrote:
> On Wed, 24 Apr 2019 16:45:45 +0000
> <Alex_Gagniuc@Dellteam.com> wrote:
>> On 4/23/2019 5:42 PM, Alex Williamson wrote:
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index 7e12d0163863..233cd4b5b6e8 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -2403,6 +2403,19 @@ void pcie_report_downtraining(struct pci_dev *dev)
>>
>> I don't think you want to change pcie_report_downtraining(). You're
>> advertising to "report" something, by nomenclature, but then go around
>> and also call a notification callback. This is also used during probe,
>> and you've now just killed your chance to notice you've booted with a
>> degraded link.
>> If what you want to do is silence the bandwidth notification, you want
>> to modify the threaded interrupt that calls this.
> 
> During probe, ie. discovery, a device wouldn't have a driver attached,
> so we'd fall through to simply printing the link status.  Nothing
> lost afaict.  The "report" verb doesn't have a subject here, report to
> whom?  Therefore I thought it reasonable that a driver ask that it be
> reported to them via a callback.  I don't see that as such a stretch of
> the interface.

That's just stretching the logic, and IMO makes the intent harder to 
understand. The argument relies on the state of the PCI device and 
logic, which is not obvious to the casual observer. If you want to 
bypass the bandwidth notification, then bypass the notification.

>>>    	if (PCI_FUNC(dev->devfn) != 0 || dev->is_virtfn)
>>>    		return;
>>>    
>>> +	/*
>>> +	 * If driver handles link_change event, defer to driver.  PCIe drivers
>>> +	 * can call pcie_print_link_status() to print current link info.
>>> +	 */
>>> +	device_lock(&dev->dev);
>>> +	if (dev->driver && dev->driver->err_handler &&
>>> +	    dev->driver->err_handler->link_change) {
>>> +		dev->driver->err_handler->link_change(dev);
>>> +		device_unlock(&dev->dev);
>>> +		return;
>>> +	}
>>> +	device_unlock(&dev->dev);
>>
>> Can we write this such that there is a single lock()/unlock() pair?
> 
> Not without introducing a tracking variable, ex.
[snip bad code]
> That's not markedly better imo, but if it's preferred I can send a v2.

How about:

if (!invoke_link_changed_handler(pdev))
	very_useful_downtraining_message(pdev);

> Alex
Alex

  reply	other threads:[~2019-04-24 17:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 22:42 [PATCH] PCI: Add link_change error handler and vfio-pci user Alex Williamson
2019-04-24 16:45 ` Alex_Gagniuc
2019-04-24 17:19   ` Alex Williamson
2019-04-24 17:35     ` Alex G [this message]
2019-04-24 17:57 ` Bjorn Helgaas
2019-04-29 14:51   ` Alex Williamson
2019-04-29 16:45     ` Sinan Kaya
2019-04-29 16:59       ` Alex Williamson
2019-04-30 17:59         ` Keith Busch
2019-04-29 17:43     ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ee5f50e-a34b-5e15-e6d8-c32f1e1e73ea@gmail.com \
    --to=mr.nuke.me@gmail.com \
    --cc=Alex_Gagniuc@Dellteam.com \
    --cc=Austin.Bolen@dell.com \
    --cc=Shyam.Iyer@dell.com \
    --cc=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=okaya@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).