From: Vojtech Pavlik <vojtech@suse.cz>
To: Samuel Thibault <samuel.thibault@fnac.net>
Cc: andre@linux-ide.org, martin@dalecki.de, alan@lxorguk.ukuu.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/ide/qd65xx: no cli/sti (2.4.19-pre3 & 2.5.28)
Date: Thu, 25 Jul 2002 09:31:54 +0200 [thread overview]
Message-ID: <20020725093154.A21541@ucw.cz> (raw)
In-Reply-To: <Pine.LNX.4.10.10207250128110.4868-100000@bureau.famille.thibault.fr>; from samuel.thibault@fnac.net on Thu, Jul 25, 2002 at 01:45:00AM +0200
On Thu, Jul 25, 2002 at 01:45:00AM +0200, Samuel Thibault wrote:
> Hello,
>
> Here are patches for 2.4.19-pre3 & 2.5.28 which free them from using
> cli/sti in qd65xx stuff.
Cool.
> (also using ide's OUT_BYTE / IN_BYTE btw)
In my opinion this doesn't make sense. The qd65xx is a VESA Local Bus
only hardware and is very very unlikely to be used on anything else than
an x86, where these defines are needed. Also, the ports written to are
not a part of the IDE controller region, so the IN_BYTE/OUT_BYTE macros
might not work there if it was ever used on a non-x86 machine. Also, it
makes the code less readable.
> IMHO, it may use its own spinlock, instead of using io_request_lock as
> suggested in pre3-ac, since what we have to protect is this card from
> parallel selectprocing 2 channels at a time which may upset the board (I
> don't know, and don't have a vlb smp system to test)
>
> 2 qd6500 boards may be ok to parallelize it, I don't know (I don't have
> any)...
>
> for 2.4.19rc3:
>
> --- linux-2.4.19rc3/drivers/ide/qd65xx.c Thu Jul 25 01:03:28 2002
> +++ linux-2.4.19rc3/drivers/ide/qd65xx.c Thu Jul 25 01:26:33 2002
> @@ -88,14 +88,15 @@
>
> static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */
>
> +static spinlock_t qd_lock = SPIN_LOCK_UNLOCKED; /* lock for i/o operations */
> +
> static void qd_write_reg (byte content, byte reg)
> {
> unsigned long flags;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - outb(content,reg);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + OUT_BYTE(content,reg);
> + spin_unlock_irqrestore(&qd_lock, flags);
> }
>
> byte __init qd_read_reg (byte reg)
> @@ -103,10 +104,9 @@
> unsigned long flags;
> byte read;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - read = inb(reg);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + read = IN_BYTE(reg);
> + spin_unlock_irqrestore(&qd_lock, flags);
> return read;
> }
>
> @@ -311,13 +311,12 @@
> byte readreg;
> unsigned long flags;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - savereg = inb_p(port);
> - outb_p(QD_TESTVAL,port); /* safe value */
> - readreg = inb_p(port);
> - outb(savereg,port);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + savereg = IN_BYTE(port);
> + OUT_BYTE(QD_TESTVAL,port); /* safe value */
> + readreg = IN_BYTE(port);
> + OUT_BYTE(savereg,port);
> + spin_unlock_irqrestore(&qd_lock, flags);
>
> if (savereg == QD_TESTVAL) {
> printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n");
> @@ -336,7 +335,7 @@
> * return 1 if another qd may be probed
> */
>
> -int __init probe (int base)
> +static int __init qd_probe(int base)
> {
> byte config;
> byte index;
> @@ -449,5 +448,5 @@
>
> void __init init_qd65xx (void)
> {
> - if (probe(0x30)) probe(0xb0);
> + if (qd_probe(0x30)) qd_probe(0xb0);
> }
>
> (also corrected silly non-static probe function !)
>
> for 2.5.28:
>
> --- linux-2.5.28/drivers/ide/qd65xx.c Thu Jul 25 01:10:26 2002
> +++ linux-2.5.28/drivers/ide/qd65xx.c Thu Jul 25 01:09:09 2002
> @@ -85,14 +85,15 @@
>
> static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */
>
> +static spinlock_t qd_lock = SPIN_LOCK_UNLOCKED; /* lock for i/o operations */
> +
> static void qd_write_reg(byte content, byte reg)
> {
> unsigned long flags;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - outb(content,reg);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + OUT_BYTE(content,reg);
> + spin_unlock_irqrestore(&qd_lock, flags);
> }
>
> byte __init qd_read_reg(byte reg)
> @@ -100,10 +101,9 @@
> unsigned long flags;
> byte read;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - read = inb(reg);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + read = IN_BYTE(reg);
> + spin_unlock_irqrestore(&qd_lock, flags);
> return read;
> }
>
> @@ -309,13 +309,12 @@
> byte readreg;
> unsigned long flags;
>
> - save_flags(flags); /* all CPUs */
> - cli(); /* all CPUs */
> - savereg = inb_p(port);
> - outb_p(QD_TESTVAL, port); /* safe value */
> - readreg = inb_p(port);
> - outb(savereg, port);
> - restore_flags(flags); /* all CPUs */
> + spin_lock_irqsave(&qd_lock, flags);
> + savereg = IN_BYTE(port);
> + OUT_BYTE(QD_TESTVAL,port); /* safe value */
> + readreg = IN_BYTE(port);
> + OUT_BYTE(savereg,port);
> + spin_unlock_irqrestore(&qd_lock, flags);
>
> if (savereg == QD_TESTVAL) {
> printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n");
>
>
> Regards,
>
> Samuel Thibault
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Vojtech Pavlik
SuSE Labs
next prev parent reply other threads:[~2002-07-25 7:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.44.0205260248160.17222-400000@youpi.residence.ens-lyon.fr>
2002-07-24 23:45 ` Samuel Thibault
2002-07-25 7:31 ` Vojtech Pavlik [this message]
2002-07-25 8:25 ` Marcin Dalecki
2002-07-25 8:52 ` Vojtech Pavlik
2002-07-25 15:15 ` Samuel Thibault
2002-07-25 15:47 ` Zwane Mwaikambo
2002-07-25 17:26 ` Samuel Thibault
[not found] <Pine.LNX.4.10.10207241643430.4719-100000@master.linux-ide.org>
2002-07-25 13:07 ` Samuel Thibault
2002-07-25 13:16 ` Andre Hedrick
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=20020725093154.A21541@ucw.cz \
--to=vojtech@suse.cz \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=andre@linux-ide.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin@dalecki.de \
--cc=samuel.thibault@fnac.net \
/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
all inboxes | Powered by JetHome®