public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: James Nelson <james4765@verizon.net>
Cc: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org,
	james4765@verizon.net
Subject: Re: [PATCH] esp: Make driver SMP-correct
Date: Fri, 31 Dec 2004 01:46:11 -0800	[thread overview]
Message-ID: <20041231014611.003281e5.akpm@osdl.org> (raw)
In-Reply-To: <20041231014403.3309.58245.96163@localhost.localdomain>

James Nelson <james4765@verizon.net> wrote:
>
> This is an attempt to make the esp serial driver SMP-correct.  It also removes
>  some cruft left over from the serial_write() conversion.

>From a quick scan:

- startup() does multiple sleeping allocations and request_irq() under
  spin_lock_irqsave().  Maybe fixed by this:

--- 25/drivers/char/esp.c~esp-make-driver-smp-correct-fixes	2004-12-31 01:40:57.987232152 -0800
+++ 25-akpm/drivers/char/esp.c	2004-12-31 01:42:21.444544712 -0800
@@ -851,16 +851,14 @@ static int startup(struct esp_struct * i
 	int	retval=0;
         unsigned int num_chars;
 
-	spin_lock_irqsave(&info->irq_lock, flags);
-
 	if (info->flags & ASYNC_INITIALIZED)
-		goto out;
+		goto out_unlocked;
 
 	if (!info->xmit_buf) {
 		info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
 		retval = -ENOMEM;
 		if (!info->xmit_buf)
-			goto out;
+			goto out_unlocked;
 	}
 
 #ifdef SERIAL_DEBUG_OPEN
@@ -907,7 +905,7 @@ static int startup(struct esp_struct * i
 					&info->tty->flags);
 			retval = 0;
 		}
-		goto out;
+		goto out_unocked;
 	}
 
 	if (!(info->stat_flags & ESP_STAT_USE_PIO) && !dma_buffer) {
@@ -926,6 +924,8 @@ static int startup(struct esp_struct * i
 			
 	}
 
+	spin_lock_irqsave(&info->irq_lock, flags);
+
 	info->MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
 	serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART);
 	serial_out(info, UART_ESI_CMD2, UART_MCR);
@@ -965,7 +965,9 @@ static int startup(struct esp_struct * i
 
 	info->flags |= ASYNC_INITIALIZED;
 	retval = 0;
-out:	spin_unlock_irqrestore(&info->irq_lock, flags);
+out:
+	spin_unlock_irqrestore(&info->irq_lock, flags);
+out_unocked:
 	return retval;
 }
 
_


- startup() calls change_speed() under info->irq_lock, but change_speed()
  also takes info->irq_lock.  Instant deadlock on driver initialisation.

The driver needs more serious surgery than this.

  parent reply	other threads:[~2004-12-31  9:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-31  1:43 [PATCH] esp: Make driver SMP-correct James Nelson
2004-12-31  9:45 ` Jan Dittmer
2004-12-31  9:46 ` Andrew Morton [this message]
2004-12-31 10:00   ` Russell King
2004-12-31 11:00     ` Jim Nelson
2004-12-31 17:01     ` Russell King
2004-12-31 22:16       ` [KJ] " Jim Nelson
2005-01-01  0:01         ` Gene Heskett
2005-01-01  0:13           ` Russell King
2005-01-01  1:14             ` Gene Heskett
2005-01-01  1:33               ` Russell King
2005-01-01  1:49                 ` Jim Nelson
2005-01-01  1:35               ` Gene Heskett
2005-01-01  1:47                 ` Jim Nelson
2005-01-01  3:11                   ` Gene Heskett

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=20041231014611.003281e5.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=james4765@verizon.net \
    --cc=kernel-janitors@lists.osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox