All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Lord <kernel@teksavvy.com>
To: Bruce Stenning <b.stenning@indigovision.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>
Subject: Re: sata_mv port lockup on hotplug (kernel 2.6.38.2)
Date: Wed, 13 Apr 2011 11:10:43 -0400	[thread overview]
Message-ID: <4DA5BCF3.5080205@teksavvy.com> (raw)
In-Reply-To: <C1438B59050E1B4C9482FF3266AD6BA32C772D9EB1@gretna.indigovision.com>

[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]

On 11-04-12 06:30 AM, Bruce Stenning wrote:
..
> I am currently inserting tracing into 2.6.38.2 to try to work out what is going
> on.  From mv_write_main_irq_mask I can see that the IRQ for each port is still
> enabled, even when ports stop responding.
..
> One thing I noticed was that there is no spinlock around the
> mv_save_cached_regs/mv_edma_cfg in mv_hardreset (unlike mv_port_start and
> mv_port_stop); why is this?

Yeah, I'm suspecting there's a loophole in the logic there somewhere.

I dusted off the 6041 reference card I have here, and played with the cables
for a while.  Managed to get one port to stop responding to hot plug fairly
quickly, though I'm not sure how/why.

Then I added a debug printk() to mv_write_main_irq_mask(),
with no other changes, and that appears to have been enough
to change the race timing so that I could no longer produce
the problem.

Bruce, here's a slightly-ugly patch that should remove all
doubt about races in the irq_mask.  Please apply it, test with it,
and let me know here if the issue goes away.

Thanks

