View | Details | Raw Unified | Return to bug 151517
Collapse All | Expand All

(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/Makefile.orig (-1 / +2 lines)
Lines 162-168 zalon7xx-objs := zalon.o ncr53c8xx.o Link Here
162
NCR_Q720_mod-objs	:= NCR_Q720.o ncr53c8xx.o
162
NCR_Q720_mod-objs	:= NCR_Q720.o ncr53c8xx.o
163
cpqfc-objs	:= cpqfcTSinit.o cpqfcTScontrol.o cpqfcTSi2c.o \
163
cpqfc-objs	:= cpqfcTSinit.o cpqfcTScontrol.o cpqfcTSi2c.o \
164
		   cpqfcTSworker.o cpqfcTStrigger.o
164
		   cpqfcTSworker.o cpqfcTStrigger.o
165
libata-objs	:= libata-core.o libata-scsi.o
165
libata-y	:= libata-core.o libata-scsi.o
166
libata-$(CONFIG_SCSI_SATA_ACPI) += libata-acpi.o
166
167
167
# Files generated that shall be removed upon make clean
168
# Files generated that shall be removed upon make clean
168
clean-files :=	53c7xx_d.h 53c700_d.h	\
169
clean-files :=	53c7xx_d.h 53c700_d.h	\
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/libata-acpi.c.orig (+995 lines)
Line 0 Link Here
1
/*
2
 * libata-acpi.c
3
 * Provides ACPI support for PATA/SATA.
4
 *
5
 * Copyright (C) 2005 Intel Corp.
6
 * Copyright (C) 2005 Randy Dunlap
7
 */
8
9
#include <linux/ata.h>
10
#include <linux/delay.h>
11
#include <linux/device.h>
12
#include <linux/errno.h>
13
#include <linux/kernel.h>
14
#include <acpi/acpi.h>
15
#include "scsi.h"
16
#include <linux/libata.h>
17
#include <linux/pci.h>
18
#include "libata.h"
19
20
#include <acpi/acpi_bus.h>
21
#include <acpi/acnames.h>
22
#include <acpi/acnamesp.h>
23
#include <acpi/acparser.h>
24
#include <acpi/acexcep.h>
25
#include <acpi/acmacros.h>
26
#include <acpi/actypes.h>
27
28
#define SATA_ROOT_PORT(x)	(((x) >> 16) & 0xffff)
29
#define SATA_PORT_NUMBER(x)	((x) & 0xffff)	/* or NO_PORT_MULT */
30
#define NO_PORT_MULT		0xffff
31
#define SATA_ADR_RSVD		0xffffffff
32
33
#define REGS_PER_GTF		7
34
struct taskfile_array {
35
	u8	tfa[REGS_PER_GTF];	/* regs. 0x1f1 - 0x1f7 */
36
};
37
38
struct GTM_buffer {
39
	__u32	PIO_speed0;
40
	__u32	DMA_speed0;
41
	__u32	PIO_speed1;
42
	__u32	DMA_speed1;
43
	__u32	GTM_flags;
44
};
45
46
#define DEBUGGING	1
47
/* note: adds function name and KERN_DEBUG */
48
#ifdef DEBUGGING
49
#define DEBPRINT(fmt, args...)	\
50
		printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ## args)
51
#else
52
#define DEBPRINT(fmt, args...)	do {} while (0)
53
#endif	/* DEBUGGING */
54
55
/**
56
 * sata_get_dev_handle - finds acpi_handle and PCI device.function
57
 * @dev: device to locate
58
 * @handle: returned acpi_handle for @dev
59
 * @pcidevfn: return PCI device.func for @dev
60
 *
61
 * This function is somewhat SATA-specific.  Or at least the
62
 * IDE and SCSI versions of this function are different,
63
 * so it's not entirely generic code.
64
 *
65
 * Returns 0 on success, <0 on error.
66
 */
67
static int sata_get_dev_handle(struct device *dev, acpi_handle *handle,
68
					acpi_integer *pcidevfn)
69
{
70
	struct pci_dev	*pci_dev;
71
	acpi_integer	addr;
72
73
	pci_dev = to_pci_dev(dev);	/* NOTE: PCI-specific */
74
	/* Please refer to the ACPI spec for the syntax of _ADR. */
75
	addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
76
	*pcidevfn = addr;
77
	*handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
78
	printk(KERN_DEBUG "%s: SATA dev addr=0x%llx, handle=0x%p\n",
79
		__FUNCTION__, (unsigned long long)addr, *handle);
80
	if (!*handle)
81
		return -ENODEV;
82
	return 0;
83
}
84
85
/**
86
 * pata_get_dev_handle - finds acpi_handle and PCI device.function
87
 * @dev: device to locate
88
 * @handle: returned acpi_handle for @dev
89
 * @pcidevfn: return PCI device.func for @dev
90
 *
91
 * The PATA and SATA versions of this function are different.
92
 *
93
 * Returns 0 on success, <0 on error.
94
 */
95
static int pata_get_dev_handle(struct device *dev, acpi_handle *handle,
96
					acpi_integer *pcidevfn)
97
{
98
	unsigned int domain, bus, devnum, func;
99
	acpi_integer addr;
100
	acpi_handle dev_handle, parent_handle;
101
	int scanned;
102
	struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER,
103
					.pointer = NULL};
104
	acpi_status status;
105
	struct acpi_device_info	*dinfo = NULL;
106
	int ret = -ENODEV;
107
108
	printk(KERN_DEBUG "%s: enter: dev->bus_id='%s'\n",
109
		__FUNCTION__, dev->bus_id);
110
	if ((scanned = sscanf(dev->bus_id, "%x:%x:%x.%x",
111
			&domain, &bus, &devnum, &func)) != 4) {
112
		printk(KERN_DEBUG "%s: sscanf ret. %d\n",
113
			__FUNCTION__, scanned);
114
		goto err;
115
	}
116
117
	dev_handle = DEVICE_ACPI_HANDLE(dev);
118
	parent_handle = DEVICE_ACPI_HANDLE(dev->parent);
119
120
	status = acpi_get_object_info(parent_handle, &buffer);
121
	if (ACPI_FAILURE(status)) {
122
		printk(KERN_DEBUG "%s: get_object_info for parent failed\n",
123
			__FUNCTION__);
124
		goto err;
125
	}
126
	dinfo = buffer.pointer;
127
	if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
128
	    dinfo->address == bus) {
129
		/* ACPI spec for _ADR for PCI bus: */
130
		addr = (acpi_integer)(devnum << 16 | func);
131
		*pcidevfn = addr;
132
		*handle = dev_handle;
133
	} else {
134
		printk(KERN_DEBUG "%s: get_object_info for parent has wrong "
135
			" bus: %llu, should be %d\n",
136
			__FUNCTION__,
137
			dinfo ? (unsigned long long)dinfo->address : -1ULL,
138
			bus);
139
		goto err;
140
	}
141
142
	printk(KERN_DEBUG "%s: dev_handle: 0x%p, parent_handle: 0x%p\n",
143
		__FUNCTION__, dev_handle, parent_handle);
144
	printk(KERN_DEBUG
145
		"%s: for dev=0x%x.%x, addr=0x%llx, parent=0x%p, *handle=0x%p\n",
146
		__FUNCTION__, devnum, func, (unsigned long long)addr,
147
		dev->parent, *handle);
148
	if (!*handle)
149
		goto err;
150
	ret = 0;
151
err:
152
	acpi_os_free(dinfo);
153
	return ret;
154
}
155
156
struct walk_info {		/* can be trimmed some */
157
	struct device	*dev;
158
	struct acpi_device *adev;
159
	acpi_handle	handle;
160
	acpi_integer	pcidevfn;
161
	unsigned int	drivenum;
162
	acpi_handle	obj_handle;
163
	struct ata_port *ataport;
164
	struct ata_device *atadev;
165
	u32		sata_adr;
166
	int		status;
167
	char		basepath[ACPI_PATHNAME_MAX];
168
	int		basepath_len;
169
};
170
171
static acpi_status get_devices(acpi_handle handle,
172
				u32 level, void *context, void **return_value)
173
{
174
	acpi_status		status;
175
	struct walk_info	*winfo = context;
176
	struct acpi_buffer	namebuf = {ACPI_ALLOCATE_BUFFER, NULL};
177
	char			*pathname;
178
	struct acpi_buffer	buffer;
179
	struct acpi_device_info	*dinfo;
180
181
	status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &namebuf);
182
	if (status)
183
		goto ret;
184
	pathname = namebuf.pointer;
185
186
	buffer.length = ACPI_ALLOCATE_BUFFER;
187
	buffer.pointer = NULL;
188
	status = acpi_get_object_info(handle, &buffer);
189
190
	if (ACPI_SUCCESS(status)) {
191
		dinfo = buffer.pointer;
192
193
		/* find full device path name for pcidevfn */
194
		if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
195
		    dinfo->address == winfo->pcidevfn) {
196
			if (ata_msg_probe(winfo->ataport))
197
				printk(KERN_DEBUG
198
					":%s: matches pcidevfn (0x%llx)\n",
199
					pathname, winfo->pcidevfn);
200
			strlcpy(winfo->basepath, pathname,
201
				sizeof(winfo->basepath));
202
			winfo->basepath_len = strlen(pathname);
203
			goto out;
204
		}
205
206
		/* if basepath is not yet known, ignore this object */
207
		if (!winfo->basepath_len)
208
			goto out;
209
210
		/* if this object is in scope of basepath, maybe use it */
211
		if (strncmp(pathname, winfo->basepath,
212
		    winfo->basepath_len) == 0) {
213
			if (!(dinfo->valid & ACPI_VALID_ADR))
214
				goto out;
215
			if (ata_msg_probe(winfo->ataport))
216
				printk(KERN_DEBUG "GOT ONE: (%s) "
217
					"root_port = 0x%llx, port_num = 0x%llx\n",
218
					pathname,
219
					SATA_ROOT_PORT(dinfo->address),
220
					SATA_PORT_NUMBER(dinfo->address));
221
			/* heuristics: */
222
			if (SATA_PORT_NUMBER(dinfo->address) != NO_PORT_MULT)
223
				if (ata_msg_probe(winfo->ataport))
224
					printk(KERN_DEBUG
225
						"warning: don't know how to handle SATA port multiplier\n");
226
			if (SATA_ROOT_PORT(dinfo->address) ==
227
				winfo->ataport->port_no &&
228
			    SATA_PORT_NUMBER(dinfo->address) == NO_PORT_MULT) {
229
				if (ata_msg_probe(winfo->ataport))
230
					printk(KERN_DEBUG
231
						"THIS ^^^^^ is the requested SATA drive (handle = 0x%p)\n",
232
						handle);
233
				winfo->sata_adr = dinfo->address;
234
				winfo->obj_handle = handle;
235
			}
236
		}
237
out:
238
		acpi_os_free(dinfo);
239
	}
240
	acpi_os_free(pathname);
241
242
ret:
243
	return status;
244
}
245
246
/* Get the SATA drive _ADR object. */
247
static int get_sata_adr(struct device *dev, acpi_handle handle,
248
			acpi_integer pcidevfn, unsigned int drive,
249
			struct ata_port *ap,
250
			struct ata_device *atadev, u32 *dev_adr)
251
{
252
	acpi_status	status;
253
	struct walk_info *winfo;
254
	int		err = -ENOMEM;
255
256
	winfo = kmalloc(sizeof(struct walk_info), GFP_KERNEL);
257
	if (!winfo)
258
		goto out;
259
260
	memset(winfo, 0, sizeof(struct walk_info));
261
262
	winfo->dev = dev;
263
	winfo->atadev = atadev;
264
	winfo->ataport = ap;
265
	if (acpi_bus_get_device(handle, &winfo->adev) < 0)
266
		if (ata_msg_probe(ap))
267
			printk(KERN_DEBUG "acpi_bus_get_device failed\n");
268
	winfo->handle = handle;
269
	winfo->pcidevfn = pcidevfn;
270
	winfo->drivenum = drive;
271
272
	status = acpi_get_devices(NULL, get_devices, winfo, NULL);
273
	if (ACPI_FAILURE(status)) {
274
		if (ata_msg_probe(ap))
275
			printk(KERN_DEBUG "%s: acpi_get_devices failed\n",
276
				__FUNCTION__);
277
		err = -ENODEV;
278
	} else {
279
		*dev_adr = winfo->sata_adr;
280
		atadev->obj_handle = winfo->obj_handle;
281
		err = 0;
282
	}
283
	kfree(winfo);
284
out:
285
	return err;
286
}
287
288
/**
289
 * ata_acpi_push_id - send Identify data to a drive
290
 * @ap: the ata_port for the drive
291
 * @ix: drive index
292
 *
293
 * _SDD ACPI object:  for SATA mode only.
294
 * Must be after Identify (Packet) Device -- uses its data.
295
 */
