* [PATCH v3 1/4] thunderbolt: Add quirk to support vendor specific implementation
2021-08-06 16:59 [PATCH v3 0/4] Added some bug fixes for USB4 Sanjay R Mehta
@ 2021-08-06 16:59 ` Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 2/4] thunderbolt: Handle ring interrupt by reading intr status Sanjay R Mehta
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sanjay R Mehta @ 2021-08-06 16:59 UTC (permalink / raw)
To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
Cc: Basavaraj.Natikar, Nehal-bakulchandra.Shah, Shyam-sundar.S-k,
linux-usb, Sanjay R Mehta
From: Sanjay R Mehta <sanju.mehta@amd.com>
Introduce nhi_check_quirks() routine to handle any vendor specific quirks
to manage a hardware specific implementation.
On Intel system, the USB4 controller requires the
REG_DMA_MISC_INT_AUTO_CLEAR to be set. Hence handle it accordingly as
per the USB4 specification via a quirk.
Fixes: 046bee1f9ab8 ("thunderbolt: Add MSI-X support")
Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
drivers/thunderbolt/nhi.c | 18 ++++++++++++++----
include/linux/thunderbolt.h | 1 +
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index fa44332..7979638 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -43,6 +43,12 @@ static int ring_interrupt_index(struct tb_ring *ring)
return bit;
}
+static void nhi_check_quirks(struct tb_nhi *nhi)
+{
+ if (nhi->pdev->vendor == PCI_VENDOR_ID_INTEL)
+ nhi->quirks |= REG_DMA_MISC_INT_AUTO_CLEAR;
+}
+
/*
* ring_interrupt_active() - activate/deactivate interrupts for a single ring
*
@@ -70,10 +76,12 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
* Ask the hardware to clear interrupt status bits automatically
* since we already know which interrupt was triggered.
*/
- misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
- if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
- misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
- iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
+ if (ring->nhi->quirks & REG_DMA_MISC_INT_AUTO_CLEAR) {
+ misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
+ if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
+ misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
+ iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
+ }
}
ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
@@ -1190,6 +1198,8 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (!nhi->tx_rings || !nhi->rx_rings)
return -ENOMEM;
+ nhi_check_quirks(nhi);
+
res = nhi_init_msi(nhi);
if (res) {
dev_err(&pdev->dev, "cannot enable MSI, aborting\n");
diff --git a/include/linux/thunderbolt.h b/include/linux/thunderbolt.h
index e7c96c3..2144123 100644
--- a/include/linux/thunderbolt.h
+++ b/include/linux/thunderbolt.h
@@ -480,6 +480,7 @@ struct tb_nhi {
bool going_away;
struct work_struct interrupt_work;
u32 hop_count;
+ u32 quirks;
};
/**
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/4] thunderbolt: Handle ring interrupt by reading intr status
2021-08-06 16:59 [PATCH v3 0/4] Added some bug fixes for USB4 Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 1/4] thunderbolt: Add quirk to support vendor specific implementation Sanjay R Mehta
@ 2021-08-06 16:59 ` Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 3/4] thunderbolt: Skip port init for control adapter(0) Sanjay R Mehta
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sanjay R Mehta @ 2021-08-06 16:59 UTC (permalink / raw)
To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
Cc: Basavaraj.Natikar, Nehal-bakulchandra.Shah, Shyam-sundar.S-k,
linux-usb, Sanjay R Mehta
From: Sanjay R Mehta <sanju.mehta@amd.com>
As per USB4 specification by default "Disable ISR Auto-Clear" bit is set
to zero and the Tx/Rx ring interrupt status needs to be cleared.
Hence handle 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 7979638..56ac343 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -385,11 +385,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->quirks & REG_DMA_MISC_INT_AUTO_CLEAR)) {
+ 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));
+ }
+}
+
static irqreturn_t ring_msix(int irq, void *data)
{
struct tb_ring *ring = data;
spin_lock(&ring->nhi->lock);
+ check_and_clear_intr_status(ring);
spin_lock(&ring->lock);
__ring_interrupt(ring);
spin_unlock(&ring->lock);
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/4] thunderbolt: Skip port init for control adapter(0)
2021-08-06 16:59 [PATCH v3 0/4] Added some bug fixes for USB4 Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 1/4] thunderbolt: Add quirk to support vendor specific implementation Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 2/4] thunderbolt: Handle ring interrupt by reading intr status Sanjay R Mehta
@ 2021-08-06 16:59 ` Sanjay R Mehta
2021-08-06 16:59 ` [PATCH v3 4/4] thunderbolt: Fix port linking by checking all adapters Sanjay R Mehta
2021-08-09 12:06 ` [PATCH v3 0/4] Added some bug fixes for USB4 Mika Westerberg
4 siblings, 0 replies; 7+ messages in thread
From: Sanjay R Mehta @ 2021-08-06 16:59 UTC (permalink / raw)
To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
Cc: Basavaraj.Natikar, Nehal-bakulchandra.Shah, Shyam-sundar.S-k,
linux-usb, Sanjay R Mehta
From: Sanjay R Mehta <sanju.mehta@amd.com>
Adapter (0) is control adapter and as per USB4 spec in "Section 1.8",
"Control Adapters do not have an Adapter Configuration Space".
Hence skip port initialization for adapter (0).
Fixes: e6b245ccd524 ("thunderbolt: Add support for host and device NVM firmware upgrade")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
drivers/thunderbolt/switch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 83b1ef3..6447876 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2740,7 +2740,7 @@ int tb_switch_add(struct tb_switch *sw)
return ret;
}
- for (i = 0; i <= sw->config.max_port_number; i++) {
+ for (i = 1; i <= sw->config.max_port_number; i++) {
if (sw->ports[i].disabled) {
tb_port_dbg(&sw->ports[i], "disabled by eeprom\n");
continue;
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/4] thunderbolt: Fix port linking by checking all adapters
2021-08-06 16:59 [PATCH v3 0/4] Added some bug fixes for USB4 Sanjay R Mehta
` (2 preceding siblings ...)
2021-08-06 16:59 ` [PATCH v3 3/4] thunderbolt: Skip port init for control adapter(0) Sanjay R Mehta
@ 2021-08-06 16:59 ` Sanjay R Mehta
2021-08-09 12:06 ` [PATCH v3 0/4] Added some bug fixes for USB4 Mika Westerberg
4 siblings, 0 replies; 7+ messages in thread
From: Sanjay R Mehta @ 2021-08-06 16:59 UTC (permalink / raw)
To: mika.westerberg, andreas.noever, michael.jamet, YehezkelShB
Cc: Basavaraj.Natikar, Nehal-bakulchandra.Shah, Shyam-sundar.S-k,
linux-usb, Sanjay R Mehta
From: Sanjay R Mehta <sanju.mehta@amd.com>
In tb_switch_default_link_ports(), while linking of ports,
only odd-numbered ports (1,3,5..) are considered and even-numbered
ports are not considered.
AMD host router has lane adapters at 2 & 3 and link ports at
adapter-2 is not considered due to which lane bonding gets disabled.
Hence added a fix such that all ports are considered during
linking of ports.
Fixes: 0d46c08d1ed4 ("thunderbolt: Add default linking between lane adapters if not provided by DROM")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
---
drivers/thunderbolt/switch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 6447876..5c3d4bd 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2456,7 +2456,7 @@ static void tb_switch_default_link_ports(struct tb_switch *sw)
{
int i;
- for (i = 1; i <= sw->config.max_port_number; i += 2) {
+ for (i = 1; i <= sw->config.max_port_number; i++) {
struct tb_port *port = &sw->ports[i];
struct tb_port *subordinate;
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] Added some bug fixes for USB4
2021-08-06 16:59 [PATCH v3 0/4] Added some bug fixes for USB4 Sanjay R Mehta
` (3 preceding siblings ...)
2021-08-06 16:59 ` [PATCH v3 4/4] thunderbolt: Fix port linking by checking all adapters Sanjay R Mehta
@ 2021-08-09 12:06 ` Mika Westerberg
2021-08-09 12:28 ` Sanjay R Mehta
4 siblings, 1 reply; 7+ messages in thread
From: Mika Westerberg @ 2021-08-09 12:06 UTC (permalink / raw)
To: Sanjay R Mehta
Cc: andreas.noever, michael.jamet, YehezkelShB, Basavaraj.Natikar,
Nehal-bakulchandra.Shah, Shyam-sundar.S-k, linux-usb
Hi,
On Fri, Aug 06, 2021 at 11:59:04AM -0500, Sanjay R Mehta wrote:
> From: Sanjay R Mehta <sanju.mehta@amd.com>
>
> This series adds some general USB4 bug fixes as per USB4 Spec.
>
> v2:
> - Added quirk to handle any vendor specific quirks.
> v1:
> - removed PCI-IDs as AMD USB4 controller exposes USB4 class ID.
> - removed clearing of interrupt using interrupt status clear register.
> - skip port Adapter(0) initialisation for both host router & device router.
>
> Sanjay R Mehta (4):
> thunderbolt: Add quirk to support vendor specific implementation
> thunderbolt: Handle ring interrupt by reading intr status
> thunderbolt: Skip port init for control adapter(0)
> thunderbolt: Fix port linking by checking all adapters
I did some minor tweaks and removed the "Fixes" lines since these are
actually not fixes per se more like improvements :) Then applied all to
thunderbolt.git/next. Please check that they still work on AMD hardware
and make sense in general.
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/4] Added some bug fixes for USB4
2021-08-09 12:06 ` [PATCH v3 0/4] Added some bug fixes for USB4 Mika Westerberg
@ 2021-08-09 12:28 ` Sanjay R Mehta
0 siblings, 0 replies; 7+ messages in thread
From: Sanjay R Mehta @ 2021-08-09 12:28 UTC (permalink / raw)
To: Mika Westerberg, Sanjay R Mehta
Cc: andreas.noever, michael.jamet, YehezkelShB, Basavaraj.Natikar,
Nehal-bakulchandra.Shah, Shyam-sundar.S-k, linux-usb
On 8/9/2021 5:36 PM, Mika Westerberg wrote:
> [CAUTION: External Email]
>
> Hi,
>
> On Fri, Aug 06, 2021 at 11:59:04AM -0500, Sanjay R Mehta wrote:
>> From: Sanjay R Mehta <sanju.mehta@amd.com>
>>
>> This series adds some general USB4 bug fixes as per USB4 Spec.
>>
>> v2:
>> - Added quirk to handle any vendor specific quirks.
>> v1:
>> - removed PCI-IDs as AMD USB4 controller exposes USB4 class ID.
>> - removed clearing of interrupt using interrupt status clear register.
>> - skip port Adapter(0) initialisation for both host router & device router.
>>
>> Sanjay R Mehta (4):
>> thunderbolt: Add quirk to support vendor specific implementation
>> thunderbolt: Handle ring interrupt by reading intr status
>> thunderbolt: Skip port init for control adapter(0)
>> thunderbolt: Fix port linking by checking all adapters
>
> I did some minor tweaks and removed the "Fixes" lines since these are
> actually not fixes per se more like improvements :) Then applied all to
> thunderbolt.git/next. Please check that they still work on AMD hardware
> and make sense in general.
>
Thanks a lot Mika :). This should work for AMD.
> Thanks!
>
^ permalink raw reply [flat|nested] 7+ messages in thread