All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: David Runge <dave@sleepmap.de>
Cc: "Ahmed S. Darwish" <a.darwish@linutronix.de>,
	linux-rt-users@vger.kernel.org,
	linux1394-devel@lists.sourceforge.net,
	Stefan Richter <stefanr@s5r6.in-berlin.de>
Subject: Re: firewire-ohci fails to initialize Texas Instruments XIO2213A/B/XIO2221 based controller on realtime kernels [5.4.91-rt50, 5.10.8-rt24]
Date: Thu, 18 Feb 2021 09:38:49 +0100	[thread overview]
Message-ID: <20210218083849.iitcrhdgv2oajfhv@linutronix.de> (raw)
In-Reply-To: <YCl28sXo7LEyCK8y@hmbx>

On 2021-02-14 20:16:02 [+0100], David Runge wrote:
> The current config can be found on the AUR [1].

So this did make a difference. John concluded that it might be related
to the RESET quirk your hardware is having and his does not.

Could you try the patch below? Everything related to canceling tasklets
is broken so it is nothing logterm. It is just to figure out if your
hardware initializes further than it does right now.

------->8-------

Subject: [PATCH] firewire: threaded interrupts

Canceling tasklets is broken.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/firewire/ohci.c | 103 ++++++++++++++++++++++++++++------------
 1 file changed, 73 insertions(+), 30 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 17c9d825188bb..f309c7f69b076 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -2000,7 +2000,6 @@ static void bus_reset_work(struct work_struct *work)
 	spin_lock_irq(&ohci->lock);
 
 	ohci->generation = generation;
-	reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
 
 	if (ohci->quirks & QUIRK_RESET_PACKET)
 		ohci->request_generation = generation;
@@ -2041,6 +2040,9 @@ static void bus_reset_work(struct work_struct *work)
 		reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0);
 	}
 
+	reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
+	if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS)
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset);
 	spin_unlock_irq(&ohci->lock);
 
 	if (free_rom)
@@ -2055,66 +2057,81 @@ static void bus_reset_work(struct work_struct *work)
 	ohci->csr_state_setclear_abdicate = false;
 }
 
-static irqreturn_t irq_handler(int irq, void *data)
+static irqreturn_t irq_th_handler(int irq, void *data)
 {
 	struct fw_ohci *ohci = data;
 	u32 event, iso_event;
 	int i;
 
-	event = reg_read(ohci, OHCI1394_IntEventClear);
+	event = reg_read(ohci, OHCI1394_IntEventSet);
 
 	if (!event || !~event)
 		return IRQ_NONE;
 
-	/*
-	 * busReset and postedWriteErr must not be cleared yet
-	 * (OHCI 1.1 clauses 7.2.3.2 and 13.2.8.1)
-	 */
-	reg_write(ohci, OHCI1394_IntEventClear,
-		  event & ~(OHCI1394_busReset | OHCI1394_postedWriteErr));
 	log_irqs(ohci, event);
 
-	if (event & OHCI1394_selfIDComplete)
-		queue_work(selfid_workqueue, &ohci->bus_reset_work);
+	if (event & OHCI1394_selfIDComplete) {
+		bus_reset_work(&ohci->bus_reset_work);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_selfIDComplete);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_selfIDComplete);
+	}
 
-	if (event & OHCI1394_RQPkt)
-		tasklet_schedule(&ohci->ar_request_ctx.tasklet);
+	if (event & OHCI1394_RQPkt) {
+		ar_context_tasklet((unsigned long)&ohci->ar_request_ctx);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_RQPkt);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_RQPkt);
+	}
 
-	if (event & OHCI1394_RSPkt)
-		tasklet_schedule(&ohci->ar_response_ctx.tasklet);
+	if (event & OHCI1394_RSPkt) {
+		ar_context_tasklet((unsigned long)&ohci->ar_response_ctx);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_RSPkt);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_RSPkt);
+	}
 
-	if (event & OHCI1394_reqTxComplete)
-		tasklet_schedule(&ohci->at_request_ctx.tasklet);
 
