linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>,
	linux-scsi@vger.kernel.org, linux-pci@vger.kernel.org,
	andy.shevchenko@gmail.com, Sathya.Prakash@broadcom.com,
	sreekanth.reddy@broadcom.com, linux-kernel@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Russell Currey <ruscur@russell.cc>,
	Sam Bobroff <sbobroff@linux.ibm.com>,
	Oliver O'Halloran <oohall@gmail.com>
Subject: Re: [PATCH v4 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available
Date: Thu, 27 Sep 2018 21:09:59 +0200	[thread overview]
Message-ID: <20180927190959.dio4qwti3i4accjm@wunner.de> (raw)
In-Reply-To: <20180927184746.GM28024@bhelgaas-glaptop.roam.corp.google.com>

On Thu, Sep 27, 2018 at 01:47:46PM -0500, Bjorn Helgaas wrote:
>   mpt3sas_wait_for_commands_to_complete(...)
>   {
>     ...
>  +  if (!mpt3sas_base_pci_device_is_available(ioc))
>  +    return;
> 
>     # In the definitive case, we returned above.  If we get here, we
>     # think the device *might* be present.  The readl() inside
>     # mpt3sas_base_get_iocstate() might fail (returning ~0 data).
>     # It happens that (~0 & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL
>     # so we will return below if the device was removed after the
>     # check above.
> 
>     ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
>     if ((ioc_state & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL)
>       return;
>     ...
> 
> 
> I think this code is unreasonably complicated.  The multiple layers
> and negations make it very difficult to figure out what's definitive.

I agree there's room for improvement.


> I'm not sure how mpt3sas benefits from adding
> mpt3sas_base_pci_device_is_available() here, other than the fact that
> it avoids an MMIO read to the device in most cases.  I think it would
> be simpler and better to make mpt3sas_base_get_iocstate() smarter
> about handling ~0 values from the readl().

Avoiding an MMIO read when it's known to run into a Completion Timeout
buys about 17 ms.  If the function is executed many times (I don't know
if that's the case here, I'm referring to the general case), or if bailing
out of it early avoids significant amounts of further I/O, then checking
for disconnectedness makes sense.

The 17 ms number is from this talk:
https://www.youtube.com/watch?v=GJ6B0xzgvlM&t=832

It's the typical Completion Timeout on an Intel chip, but it can be up to
50 ms in the default setting or up to 64 s if so configured in the Device
Control 2 register (PCIe r4.0 sec 7.8.16).

Thanks,

Lukas

  reply	other threads:[~2018-09-27 19:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26  4:22 [PATCH v4 0/6] mpt3sas: Hot-Plug Surprise removal support on IOC Suganath Prabu S
2018-09-26  4:22 ` [PATCH v4 1/6] mpt3sas: Introduce mpt3sas_base_pci_device_is_available Suganath Prabu S
2018-09-26 21:32   ` Bjorn Helgaas
2018-09-27  7:03     ` Lukas Wunner
2018-09-27 18:47       ` Bjorn Helgaas
2018-09-27 19:09         ` Lukas Wunner [this message]
2018-10-01  6:57           ` Suganath Prabu Subramani
2018-10-01 20:40             ` Bjorn Helgaas
2018-10-02 14:04               ` Bjorn Helgaas
2018-10-08  6:44                 ` Suganath Prabu Subramani
2018-10-12  5:47                   ` Sreekanth Reddy
2018-10-12 23:43                   ` Bjorn Helgaas
2018-09-26  4:22 ` [PATCH v4 2/6] mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational Suganath Prabu S
2018-09-26 21:03   ` Bjorn Helgaas
2018-09-27 10:31     ` Suganath Prabu Subramani
2018-09-26  4:22 ` [PATCH v4 3/6] mpt3sas: Introdude _scsih_get_shost_and_ioc Suganath Prabu S
2018-09-26 21:09   ` Bjorn Helgaas
2018-10-01  7:27     ` Suganath Prabu Subramani
2018-10-01 13:40       ` Bjorn Helgaas
2018-10-08  6:47         ` Suganath Prabu Subramani
2018-09-26 21:33   ` Bjorn Helgaas
2018-09-26  4:22 ` [PATCH v4 4/6] mpt3sas: Fix Sync cache command failure during driver unload Suganath Prabu S
2018-09-26  4:22 ` [PATCH v4 5/6] mpt3sas: Fix driver modifying NVRAM/persistent data Suganath Prabu S
2018-09-26  4:22 ` [PATCH v4 6/6] mpt3sas: Bump driver version to 27.100.00.00 Suganath Prabu S

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=20180927190959.dio4qwti3i4accjm@wunner.de \
    --to=lukas@wunner.de \
    --cc=Sathya.Prakash@broadcom.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=oohall@gmail.com \
    --cc=ruscur@russell.cc \
    --cc=sbobroff@linux.ibm.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    /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).