public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
[parent not found: <4136E7EF00073144@mail-3.tiscali.it>]
* RE: Cannot enable DMA on SATA drive (SCSI-libsata, VIA SATA)
@ 2004-09-01  2:57 Tomita, Haruo
  0 siblings, 0 replies; 10+ messages in thread
From: Tomita, Haruo @ 2004-09-01  2:57 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Petr Sebor, Alan Cox, petter.sundlof, linux-kernel,
	'linux-ide@vger.kernel.org', Tomita, Haruo

Hi Jeff,

Sorry for not writing you soon.

Haruo> Combined mode can be set up by the SATA controller of ESB of Intel tip. 
Haruo> This mode is the mode which can use SATA and PATA simultaneously. 
Haruo> In ata_piix driver, when combined mode is specified, it does not work.
 
Jeff> May I request, again, information on this.  In the current kernel you 
Jeff> are the only one reporting this problem.
Jeff> Does 2.6.9-rc1-bk work for you?

2.6.9-rc1-bk7 has no problem. It is worked.
But, 2.4.28-pre2-bk1 is not work.
As 2.4.28-pre2-bk1, I created the patch for solving this problem. 
Is it right? The patch is as follows.

===== SATA combined mode patch for linux-2.4.28-pre2 =====

diff -urN linux-2.4.28-pre2-bk1orig/drivers/pci/quirks.c linux-2.4.28-pre2-bk1/drivers/pci/quirks.c
--- linux-2.4.28-pre2-bk1orig/drivers/pci/quirks.c	2004-08-31 15:11:08.000000000 +0900
+++ linux-2.4.28-pre2-bk1/drivers/pci/quirks.c	2004-09-01 09:33:11.000000000 +0900
@@ -719,6 +719,61 @@
 	}
 }
 
+#ifdef CONFIG_SCSI_SATA
+static void __init quirk_intel_ide_combined(struct pci_dev *pdev)
+{
+	u8 prog, comb, tmp;
+
+	/*
+	 * Narrow down to Intel SATA PCI devices.
+	 */
+	switch (pdev->device) {
+	/* PCI ids taken from drivers/scsi/ata_piix.c */
+	case 0x24d1:
+	case 0x24df:
+	case 0x25a3:
+	case 0x25b0:
+	case 0x2651:
+	case 0x2652:
+		break;
+	default:
+		/* we do not handle this PCI device */
+		return;
+	}
+
+	/*
+	 * Read combined mode register.
+	 */
+	pci_read_config_byte(pdev, 0x90, &tmp); /* combined mode reg */
+	tmp &= 0x6;     /* interesting bits 2:1, PATA primary/secondary */
+	if (tmp == 0x4)         /* bits 10x */
+		comb = (1 << 0);                /* SATA port 0, PATA port 1 */
+	else if (tmp == 0x6)    /* bits 11x */
+		comb = (1 << 2);                /* PATA port 0, SATA port 1 */
+	else
+		return;                         /* not in combined mode */
+
+	/*
+	 * Read programming interface register.
+	 * (Tells us if it's legacy or native mode)
+	 */
+	pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
+	/* if SATA port is in native mode, we're ok. */
+	if (prog & comb)
+		return;
+
+	/* SATA port is in legacy mode.  Reserve port so that
+	 * IDE driver does not attempt to use it.  If request_region
+	 * fails, it will be obvious at boot time, so we don't bother
+	 * checking return values.
+	 */
+	if (comb == (1 << 0))
+		request_region(0x1f0, 8, "libata");     /* port 0 */
+	else
+		request_region(0x170, 8, "libata");     /* port 1 */
+}
+#endif
+
 /*
  *  The main table of quirks.
  */
@@ -797,6 +852,10 @@
 	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_AMD,      PCI_DEVICE_ID_AMD_8131_APIC, 
 	  quirk_amd_8131_ioapic }, 
 #endif
+#ifdef CONFIG_SCSI_SATA
+	{ PCI_FIXUP_FINAL,	PCI_VENDOR_ID_INTEL,	PCI_ANY_ID,
+	  quirk_intel_ide_combined },
+#endif
 
 	/*
 	 * on Asus P4B boards, the i801SMBus device is disabled at startup.
diff -urN linux-2.4.28-pre2-bk1orig/drivers/scsi/ata_piix.c linux-2.4.28-pre2-bk1/drivers/scsi/ata_piix.c
--- linux-2.4.28-pre2-bk1orig/drivers/scsi/ata_piix.c	2004-08-31 15:11:08.000000000 +0900
+++ linux-2.4.28-pre2-bk1/drivers/scsi/ata_piix.c	2004-09-01 12:07:22.000000000 +0900
@@ -620,8 +620,7 @@
 		port_info[pata_chan] = &piix_port_info[ich5_pata];
 		n_ports++;
 
-		printk(KERN_ERR DRV_NAME ": combined mode not supported\n");
-		return -ENODEV;
+		printk(KERN_WARNING DRV_NAME ": combined mode detected\n");
 	}
 
 	return ata_pci_init_one(pdev, port_info, n_ports);
diff -urN linux-2.4.28-pre2-bk1orig/drivers/scsi/libata-core.c linux-2.4.28-pre2-bk1/drivers/scsi/libata-core.c
--- linux-2.4.28-pre2-bk1orig/drivers/scsi/libata-core.c	2004-08-31 15:11:08.000000000 +0900
+++ linux-2.4.28-pre2-bk1/drivers/scsi/libata-core.c	2004-09-01 10:20:06.000000000 +0900
@@ -3296,14 +3296,27 @@
 		goto err_out;
 
 	if (legacy_mode) {
-		if (!request_region(0x1f0, 8, "libata"))
-			printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n");
-		else
+		if (!request_region(0x1f0, 8, "libata")) {
+			struct resource *conflict, res;
+			res.start = 0x1f0;
+			res.end = 0x1f0 + 8 - 1;
+			conflict = ____request_resource(&ioport_resource, &res);			if (!strcmp(conflict->name, "libata"))
+				legacy_mode |= (1 << 0);
+			else
+				printk(KERN_WARNING "ata: 0x1f0 IDE port busy\n");
+		} else
 			legacy_mode |= (1 << 0);
 
-		if (!request_region(0x170, 8, "libata"))
-			printk(KERN_WARNING "ata: 0x170 IDE port busy\n");
-		else
+		if (!request_region(0x170, 8, "libata")) {
+			struct resource *conflict, res;
+			res.start = 0x170;
+			res.end = 0x170 + 8 - 1;
+			conflict = ____request_resource(&ioport_resource, &res);
+			if (!strcmp(conflict->name, "libata"))
+				legacy_mode |= (1 << 1);
+			else
+				printk(KERN_WARNING "ata: 0x170 IDE port busy\n");
+		} else
 			legacy_mode |= (1 << 1);
 	}
 
diff -urN linux-2.4.28-pre2-bk1orig/include/linux/ioport.h linux-2.4.28-pre2-bk1/include/linux/ioport.h
--- linux-2.4.28-pre2-bk1orig/include/linux/ioport.h	2003-11-29 03:26:21.000000000 +0900
+++ linux-2.4.28-pre2-bk1/include/linux/ioport.h	2004-09-01 09:51:25.000000000 +0900
@@ -85,6 +85,7 @@
 
 extern int check_resource(struct resource *root, unsigned long, unsigned long);
 extern int request_resource(struct resource *root, struct resource *new);
+extern struct resource * ____request_resource(struct resource *root, struct resource *new);
 extern int release_resource(struct resource *new);
 extern int allocate_resource(struct resource *root, struct resource *new,
 			     unsigned long size,
diff -urN linux-2.4.28-pre2-bk1orig/kernel/ksyms.c linux-2.4.28-pre2-bk1/kernel/ksyms.c
--- linux-2.4.28-pre2-bk1orig/kernel/ksyms.c	2004-02-18 22:36:32.000000000 +0900
+++ linux-2.4.28-pre2-bk1/kernel/ksyms.c	2004-09-01 09:58:33.000000000 +0900
@@ -448,6 +448,7 @@
 #endif
 
 /* resource handling */
+EXPORT_SYMBOL(____request_resource);
 EXPORT_SYMBOL(request_resource);
 EXPORT_SYMBOL(release_resource);
 EXPORT_SYMBOL(allocate_resource);
diff -urN linux-2.4.28-pre2-bk1orig/kernel/resource.c linux-2.4.28-pre2-bk1/kernel/resource.c
--- linux-2.4.28-pre2-bk1orig/kernel/resource.c	2003-11-29 03:26:21.000000000 +0900
+++ linux-2.4.28-pre2-bk1/kernel/resource.c	2004-09-01 09:47:24.000000000 +0900
@@ -166,6 +166,16 @@
 	return conflict ? -EBUSY : 0;
 }
 
+struct resource *____request_resource(struct resource *root, struct resource *new)
+{
+struct resource *conflict;
+
+	write_lock(&resource_lock);
+	conflict = __request_resource(root, new);
+	write_unlock(&resource_lock);
+	return conflict;
+}
+
 int release_resource(struct resource *old)
 {
 	int retval;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: Cannot enable DMA on SATA drive (SCSI-libsata, VIA SATA)
@ 2004-08-31  5:58 Tomita, Haruo
  2004-08-31  6:06 ` Jeff Garzik
  0 siblings, 1 reply; 10+ messages in thread
From: Tomita, Haruo @ 2004-08-31  5:58 UTC (permalink / raw)
  To: Petr Sebor; +Cc: Alan Cox, petter.sundlof, linux-kernel

Hi Petr

Petr wrote> I am not using the combine mode on the sata drives 
Petr wrote> (or at least, I don't know about it). I was implying that
Petr wrote> when I connect another pure IDE drive to the motherboard, 
Petr wrote> then the situation gets better.

It seems that I have mistaken. 
The misunderstood problem is as follows. 

Combined mode can be set up by the SATA controller of ESB of Intel tip. 
This mode is the mode which can use SATA and PATA simultaneously. 
In ata_piix driver, when combined mode is specified, it does not work.
On the other hand, at the piix driver, in order not to recognize ESB tip, 
it worked only by PIO mode.

Petr wrote> Whats wrong here (or ... what feels wrong) is that the system 
Petr wrote> slows down noticeably when transferring data
Petr wrote> to/from the sata drives. It 'feels' like using an old ide 
Petr wrote> disk with pio mode only. I am not saying that the transfer rates
Petr wrote> are low though... hdparm -t on the sata drives gives me following:

It is the result of measuring in my environment:

  Linux-2.4.28-pre2 (RedHat Enterprise Linux 3 Update2 Base)
  HDD: HITACHI DeskStar 80G x 2
  SATA: Intel 82801ESB
  ata_piix driver version : 1.02.

The result is as follows. 
I think that there are not your result and great difference.

/dev/sda:
Timing buffered disk reads:  152 MB in  3.00 seconds =  50.67 MB/sec

/dev/sdb:
Timing buffered disk reads:  174 MB in  3.02 seconds =  57.62 MB/sec

Best Regards,
Haruo 

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Cannot enable DMA on SATA drive (SCSI-libsata, VIA SATA)
@ 2004-08-27 16:12 Petter Sundlöf
  2004-08-27 16:32 ` Jeff Garzik
  2004-08-27 23:45 ` Petr Sebor
  0 siblings, 2 replies; 10+ messages in thread
From: Petter Sundlöf @ 2004-08-27 16:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: jgarzik

Using 2.6.8.1. DMA works fine on /dev/hda (PATA, CD burner).

When I try to enable it for my SATA drive (which is performing horribly 
bad -- 80-90% CPU load on an AMD64 3200+ during copy of large files) I 
get this error:

# hdparm -d 1 /dev/sda

/dev/sda:
  setting using_dma to 1 (on)
  HDIO_SET_DMA failed: Invalid argument

Tried different commands:

# hdparm -X66 -d1 /dev/sda

/dev/sda:
  setting using_dma to 1 (on)
  HDIO_SET_DMA failed: Invalid argument
  setting xfermode to 66 (UltraDMA mode2)
  HDIO_DRIVE_CMD(setxfermode) failed: Invalid argument

hdparm -d /dev/sda gives absolutely no information.

The chipset is VIA82Cxx (ASUS K8VSE Deluxe motherboard). Disk is Maxtor 
6Y200M0.

Seen in /proc/scsi/scsi like this:

Host: scsi0 Channel: 00 Id: 00 Lun: 00
   Vendor: ATA      Model: Maxtor 6Y200M0   Rev: YAR5
   Type:   Direct-Access                    ANSI SCSI revision: 05

I also have the Promise controller, which I can use use a regular SATA 
controller (not RAID as is default). Should I attach it to it instead 
(I'd rather not if it can be avoided).

dmesg info:

libata version 1.02 loaded.
sata_via version 0.20
ACPI: PCI interrupt 0000:00:0f.0[B] -> GSI 20 (level, low) -> IRQ 20
sata_via(0000:00:0f.0): routed to hard irq line 10
ata1: SATA max UDMA/133 cmd 0xE400 ctl 0xE002 bmdma 0xD000 irq 20
ata2: SATA max UDMA/133 cmd 0xD800 ctl 0xD402 bmdma 0xD008 irq 20
ata1: dev 0 cfg 49:2f00 82:7c6b 83:7f09 84:4003 85:7c69 86:3e01 87:4003 
88:407f
ata1: dev 0 ATA, max UDMA/133, 398297088 sectors: lba48
ata1: dev 0 configured for UDMA/133
scsi0 : sata_via
ata2: no device found (phy stat 00000000)
scsi1 : sata_via
   Vendor: ATA       Model: Maxtor 6Y200M0    Rev: YAR5
   Type:   Direct-Access                      ANSI SCSI revision: 05
SCSI device sda: 398297088 512-byte hdwr sectors (203928 MB)
SCSI device sda: drive cache: write back
  /dev/scsi/host0/bus0/target0/lun0: p1 p2 < p5 p6 p7 p8 p9 p10 p11 p12 
p13 >
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0,  type 0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-10-06  0:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <7076215DFAA4574099E5CD59FE42226204F6C364@pcssrv42.pcs.pc.ome.toshiba.co.jp>
2004-08-30  6:44 ` Cannot enable DMA on SATA drive (SCSI-libsata, VIA SATA) Petr Sebor
     [not found] <4136E7EF00073144@mail-3.tiscali.it>
2004-10-06  0:30 ` Gianluca Cecchi
2004-10-06  0:54   ` Jeff Garzik
2004-09-01  2:57 Tomita, Haruo
  -- strict thread matches above, loose matches on Subject: below --
2004-08-31  5:58 Tomita, Haruo
2004-08-31  6:06 ` Jeff Garzik
2004-08-27 16:12 Petter Sundlöf
2004-08-27 16:32 ` Jeff Garzik
2004-08-27 23:45 ` Petr Sebor
2004-08-29 13:05   ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox