From: Sanjay R Mehta <sanmehta@amd.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
Sanjay R Mehta <Sanju.Mehta@amd.com>
Cc: andreas.noever@gmail.com, michael.jamet@intel.com,
YehezkelShB@gmail.com, Basavaraj.Natikar@amd.com,
linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 2/4] thunderbolt: Handle ring interrupt by reading intr status
Date: Thu, 5 Aug 2021 18:36:17 +0530 [thread overview]
Message-ID: <27bbe268-fd1f-8a72-7ba2-76eb82d3185e@amd.com> (raw)
In-Reply-To: <YQvgD/4OA9enELwm@lahna>
On 8/5/2021 6:26 PM, Mika Westerberg wrote:
> [CAUTION: External Email]
>
> On Wed, Aug 04, 2021 at 06:48:45PM +0300, Mika Westerberg wrote:
>> Hi,
>>
>> On Tue, Aug 03, 2021 at 07:34:54AM -0500, Sanjay R Mehta wrote:
>>> From: Sanjay R Mehta <sanju.mehta@amd.com>
>>>
>>> As per USB4 spec by default "Disable ISR Auto-Clear" bit is set to 0,
>>> and the Tx/Rx ring interrupt status is needs to be cleared.
>>>
>>> Hence handling it by reading the "Interrupt status" register in the ISR.
>>>
>>> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
>>> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
>>> ---
>>> drivers/thunderbolt/nhi.c | 14 ++++++++++++++
>>> 1 file changed, 14 insertions(+)
>>>
>>> diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
>>> index ef01aa6..7ad2202 100644
>>> --- a/drivers/thunderbolt/nhi.c
>>> +++ b/drivers/thunderbolt/nhi.c
>>> @@ -373,11 +373,25 @@ void tb_ring_poll_complete(struct tb_ring *ring)
>>> }
>>> EXPORT_SYMBOL_GPL(tb_ring_poll_complete);
>>>
>>> +static void check_and_clear_intr_status(struct tb_ring *ring)
>>> +{
>>> + if (!(ring->nhi->pdev->vendor == PCI_VENDOR_ID_INTEL)) {
>>> + if (ring->is_tx)
>>> + ioread32(ring->nhi->iobase
>>> + + REG_RING_NOTIFY_BASE);
>>> + else
>>> + ioread32(ring->nhi->iobase
>>> + + REG_RING_NOTIFY_BASE
>>> + + 4 * (ring->nhi->hop_count / 32));
>>> + }
>>> +}
>>
>> I'm now playing with this series on Intel hardware. I wanted to check
>> from you whether the AMD controller implements the Auto-Clear feature? I
>> mean if we always clear bit 17 of the Host Interface Control register do
>> you still need to call the above or it is cleared automatically?
>>
>> I'm hoping that we could make this work on all controllers without too
>> many special cases ;-)
>
> I mean if you replace patches 1 and 2 in this series with the below,
> does it work with the AMD controller too?
>
Actually, it wont work on AMD controller because explicit read operation
of interrupt status is required to clear it.
> diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
> index fa44332845a1..8a5656fb956f 100644
> --- a/drivers/thunderbolt/nhi.c
> +++ b/drivers/thunderbolt/nhi.c
> @@ -71,10 +71,14 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
> * since we already know which interrupt was triggered.
> */
> misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
> - if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
> + /* Special bit for Intel */
> + if (ring->nhi->pdev->vendor == PCI_VENDOR_ID_INTEL &&
> + !(misc & REG_DMA_MISC_INT_AUTO_CLEAR))
> misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
> - iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
> - }
> + /* USB4 clear the disable auto-clear bit */
> + if (misc & BIT(17))
> + misc &= ~BIT(17);
> + iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
>
> ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
> step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
>
next prev parent reply other threads:[~2021-08-05 13:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 12:34 [PATCH v2 0/4] Added some bug fixes for USB4 Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 1/4] thunderbolt: Intel controller uses BIT(2) for intr auto Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 2/4] thunderbolt: Handle ring interrupt by reading intr status Sanjay R Mehta
2021-08-04 15:48 ` Mika Westerberg
2021-08-05 12:56 ` Mika Westerberg
2021-08-05 13:06 ` Sanjay R Mehta [this message]
2021-08-05 14:20 ` Mika Westerberg
2021-08-05 12:59 ` Sanjay R Mehta
2021-08-05 14:19 ` Mika Westerberg
2021-08-05 14:46 ` Mika Westerberg
2021-08-05 18:03 ` Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 3/4] thunderbolt: Skip port init for control adapter(0) Sanjay R Mehta
2021-08-03 12:34 ` [PATCH v2 4/4] thunderbolt: Fix port linking by checking all adapters Sanjay R Mehta
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=27bbe268-fd1f-8a72-7ba2-76eb82d3185e@amd.com \
--to=sanmehta@amd.com \
--cc=Basavaraj.Natikar@amd.com \
--cc=Sanju.Mehta@amd.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=michael.jamet@intel.com \
--cc=mika.westerberg@linux.intel.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).