All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Jim Quinlan <james.quinlan@broadcom.com>
Cc: linux-serial@vger.kernel.org,
	"Kevin Cernekee" <cernekee@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"John Ogness" <john.ogness@linutronix.de>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"open list:TTY LAYER AND SERIAL DRIVERS"
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tty: rp2: Fix reset with non forgiving PCIe host bridges
Date: Wed, 11 Sep 2024 17:19:08 -0700	[thread overview]
Message-ID: <fb68e9ab-06b1-43b9-906a-9c1e83bee2c7@broadcom.com> (raw)
In-Reply-To: <CA+-6iNyS45YOHuVRcnPrMk4NOdrDZLAX=k8NBF_HwA41m4LbvQ@mail.gmail.com>

On 9/11/24 15:44, Jim Quinlan wrote:
> On Wed, Sep 11, 2024 at 6:19 PM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
>>
>> On 9/11/24 15:16, Jim Quinlan wrote:
>>> On Wed, Sep 11, 2024 at 6:01 PM Florian Fainelli
>>> <florian.fainelli@broadcom.com> wrote:
>>>>
>>>> On 9/11/24 14:47, Jim Quinlan wrote:
>>>>> On Fri, Sep 6, 2024 at 6:54 PM Florian Fainelli
>>>>> <florian.fainelli@broadcom.com> wrote:
>>>>>>
>>>>>> The write to RP2_GLOBAL_CMD followed by an immediate read of
>>>>>> RP2_GLOBAL_CMD in rp2_reset_asic() is intented to flush out the write,
>>>>>> however by then the device is already in reset and cannot respond to a
>>>>>> memory cycle access.
>>>>>>
>>>>>> On platforms such as the Raspberry Pi 4 and others using the
>>>>>> pcie-brcmstb.c driver, any memory access to a device that cannot respond
>>>>>> is met with a fatal system error, rather than being substituted with all
>>>>>> 1s as is usually the case on PC platforms.
>>>>>>
>>>>>> Swapping the delay and the read ensures that the device has finished
>>>>>> resetting before we attempt to read from it.
>>>>>>
>>>>>> Fixes: 7d9f49afa451 ("serial: rp2: New driver for Comtrol RocketPort 2 cards")
>>>>>> Suggested-by: Jim Quinlan <james.quinlan@broadcom.com>
>>>>>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>>>>> ---
>>>>>>     drivers/tty/serial/rp2.c | 2 +-
>>>>>>     1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c
>>>>>> index 4132fcff7d4e..8bab2aedc499 100644
>>>>>> --- a/drivers/tty/serial/rp2.c
>>>>>> +++ b/drivers/tty/serial/rp2.c
>>>>>> @@ -577,8 +577,8 @@ static void rp2_reset_asic(struct rp2_card *card, unsigned int asic_id)
>>>>>>            u32 clk_cfg;
>>>>>>
>>>>>>            writew(1, base + RP2_GLOBAL_CMD);
>>>>>> -       readw(base + RP2_GLOBAL_CMD);
>>>>>>            msleep(100);
>>>>>> +       readw(base + RP2_GLOBAL_CMD);
>>>>>
>>>>> Since the assumed purpose of the readw() was to flush the writew(),
>>>>> would it make sense to add a barrier after the writew()?
>>>>
>>>> AFAICT there is one which is implied within the name, as it is not a
>>>> _relaxed() variant. Did you mean a different sort of barrier to be used?
>>>
>>> Not sure.  The __raw_writew() is followed by __io_aw(), which is a
>>> no-op on arm64.  I don't know arm64 well enough to know if a follow-up
>>> barrier is needed.
>>
>> By definition all of the {read,write}{b,w,l,q} do include an adequate
>> barrier
> I do see this in the kernel, e.g. altera_edac.c, pci-hyperv.c,
> oxu210hp-hcd.c, etc:
> 
>          write[lw](..);
>          wmb();
> 
> All I am saying is that the definition of writew() for arm64 has no
> explicit barrier *after* it makes the __raw_writew() call, since its
> __io_aw() call is a no-op.  I really don't know if this matters, just
> wanted to mention it.

Not having the documentation for this peripheral, not sure TBH.

As far as the drivers you quoted given the __io_bw() does include a 
barrier, it would appear that the barrier after is possibly redundant, 
or is based upon a misunderstanding of which side of the write the 
barrier must be on, or maybe they are actually necessary, but 
undocumented as such..
-- 
Florian

  reply	other threads:[~2024-09-12  0:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06 22:54 [PATCH] tty: rp2: Fix reset with non forgiving PCIe host bridges Florian Fainelli
2024-09-11 13:46 ` Greg Kroah-Hartman
2024-09-11 21:47 ` Jim Quinlan
2024-09-11 22:01   ` Florian Fainelli
2024-09-11 22:16     ` Jim Quinlan
2024-09-11 22:19       ` Florian Fainelli
2024-09-11 22:44         ` Jim Quinlan
2024-09-12  0:19           ` Florian Fainelli [this message]
2024-09-23  9:44 ` Jiri Slaby
2024-09-26 22:50   ` Florian Fainelli

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=fb68e9ab-06b1-43b9-906a-9c1e83bee2c7@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=cernekee@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.quinlan@broadcom.com \
    --cc=jirislaby@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.