-	if (event & OHCI1394_respTxComplete)
-		tasklet_schedule(&ohci->at_response_ctx.tasklet);
+	if (event & OHCI1394_reqTxComplete) {
+		context_tasklet((unsigned long)&ohci->at_request_ctx);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_reqTxComplete);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_reqTxComplete);
+	}
+
+	if (event & OHCI1394_respTxComplete) {
+		context_tasklet((unsigned long)&ohci->ar_response_ctx);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_respTxComplete);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_respTxComplete);
+	}
+
 
 	if (event & OHCI1394_isochRx) {
 		iso_event = reg_read(ohci, OHCI1394_IsoRecvIntEventClear);
-		reg_write(ohci, OHCI1394_IsoRecvIntEventClear, iso_event);
 
 		while (iso_event) {
 			i = ffs(iso_event) - 1;
-			tasklet_schedule(
-				&ohci->ir_context_list[i].context.tasklet);
+			context_tasklet((unsigned long)&ohci->ir_context_list[i].context);
 			iso_event &= ~(1 << i);
 		}
+		reg_write(ohci, OHCI1394_IsoRecvIntEventClear, iso_event);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_isochRx);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_isochRx);
 	}
 
 	if (event & OHCI1394_isochTx) {
 		iso_event = reg_read(ohci, OHCI1394_IsoXmitIntEventClear);
-		reg_write(ohci, OHCI1394_IsoXmitIntEventClear, iso_event);
 
 		while (iso_event) {
 			i = ffs(iso_event) - 1;
-			tasklet_schedule(
-				&ohci->it_context_list[i].context.tasklet);
+			context_tasklet((unsigned long)&ohci->it_context_list[i].context.tasklet);
 			iso_event &= ~(1 << i);
 		}
+		reg_write(ohci, OHCI1394_IsoXmitIntEventClear, iso_event);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_isochTx);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_isochTx);
 	}
 
 	if (unlikely(event & OHCI1394_regAccessFail))
 		ohci_err(ohci, "register access failure\n");
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_regAccessFail);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_regAccessFail);
 
 	if (unlikely(event & OHCI1394_postedWriteErr)) {
 		reg_read(ohci, OHCI1394_PostedWriteAddressHi);
@@ -2123,6 +2140,7 @@ static irqreturn_t irq_handler(int irq, void *data)
 			  OHCI1394_postedWriteErr);
 		if (printk_ratelimit())
 			ohci_err(ohci, "PCI posted write error\n");
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_postedWriteErr);
 	}
 
 	if (unlikely(event & OHCI1394_cycleTooLong)) {
@@ -2130,6 +2148,8 @@ static irqreturn_t irq_handler(int irq, void *data)
 			ohci_notice(ohci, "isochronous cycle too long\n");
 		reg_write(ohci, OHCI1394_LinkControlSet,
 			  OHCI1394_LinkControl_cycleMaster);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_cycleTooLong);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycleTooLong);
 	}
 
 	if (unlikely(event & OHCI1394_cycleInconsistent)) {
@@ -2141,21 +2161,44 @@ static irqreturn_t irq_handler(int irq, void *data)
 		 */
 		if (printk_ratelimit())
 			ohci_notice(ohci, "isochronous cycle inconsistent\n");
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_cycleInconsistent);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycleInconsistent);
 	}
 
-	if (unlikely(event & OHCI1394_unrecoverableError))
+	if (unlikely(event & OHCI1394_unrecoverableError)) {
 		handle_dead_contexts(ohci);
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_unrecoverableError);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_unrecoverableError);
+	}
 
 	if (event & OHCI1394_cycle64Seconds) {
 		spin_lock(&ohci->lock);
 		update_bus_time(ohci);
 		spin_unlock(&ohci->lock);
-	} else
+		reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_cycle64Seconds);
+		reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds);
+	} else {
 		flush_writes(ohci);
+	}
 
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t irq_handler(int irq, void *data)
+{
+	struct fw_ohci *ohci = data;
+	u32 event;
+
+	event = reg_read(ohci, OHCI1394_IntEventClear);
+
+	if (!event || !~event)
+		return IRQ_NONE;
+
+	reg_write(ohci, OHCI1394_IntMaskClear, event);
+
+	return IRQ_WAKE_THREAD;
+}
+
 static int software_reset(struct fw_ohci *ohci)
 {
 	u32 val;
@@ -3689,9 +3732,9 @@ static int pci_probe(struct pci_dev *dev,
 
 	if (!(ohci->quirks & QUIRK_NO_MSI))
 		pci_enable_msi(dev);
-	if (request_irq(dev->irq, irq_handler,
-			pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED,
-			ohci_driver_name, ohci)) {
+	if (request_threaded_irq(dev->irq, irq_handler, irq_th_handler,
+				 pci_dev_msi_enabled(dev) ? 0 : IRQF_SHARED,
+				 ohci_driver_name, ohci)) {
 		ohci_err(ohci, "failed to allocate interrupt %d\n", dev->irq);
 		err = -EIO;
 		goto fail_msi;
-- 
2.30.0


Sebastian

  reply	other threads:[~2021-02-18  8:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-23 11:59 firewire-ohci fails to initialize Texas Instruments XIO2213A/B/XIO2221 based controller on realtime kernels [5.4.91-rt50, 5.10.8-rt24] David Runge
2021-01-28  6:28 ` Ahmed S. Darwish
2021-01-28 21:41   ` David Runge
2021-01-29 17:04     ` Sebastian Andrzej Siewior
2021-01-30 11:46       ` David Runge
2021-02-01  8:34         ` Sebastian Andrzej Siewior
2021-02-05 11:26           ` Sebastian Andrzej Siewior
2021-02-05 23:22             ` David Runge
2021-02-07  9:58               ` David Runge
2021-02-08  9:19                 ` Sebastian Andrzej Siewior
2021-02-14 19:16                   ` David Runge
2021-02-18  8:38                     ` Sebastian Andrzej Siewior [this message]
2021-02-18  9:27                       ` Sebastian Andrzej Siewior
2021-03-08 14:12                         ` Sebastian Andrzej Siewior
2021-03-10 18:15                           ` David Runge
2021-09-07 23:17                             ` David Runge
2021-09-08  2:17                               ` Takashi Sakamoto
2021-09-08 17:30                                 ` David Runge
2021-09-09  0:46                                   ` Takashi Sakamoto
2021-09-12 18:44                                     ` David Runge
2021-09-10 11:55                                 ` Sebastian Andrzej Siewior
2021-09-11  9:46                                   ` Takashi Sakamoto
2021-09-12 18:53                                     ` David Runge
2022-01-05 21:01                                       ` Holger Dehnhardt

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=20210218083849.iitcrhdgv2oajfhv@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=a.darwish@linutronix.de \
    --cc=dave@sleepmap.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=stefanr@s5r6.in-berlin.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.