296
int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
297
{
298
	acpi_handle			handle;
299
	acpi_integer			pcidevfn;
300
	int				err = -ENODEV;
301
	struct device			*dev = ap->host_set->dev;
302
	struct ata_device		*atadev = &ap->device[ix];
303
	u32				dev_adr;
304
	acpi_status			status;
305
	struct acpi_object_list		input;
306
	union acpi_object 		in_params[1];
307
308
	if (ap->legacy_mode) {
309
		printk(KERN_DEBUG "%s: should not be here for PATA mode\n",
310
			__FUNCTION__);
311
		return 0;
312
	}
313
	if (noacpi)
314
		return 0;
315
316
	if (ata_msg_probe(ap))
317
		printk(KERN_DEBUG
318
			"%s: ap->id: %d, ix = %d, port#: %d, hard_port#: %d\n",
319
			__FUNCTION__, ap->id, ix,
320
			ap->port_no, ap->hard_port_no);
321
322
	/* Don't continue if not a SATA device. */
323
	if (!ata_id_is_sata(atadev->id)) {
324
		if (ata_msg_probe(ap))
325
			printk(KERN_DEBUG "%s: ata_id_is_sata is False\n",
326
				__FUNCTION__);
327
		goto out;
328
	}
329
330
	/* Don't continue if device has no _ADR method.
331
	 * _SDD is intended for known motherboard devices. */
332
	err = sata_get_dev_handle(dev, &handle, &pcidevfn);
333
	if (err < 0) {
334
		if (ata_msg_probe(ap))
335
			printk(KERN_DEBUG
336
				"%s: sata_get_dev_handle failed (%d\n",
337
				__FUNCTION__, err);
338
		goto out;
339
	}
340
341
	/* Get this drive's _ADR info. if not already known. */
342
	if (!atadev->obj_handle) {
343
		dev_adr = SATA_ADR_RSVD;
344
		err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev,
345
				&dev_adr);
346
		if (err < 0 || dev_adr == SATA_ADR_RSVD ||
347
		    !atadev->obj_handle) {
348
			if (ata_msg_probe(ap))
349
				printk(KERN_DEBUG "%s: get_sata_adr failed: "
350
					"err=%d, dev_adr=%u, obj_handle=0x%p\n",
351
					__FUNCTION__, err, dev_adr,
352
					atadev->obj_handle);
353
			goto out;
354
		}
355
	}
356
357
	/* Give the drive Identify data to the drive via the _SDD method */
358
	/* _SDD: set up input parameters */
359
	input.count = 1;
360
	input.pointer = in_params;
361
	in_params[0].type = ACPI_TYPE_BUFFER;
362
	in_params[0].buffer.length = sizeof(atadev->id);
363
	in_params[0].buffer.pointer = (u8 *)atadev->id;
364
	/* Output buffer: _SDD has no output */
365
366
	/* It's OK for _SDD to be missing too. */
367
	swap_buf_le16(atadev->id, ATA_ID_WORDS);
368
	status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL);
369
	swap_buf_le16(atadev->id, ATA_ID_WORDS);
370
371
	err = ACPI_FAILURE(status) ? -EIO : 0;
372
	if (err < 0) {
373
		if (ata_msg_probe(ap))
374
			printk(KERN_DEBUG
375
				"ata%u(%u): %s _SDD error: status = 0x%x\n",
376
				ap->id, ap->device->devno,
377
				__FUNCTION__, status);
378
	}
379
out:
380
	return err;
381
}
382
EXPORT_SYMBOL_GPL(ata_acpi_push_id);
383
384
/**
385
 * do_drive_get_GTF - get the drive bootup default taskfile settings
386
 * @ap: the ata_port for the drive
387
 * @atadev: target ata_device
388
 * @gtf_length: number of bytes of _GTF data returned at @gtf_address
389
 * @gtf_address: buffer containing _GTF taskfile arrays
390
 *
391
 * This applies to both PATA and SATA drives.
392
 *
393
 * The _GTF method has no input parameters.
394
 * It returns a variable number of register set values (registers
395
 * hex 1F1..1F7, taskfiles).
396
 * The <variable number> is not known in advance, so have ACPI-CA
397
 * allocate the buffer as needed and return it, then free it later.
398
 *
399
 * The returned @gtf_length and @gtf_address are only valid if the
400
 * function return value is 0.
401
 */
402
int do_drive_get_GTF(struct ata_port *ap, struct ata_device *atadev,
403
			unsigned int *gtf_length, unsigned long *gtf_address,
404
			unsigned long *obj_loc)
405
{
406
	acpi_status			status;
407
	acpi_handle			handle;
408
	acpi_integer			pcidevfn;
409
	u32				dev_adr;
410
	struct acpi_buffer		output;
411
	union acpi_object 		*out_obj;
412
	struct device			*dev = ap->host_set->dev;
413
	int				err = -ENODEV;
414
415
	if (ata_msg_probe(ap))
416
		printk(KERN_DEBUG
417
			"%s: ENTER: ap->id: %d, port#: %d, hard_port#: %d\n",
418
			__FUNCTION__, ap->id,
419
		ap->port_no, ap->hard_port_no);
420
421
	*gtf_length = 0;
422
	*gtf_address = 0UL;
423
	*obj_loc = 0UL;
424
425
	if (noacpi)
426
		return 0;
427
428
	if (!ata_dev_present(atadev) ||
429
	    (ap->flags & ATA_FLAG_PORT_DISABLED)) {
430
		if (ata_msg_probe(ap))
431
			printk(KERN_DEBUG "%s: ERR: "
432
				"ata_dev_present: %d, PORT_DISABLED: %lu\n",
433
				__FUNCTION__, ata_dev_present(atadev),
434
				ap->flags & ATA_FLAG_PORT_DISABLED);
435
		goto out;
436
	}
437
438
	/* Don't continue if device has no _ADR method.
439
	 * _GTF is intended for known motherboard devices. */
440
	if (!ata_id_is_sata(atadev->id)) {
441
		err = pata_get_dev_handle(dev, &handle, &pcidevfn);
442
		if (err < 0) {
443
			if (ata_msg_probe(ap))
444
				printk(KERN_DEBUG
445
					"%s: pata_get_dev_handle failed (%d)\n",
446
					__FUNCTION__, err);
447
			goto out;
448
		}
449
	} else {
450
		err = sata_get_dev_handle(dev, &handle, &pcidevfn);
451
		if (err < 0) {
452
			if (ata_msg_probe(ap))
453
				printk(KERN_DEBUG
454
					"%s: sata_get_dev_handle failed (%d\n",
455
					__FUNCTION__, err);
456
			goto out;
457
		}
458
	}
459
460
	/* Get this drive's _ADR info. if not already known. */
461
	if (!atadev->obj_handle) {
462
		dev_adr = SATA_ADR_RSVD;
463
		err = get_sata_adr(dev, handle, pcidevfn, 0, ap, atadev,
464
				&dev_adr);
465
		if (!ata_id_is_sata(atadev->id)) {
466
			printk(KERN_DEBUG "%s: early exit\n", __FUNCTION__);
467
			err = -1;
468
			goto out;
469
		}
470
		if (err < 0 || dev_adr == SATA_ADR_RSVD ||
471
		    !atadev->obj_handle) {
472
			if (ata_msg_probe(ap))
473
				printk(KERN_DEBUG "%s: get_sata_adr failed: "
474
					"err=%d, dev_adr=%u, obj_handle=0x%p\n",
475
					__FUNCTION__, err, dev_adr,
476
					atadev->obj_handle);
477
			goto out;
478
		}
479
	}
480
481
	/* Setting up output buffer */
482
	output.length = ACPI_ALLOCATE_BUFFER;
483
	output.pointer = NULL;	/* ACPI-CA sets this; save/free it later */
484
485
	/* _GTF has no input parameters */
486
	err = -EIO;
487
	status = acpi_evaluate_object(atadev->obj_handle, "_GTF",
488
					NULL, &output);
489
	if (ACPI_FAILURE(status)) {
490
		if (ata_msg_probe(ap))
491
			printk(KERN_DEBUG
492
				"%s: Run _GTF error: status = 0x%x\n",
493
				__FUNCTION__, status);
494
		goto out;
495
	}
496
497
	if (!output.length || !output.pointer) {
498
		if (ata_msg_probe(ap))
499
			printk(KERN_DEBUG "%s: Run _GTF: "
500
				"length or ptr is NULL (0x%llx, 0x%p)\n",
501
				__FUNCTION__,
502
				(unsigned long long)output.length,
503
				output.pointer);
504
		acpi_os_free(output.pointer);
505
		goto out;
506
	}
507
508
	out_obj = output.pointer;
509
	if (out_obj->type != ACPI_TYPE_BUFFER) {
510
		acpi_os_free(output.pointer);
511
		if (ata_msg_probe(ap))
512
			printk(KERN_DEBUG "%s: Run _GTF: error: "
513
				"expected object type of ACPI_TYPE_BUFFER, "
514
				"got 0x%x\n",
515
				__FUNCTION__, out_obj->type);
516
		err = -ENOENT;
517
		goto out;
518
	}
519
520
	if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
521
	    out_obj->buffer.length % REGS_PER_GTF) {
522
		if (ata_msg_drv(ap))
523
			printk(KERN_ERR
524
				"%s: unexpected GTF length (%d) or addr (0x%p)\n",
525
				__FUNCTION__, out_obj->buffer.length,
526
				out_obj->buffer.pointer);
527
		err = -ENOENT;
528
		goto out;
529
	}
530
531
	*gtf_length = out_obj->buffer.length;
532
	*gtf_address = (unsigned long)out_obj->buffer.pointer;
533
	*obj_loc = (unsigned long)out_obj;
534
	if (ata_msg_probe(ap))
535
		printk(KERN_DEBUG "%s: returning "
536
			"gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n",
537
			__FUNCTION__, *gtf_length, *gtf_address, *obj_loc);
538
	err = 0;
539
out:
540
	return err;
541
}
542
EXPORT_SYMBOL_GPL(do_drive_get_GTF);
543
544
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat)
545
{
546
	return 0;
547
}
548
549
/**
550
 * taskfile_load_raw - send taskfile registers to host controller
551
 * @ap: Port to which output is sent
552
 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
553
 *
554
 * Outputs ATA taskfile to standard ATA host controller using MMIO
555
 * or PIO as indicated by the ATA_FLAG_MMIO flag.
556
 * Writes the control, feature, nsect, lbal, lbam, and lbah registers.
557
 * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,
558
 * hob_lbal, hob_lbam, and hob_lbah.
559
 *
560
 * This function waits for idle (!BUSY and !DRQ) after writing
561
 * registers.  If the control register has a new value, this
562
 * function also waits for idle after writing control and before
563
 * writing the remaining registers.
564
 *
565
 * LOCKING: TBD:
566
 * Inherited from caller.
567
 */
568
static void taskfile_load_raw(struct ata_port *ap,
569
				struct ata_device *atadev,
570
				const struct taskfile_array *gtf)
571
{
572
	unsigned long timeout = HZ * 5;
573
574
	if (ata_msg_probe(ap))
575
		printk(KERN_DEBUG "%s: (0x1f1-1f7): hex: "
576
			"%02x %02x %02x %02x %02x %02x %02x\n",
577
			__FUNCTION__,
578
			gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
579
			gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]);
580
581
	if (ap->ops->qc_issue) {
582
		DECLARE_COMPLETION(wait);
583
		struct ata_queued_cmd *qc;
584
		int rc;
585
		unsigned long flags;
586
587
		qc = ata_qc_new_init(ap, atadev);
588
		BUG_ON(qc == NULL);
589
590
		/* convert gtf to tf */
591
		qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */
592
		qc->tf.protocol = atadev->class == ATA_DEV_ATAPI ?
593
			ATA_PROT_ATAPI_NODATA : ATA_PROT_NODATA;
594
		qc->tf.feature = gtf->tfa[0];	/* 0x1f1 */
595
		qc->tf.nsect   = gtf->tfa[1];	/* 0x1f2 */
596
		qc->tf.lbal    = gtf->tfa[2];	/* 0x1f3 */
597
		qc->tf.lbam    = gtf->tfa[3];	/* 0x1f4 */
598
		qc->tf.lbah    = gtf->tfa[4];	/* 0x1f5 */
599
		qc->tf.device  = gtf->tfa[5];	/* 0x1f6 */
600
		qc->tf.command = gtf->tfa[6];	/* 0x1f7 */
601
602
		if (ata_msg_probe(ap))
603
			printk(KERN_DEBUG "call ata_qc_issue:\n");
604
605
		qc->waiting = &wait;
606
		qc->complete_fn = ata_qc_complete_noop;
607
608
		spin_lock_irqsave(&ap->host_set->lock, flags);
609
		rc = ata_qc_issue(qc);
610
		spin_unlock_irqrestore(&ap->host_set->lock, flags);
611
		if (rc) {
612
			if (ata_msg_probe(ap))
613
				printk(KERN_ERR "%s: ata_qc_issue failed: %u\n",
614
				       __FUNCTION__, rc);
615
		} else {
616
			if (!wait_for_completion_timeout(&wait, timeout)) {
617
				if (ata_msg_probe(ap))
618
					printk(KERN_ERR "%s: ata_qc_issue timeout\n", __FUNCTION__);
619
				qc->flags &= ~ATA_QCFLAG_ACTIVE;
620
			}
621
		}
622
	} else
623
		if (ata_msg_warn(ap))
624
			printk(KERN_WARNING
625
				"%s: SATA driver is missing qc_issue function entry points\n",
626
				__FUNCTION__);
627
}
628
629
/**
630
 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
631
 * @ap: the ata_port for the drive
632
 * @atadev: target ata_device
633
 * @gtf_length: total number of bytes of _GTF taskfiles
634
 * @gtf_address: location of _GTF taskfile arrays
635
 *
636
 * This applies to both PATA and SATA drives.
637
 *
638
 * Write {gtf_address, length gtf_length} in groups of
639
 * REGS_PER_GTF bytes.
640
 */
641
int do_drive_set_taskfiles(struct ata_port *ap, struct ata_device *atadev,
642
			unsigned int gtf_length, unsigned long gtf_address)
643
{
644
	int			err = -ENODEV;
645
	int			gtf_count = gtf_length / REGS_PER_GTF;
646
	int			ix;
647
	struct taskfile_array	*gtf;
648
649
	if (ata_msg_probe(ap))
650
		printk(KERN_DEBUG
651
			"%s: ENTER: ap->id: %d, port#: %d, hard_port#: %d\n",
652
			__FUNCTION__, ap->id,
653
			ap->port_no, ap->hard_port_no);
654
655
	if (noacpi)
656
		return 0;
657
	if (!ata_id_is_sata(atadev->id)) {
658
		printk(KERN_DEBUG "%s: skipping non-SATA drive\n",
659
			__FUNCTION__);
660
		return 0;
661
	}
662
663
	if (!ata_dev_present(atadev) ||
664
	    (ap->flags & ATA_FLAG_PORT_DISABLED))
665
		goto out;
666
	if (!gtf_count)		/* shouldn't be here */
667
		goto out;
668
669
	if (ata_msg_probe(ap))
670
		printk(KERN_DEBUG
671
			"%s: total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
672
			__FUNCTION__, gtf_length, gtf_length, gtf_count,
673
			gtf_address);
674
	if (gtf_length % REGS_PER_GTF) {
675
		if (ata_msg_drv(ap))
676
			printk(KERN_ERR "%s: unexpected GTF length (%d)\n",
677
				__FUNCTION__, gtf_length);
678
		goto out;
679
	}
680
681
	for (ix = 0; ix < gtf_count; ix++) {
682
		gtf = (struct taskfile_array *)
683
			(gtf_address + ix * REGS_PER_GTF);
684
685
		/* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
686
		taskfile_load_raw(ap, atadev, gtf);
687
	}
688
689
	err = 0;
690
out:
691
	return err;
692
}
693
EXPORT_SYMBOL_GPL(do_drive_set_taskfiles);
694
695
/**
696
 * ata_acpi_exec_tfs - get then write drive taskfile settings
697
 * @ap: the ata_port for the drive
698
 *
699
 * This applies to both PATA and SATA drives.
700
 */
701
int ata_acpi_exec_tfs(struct ata_port *ap)
702
{
703
	int		ix;
704
	int		ret;
705
	unsigned int	gtf_length;
706
	unsigned long	gtf_address;
707
	unsigned long	obj_loc;
708
709
	if (ata_msg_probe(ap))
710
		printk(KERN_DEBUG "%s: ENTER:\n", __FUNCTION__);
711
712
	if (noacpi)
713
		return 0;
714
715
	for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
716
		if (ata_msg_probe(ap))
717
			printk(KERN_DEBUG "%s: call get_GTF, ix=%d\n",
718
				__FUNCTION__, ix);
719
		ret = do_drive_get_GTF(ap, &ap->device[ix],
720
				&gtf_length, &gtf_address, &obj_loc);
721
		if (ret < 0) {
722
			if (ata_msg_probe(ap))
723
				printk(KERN_DEBUG "%s: get_GTF error (%d)\n",
724
					__FUNCTION__, ret);
725
			break;
726
		}
727
728
		if (ata_msg_probe(ap))
729
			printk(KERN_DEBUG "%s: call set_taskfiles, ix=%d\n",
730
				__FUNCTION__, ix);
731
		ret = do_drive_set_taskfiles(ap, &ap->device[ix],
732
				gtf_length, gtf_address);
733
		acpi_os_free((void *)obj_loc);
734
		if (ret < 0) {
735
			if (ata_msg_probe(ap))
736
				printk(KERN_DEBUG
737
					"%s: set_taskfiles error (%d)\n",
738
					__FUNCTION__, ret);
739
			break;
740
		}
741
	}
742
743
	if (ata_msg_probe(ap))
744
		printk(KERN_DEBUG "%s: ret=%d\n", __FUNCTION__, ret);
745
746
	return ret;
747
}
748
EXPORT_SYMBOL_GPL(ata_acpi_exec_tfs);
749
750
/**
751
 * ata_acpi_get_timing - get the channel (controller) timings
752
 * @ap: target ata_port (channel)
753
 *
754
 * For PATA ACPI, this function executes the _GTM ACPI method for the
755
 * target channel.
756
 *
757
 * _GTM only applies to ATA controllers in PATA (legacy) mode, not to SATA.
758
 * In legacy mode, ap->hard_port_no is channel (controller) number.
759
 */
760
void ata_acpi_get_timing(struct ata_port *ap)
761
{
762
	struct device		*dev = ap->dev;
763
	int			err;
764
	acpi_handle		dev_handle;
765
	acpi_integer		pcidevfn;
766
	acpi_handle		chan_handle;
767
	acpi_status		status;
768
	struct acpi_buffer	output;
769
	union acpi_object 	*out_obj;
770
	struct GTM_buffer	*gtm;
771
772
	if (noacpi)
773
		goto out;
774
775
	if (!ap->legacy_mode) {
776
		if (ata_msg_probe(ap))
777
			printk(KERN_DEBUG
778
				"%s: channel/controller not in legacy mode (%s)\n",
779
				__FUNCTION__, dev->bus_id);
780
		goto out;
781
	}
782
783
	err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn);
784
	if (err < 0) {
785
		if (ata_msg_probe(ap))
786
			printk(KERN_DEBUG
787
				"%s: pata_get_dev_handle failed (%d)\n",
788
				__FUNCTION__, err);
789
		goto out;
790
	}
791
792
	/* get child objects of dev_handle == channel objects,
793
	 * + _their_ children == drive objects */
794
	/* channel is ap->hard_port_no */
795
	chan_handle = acpi_get_child(dev_handle, ap->hard_port_no);
796
	if (ata_msg_probe(ap))
797
		printk(KERN_DEBUG "%s: chan adr=%d: handle=0x%p\n",
798
			__FUNCTION__, ap->hard_port_no, chan_handle);
799
	if (!chan_handle)
800
		goto out;
801
802
#if 0
803
	/* TBD: also check ACPI object VALID bits */
804
	drive_handle = acpi_get_child(chan_handle, 0);
805
	printk(KERN_DEBUG "%s:   drive w/ adr=0: %c: 0x%p\n",
806
		__FUNCTION__,
807
		ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v',
808
		drive_handle);
809
	drive_handle = acpi_get_child(chan_handle, 1);
810
	printk(KERN_DEBUG "%s:   drive w/ adr=1: %c: 0x%p\n",
811
		__FUNCTION__,
812
		ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v',
813
		drive_handle);
814
#endif
815
816
	/* Setting up output buffer for _GTM */
817
	output.length = ACPI_ALLOCATE_BUFFER;
818
	output.pointer = NULL;	/* ACPI-CA sets this; save/free it later */
819
820
	/* _GTM has no input parameters */
821
	status = acpi_evaluate_object(chan_handle, "_GTM",
822
					NULL, &output);
823
	if (ata_msg_probe(ap))
824
		printk(KERN_DEBUG "%s: _GTM status: %d, outptr: 0x%p, outlen: 0x%llx\n",
825
			__FUNCTION__, status, output.pointer,
826
			(unsigned long long)output.length);
827
	if (ACPI_FAILURE(status)) {
828
		if (ata_msg_probe(ap))
829
			printk(KERN_DEBUG
830
				"%s: Run _GTM error: status = 0x%x\n",
831
				__FUNCTION__, status);
832
		goto out;
833
	}
834
835
	if (!output.length || !output.pointer) {
836
		if (ata_msg_probe(ap))
837
			printk(KERN_DEBUG "%s: Run _GTM: "
838
				"length or ptr is NULL (0x%llx, 0x%p)\n",
839
				__FUNCTION__,
840
				(unsigned long long)output.length,
841
				output.pointer);
842
		acpi_os_free(output.pointer);
843
		goto out;
844
	}
845
846
	out_obj = output.pointer;
847
	if (out_obj->type != ACPI_TYPE_BUFFER) {
848
		acpi_os_free(output.pointer);
849
		if (ata_msg_probe(ap))
850
			printk(KERN_DEBUG "%s: Run _GTM: error: "
851
				"expected object type of ACPI_TYPE_BUFFER, "
852
				"got 0x%x\n",
853
				__FUNCTION__, out_obj->type);
854
		goto out;
855
	}
856
857
	if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
858
	    out_obj->buffer.length != sizeof(struct GTM_buffer)) {
859
		acpi_os_free(output.pointer);
860
		if (ata_msg_drv(ap))
861
			printk(KERN_ERR
862
				"%s: unexpected _GTM length (0x%x)[should be 0x%x] or addr (0x%p)\n",
863
				__FUNCTION__, out_obj->buffer.length,
864
				sizeof(struct GTM_buffer), out_obj->buffer.pointer);
865
		goto out;
866
	}
867
868
	gtm = (struct GTM_buffer *)out_obj->buffer.pointer;
869
	if (ata_msg_probe(ap)) {
870
		printk(KERN_DEBUG "%s: _GTM info: ptr: 0x%p, len: 0x%x, exp.len: 0x%Zx\n",
871
			__FUNCTION__, out_obj->buffer.pointer,
872
			out_obj->buffer.length, sizeof(struct GTM_buffer));
873
		printk(KERN_DEBUG "%s: _GTM fields: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
874
			__FUNCTION__, gtm->PIO_speed0, gtm->DMA_speed0,
875
			gtm->PIO_speed1, gtm->DMA_speed1, gtm->GTM_flags);
876
	}
877
878
	/* TBD: when to free gtm */
879
	ap->gtm = gtm;
880
	kfree(ap->gtm_object_area); /* free previous then store new one */
881
	ap->gtm_object_area = out_obj;
882
out:;
883
}
884
EXPORT_SYMBOL_GPL(ata_acpi_get_timing);
885
886
/**
887
 * platform_set_timing - set the channel (controller) timings
888
 * @ap: target ata_port (channel)
889
 *
890
 * For PATA ACPI, this function executes the _STM ACPI method for the
891
 * target channel.
892
 *
893
 * _STM only applies to ATA controllers in PATA (legacy) mode, not to SATA.
894
 * In legacy mode, ap->hard_port_no is channel (controller) number.
895
 *
896
 * _STM requires Identify Drive data, which must already be present in
897
 * ata_device->id[] (i.e., it's not fetched here).
898
 */
899
void ata_acpi_push_timing(struct ata_port *ap)
900
{
901
	struct device		*dev = ap->dev;
902
	int			err;
903
	acpi_handle		dev_handle;
904
	acpi_integer		pcidevfn;
905
	acpi_handle		chan_handle;
906
	acpi_status		status;
907
	struct acpi_object_list	input;
908
	union acpi_object 	in_params[1];
909
910
	if (noacpi)
911
		goto out;
912
913
	if (!ap->legacy_mode) {
914
		if (ata_msg_probe(ap))
915
			printk(KERN_DEBUG
916
				"%s: channel/controller not in legacy mode (%s)\n",
917
				__FUNCTION__, dev->bus_id);
918
		goto out;
919
	}
920
921
	if (ap->device[0].id[49] || ap->device[1].id[49]) {
922
		if (ata_msg_probe(ap))
923
			printk(KERN_DEBUG "%s: drive(s) on channel %d: missing Identify data\n",
924
				__FUNCTION__, ap->hard_port_no);
925
		goto out;
926
	}
927
928
	err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn);
929
	if (err < 0) {
930
		if (ata_msg_probe(ap))
931
			printk(KERN_DEBUG
932
				"%s: pata_get_dev_handle failed (%d)\n",
933
				__FUNCTION__, err);
934
		goto out;
935
	}
936
937
	/* get child objects of dev_handle == channel objects,
938
	 * + _their_ children == drive objects */
939
	/* channel is ap->hard_port_no */
940
	chan_handle = acpi_get_child(dev_handle, ap->hard_port_no);
941
	if (ata_msg_probe(ap))
942
		printk(KERN_DEBUG "%s: chan adr=%d: handle=0x%p\n",
943
			__FUNCTION__, ap->hard_port_no, chan_handle);
944
	if (!chan_handle)
945
		goto out;
946
947
#if 0
948
	/* TBD: also check ACPI object VALID bits */
949
	drive_handle = acpi_get_child(chan_handle, 0);
950
	printk(KERN_DEBUG "%s:   drive w/ adr=0: %c: 0x%p\n",
951
		__FUNCTION__,
952
		ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v',
953
		drive_handle);
954
	drive_handle = acpi_get_child(chan_handle, 1);
955
	printk(KERN_DEBUG "%s:   drive w/ adr=1: %c: 0x%p\n",
956
		__FUNCTION__,
957
		ap->device[0].class == ATA_DEV_NONE ? 'n' : 'v',
958
		drive_handle);
959
#endif
960
961
	/* Give the GTM buffer + drive Identify data to the channel via the
962
	 * _STM method: */
963
	/* setup input parameters buffer for _STM */
964
	input.count = 3;
965
	input.pointer = in_params;
966
	in_params[0].type = ACPI_TYPE_BUFFER;
967
	in_params[0].buffer.length = sizeof(struct GTM_buffer);
968
	in_params[0].buffer.pointer = (u8 *)ap->gtm;
969
	in_params[1].type = ACPI_TYPE_BUFFER;
970
	in_params[1].buffer.length = sizeof(ap->device[0].id);
971
	in_params[1].buffer.pointer = (u8 *)ap->device[0].id;
972
	in_params[2].type = ACPI_TYPE_BUFFER;
973
	in_params[2].buffer.length = sizeof(ap->device[1].id);
974
	in_params[2].buffer.pointer = (u8 *)ap->device[1].id;
975
	/* Output buffer: _STM has no output */
976
977
	swap_buf_le16(ap->device[0].id, ATA_ID_WORDS);
978
	swap_buf_le16(ap->device[1].id, ATA_ID_WORDS);
979
	status = acpi_evaluate_object(chan_handle, "_STM", &input, NULL);
980
	swap_buf_le16(ap->device[0].id, ATA_ID_WORDS);
981
	swap_buf_le16(ap->device[1].id, ATA_ID_WORDS);
982
	if (ata_msg_probe(ap))
983
		printk(KERN_DEBUG "%s: _STM status: %d\n",
984
			__FUNCTION__, status);
985
	if (ACPI_FAILURE(status)) {
986
		if (ata_msg_probe(ap))
987
			printk(KERN_DEBUG
988
				"%s: Run _STM error: status = 0x%x\n",
989
				__FUNCTION__, status);
990
		goto out;
991
	}
992
993
out:;
994
}
995
EXPORT_SYMBOL_GPL(ata_acpi_push_timing);
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/libata.h.orig (+48 lines)
Lines 35-40 struct ata_scsi_args { Link Here
35
};
35
};
36
36
37
/* libata-core.c */
37
/* libata-core.c */
38
extern int noacpi;
39
extern int libata_printk;
38
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
40
extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
39
				      struct ata_device *dev);
41
				      struct ata_device *dev);
40
extern void ata_qc_free(struct ata_queued_cmd *qc);
42
extern void ata_qc_free(struct ata_queued_cmd *qc);
Lines 44-49 extern void ata_dev_select(struct ata_po Link Here
44
                           unsigned int wait, unsigned int can_sleep);
46
                           unsigned int wait, unsigned int can_sleep);
45
extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf);
47
extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf);
46
extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
48
extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
49
extern unsigned int ata_exec_internal(struct ata_port *ap,
50
				struct ata_device *dev,
51
				struct ata_taskfile *tf,
52
				int dma_dir, void *buf, unsigned int buflen);
53
54
55
/* libata-acpi.c */
56
#ifdef CONFIG_SCSI_SATA_ACPI
57
extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix);
58
extern int do_drive_get_GTF(struct ata_port *ap, struct ata_device *atadev,
59
			unsigned int *gtf_length, unsigned long *gtf_address,
60
			unsigned long *obj_loc);
61
extern int do_drive_set_taskfiles(struct ata_port *ap, struct ata_device *atadev,
62
			unsigned int gtf_length, unsigned long gtf_address);
63
extern int ata_acpi_exec_tfs(struct ata_port *ap);
64
extern void ata_acpi_get_timing(struct ata_port *ap);
65
extern void ata_acpi_push_timing(struct ata_port *ap);
66
#else
67
static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
68
{
69
	return 0;
70
}
71
static inline int do_drive_get_GTF(struct ata_port *ap,
72
			struct ata_device *atadev,
73
			unsigned int *gtf_length, unsigned long *gtf_address,
74
			unsigned long *obj_loc)
75
{
76
	return 0;
77
}
78
static inline int do_drive_set_taskfiles(struct ata_port *ap,
79
			struct ata_device *atadev,
80
			unsigned int gtf_length, unsigned long gtf_address)
81
{
82
	return 0;
83
}
84
static inline int ata_acpi_exec_tfs(struct ata_port *ap)
85
{
86
	return 0;
87
}
88
static void ata_acpi_get_timing(struct ata_port *ap)
89
{
90
}
91
static void ata_acpi_push_timing(struct ata_port *ap)
92
{
93
}
94
#endif
47
95
48
96
49
/* libata-scsi.c */
97
/* libata-scsi.c */
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/ahci.c.orig (-40 / +178 lines)
Lines 87-98 enum { Link Here
87
	PORT_CMD		= 0x18, /* port command */
87
	PORT_CMD		= 0x18, /* port command */
88
	PORT_TFDATA		= 0x20,	/* taskfile data */
88
	PORT_TFDATA		= 0x20,	/* taskfile data */
89
	PORT_SIG		= 0x24,	/* device TF signature */
89
	PORT_SIG		= 0x24,	/* device TF signature */
90
	PORT_CMD_ISSUE		= 0x38, /* command issue */
91
	PORT_SCR		= 0x28, /* SATA phy register block */
90
	PORT_SCR		= 0x28, /* SATA phy register block */
92
	PORT_SCR_STAT		= 0x28, /* SATA phy register: SStatus */
91
	PORT_SCR_STAT		= 0x28, /* SATA phy register: SStatus */
93
	PORT_SCR_CTL		= 0x2c, /* SATA phy register: SControl */
92
	PORT_SCR_CTL		= 0x2c, /* SATA phy register: SControl */
94
	PORT_SCR_ERR		= 0x30, /* SATA phy register: SError */
93
	PORT_SCR_ERR		= 0x30, /* SATA phy register: SError */
95
	PORT_SCR_ACT		= 0x34, /* SATA phy register: SActive */
94
	PORT_SCR_ACT		= 0x34, /* SATA phy register: SActive */
95
	PORT_CMD_ISSUE		= 0x38, /* command issue */
96
96
97
	/* PORT_IRQ_{STAT,MASK} bits */
97
	/* PORT_IRQ_{STAT,MASK} bits */
98
	PORT_IRQ_COLD_PRES	= (1 << 31), /* cold presence detect */
98
	PORT_IRQ_COLD_PRES	= (1 << 31), /* cold presence detect */
Lines 176-185 static void ahci_scr_write (struct ata_p Link Here
176
static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
176
static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
177
static int ahci_qc_issue(struct ata_queued_cmd *qc);
177
static int ahci_qc_issue(struct ata_queued_cmd *qc);
178
static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
178
static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
179
static void ahci_start_engine(struct ata_port *ap);
180
static int ahci_stop_engine(struct ata_port *ap);
179
static void ahci_phy_reset(struct ata_port *ap);
181
static void ahci_phy_reset(struct ata_port *ap);
180
static void ahci_irq_clear(struct ata_port *ap);
182
static void ahci_irq_clear(struct ata_port *ap);
181
static void ahci_eng_timeout(struct ata_port *ap);
183
static void ahci_eng_timeout(struct ata_port *ap);
184
static void ahci_restart_port(struct ata_port *ap, u32 irq_stat);
182
static int ahci_port_start(struct ata_port *ap);
185
static int ahci_port_start(struct ata_port *ap);
186
static void ahci_port_suspend(struct ata_port *ap);
187
static void ahci_port_resume(struct ata_port *ap);
183
static void ahci_port_stop(struct ata_port *ap);
188
static void ahci_port_stop(struct ata_port *ap);
184
static void ahci_host_stop(struct ata_host_set *host_set);
189
static void ahci_host_stop(struct ata_host_set *host_set);
185
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
190
static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
Lines 187-192 static void ahci_qc_prep(struct ata_queu Link Here
187
static u8 ahci_check_status(struct ata_port *ap);
192
static u8 ahci_check_status(struct ata_port *ap);
188
static u8 ahci_check_err(struct ata_port *ap);
193
static u8 ahci_check_err(struct ata_port *ap);
189
static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
194
static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
195
static int ahci_scsi_device_suspend(struct scsi_device *sdev);
196
static int ahci_scsi_device_resume(struct scsi_device *sdev);
190
static void ahci_remove_one (struct pci_dev *pdev);
197
static void ahci_remove_one (struct pci_dev *pdev);
191
198
192
static Scsi_Host_Template ahci_sht = {
199
static Scsi_Host_Template ahci_sht = {
Lines 207-214 static Scsi_Host_Template ahci_sht = { Link Here
207
	.slave_configure	= ata_scsi_slave_config,
214
	.slave_configure	= ata_scsi_slave_config,
208
	.bios_param		= ata_std_bios_param,
215
	.bios_param		= ata_std_bios_param,
209
	.ordered_flush		= 1,
216
	.ordered_flush		= 1,
210
	.resume			= ata_scsi_device_resume,
217
	.resume			= ahci_scsi_device_resume,
211
	.suspend		= ata_scsi_device_suspend,
218
	.suspend		= ahci_scsi_device_suspend,
212
};
219
};
213
220
214
static struct ata_port_operations ahci_ops = {
221
static struct ata_port_operations ahci_ops = {
Lines 246-252 static struct ata_port_info ahci_port_in Link Here
246
		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
253
		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
247
				  ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
254
				  ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
248
				  ATA_FLAG_PIO_DMA,
255
				  ATA_FLAG_PIO_DMA,
249
		.pio_mask	= 0x03, /* pio3-4 */
256
		.pio_mask	= 0x1f, /* pio0-4 */
250
		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
257
		.udma_mask	= 0x7f, /* udma0-6 ; FIXME */
251
		.port_ops	= &ahci_ops,
258
		.port_ops	= &ahci_ops,
252
	},
259
	},
Lines 295-300 static inline void *ahci_port_base (void Link Here
295
	return (void *) ahci_port_base_ul((unsigned long)base, port);
302
	return (void *) ahci_port_base_ul((unsigned long)base, port);
296
}
303
}
297
304
305
static void ahci_dump_port_status(struct ata_port *ap, int irq_stat,
306
				  char *msg)
307
{
308
	void *mmio = ap->host_set->mmio_base;
309
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
310
311
	VPRINTK("ata%u: %s, "
312
	       "p_is %x is %x pis %x cmd %x tf %x ss %x se %x\n",
313
	       ap->id, msg,
314
	       irq_stat,
315
	       readl(mmio + HOST_IRQ_STAT),
316
	       readl(port_mmio + PORT_IRQ_STAT),
317
	       readl(port_mmio + PORT_CMD),
318
	       readl(port_mmio + PORT_TFDATA),
319
	       readl(port_mmio + PORT_SCR_STAT),
320
	       readl(port_mmio + PORT_SCR_ERR));
321
}
322
298
static void ahci_host_stop(struct ata_host_set *host_set)
323
static void ahci_host_stop(struct ata_host_set *host_set)
299
{
324
{
300
	struct ahci_host_priv *hpriv = host_set->private_data;
325
	struct ahci_host_priv *hpriv = host_set->private_data;
Lines 306-315 static void ahci_host_stop(struct ata_ho Link Here
306
static int ahci_port_start(struct ata_port *ap)
331
static int ahci_port_start(struct ata_port *ap)
307
{
332
{
308
	struct device *dev = ap->host_set->dev;
333
	struct device *dev = ap->host_set->dev;
309
	struct ahci_host_priv *hpriv = ap->host_set->private_data;
310
	struct ahci_port_priv *pp;
334
	struct ahci_port_priv *pp;
311
	void *mem, *mmio = ap->host_set->mmio_base;
335
	void *mem;
312
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
313
	dma_addr_t mem_dma;
336
	dma_addr_t mem_dma;
314
337
315
	pp = kmalloc(sizeof(*pp), GFP_KERNEL);
338
	pp = kmalloc(sizeof(*pp), GFP_KERNEL);
Lines 354-359 static int ahci_port_start(struct ata_po Link Here
354
377
355
	ap->private_data = pp;
378
	ap->private_data = pp;
356
379
380
	/*
381
	 * Internal structures are initialized,
382
	 * we can now do a simple resume()
383
	 */
384
	ahci_port_resume(ap);
385
386
	return 0;
387
}
388
389
390
static void ahci_port_resume(struct ata_port *ap)
391
{
392
	void *mmio = ap->host_set->mmio_base;
393
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
394
	struct ahci_host_priv *hpriv = ap->host_set->private_data;
395
	struct ahci_port_priv *pp = ap->private_data;
396
357
	if (hpriv->cap & HOST_CAP_64)
397
	if (hpriv->cap & HOST_CAP_64)
358
		writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
398
		writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
359
	writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
399
	writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
Lines 365-395 static int ahci_port_start(struct ata_po Link Here
365
	readl(port_mmio + PORT_FIS_ADDR); /* flush */
405
	readl(port_mmio + PORT_FIS_ADDR); /* flush */
366
406
367
	writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
407
	writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
368
	       PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
408
	       PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP,
369
	       PORT_CMD_START, port_mmio + PORT_CMD);
409
	       port_mmio + PORT_CMD);
370
	readl(port_mmio + PORT_CMD); /* flush */
410
	readl(port_mmio + PORT_CMD); /* flush */
371
411
372
	return 0;
412
	ahci_start_engine(ap);
373
}
413
}
374
414
375
415
static void ahci_port_suspend(struct ata_port *ap)
376
static void ahci_port_stop(struct ata_port *ap)
377
{
416
{
378
	struct device *dev = ap->host_set->dev;
379
	struct ahci_port_priv *pp = ap->private_data;
380
	void *mmio = ap->host_set->mmio_base;
417
	void *mmio = ap->host_set->mmio_base;
381
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
418
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
382
	u32 tmp;
419
	u32 tmp;
420
	int work;
421
422
	ahci_stop_engine(ap);
383
423
424
	/*
425
	 * Disable FIS reception
426
	 */
384
	tmp = readl(port_mmio + PORT_CMD);
427
	tmp = readl(port_mmio + PORT_CMD);
385
	tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX);
428
	tmp &= ~(PORT_CMD_FIS_RX);
386
	writel(tmp, port_mmio + PORT_CMD);
429
	writel(tmp, port_mmio + PORT_CMD);
387
	readl(port_mmio + PORT_CMD); /* flush */
430
	readl(port_mmio + PORT_CMD); /* flush */
388
431
389
	/* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so
432
	/*
390
	 * this is slightly incorrect.
433
	 * Wait for HBA to acknowledge.
434
	 * This could be as long as 500 msec
391
	 */
435
	 */
392
	msleep(500);
436
	work = 1000;
437
	while (work-- > 0) {
438
		tmp = readl(port_mmio + PORT_CMD);
439
		if ((tmp & PORT_CMD_FIS_ON) == 0)
440
			break;
441
		udelay(10);
442
	}
443
}
444
445
static void ahci_port_stop(struct ata_port *ap)
446
{
447
	struct device *dev = ap->host_set->dev;
448
	struct ahci_port_priv *pp = ap->private_data;
449
450
	ahci_port_suspend(ap);
393
451
394
	ap->private_data = NULL;
452
	ap->private_data = NULL;
395
	dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
453
	dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
Lines 438-445 static void ahci_phy_reset(struct ata_po Link Here
438
	struct ata_device *dev = &ap->device[0];
496
	struct ata_device *dev = &ap->device[0];
439
	u32 tmp;
497
	u32 tmp;
440
498
499
	ahci_stop_engine(ap);
500
441
	__sata_phy_reset(ap);
501
	__sata_phy_reset(ap);
442
502
503
	/* clear SATA phy error, if any */
504
	tmp = readl(port_mmio + PORT_SCR_ERR);
505
	writel(tmp, port_mmio + PORT_SCR_ERR);
506
507
	ahci_start_engine(ap);
508
443
	if (ap->flags & ATA_FLAG_PORT_DISABLED)
509
	if (ap->flags & ATA_FLAG_PORT_DISABLED)
444
		return;
510
		return;
445
511
Lines 538-566 static void ahci_qc_prep(struct ata_queu Link Here
538
	ahci_fill_sg(qc);
604
	ahci_fill_sg(qc);
539
}
605
}
540
606
541
static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
607
static void ahci_start_engine(struct ata_port *ap)
542
{
608
{
543
	void *mmio = ap->host_set->mmio_base;
609
	void __iomem *mmio = ap->host_set->mmio_base;
544
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
610
	void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
545
	u32 tmp;
611
	u32 tmp;
546
	int work;
612
	int work;
547
613
548
	/* stop DMA */
614
	tmp = readl(port_mmio + PORT_CMD);
615
	/*
616
	 * AHCI rev 1.1 section 10.3.1:
617
	 * Software shall not set PxCMD.ST to ‘1’ until it verifies
618
	 * that PxCMD.CR is ‘0’ and has set PxCMD.FRE to ‘1’.
619
	 */
620
	if ((tmp & PORT_CMD_FIS_RX) == 0)
621
		printk(KERN_WARNING "ata%d: dma not running\n",ap->id);
622
	/* 
623
	 * wait for engine to become idle.
624
	 */
625
	work = 1000;
626
	while (work-- > 0) {
627
		tmp = readl(port_mmio + PORT_CMD);
628
		if ((tmp & PORT_CMD_LIST_ON) == 0)
629
			break;
630
		udelay(10);
631
	}
632
	
633
	/*
634
	 * Start DMA
635
	 */
636
	tmp |= PORT_CMD_START;
637
	writel(tmp, port_mmio + PORT_CMD);
638
	readl(port_mmio + PORT_CMD); /* flush */
639
}
640
641
static int ahci_stop_engine(struct ata_port *ap)
642
{
643
	void __iomem *mmio = ap->host_set->mmio_base;
644
	void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
645
	int work;
646
	u32 tmp;
647
549
	tmp = readl(port_mmio + PORT_CMD);
648
	tmp = readl(port_mmio + PORT_CMD);
550
	tmp &= ~PORT_CMD_START;
649
	tmp &= ~PORT_CMD_START;
551
	writel(tmp, port_mmio + PORT_CMD);
650
	writel(tmp, port_mmio + PORT_CMD);
552
651
553
	/* wait for engine to stop.  TODO: this could be
652
	/* 
554
	 * as long as 500 msec
653
	 * wait for engine to become idle
555
	 */
654
	 */
556
	work = 1000;
655
	work = 1000;
557
	while (work-- > 0) {
656
	while (work-- > 0) {
558
		tmp = readl(port_mmio + PORT_CMD);
657
		tmp = readl(port_mmio + PORT_CMD);
559
		if ((tmp & PORT_CMD_LIST_ON) == 0)
658
		if ((tmp & PORT_CMD_LIST_ON) == 0)
560
			break;
659
			return 0;
561
		udelay(10);
660
		udelay(10);
562
	}
661
	}
563
662
663
	return -EIO;
664
}
665
666
static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
667
{
668
	void *mmio = ap->host_set->mmio_base;
669
	void *port_mmio = ahci_port_base(mmio, ap->port_no);
670
	u32 tmp;
671
672
	if ((ap->device[0].class != ATA_DEV_ATAPI) ||
673
	    ((irq_stat & PORT_IRQ_TF_ERR) == 0))
674
		ahci_dump_port_status(ap, irq_stat, "port reset");
675
676
	ahci_stop_engine(ap);
677
564
	/* clear SATA phy error, if any */
678
	/* clear SATA phy error, if any */
565
	tmp = readl(port_mmio + PORT_SCR_ERR);
679
	tmp = readl(port_mmio + PORT_SCR_ERR);
566
	writel(tmp, port_mmio + PORT_SCR_ERR);
680
	writel(tmp, port_mmio + PORT_SCR_ERR);
Lines 577-589 static void ahci_intr_error(struct ata_p Link Here
577
		readl(port_mmio + PORT_SCR_CTL); /* flush */
691
		readl(port_mmio + PORT_SCR_CTL); /* flush */
578
	}
692
	}
579
693
580
	/* re-start DMA */
694
	ahci_start_engine(ap);
581
	tmp = readl(port_mmio + PORT_CMD);
582
	tmp |= PORT_CMD_START;
583
	writel(tmp, port_mmio + PORT_CMD);
584
	readl(port_mmio + PORT_CMD); /* flush */
585
586
	printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id);
587
}
695
}
588
696
589
static void ahci_eng_timeout(struct ata_port *ap)
697
static void ahci_eng_timeout(struct ata_port *ap)
Lines 594-610 static void ahci_eng_timeout(struct ata_ Link Here
594
	struct ata_queued_cmd *qc;
702
	struct ata_queued_cmd *qc;
595
	unsigned long flags;
703
	unsigned long flags;
596
704
597
	DPRINTK("ENTER\n");
705
	printk(KERN_WARNING "ata%u: handling error/timeout\n", ap->id);
598
706
599
	spin_lock_irqsave(&host_set->lock, flags);
707
	spin_lock_irqsave(&host_set->lock, flags);
600
708
601
	ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
602
603
	qc = ata_qc_from_tag(ap, ap->active_tag);
709
	qc = ata_qc_from_tag(ap, ap->active_tag);
604
	if (!qc) {
710
	if (!qc) {
605
		printk(KERN_ERR "ata%u: BUG: timeout without command\n",
711
		printk(KERN_ERR "ata%u: BUG: timeout without command\n",
606
		       ap->id);
712
		       ap->id);
607
	} else {
713
	} else {
714
		ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT));
715
608
		/* hack alert!  We cannot use the supplied completion
716
		/* hack alert!  We cannot use the supplied completion
609
	 	 * function from inside the ->eh_strategy_handler() thread.
717
	 	 * function from inside the ->eh_strategy_handler() thread.
610
	 	 * libata is the only user of ->eh_strategy_handler() in
718
	 	 * libata is the only user of ->eh_strategy_handler() in
Lines 639-645 static inline int ahci_host_intr(struct Link Here
639
	}
747
	}
640
748
641
	if (status & PORT_IRQ_FATAL) {
749
	if (status & PORT_IRQ_FATAL) {
642
		ahci_intr_error(ap, status);
750
		/* command processing has stopped due to error; restart */
751
		ahci_restart_port(ap, status);
752
643
		if (qc)
753
		if (qc)
644
			ata_qc_complete(qc, ATA_ERR);
754
			ata_qc_complete(qc, ATA_ERR);
645
	}
755
	}
Lines 675-686 static irqreturn_t ahci_interrupt (int i Link Here
675
785
676
        for (i = 0; i < host_set->n_ports; i++) {
786
        for (i = 0; i < host_set->n_ports; i++) {
677
		struct ata_port *ap;
787
		struct ata_port *ap;
678
		u32 tmp;
679
788
680
		VPRINTK("port %u\n", i);
789
		if (!(irq_stat & (1 << i)))
790
			continue;
791
681
		ap = host_set->ports[i];
792
		ap = host_set->ports[i];
682
		tmp = irq_stat & (1 << i);
793
		if (ap) {
683
		if (tmp && ap) {
684
			struct ata_queued_cmd *qc;
794
			struct ata_queued_cmd *qc;
685
			qc = ata_qc_from_tag(ap, ap->active_tag);
795
			qc = ata_qc_from_tag(ap, ap->active_tag);
686
			if (ahci_host_intr(ap, qc))
796
			if (ahci_host_intr(ap, qc))
Lines 724-729 static void ahci_setup_port(struct ata_i Link Here
724
	VPRINTK("EXIT\n");
834
	VPRINTK("EXIT\n");
725
}
835
}
726
836
837
int ahci_scsi_device_suspend(struct scsi_device *sdev)
838
{
839
	struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
840
	struct ata_device *dev = &ap->device[sdev->id];
841
	int rc;
842
843
	rc = ata_device_suspend(ap, dev);
844
845
	if (!rc) {
846
		ahci_dump_port_status(ap, 0, "port suspend");
847
		ahci_port_suspend(ap);
848
	}
849
850
	return rc;
851
}
852
853
int ahci_scsi_device_resume(struct scsi_device *sdev)
854
{
855
	struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
856
	struct ata_device *dev = &ap->device[sdev->id];
857
858
	ahci_port_resume(ap);
859
860
	ahci_dump_port_status(ap, 0, "port resume");
861
862
	return ata_device_resume(ap, dev);
863
}
864
727
static int ahci_host_init(struct ata_probe_ent *probe_ent)
865
static int ahci_host_init(struct ata_probe_ent *probe_ent)
728
{
866
{
729
	struct ahci_host_priv *hpriv = probe_ent->private_data;
867
	struct ahci_host_priv *hpriv = probe_ent->private_data;
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/libata-core.c.orig (-16 / +155 lines)
Lines 50-57 Link Here
50
#include "libata.h"
50
#include "libata.h"
51
51
52
static unsigned int ata_busy_sleep (struct ata_port *ap,
52
static unsigned int ata_busy_sleep (struct ata_port *ap,
53
				    unsigned long tmout_pat,
53
				    unsigned long timeout_pat,
54
			    	    unsigned long tmout);
54
				    unsigned long timeout);
55
static void ata_set_mode(struct ata_port *ap);
55
static void ata_set_mode(struct ata_port *ap);
56
static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
56
static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
57
static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift);
57
static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift);
Lines 59-70 static int fgb(u32 bitmap); Link Here
59
static int ata_choose_xfer_mode(struct ata_port *ap,
59
static int ata_choose_xfer_mode(struct ata_port *ap,
60
				u8 *xfer_mode_out,
60
				u8 *xfer_mode_out,
61
				unsigned int *xfer_shift_out);
61
				unsigned int *xfer_shift_out);
62
static u64 ata_hpa_max_address(struct ata_port *ap, struct ata_device *dev);
62
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
63
static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
63
static void __ata_qc_complete(struct ata_queued_cmd *qc);
64
static void __ata_qc_complete(struct ata_queued_cmd *qc);
64
65
65
static unsigned int ata_unique_id = 1;
66
static unsigned int ata_unique_id = 1;
66
static struct workqueue_struct *ata_wq;
67
static struct workqueue_struct *ata_wq;
67
68
69
int noacpi = 0;
70
module_param(noacpi, int, 0444);
71
MODULE_PARM_DESC(noacpi, "Disables use of ACPI in suspend/resume when set");
72
73
int libata_printk = ATA_MSG_DRV;
74
module_param_named(printk, libata_printk, int, 0644);
75
MODULE_PARM_DESC(printk, "Set libata printk flags"); /* in linux/libata.h */
76
68
MODULE_AUTHOR("Jeff Garzik");
77
MODULE_AUTHOR("Jeff Garzik");
69
MODULE_DESCRIPTION("Library module for ATA devices");
78
MODULE_DESCRIPTION("Library module for ATA devices");
70
MODULE_LICENSE("GPL");
79
MODULE_LICENSE("GPL");
Lines 1205-1215 retry: Link Here
1205
1214
1206
	/* print device capabilities */
1215
	/* print device capabilities */
1207
	printk(KERN_DEBUG "ata%u: dev %u cfg "
1216
	printk(KERN_DEBUG "ata%u: dev %u cfg "
1208
	       "49:%04x 82:%04x 83:%04x 84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n",
1217
	       "00:%04x 49:%04x 82:%04x 83:%04x 84:%04x 85:%04x 86:%04x 87:%04x 88:%04x 93:%04x\n",
1209
	       ap->id, device, dev->id[49],
1218
	       ap->id, device, dev->id[0], dev->id[49],
1210
	       dev->id[82], dev->id[83], dev->id[84],
1219
	       dev->id[82], dev->id[83], dev->id[84],
1211
	       dev->id[85], dev->id[86], dev->id[87],
1220
	       dev->id[85], dev->id[86], dev->id[87],
1212
	       dev->id[88]);
1221
	       dev->id[88], dev->id[93]);
1213
1222
1214
	/*
1223
	/*
1215
	 * common ATA, ATAPI feature tests
1224
	 * common ATA, ATAPI feature tests
Lines 1258-1268 retry: Link Here
1258
		ap->host->max_cmd_len = 16;
1267
		ap->host->max_cmd_len = 16;
1259
1268
1260
		/* print device info to dmesg */
1269
		/* print device info to dmesg */
1261
		printk(KERN_INFO "ata%u: dev %u ATA, max %s, %Lu sectors:%s\n",
1270
		printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",
1262
		       ap->id, device,
1271
		       ap->id, device, i,
1263
		       ata_mode_string(xfer_modes),
1272
		       ata_mode_string(xfer_modes),
1264
		       (unsigned long long)dev->n_sectors,
1273
		       (unsigned long long)dev->n_sectors,
1265
		       dev->flags & ATA_DFLAG_LBA48 ? " lba48" : "");
1274
		       dev->flags & ATA_DFLAG_LBA48 ? " lba48" : "");
1275
1276
		if (ata_id_hpa_enabled(dev->id)) {
1277
			u64 max_address;
1278
1279
			max_address = ata_hpa_max_address(ap, dev);
1280
			printk(KERN_INFO "ata%u: native max address %Lu\n",
1281
			       ap->id, max_address);
1282
		}
1283
1266
	}
1284
	}
1267
1285
1268
	/* ATAPI-specific feature tests */
1286
	/* ATAPI-specific feature tests */
Lines 1324-1329 void ata_dev_config(struct ata_port *ap, Link Here
1324
1342
1325
	if (ap->ops->dev_config)
1343
	if (ap->ops->dev_config)
1326
		ap->ops->dev_config(ap, &ap->device[i]);
1344
		ap->ops->dev_config(ap, &ap->device[i]);
1345
1346
	ata_acpi_push_id(ap, i);
1327
}
1347
}
1328
1348
1329
/**
1349
/**
Lines 1364-1369 static int ata_bus_probe(struct ata_port Link Here
1364
	if (ap->flags & ATA_FLAG_PORT_DISABLED)
1384
	if (ap->flags & ATA_FLAG_PORT_DISABLED)
1365
		goto err_out_disable;
1385
		goto err_out_disable;
1366
1386
1387
	ata_acpi_exec_tfs(ap);
1388
1367
	return 0;
1389
	return 0;
1368
1390
1369
err_out_disable:
1391
err_out_disable:
Lines 1436-1441 void __sata_phy_reset(struct ata_port *a Link Here
1436
		return;
1458
		return;
1437
1459
1438
	if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
1460
	if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
1461
		printk(KERN_INFO "ata%d: device not ready, disabling\n",
1462
		       ap->id);
1439
		ata_port_disable(ap);
1463
		ata_port_disable(ap);
1440
		return;
1464
		return;
1441
	}
1465
	}
Lines 1639-1650 err_out: Link Here
1639
 *	or a timeout occurs.
1663
 *	or a timeout occurs.
1640
 *
1664
 *
1641
 *	LOCKING: None.
1665
 *	LOCKING: None.
1642
 *
1643
 */
1666
 */
1644
1667
1645
static unsigned int ata_busy_sleep (struct ata_port *ap,
1668
static unsigned int ata_busy_sleep (struct ata_port *ap,
1646
				    unsigned long tmout_pat,
1669
				    unsigned long tmout_pat,
1647
			    	    unsigned long tmout)
1670
				    unsigned long tmout)
1648
{
1671
{
1649
	unsigned long timer_start, timeout;
1672
	unsigned long timer_start, timeout;
1650
	u8 status;
1673
	u8 status;
Lines 2129-2134 static void ata_dev_set_xfermode(struct Link Here
2129
	DPRINTK("EXIT\n");
2152
	DPRINTK("EXIT\n");
2130
}
2153
}
2131
2154
2155
/*
2156
 * Execute a 'READ NATIVE MAX ADDRESS' command.
2157
 */
2158
static u64 ata_hpa_max_address(struct ata_port *ap, struct ata_device *dev)
2159
{
2160
	DECLARE_COMPLETION(wait);
2161
	struct ata_queued_cmd *qc;
2162
	int rc;
2163
	u64 max_address = 0;
2164
	unsigned long flags;
2165
2166
	/* set up set-features taskfile */
2167
	DPRINTK("read native max address\n");
2168
2169
	qc = ata_qc_new_init(ap, dev);
2170
	BUG_ON(qc == NULL);
2171
2172
	if (dev->flags & ATA_DFLAG_LBA48)
2173
		qc->tf.command = ATA_CMD_READ_NATIVE_EXT;
2174
	else
2175
		qc->tf.command = ATA_CMD_READ_NATIVE;
2176
2177
	qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2178
	qc->tf.protocol = ATA_PROT_NODATA;
2179
	if (dev->devno)
2180
		qc->tf.device = ATA_LBA | ATA_DEV1;
2181
	else
2182
		qc->tf.device = ATA_LBA;
2183
2184
	qc->waiting = &wait;
2185
	qc->complete_fn = ata_qc_complete_noop;
2186
2187
	spin_lock_irqsave(&ap->host_set->lock, flags);
2188
	rc = ata_qc_issue(qc);
2189
	spin_unlock_irqrestore(&ap->host_set->lock, flags);
2190
2191
	if (rc)
2192
		ata_port_disable(ap);
2193
	else {
2194
		u8 status;
2195
2196
		wait_for_completion(&wait);
2197
2198
		status = ata_chk_status(ap);
2199
		if (status & ATA_ERR) {
2200
			u8 err = ata_chk_err(ap);
2201
			if (err & ATA_ABORTED) {
2202
				DPRINTK("error, command aborted\n");
2203
			} else {
2204
				DPRINTK("error, status %x\n", err);
2205
			}
2206
			return 0;
2207
		}
2208
2209
		ap->ops->tf_read(ap, &qc->tf);
2210
2211
		max_address =  (qc->tf.lbah << 16) + 
2212
			(qc->tf.lbam << 8) + qc->tf.lbal;
2213
		if (dev->flags & ATA_DFLAG_LBA48) {
2214
			max_address += ((u64)qc->tf.hob_lbal << 24) +
2215
				((u64)qc->tf.hob_lbam << 32) +
2216
				((u64)qc->tf.hob_lbah << 40);
2217
		} else {
2218
			max_address += ((qc->tf.device & 0x0f) << 24);
2219
		}
2220
		
2221
		/* Add 1 to be compatible with the IDENTIFY output */
2222
		DPRINTK("max_address %Lu\n", max_address + 1);
2223
	}
2224
	DPRINTK("EXIT\n");
2225
2226
	return max_address;
2227
}
2228
2132
/**
2229
/**
2133
 *	ata_sg_clean - Unmap DMA memory associated with command
2230
 *	ata_sg_clean - Unmap DMA memory associated with command
2134
 *	@qc: Command containing DMA memory to be released
2231
 *	@qc: Command containing DMA memory to be released
Lines 3840-3848 static int ata_do_simple_cmd(struct ata_ Link Here
3840
	rc = ata_qc_issue(qc);
3937
	rc = ata_qc_issue(qc);
3841
	spin_unlock_irqrestore(&ap->host_set->lock, flags);
3938
	spin_unlock_irqrestore(&ap->host_set->lock, flags);
3842
3939
3843
	if (!rc)
3940
	if (!rc) {
3941
		u8 status;
3844
		wait_for_completion(&wait);
3942
		wait_for_completion(&wait);
3845
3943
3944
		status = ata_chk_status(ap);
3945
		if (status & ATA_ERR) {
3946
			u8 err = ata_chk_err(ap);
3947
			DPRINTK("cmd %x error %x\n", cmd, err);
3948
			rc = -1;
3949
		}
3950
	}
3846
	return rc;
3951
	return rc;
3847
}
3952
}
3848
3953
Lines 3871-3876 static int ata_start_drive(struct ata_po Link Here
3871
	return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE);
3976
	return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE);
3872
}
3977
}
3873
3978
3979
static int ata_suspend_drive(struct ata_port *ap, struct ata_device *dev)
3980
{
3981
	return ata_do_simple_cmd(ap, dev, ATA_CMD_SLEEP);
3982
}
3983
3874
/**
3984
/**
3875
 *	ata_device_resume - wakeup a previously suspended devices
3985
 *	ata_device_resume - wakeup a previously suspended devices
3876
 *
3986
 *
Lines 3881-3896 static int ata_start_drive(struct ata_po Link Here
3881
 */
3991
 */
3882
int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
3992
int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
3883
{
3993
{
3994
	int rc;
3995
3996
	if (!ata_dev_present(dev))
3997
		return 0;
3998
3999
	printk(KERN_WARNING "ata%d: resume device\n", ap->id);
4000
4001
	ata_bus_probe(ap);
4002
3884
	if (ap->flags & ATA_FLAG_SUSPENDED) {
4003
	if (ap->flags & ATA_FLAG_SUSPENDED) {
3885
		ap->flags &= ~ATA_FLAG_SUSPENDED;
4004
		ap->flags &= ~ATA_FLAG_SUSPENDED;
3886
		ata_set_mode(ap);
4005
		ata_set_mode(ap);
3887
	}
4006
	}
3888
	if (!ata_dev_present(dev))
3889
		return 0;
3890
	if (dev->class == ATA_DEV_ATA)
3891
		ata_start_drive(ap, dev);
3892
4007
3893
	return 0;
4008
	rc = ata_start_drive(ap, dev);
4009
4010
	return rc;
3894
}
4011
}
3895
4012
3896
/**
4013
/**
Lines 3904-3914 int ata_device_suspend(struct ata_port * Link Here
3904
{
4021
{
3905
	if (!ata_dev_present(dev))
4022
	if (!ata_dev_present(dev))
3906
		return 0;
4023
		return 0;
4024
4025
	printk(KERN_WARNING "ata%d: suspend device\n", ap->id);
4026
3907
	if (dev->class == ATA_DEV_ATA)
4027
	if (dev->class == ATA_DEV_ATA)
3908
		ata_flush_cache(ap, dev);
4028
		ata_flush_cache(ap, dev);
3909
4029
3910
	ata_standby_drive(ap, dev);
4030
	ata_suspend_drive(ap, dev);
3911
	ap->flags |= ATA_FLAG_SUSPENDED;
4031
	ap->flags |= ATA_FLAG_SUSPENDED;
4032
3912
	return 0;
4033
	return 0;
3913
}
4034
}
3914
4035
Lines 4009-4014 static void ata_host_init(struct ata_por Link Here
4009
	ap->port_no = port_no;
4130
	ap->port_no = port_no;
4010
	ap->hard_port_no =
4131
	ap->hard_port_no =
4011
		ent->legacy_mode ? ent->hard_port_no : port_no;
4132
		ent->legacy_mode ? ent->hard_port_no : port_no;
4133
	ap->legacy_mode = ent->legacy_mode;
4012
	ap->pio_mask = ent->pio_mask;
4134
	ap->pio_mask = ent->pio_mask;
4013
	ap->mwdma_mask = ent->mwdma_mask;
4135
	ap->mwdma_mask = ent->mwdma_mask;
4014
	ap->udma_mask = ent->udma_mask;
4136
	ap->udma_mask = ent->udma_mask;
Lines 4017-4022 static void ata_host_init(struct ata_por Link Here
4017
	ap->cbl = ATA_CBL_NONE;
4139
	ap->cbl = ATA_CBL_NONE;
4018
	ap->active_tag = ATA_TAG_POISON;
4140
	ap->active_tag = ATA_TAG_POISON;
4019
	ap->last_ctl = 0xFF;
4141
	ap->last_ctl = 0xFF;
4142
	ap->dev = ent->dev;
4020
4143
4021
	INIT_WORK(&ap->packet_task, atapi_packet_task, ap);
4144
	INIT_WORK(&ap->packet_task, atapi_packet_task, ap);
4022
	INIT_WORK(&ap->pio_task, ata_pio_task, ap);
4145
	INIT_WORK(&ap->pio_task, ata_pio_task, ap);
Lines 4132-4141 int ata_device_add(struct ata_probe_ent Link Here
4132
				(ap->mwdma_mask << ATA_SHIFT_MWDMA) |
4255
				(ap->mwdma_mask << ATA_SHIFT_MWDMA) |
4133
				(ap->pio_mask << ATA_SHIFT_PIO);
4256
				(ap->pio_mask << ATA_SHIFT_PIO);
4134
4257
4258
		ap->msg_enable = libata_printk;
4259
4135
		/* print per-port info to dmesg */
4260
		/* print per-port info to dmesg */
4136
		printk(KERN_INFO "ata%u: %cATA max %s cmd 0x%lX ctl 0x%lX "
4261
		printk(KERN_INFO "ata%u: %cATA max %s cmd 0x%lX ctl 0x%lX "
4137
				 "bmdma 0x%lX irq %lu\n",
4262
				 "bmdma 0x%lX irq %lu\n",
4138
			ap->id,
4263
			ap->id,
4264
			ap->flags & ATA_FLAG_PATA_MODE ? 'P' :
4139
			ap->flags & ATA_FLAG_SATA ? 'S' : 'P',
4265
			ap->flags & ATA_FLAG_SATA ? 'S' : 'P',
4140
			ata_mode_string(xfer_mode_mask),
4266
			ata_mode_string(xfer_mode_mask),
4141
	       		ap->ioaddr.cmd_addr,
4267
	       		ap->ioaddr.cmd_addr,
Lines 4199-4204 int ata_device_add(struct ata_probe_ent Link Here
4199
		scsi_scan_host(ap->host);
4325
		scsi_scan_host(ap->host);
4200
	}
4326
	}
4201
4327
4328
	for (i = 0; i < ent->n_ports; i++) {
4329
		struct ata_port *ap = host_set->ports[i];
4330
4331
		ata_acpi_get_timing(ap);
4332
	}
4333
4202
	dev_set_drvdata(dev, host_set);
4334
	dev_set_drvdata(dev, host_set);
4203
4335
4204
	VPRINTK("EXIT, returning %u\n", ent->n_ports);
4336
	VPRINTK("EXIT, returning %u\n", ent->n_ports);
Lines 4423-4436 int ata_pci_init_one (struct pci_dev *pd Link Here
4423
	else
4555
	else
4424
		port[1] = port[0];
4556
		port[1] = port[0];
4425
4557
4558
	printk(KERN_DEBUG "%s: pci_dev class+intf: 0x%x\n",
4559
		__FUNCTION__, pdev->class);
4426
	if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0
4560
	if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0
4427
	    && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
4561
	    && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
4562
		printk(KERN_DEBUG "%s: NO_LEGACY == 0\n", __FUNCTION__);
4563
		port[0]->host_flags |= ATA_FLAG_PATA_MODE;
4564
		port[0]->host_flags &= ~ATA_FLAG_SATA;
4428
		/* TODO: support transitioning to native mode? */
4565
		/* TODO: support transitioning to native mode? */
4429
		pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
4566
		pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
4430
		mask = (1 << 2) | (1 << 0);
4567
		mask = (1 << 2) | (1 << 0);
4431
		if ((tmp8 & mask) != mask)
4568
		if ((tmp8 & mask) != mask)
4432
			legacy_mode = (1 << 3);
4569
			legacy_mode = (1 << 3);
4433
	}
4570
	}
4571
	else
4572
		printk(KERN_DEBUG "%s: NO_LEGACY == 1\n", __FUNCTION__);
4434
4573
4435
	/* FIXME... */
4574
	/* FIXME... */
4436
	if ((!legacy_mode) && (n_ports > 1)) {
4575
	if ((!legacy_mode) && (n_ports > 1)) {
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/sd.c.orig (-1 / +99 lines)
Lines 119-124 static void sd_rw_intr(struct scsi_cmnd Link Here
119
static int sd_probe(struct device *);
119
static int sd_probe(struct device *);
120
static int sd_remove(struct device *);
120
static int sd_remove(struct device *);
121
static void sd_shutdown(struct device *dev);
121
static void sd_shutdown(struct device *dev);
122
static int sd_suspend(struct device *dev, pm_message_t state, u32 level);
123
static int sd_resume(struct device *dev, u32 level);
122
static void sd_rescan(struct device *);
124
static void sd_rescan(struct device *);
123
static int sd_init_command(struct scsi_cmnd *);
125
static int sd_init_command(struct scsi_cmnd *);
124
static int sd_issue_flush(struct device *, sector_t *);
126
static int sd_issue_flush(struct device *, sector_t *);
Lines 134-139 static struct scsi_driver sd_template = Link Here
134
		.probe		= sd_probe,
136
		.probe		= sd_probe,
135
		.remove		= sd_remove,
137
		.remove		= sd_remove,
136
		.shutdown	= sd_shutdown,
138
		.shutdown	= sd_shutdown,
139
		.suspend	= sd_suspend,
140
		.resume		= sd_resume,
137
	},
141
	},
138
	.rescan			= sd_rescan,
142
	.rescan			= sd_rescan,
139
	.init_command		= sd_init_command,
143
	.init_command		= sd_init_command,
Lines 680-685 not_present: Link Here
680
	return 1;
684
	return 1;
681
}
685
}
682
686
687
static int sd_start_stop_unit(struct scsi_device *sdp, int start)
688
{
689
	struct scsi_request *sreq;
690
	int retries, res;
691
692
	if (!scsi_device_online(sdp))
693
		return -ENODEV;
694
695
	sreq = scsi_allocate_request(sdp, GFP_KERNEL);
696
	if (!sreq) {
697
		printk("FAILED\n  No memory for request\n");
698
		return -ENOMEM;
699
	}
700
701
	sreq->sr_data_direction = DMA_NONE;
702
	for (retries = 3; retries > 0; --retries) {
703
		unsigned char cmd[10] = { 0 };
704
705
		cmd[0] = START_STOP;
706
		cmd[1] = 1; /* Return immediately */
707
		memset((void *) &cmd[2], 0, 8);
708
		cmd[4] = start;
709
		/*
710
		 * Leave the rest of the command zero to indicate
711
		 * flush everything.
712
		 */
713
		scsi_wait_req(sreq, cmd, NULL, 0, SD_TIMEOUT, SD_MAX_RETRIES);
714
		if (sreq->sr_result == 0)
715
			break;
716
	}
717
718
	res = sreq->sr_result;
719
	if (res) {
720
		printk(KERN_WARNING "FAILED\n  status = %x, message = %02x, "
721
				    "host = %d, driver = %02x\n  ",
722
				    status_byte(res), msg_byte(res),
723
				    host_byte(res), driver_byte(res));
724
			if (driver_byte(res) & DRIVER_SENSE)
725
				scsi_print_req_sense("sd", sreq);
726
	}
727
728
	scsi_release_request(sreq);
729
	return res;
730
}
731
683
static int sd_sync_cache(struct scsi_device *sdp)
732
static int sd_sync_cache(struct scsi_device *sdp)
684
{
733
{
685
	struct scsi_request *sreq;
734
	struct scsi_request *sreq;
Lines 1701-1714 static void sd_shutdown(struct device *d Link Here
1701
	if (!sdkp)
1750
	if (!sdkp)
1702
		return;         /* this can happen */
1751
		return;         /* this can happen */
1703
1752
1753
	SCSI_LOG_HLQUEUE(3, printk("sd_shutdown: disk=%s\n",
1754
				   sdkp->disk->disk_name));
1755
1704
	if (!sdkp->WCE)
1756
	if (!sdkp->WCE)
1705
		return;
1757
		return;
1706
1758
1707
	printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
1759
	printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
1708
			sdkp->disk->disk_name);
1760
	       sdkp->disk->disk_name);
1709
	sd_sync_cache(sdp);
1761
	sd_sync_cache(sdp);
1762
1710
}	
1763
}	
1711
1764
1765
/* Just quietly quiesce the device and SYNCHRONIZE CACHE for suspend too */
1766
static int sd_suspend(struct device *dev, pm_message_t state, u32 level)
1767
{
1768
	struct scsi_device *sdp = to_scsi_device(dev);
1769
	struct scsi_disk *sdkp = dev_get_drvdata(dev);
1770
1771
	if (!sdkp)
1772
		return 0;         /* this can happen */
1773
1774
	printk(KERN_NOTICE "Suspending SCSI disk %s\n",
1775
	       sdkp->disk->disk_name);
1776
1777
	if (!sdkp->WCE)
1778
		return 0;
1779
1780
	/* don't try to sync an offline device ... it will only error */
1781
	if (!scsi_device_online(sdp))
1782
		return 0;
1783
1784
	if (sd_sync_cache(sdp))
1785
		return -EIO;
1786
1787
	if (sd_start_stop_unit(sdp, 0))
1788
		return -EIO;
1789
	
1790
	return 0;
1791
}
1792
1793
static int sd_resume(struct device *dev, u32 level)
1794
{
1795
	struct scsi_device *sdp = to_scsi_device(dev);
1796
	struct scsi_disk *sdkp = dev_get_drvdata(dev);
1797
1798
	if (!sdkp)
1799
		return 0;
1800
1801
	printk(KERN_NOTICE "Resuming SCSI disk %s\n",
1802
		sdkp->disk->disk_name);
1803
1804
	if (sd_start_stop_unit(sdp, 1))
1805
		return -EIO;
1806
1807
	return 0;
1808
}
1809
1712
/**
1810
/**
1713
 *	init_sd - entry point for this driver (both when built in or when
1811
 *	init_sd - entry point for this driver (both when built in or when
1714
 *	a module).
1812
 *	a module).
(-)linux-2.6.13-SL100_BRANCH/drivers/scsi/Kconfig.orig (+13 lines)
Lines 572-577 config SCSI_SATA_VITESSE Link Here
572
572
573
	  If unsure, say N.
573
	  If unsure, say N.
574
574
575
config SCSI_SATA_ACPI
576
	bool
577
	depends on SCSI_SATA && ACPI && PCI
578
	default y
579
	help
580
	  This option adds support for SATA-related ACPI objects.
581
	  These ACPI objects add the ability to retrieve taskfiles
582
	  from the ACPI BIOS and write them to the disk controller.
583
	  These objects may be related to performance, security,
584
	  power management, or other areas.
585
	  You can disable this at kernel boot time by using the
586
	  option 'libata.noacpi'.
587
575
config SCSI_BUSLOGIC
588
config SCSI_BUSLOGIC
576
	tristate "BusLogic SCSI support"
589
	tristate "BusLogic SCSI support"
577
	depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
590
	depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
(-)linux-2.6.13-SL100_BRANCH/Documentation/kernel-parameters.txt.orig (+10 lines)
Lines 41-46 restrictions referred to are that the re Link Here
41
	ISAPNP	ISA PnP code is enabled.
41
	ISAPNP	ISA PnP code is enabled.
42
	ISDN	Appropriate ISDN support is enabled.
42
	ISDN	Appropriate ISDN support is enabled.
43
	JOY	Appropriate joystick support is enabled.
43
	JOY	Appropriate joystick support is enabled.
44
	LIBATA	libata driver is enabled.
44
	LP	Printer support is enabled.
45
	LP	Printer support is enabled.
45
	LOOP	Loopback device support is enabled.
46
	LOOP	Loopback device support is enabled.
46
	M68k	M68k architecture is enabled.
47
	M68k	M68k architecture is enabled.
Lines 898-903 running once the system is up. Link Here
898
			emulation library even if a 387 maths coprocessor
899
			emulation library even if a 387 maths coprocessor
899
			is present.
900
			is present.
900
901
902
	noacpi=		[LIBATA] Disables use of ACPI in libata suspend/resume
903
			when set.
904
			Format: <int>
905
901
	noalign		[KNL,ARM] 
906
	noalign		[KNL,ARM] 
902
 
907
 
903
	noapic		[SMP,APIC] Tells the kernel to not make use of any
908
	noapic		[SMP,APIC] Tells the kernel to not make use of any
Lines 1138-1143 running once the system is up. Link Here
1138
			[ISAPNP] Exclude memory regions for the autoconfiguration
1143
			[ISAPNP] Exclude memory regions for the autoconfiguration
1139
			Ranges are in pairs (memory base and size).
1144
			Ranges are in pairs (memory base and size).
1140
1145
1146
	printk=		[LIBATA] Set libata printk level (mask).
1147
			The values are defined in include/linux/libata.h.
1148
			The default value is 1 (ATA_MSG_DRV).
1149
			Format: <int>
1150
1141
	profile=	[KNL] Enable kernel profiling via /proc/profile
1151
	profile=	[KNL] Enable kernel profiling via /proc/profile
1142
			{ schedule | <number> }
1152
			{ schedule | <number> }
1143
			(param: schedule - profile schedule points}
1153
			(param: schedule - profile schedule points}
(-)linux-2.6.13-SL100_BRANCH/include/linux/libata.h.orig (-7 / +61 lines)
Lines 29-37 Link Here
29
#include <asm/io.h>
29
#include <asm/io.h>
30
#include <linux/ata.h>
30
#include <linux/ata.h>
31
#include <linux/workqueue.h>
31
#include <linux/workqueue.h>
32
#ifdef CONFIG_ACPI
33
#include <acpi/acpi.h>
34
#endif
32
35
33
/*
36
/*
34
 * compile-time options
37
 * compile-time options: to be removed as soon as all the drivers are
38
 * converted to the new debugging mechanism
35
 */
39
 */
36
#undef ATA_DEBUG		/* debugging output */
40
#undef ATA_DEBUG		/* debugging output */
37
#undef ATA_VERBOSE_DEBUG	/* yet more debugging output */
41
#undef ATA_VERBOSE_DEBUG	/* yet more debugging output */
Lines 66-71 Link Here
66
        }
70
        }
67
#endif
71
#endif
68
72
73
/* NEW: debug levels */
74
#define HAVE_LIBATA_MSG 1
75
76
enum {
77
	ATA_MSG_DRV	= 0x0001,
78
	ATA_MSG_INFO	= 0x0002,
79
	ATA_MSG_PROBE	= 0x0004,
80
	ATA_MSG_WARN	= 0x0008,
81
	ATA_MSG_MALLOC	= 0x0010,
82
	ATA_MSG_CTL	= 0x0020,
83
	ATA_MSG_INTR	= 0x0040,
84
	ATA_MSG_ERR	= 0x0080,
85
};
86
87
#define ata_msg_drv(p)    ((p)->msg_enable & ATA_MSG_DRV)
88
#define ata_msg_info(p)   ((p)->msg_enable & ATA_MSG_INFO)
89
#define ata_msg_probe(p)  ((p)->msg_enable & ATA_MSG_PROBE)
90
#define ata_msg_warn(p)   ((p)->msg_enable & ATA_MSG_WARN)
91
#define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC)
92
#define ata_msg_ctl(p)    ((p)->msg_enable & ATA_MSG_CTL)
93
#define ata_msg_intr(p)   ((p)->msg_enable & ATA_MSG_INTR)
94
#define ata_msg_err(p)    ((p)->msg_enable & ATA_MSG_ERR)
95
96
static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
97
{
98
	if (dval < 0 || dval >= (sizeof(u32) * 8))
99
		return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */
100
	if (!dval)
101
		return 0;
102
	return (1 << dval) - 1;
103
}
104
69
/* defines only for the constants which don't work well as enums */
105
/* defines only for the constants which don't work well as enums */
70
#define ATA_TAG_POISON		0xfafbfcfdU
106
#define ATA_TAG_POISON		0xfafbfcfdU
71
107
Lines 116-121 enum { Link Here
116
	ATA_FLAG_SUSPENDED	= (1 << 9), /* port is suspended */
152
	ATA_FLAG_SUSPENDED	= (1 << 9), /* port is suspended */
117
	ATA_FLAG_NOINTR		= (1 << 10),/* FIXME: Remove this once
153
	ATA_FLAG_NOINTR		= (1 << 10),/* FIXME: Remove this once
118
					     * proper HSM is in place. */
154
					     * proper HSM is in place. */
155
	ATA_FLAG_PATA_MODE	= (1 << 15), /* port in PATA mode */
119
156
120
	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
157
	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
121
	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
158
	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
Lines 171-176 struct scsi_device; Link Here
171
struct ata_port_operations;
208
struct ata_port_operations;
172
struct ata_port;
209
struct ata_port;
173
struct ata_queued_cmd;
210
struct ata_queued_cmd;
211
struct GTM_buffer;
174
212
175
/* typedefs */
213
/* typedefs */
176
typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat);
214
typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat);
Lines 281-286 struct ata_device { Link Here
281
	u8			xfer_protocol;	/* taskfile xfer protocol */
319
	u8			xfer_protocol;	/* taskfile xfer protocol */
282
	u8			read_cmd;	/* opcode to use on read */
320
	u8			read_cmd;	/* opcode to use on read */
283
	u8			write_cmd;	/* opcode to use on write */
321
	u8			write_cmd;	/* opcode to use on write */
322
323
#ifdef CONFIG_SCSI_SATA_ACPI
324
	/* ACPI objects info */
325
	acpi_handle		obj_handle;
326
#endif
284
};
327
};
285
328
286
struct ata_port {
329
struct ata_port {
Lines 298-303 struct ata_port { Link Here
298
341
299
	u8			ctl;	/* cache of ATA control register */
342
	u8			ctl;	/* cache of ATA control register */
300
	u8			last_ctl;	/* Cache last written value */
343
	u8			last_ctl;	/* Cache last written value */
344
	u8			legacy_mode;
301
	unsigned int		bus_state;
345
	unsigned int		bus_state;
302
	unsigned int		port_state;
346
	unsigned int		port_state;
303
	unsigned int		pio_mask;
347
	unsigned int		pio_mask;
Lines 320-325 struct ata_port { Link Here
320
	struct work_struct	pio_task;
364
	struct work_struct	pio_task;
321
	unsigned int		pio_task_state;
365
	unsigned int		pio_task_state;
322
	unsigned long		pio_task_timeout;
366
	unsigned long		pio_task_timeout;
367
	struct device		*dev;
368
369
	u32			msg_enable;
370
#ifdef CONFIG_SCSI_SATA_ACPI
371
	struct GTM_buffer	*gtm;
372
	void			*gtm_object_area;
373
#endif
323
374
324
	void			*private_data;
375
	void			*private_data;
325
};
376
};
Lines 537-545 static inline u8 ata_wait_idle(struct at Link Here
537
588
538
	if (status & (ATA_BUSY | ATA_DRQ)) {
589
	if (status & (ATA_BUSY | ATA_DRQ)) {
539
		unsigned long l = ap->ioaddr.status_addr;
590
		unsigned long l = ap->ioaddr.status_addr;
540
		printk(KERN_WARNING
591
		if (ata_msg_warn(ap))
541
		       "ATA: abnormal status 0x%X on port 0x%lX\n",
592
			printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n",
542
		       status, l);
593
				status, l);
543
	}
594
	}
544
595
545
	return status;
596
	return status;
Lines 619-625 static inline u8 ata_irq_ack(struct ata_ Link Here
619
670
620
	status = ata_busy_wait(ap, bits, 1000);
671
	status = ata_busy_wait(ap, bits, 1000);
621
	if (status & bits)
672
	if (status & bits)
622
		DPRINTK("abnormal status 0x%X\n", status);
673
		if (ata_msg_err(ap))
674
			printk(KERN_ERR "abnormal status 0x%X\n", status);
623
675
624
	/* get controller status; clear intr, err bits */
676
	/* get controller status; clear intr, err bits */
625
	if (ap->flags & ATA_FLAG_MMIO) {
677
	if (ap->flags & ATA_FLAG_MMIO) {
Lines 637-644 static inline u8 ata_irq_ack(struct ata_ Link Here
637
		post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
689
		post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
638
	}
690
	}
639
691
640
	VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
692
	if (ata_msg_intr(ap))
641
		host_stat, post_stat, status);
693
		printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
694
			__FUNCTION__,
695
			host_stat, post_stat, status);
642
696
643
	return status;
697
	return status;
644
}
698
}
(-)linux-2.6.13-SL100_BRANCH/include/linux/ata.h.orig (+6 lines)
Lines 127-132 enum { Link Here
127
	ATA_CMD_VERIFY_EXT	= 0x42,
127
	ATA_CMD_VERIFY_EXT	= 0x42,
128
	ATA_CMD_STANDBYNOW1	= 0xE0,
128
	ATA_CMD_STANDBYNOW1	= 0xE0,
129
	ATA_CMD_IDLEIMMEDIATE	= 0xE1,
129
	ATA_CMD_IDLEIMMEDIATE	= 0xE1,
130
	ATA_CMD_SLEEP		= 0xE6,
131
	ATA_CMD_READ_NATIVE	= 0xF8,
132
	ATA_CMD_READ_NATIVE_EXT = 0x27,
130
133
131
	/* SETFEATURES stuff */
134
	/* SETFEATURES stuff */
132
	SETFEATURES_XFER	= 0x03,
135
	SETFEATURES_XFER	= 0x03,
Lines 227-237 struct ata_taskfile { Link Here
227
230
228
#define ata_id_is_ata(id)	(((id)[0] & (1 << 15)) == 0)
231
#define ata_id_is_ata(id)	(((id)[0] & (1 << 15)) == 0)
229
#define ata_id_is_sata(id)	((id)[93] == 0)
232
#define ata_id_is_sata(id)	((id)[93] == 0)
233
#define ata_id_set_max_locked(id) ((id)[86] & (1 << 8))
234
#define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10))
230
#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
235
#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
231
#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
236
#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
232
#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
237
#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
233
#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
238
#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
234
#define ata_id_has_lba48(id)	((id)[83] & (1 << 10))
239
#define ata_id_has_lba48(id)	((id)[83] & (1 << 10))
240
#define ata_id_has_hpa(id)	((id)[82] & (1 << 10))
235
#define ata_id_has_wcache(id)	((id)[82] & (1 << 5))
241
#define ata_id_has_wcache(id)	((id)[82] & (1 << 5))
236
#define ata_id_has_pm(id)	((id)[82] & (1 << 3))
242
#define ata_id_has_pm(id)	((id)[82] & (1 << 3))
237
#define ata_id_has_lba(id)	((id)[49] & (1 << 9))
243
#define ata_id_has_lba(id)	((id)[49] & (1 << 9))

Return to bug 151517