From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH] (2.6.20-rc7) cmd64x: fix PIO mode setup (take 2)
Date: Wed, 07 Feb 2007 00:33:39 +0100 [thread overview]
Message-ID: <45C91053.6000707@gmail.com> (raw)
In-Reply-To: <58cb370e0702061459k4a147891v3686b267d8e3001a@mail.gmail.com>
Hi,
Sergei Shtylyov wrote:
>
> Hello.
>
> Bartlomiej Zolnierkiewicz wrote:
>
>>> [Finally forgot to stamp MV's copyright on the driver, so here's take #2...]
>
>>> The driver's tuneproc() method fails to set the drive's own speed -- fix this
>>> by renaming the function to cmd64x_tune_pio(), making it return the mode set,
>>> and "wrapping" the new tuneproc() method around it; while at it, also get rid
>>> of the non-working prefetch control code, remove redundant PIO5 mode limitation,
>>> and make cmdprintk() give more sensible mode info. Also, get rid of the broken
>>> config_chipset_for_pio() which always tried to set PIO4 instead auto-tuning PIO.
>>> Note that removing a call from config_chipset_for_dma() breaks "rudimentary"
>>> MWDMA2 support which can only work because of the timing registers being pre-
>>> setup for PIO4 since the code in the speedproc() method which sets up the chip
>>> for SW/MW DMA is completely bogus (!) and I'm going to remove it for the time
>>> being in the next patch.
>>> Oh, and add the missing PIO5 support to the speedproc() method while at it. :-)
>
>> Generally looks fine, some comments below.
>
>>> Warning: compile tested only -- getting to the real hardware isn't
> that easy...
>
>>> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
>
>>> drivers/ide/pci/cmd64x.c | 95
> ++++++++++++++++-------------------------------
>>> 1 files changed, 34 insertions(+), 61 deletions(-)
>
>>> Index: linux-2.6/drivers/ide/pci/cmd64x.c
>>> ===================================================================
>>> --- linux-2.6.orig/drivers/ide/pci/cmd64x.c
>>> +++ linux-2.6/drivers/ide/pci/cmd64x.c
>>> @@ -1,6 +1,6 @@
>>> /* $Id: cmd64x.c,v 1.21 2000/01/30 23:23:16
>>> *
>>> - * linux/drivers/ide/pci/cmd64x.c Version 1.30 Sept 10, 2002
>>> + * linux/drivers/ide/pci/cmd64x.c Version 1.41 Feb 3, 2007
>>> *
>>> * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
>>> * Note, this driver is not used at all on other systems because
>>> @@ -12,6 +12,7 @@
>>> * Copyright (C) 1998 David S. Miller (davem@redhat.com)
>>> *
>>> * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
>>> + * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
>>> */
>>>
>>> #include <linux/module.h>
>>> @@ -262,43 +263,25 @@ static void program_drive_counts (ide_dr
>>> }
>>>
>>> /*
>>> - * Attempts to set the interface PIO mode.
>>> - * The preferred method of selecting PIO modes (e.g. mode 4) is
>>> - * "echo 'piomode:4' > /proc/ide/hdx/settings". Special cases are
>>> - * 8: prefetch off, 9: prefetch on, 255: auto-select best mode.
>>> - * Called with 255 at boot time.
>>> + * This routine selects drive's best PIO mode, calculates setup/active/recovery
>>> + * counts, and writes them into the chipset registers.
>>> */
>>> -
>>> -static void cmd64x_tuneproc (ide_drive_t *drive, u8 mode_wanted)
>>> +static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted)
>>> {
>>> int setup_time, active_time, recovery_time;
>>> int clock_time, pio_mode, cycle_time;
>>> u8 recovery_count2, cycle_count;
>>> int setup_count, active_count, recovery_count;
>>> int bus_speed = system_bus_clock();
>>> - /*byte b;*/
>>> ide_pio_data_t d;
>>>
>>> - switch (mode_wanted) {
>>> - case 8: /* set prefetch off */
>>> - case 9: /* set prefetch on */
>>> - mode_wanted &= 1;
>>> - /*set_prefetch_mode(index, mode_wanted);*/
>>> - cmdprintk("%s: %sabled cmd640 prefetch\n",
>>> - drive->name, mode_wanted ? "en" : "dis");
>>> - return;
>>> - }
>>> -
>>> - mode_wanted = ide_get_best_pio_mode (drive, mode_wanted, 5, &d);
>>> - pio_mode = d.pio_mode;
>>> + pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &d);
>>> cycle_time = d.cycle_time;
>
>> After this change if an unaware user passes "8" or "9" to enable/disable
>> prefetch (user doesn't know that it has never worked) it will result
>> in PIO5 being programmed.
>
> Yes. :-)
>
>> I don't think that this is a real world issue but for paranoia reasons
>> please add pio == 8/9 check to cmd64x_tune_drive(), something like:
>
>> /*
>> * letf-over from prefetch setting (pio == 8/9),
>> * needed to prevent PIO5 from being programmed
>> */
>> if (pio == 8 || pio == 9)
>> return;
>
> OK, I'll probably just leave the prefetch code where it was.
>
>> This will vanish when core code will do filtering of user space
>> PIO mode change requests...
>
>> [ ... ]
>
>>> +/*
>>> + * Attempts to set drive's PIO mode.
>>> + * The preferred method of selecting PIO modes (e.g. mode 4) is
>>> + * "echo 'piomode:4' > /proc/ide/hdx/settings".
>>> + * Special case is 255: auto-select best mode (used at boot time).
>>> + */
>
>> The preferred method is to let the driver do the tuning and if for some
>> reason somebody wants to change the PIO mode, the ioctl interface is
>> preferred over the deprecated "/proc/ide/hdx/settings".
>
>> Therefore please remove this comment while at it.
>
> Will do.
>
>>> +static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio)
>>> +{
>>> + pio = cmd64x_tune_pio(drive, pio);
>>> + (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
>>> }
>
>>> static u8 cmd64x_ratemask (ide_drive_t *drive)
>>> @@ -387,22 +375,6 @@ static u8 cmd64x_ratemask (ide_drive_t *
>>> return mode;
>>> }
>>>
>>> -static void config_cmd64x_chipset_for_pio (ide_drive_t *drive, u8
>>> set_speed)
>>> -{
>>> - u8 speed = 0x00;
>>> - u8 set_pio = ide_get_best_pio_mode(drive, 4, 5, NULL);
>>> -
>>> - cmd64x_tuneproc(drive, set_pio);
>>> - speed = XFER_PIO_0 + set_pio;
>>> - if (set_speed)
>>> - (void) ide_config_drive_speed(drive, speed);
>>> -}
>>> -
>>> -static void config_chipset_for_pio (ide_drive_t *drive, u8 set_speed)
>>> -{
>>> - config_cmd64x_chipset_for_pio(drive, set_speed);
>>> -}
>
>> [ ... ]
>
>>> @@ -461,8 +436,6 @@ static int config_chipset_for_dma (ide_d
>>> {
>>> u8 speed = ide_dma_speed(drive, cmd64x_ratemask(drive));
>>>
>>> - config_chipset_for_pio(drive, !speed);
>>> -
>
>> While this was always incorrectly setting PIO4, the PIO4 is "the usual" case
>> and for this driver we need to program PIO explicitly even when using
>> DMA.
>
> Hm, why it's *so* special, i.e. why almost all the other drivers can get
> away without it (the majority seems to have autotune set *only* if
> hwif->dma_base is seen as 0 in the init_hwif() method? :-/
This is really a bug and drivers get away with it because for many systems
BIOS will setup the correct PIO mode and/or ->speeproc method also sets
the PIO mode on the chipset while setting DMA.
In cmd64x case getting PIO setup right matters a bit more since there are
many add-on cards using CMD/SiI chipsets and they can also be used on non-x86
systems (I don't think that there are non-x86 BIOS/firmwares for these cards).
>> The core code doesn't program PIO mode unless told to (->autotune flag == 1)
>> so after the above change PIO mode won't be programmed et all.
>
>> I think that we now need to set ->autotune unconditionally in
>> init_hwif_cmd64x().
>
> No problem. This actually seems the right thing to do in all drivers,
> just like the libata core does. :-)
Yes.
Thanks,
Bart
next prev parent reply other threads:[~2007-02-06 23:28 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 20:09 [PATCH] (2.6.20-rc7) cmd64x: fix PIO mode setup Sergei Shtylyov
2007-02-03 21:04 ` [PATCH] (2.6.20-rc7) cmd64x: fix PIO mode setup (take 2) Sergei Shtylyov
2007-02-03 22:25 ` Bartlomiej Zolnierkiewicz
2007-02-05 13:29 ` Sergei Shtylyov
2007-02-05 13:57 ` Sergei Shtylyov
[not found] ` <58cb370e0702061459r1b001421gb4592d066793ab46@mail.gmail.com>
2007-02-06 23:44 ` Bartlomiej Zolnierkiewicz
2007-02-07 12:50 ` Sergei Shtylyov
[not found] ` <58cb370e0702061459k4a147891v3686b267d8e3001a@mail.gmail.com>
2007-02-06 23:33 ` Bartlomiej Zolnierkiewicz [this message]
2007-02-06 14:45 ` [PATCH] (2.6.20) cmd64x: fix PIO mode setup (take 3) Sergei Shtylyov
2007-02-06 21:11 ` Mikael Pettersson
2007-02-07 0:28 ` Bartlomiej Zolnierkiewicz
[not found] ` <58cb370e0702061500g3047b8ccpca894962491b588a@mail.gmail.com>
2007-02-06 23:48 ` Bartlomiej Zolnierkiewicz
2007-02-09 22:29 ` [PATCH] (pata-2.6 fix queue) cmd64x: fix recovery time calculation Sergei Shtylyov
2007-02-10 0:14 ` Bartlomiej Zolnierkiewicz
2007-02-14 21:42 ` [PATCH] (pata-2.6 fix queue) cmd64x: interrupt status fixes Sergei Shtylyov
2007-02-14 22:35 ` [PATCH] (pata-2.6 fix queue) cmd64x: add/fix enablebits Sergei Shtylyov
2007-02-19 23:09 ` Bartlomiej Zolnierkiewicz
2007-02-20 14:28 ` Sergei Shtylyov
2007-02-23 20:10 ` Bartlomiej Zolnierkiewicz
2007-04-14 19:31 ` [PATCH pata-2.6] cmd64x: add/fix enablebits (take 2) Sergei Shtylyov
2007-04-23 21:54 ` Bartlomiej Zolnierkiewicz
2007-02-15 13:53 ` [PATCH] (pata-2.6 fix queue) cmd64x: interrupt status fixes (resend) Sergei Shtylyov
2007-02-19 23:04 ` Bartlomiej Zolnierkiewicz
2007-04-14 19:17 ` [PATCH pata-2.6] cmd64x: interrupt status fixes (take 2) Sergei Shtylyov
2007-04-23 21:52 ` Bartlomiej Zolnierkiewicz
2007-02-15 19:17 ` [PATCH] (pata-2.6 fix queue) cmd64x: procfs code fixes/cleanups Sergei Shtylyov
2007-02-19 23:10 ` Bartlomiej Zolnierkiewicz
2007-04-14 19:41 ` [PATCH pata-2.6] cmd64x: procfs code fixes/cleanups (take 2) Sergei Shtylyov
2007-04-23 21:58 ` Bartlomiej Zolnierkiewicz
2007-02-16 20:15 ` [PATCH] (pata-2.6 fix queue) cmd64x: Sergei Shtylyov
2007-02-16 20:21 ` [PATCH] (pata-2.6 fix queue) cmd64x: use interrupt status from MRDMODE register Sergei Shtylyov
2007-02-23 20:09 ` Bartlomiej Zolnierkiewicz
2007-04-14 19:53 ` [PATCH pata-2.6] cmd64x: use interrupt status from MRDMODE register (take 2) Sergei Shtylyov
2007-04-23 22:03 ` Bartlomiej Zolnierkiewicz
2007-04-18 19:38 ` [PATCH pata-2.6 fix queue] hpt366: fix kernel oops with HPT302N Sergei Shtylyov
2007-04-20 19:54 ` Bartlomiej Zolnierkiewicz
2007-04-22 18:05 ` [PATCH pata-2.6 fix queue] aec62xx: fix PIO/DMA setup issues Sergei Shtylyov
2007-04-23 22:33 ` Bartlomiej Zolnierkiewicz
2007-05-10 20:01 ` [PATCH pata-2.6 fix queue] cmd64x: init. code cleanup Sergei Shtylyov
2007-05-10 20:04 ` Sergei Shtylyov
2007-05-15 21:16 ` Bartlomiej Zolnierkiewicz
2007-05-11 19:31 ` [PATCH pata-2.6 fix queue] aec62xx: rework init_setup_aec6x80() Sergei Shtylyov
2007-05-15 21:31 ` Bartlomiej Zolnierkiewicz
2007-05-11 21:11 ` [PATCH pata-2.6 fix queue] aec62xx: remove init_dma() method Sergei Shtylyov
2007-05-15 21:40 ` Bartlomiej Zolnierkiewicz
2007-05-11 21:22 ` [PATCH pata-2.6 fix queue] aec62xx: kill speedproc() method wrapper Sergei Shtylyov
2007-05-15 21:43 ` Bartlomiej Zolnierkiewicz
2007-05-16 14:20 ` Sergei Shtylyov
2007-05-23 23:33 ` Bartlomiej Zolnierkiewicz
2007-05-24 13:18 ` Sergei Shtylyov
2007-05-24 16:44 ` [PATCH pata-2.6] aec62xx: remove init_dma() method (take 2) Sergei Shtylyov
2007-05-24 16:46 ` [PATCH pata-2.6] aec62xx: kill speedproc() method wrapper " Sergei Shtylyov
2007-05-28 20:44 ` Bartlomiej Zolnierkiewicz
2007-06-05 15:15 ` Sergei Shtylyov
2007-06-08 12:22 ` Bartlomiej Zolnierkiewicz
2007-06-09 10:05 ` Sergei Shtylyov
2007-11-09 11:07 ` [PATCH] cmd64x: don't clear the other channels interrupt Sergei Shtylyov
2007-11-11 21:52 ` Bartlomiej Zolnierkiewicz
2007-11-13 20:58 ` Bartlomiej Zolnierkiewicz
2007-11-15 19:23 ` Martin Rogge
2007-11-16 13:34 ` Sergei Shtylyov
2007-02-26 20:32 ` [PATCH] (pata-2.6 fix queue) cmd64x: fix recovery time calculation (take 2) Sergei Shtylyov
2007-03-02 20:34 ` Bartlomiej Zolnierkiewicz
2007-03-03 20:17 ` [PATCH pata-2.6 fix queue] cmd64x: fix recovery time calculation (take 3) Sergei Shtylyov
2007-03-15 20:29 ` Bartlomiej Zolnierkiewicz
2007-02-27 21:49 ` [PATCH] (pata-2.6 fix queue) cmd64x: fix primary channel address setup time Sergei Shtylyov
2007-02-28 13:27 ` Sergei Shtylyov
2007-02-28 20:52 ` [PATCH] (pata-2.6 fix queue) cmd64x: add back MWDMA support Sergei Shtylyov
2007-03-02 22:03 ` Bartlomiej Zolnierkiewicz
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=45C91053.6000707@gmail.com \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=sshtylyov@ru.mvista.com \
/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;
as well as URLs for NNTP newsgroup(s).