--- old/drivers/ata/sata_mv.c	2011-04-13 11:03:07.442481426 -0400
+++ linux/drivers/ata/sata_mv.c	2011-04-13 11:07:55.224249621 -0400
@@ -1027,15 +1027,19 @@
 static void mv_set_main_irq_mask(struct ata_host *host,
 				 u32 disable_bits, u32 enable_bits)
 {
+	static spinlock_t irq_mask_lock = __SPIN_LOCK_UNLOCKED(irq_mask_lock); //
FIXME: per-host would be nicer
 	struct mv_host_priv *hpriv = host->private_data;
 	u32 old_mask, new_mask;
+	unsigned long flags;

+	spin_lock_irqsave(&irq_mask_lock, flags);
 	old_mask = hpriv->main_irq_mask;
 	new_mask = (old_mask & ~disable_bits) | enable_bits;
 	if (new_mask != old_mask) {
 		hpriv->main_irq_mask = new_mask;
 		mv_write_main_irq_mask(new_mask, hpriv);
 	}
+	spin_unlock_irqrestore(&irq_mask_lock, flags);
 }

 static void mv_enable_port_irqs(struct ata_port *ap,

[-- Attachment #2: sata_mv_irq_mask_lock.patch --]
[-- Type: text/x-patch, Size: 824 bytes --]

--- old/drivers/ata/sata_mv.c	2011-04-13 11:03:07.442481426 -0400
+++ linux/drivers/ata/sata_mv.c	2011-04-13 11:07:55.224249621 -0400
@@ -1027,15 +1027,19 @@
 static void mv_set_main_irq_mask(struct ata_host *host,
 				 u32 disable_bits, u32 enable_bits)
 {
+	static spinlock_t irq_mask_lock = __SPIN_LOCK_UNLOCKED(irq_mask_lock); // FIXME: per-host would be nicer
 	struct mv_host_priv *hpriv = host->private_data;
 	u32 old_mask, new_mask;
+	unsigned long flags;
 
+	spin_lock_irqsave(&irq_mask_lock, flags);
 	old_mask = hpriv->main_irq_mask;
 	new_mask = (old_mask & ~disable_bits) | enable_bits;
 	if (new_mask != old_mask) {
 		hpriv->main_irq_mask = new_mask;
 		mv_write_main_irq_mask(new_mask, hpriv);
 	}
+	spin_unlock_irqrestore(&irq_mask_lock, flags);
 }
 
 static void mv_enable_port_irqs(struct ata_port *ap,

  parent reply	other threads:[~2011-04-13 15:10 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 14:20 sata_mv port lockup on hotplug (kernel 2.6.38.2) Bruce Stenning
2011-04-06 14:57 ` Bruce Stenning
2011-04-06 20:52   ` Mark Lord
2011-04-08 12:43     ` Bruce Stenning
2011-04-08 12:43       ` Bruce Stenning
2011-04-09  0:48       ` Mark Lord
2011-04-12 10:30         ` Bruce Stenning
2011-04-12 10:30           ` Bruce Stenning
2011-04-12 14:07           ` Mark Lord
2011-04-12 14:55             ` Mark Lord
2011-04-23  0:56               ` Tejun Heo
2011-04-25 11:07                 ` Bruce Stenning
2011-04-25 11:30                   ` Tejun Heo
2011-04-26 18:27                     ` Mark Lord
2011-04-25 14:54                 ` Bruce Stenning
2011-04-25 16:22                   ` Tejun Heo
2011-04-26 13:13                     ` Bruce Stenning
2011-04-26 13:50                       ` Tejun Heo
2011-04-26 15:41                         ` Bruce Stenning
2011-04-26 15:52                           ` Tejun Heo
2011-04-26 16:05                             ` Bruce Stenning
2011-04-30 14:01                               ` Tejun Heo
2011-05-17 15:30                                 ` Bruce Stenning
2011-05-25  9:41                                   ` Tejun Heo
2011-05-25 13:36                                     ` Bruce Stenning
2011-05-25 22:27                                       ` Mark Lord
2011-05-30 13:07                                         ` Bruce Stenning
2011-05-30 13:07                                           ` Bruce Stenning
2011-05-31  2:04                                           ` Mark Lord
2011-06-10 12:28                                     ` Mark Lord
2011-06-10 14:01                                       ` Tejun Heo
2011-06-10 17:32                                         ` Mark Lord
2011-06-10 17:39                                           ` Jeff Garzik
2011-06-10 20:49                                             ` Mark Lord
2011-06-10 21:20                                               ` Jeff Garzik
2011-06-11 12:19                                           ` Tejun Heo
2011-06-12 17:10                                             ` Mark Lord
2011-06-13 10:48                                               ` Tejun Heo
2011-08-29 15:49                                                 ` Bruce Stenning
2011-09-02  1:13                                                   ` Tejun Heo
2011-09-02 16:22                                                     ` Bruce Stenning
2011-09-06  3:45                                                       ` Tejun Heo
2011-09-06 12:19                                                         ` Bruce Stenning
2011-09-06 16:33                                                           ` Tejun Heo
2011-09-06 16:42                                                             ` Tejun Heo
2011-09-07 12:09                                                               ` Bruce Stenning
2011-09-08  1:16                                                                 ` Tejun Heo
2011-09-06 12:26                                                         ` Bruce Stenning
2011-09-06 14:40                                                         ` Bruce Stenning
2011-09-06 15:22                                                         ` Bruce Stenning
2011-04-26 18:37                           ` Mark Lord
2011-04-13 15:10           ` Mark Lord [this message]
2011-04-13 16:13             ` Bruce Stenning
2011-04-13 16:13               ` Bruce Stenning
2011-04-14 16:50             ` Bruce Stenning
2011-04-14 16:50               ` Bruce Stenning
2011-04-15  0:28               ` Mark Lord
2011-04-15 13:21                 ` Bruce Stenning
2011-04-15 13:21                   ` Bruce Stenning
2011-04-15 15:36                   ` Mark Lord
2011-04-18 10:30                     ` Bruce Stenning
2011-04-18 10:30                       ` Bruce Stenning
2011-04-23  0:56                     ` Tejun Heo
2011-04-15  3:15       ` Mikael Abrahamsson
2011-04-15  3:32         ` Mark Lord
2011-04-15  7:43           ` Mikael Abrahamsson
2011-04-15 12:35             ` Mark Lord
2011-04-15 14:04               ` Mikael Abrahamsson
2011-04-15 15:30                 ` Mark Lord
2011-04-06 21:00   ` Alejandro Riveira Fernández

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=4DA5BCF3.5080205@teksavvy.com \
    --to=kernel@teksavvy.com \
    --cc=b.stenning@indigovision.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.