[PATCH 4/4] hpt366: MWDMA filter for SATA cards (take 2)



The Marvell bridge chips used on HighPoint SATA cards do not seem to support
the MWDMA modes (at least that caould be seen in their so-called drivers :-),
so the driver needs to account for this -- to achieve this:

- add mdma_filter() method from the original patch by Bartlomiej Zolnierkewicz
with his consent, also adding the method callout to ide_rate_filter();

- install the method for all chips to only return empty mask if a SATA drive
is detected on HPT372{AN]/374 chips...

Signed-off-by: Sergei Shtylyov <sshtylyov@xxxxxxxxxxxxx>

---
This patch is against the current Linus' tree.
It has not been tested on a real SATA card...

drivers/ide/ide-dma.c | 9 +++++++--
drivers/ide/ide.c | 1 +
drivers/ide/pci/hpt366.c | 23 +++++++++++++++++++++--
include/linux/ide.h | 1 +
4 files changed, 30 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/ide/ide-dma.c
===================================================================
--- linux-2.6.orig/drivers/ide/ide-dma.c
+++ linux-2.6/drivers/ide/ide-dma.c
@@ -674,8 +674,13 @@ static unsigned int ide_get_mode_mask(id
mask &= 0x07;
break;
case XFER_MW_DMA_0:
- if (id->field_valid & 2)
- mask = id->dma_mword & hwif->mwdma_mask;
+ if ((id->field_valid & 2) == 0)
+ break;
+ if (hwif->mdma_filter)
+ mask = hwif->mdma_filter(drive);
+ else
+ mask = hwif->mwdma_mask;
+ mask &= id->dma_mword;
break;
case XFER_SW_DMA_0:
if (id->field_valid & 2) {
Index: linux-2.6/drivers/ide/ide.c
===================================================================
--- linux-2.6.orig/drivers/ide/ide.c
+++ linux-2.6/drivers/ide/ide.c
@@ -398,6 +398,7 @@ static void ide_hwif_restore(ide_hwif_t

hwif->tuneproc = tmp_hwif->tuneproc;
hwif->speedproc = tmp_hwif->speedproc;
+ hwif->mdma_filter = tmp_hwif->mdma_filter;
hwif->udma_filter = tmp_hwif->udma_filter;
hwif->selectproc = tmp_hwif->selectproc;
hwif->reset_poll = tmp_hwif->reset_poll;
Index: linux-2.6/drivers/ide/pci/hpt366.c
===================================================================
--- linux-2.6.orig/drivers/ide/pci/hpt366.c
+++ linux-2.6/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
/*
- * linux/drivers/ide/pci/hpt366.c Version 1.12 Aug 19, 2007
+ * linux/drivers/ide/pci/hpt366.c Version 1.13 Sep 29, 2007
*
* Copyright (C) 1999-2003 Andre Hedrick <andre@xxxxxxxxxxxxx>
* Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -114,7 +114,7 @@
* unify HPT36x/37x timing setup code and the speedproc handlers by joining
* the register setting lists into the table indexed by the clock selected
* - set the correct hwif->ultra_mask for each individual chip
- * - add UltraDMA mode filtering for the HPT37[24] based SATA cards
+ * - add Ultra and MW DMA mode filtering for the HPT37[24] based SATA cards
* Sergei Shtylyov, <sshtylyov@xxxxxxxxxxxxx> or <source@xxxxxxxxxx>
*/

@@ -562,6 +562,24 @@ static u8 hpt3xx_udma_filter(ide_drive_t
return check_in_drive_list(drive, bad_ata33) ? 0x00 : mask;
}

+static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct hpt_info *info = pci_get_drvdata(hwif->pci_dev);
+
+ switch (info->chip_type) {
+ case HPT372 :
+ case HPT372A:
+ case HPT372N:
+ case HPT374 :
+ if (ide_dev_is_sata(drive->id))
+ return 0x00;
+ /* Fall thru */
+ default:
+ return 0x07;
+ }
+}
+
static u32 get_speed_setting(u8 speed, struct hpt_info *info)
{
int i;
@@ -1257,6 +1275,7 @@ static void __devinit init_hwif_hpt366(i
hwif->busproc = &hpt3xx_busproc;

hwif->udma_filter = &hpt3xx_udma_filter;
+ hwif->mdma_filter = &hpt3xx_mdma_filter;

/*
* HPT3xxN chips have some complications:
Index: linux-2.6/include/linux/ide.h
===================================================================
--- linux-2.6.orig/include/linux/ide.h
+++ linux-2.6/include/linux/ide.h
@@ -723,6 +723,7 @@ typedef struct hwif_s {
/* driver soft-power interface */
int (*busproc)(ide_drive_t *, int);
#endif
+ u8 (*mdma_filter)(ide_drive_t *);
u8 (*udma_filter)(ide_drive_t *);

void (*ata_input_data)(ide_drive_t *, void *, u32);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Kernel 2.4.x SATA Support?
    ... > Highpoint SATA controller. ... You don't necessarily need the proprietary drivers from HighPoint ... number of SATA chipsets -- not all of them, ... because I'm a SCSI bigot.) ...
    (comp.os.linux.hardware)
  • Re: SATA optical not seen
    ... How did you set up the 3 - SATA drives configuration? ... said, though, the glitch might be with the nVidia IDE drivers rather ...
    (alt.comp.periphs.mainboard.asus)
  • Re: SATA support?
    ... >>I have a SiS based MB and the SATA works like a dream but not as RAID. ... > can support 8 SATA hard drives. ... > I've been trying to confirm that FC3 will support non-raid SATA drivers ... > Planning on using several Maxtor 300GB SATA drives on this system. ...
    (Fedora)
  • Re: A8N32-SLI questions
    ... >Memory...I am not really an overclocker but I would like good RAM. ... >the WinXP SATA drivers or should I use the ASUS CD drivers? ... >I will not be using RAID....is the NF4 chip SATA faster than the SIL ...
    (alt.comp.periphs.mainboard.asus)
  • Re: SATA HD & DMA ?
    ... > If your drivers access the disks via the kernel's SCSI layers, ... >> pata is cheaper and works. ... > There's no reason SATA shouldn't be cheaper yet, ... Early drives were indeed just PATA drives with a Marvell (or ...
    (comp.os.linux.hardware)