From a619f981b477035027dd27dfbee6148b4cd4a83c Mon Sep 17 00:00:00 2001 From: Akira Iguchi Date: Fri, 26 Jan 2007 16:28:18 +0900 Subject: libata: PATA driver for Celleb This is the patch for PATA controller of Celleb. This driver uses the managed iomap (devres). Because this driver needs special taskfile accesses, there is a copy of ata_std_softreset(). ata_dev_try_classify() is exported so that it can be used in this function. Signed-off-by: Kou Ishizaki Signed-off-by: Akira Iguchi Signed-off-by: Jeff Garzik --- include/linux/libata.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/libata.h b/include/linux/libata.h index 86762a9f52b..60dfc5f7e88 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -759,6 +759,7 @@ extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, unsigned long interval_msec, unsigned long timeout_msec); +extern unsigned int ata_dev_try_classify(struct ata_port *, unsigned int, u8 *); /* * Default driver ops implementations -- cgit v1.2.3 From 7d47e8d4d4fb0c3d3bdc706759e70d5453b61ec3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 2 Feb 2007 16:22:31 +0900 Subject: libata: put some intelligence into EH speed down sequence The current EH speed down code is more of a proof that the EH framework is capable of adjusting transfer speed in response to error. This patch puts some intelligence into EH speed down sequence. The rules are.. * If there have been more than three timeout, HSM violation or unclassified DEV errors for known supported commands during last 10 mins, NCQ is turned off. * If there have been more than three timeout or HSM violation for known supported command, transfer mode is slowed down. If DMA is active, it is first slowered by one grade (e.g. UDMA133->100). If that doesn't help, it's slowered to 40c limit (UDMA33). If PIO is active, it's slowered by one grade first. If that doesn't help, PIO0 is forced. Note that this rule does not change transfer mode. DMA is never degraded into PIO by this rule. * If there have been more than ten ATA bus, timeout, HSM violation or unclassified device errors for known supported commands && speeding down DMA mode didn't help, the device is forced into PIO mode. Note that this rule is considered only for PATA devices and is pretty difficult to trigger. One error can only trigger one rule at a time. After a rule is triggered, error history is cleared such that the next speed down happens only after some number of errors are accumulated. This makes sense because now speed down is done in bigger stride. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/libata.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/libata.h b/include/linux/libata.h index 60dfc5f7e88..5db50fa594a 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -495,6 +495,7 @@ struct ata_device { /* error history */ struct ata_ering ering; + int spdn_cnt; unsigned int horkage; /* List of broken features */ #ifdef CONFIG_SATA_ACPI /* ACPI objects info */ -- cgit v1.2.3 From 6d1245bf294e9ea65b3717be9fa0338bfb6ff6c9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 20 Feb 2007 23:20:27 +0900 Subject: libata: separate out ata_ncq_enabled() Separate out ata_ncq_enabled(). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/libata.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/linux/libata.h b/include/linux/libata.h index 5db50fa594a..5233e47eeb8 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1033,6 +1033,21 @@ static inline u8 ata_chk_status(struct ata_port *ap) return ap->ops->check_status(ap); } +/** + * ata_ncq_enabled - Test whether NCQ is enabled + * @dev: ATA device to test for + * + * LOCKING: + * spin_lock_irqsave(host lock) + * + * RETURNS: + * 1 if NCQ is enabled for @dev, 0 otherwise. + */ +static inline int ata_ncq_enabled(struct ata_device *dev) +{ + return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | + ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; +} /** * ata_pause - Flush writes and pause 400 nanoseconds. -- cgit v1.2.3 From 44877b4e22f391d39c6589412106a3668e81a05b Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 21 Feb 2007 01:06:51 +0900 Subject: libata: s/ap->id/ap->print_id/g ata_port has two different id fields - id and port_no. id is system-wide 1-based unique id for the port while port_no is 0-based host-wide port number. The former is primarily used to identify the ATA port to the user in printk messages while the latter is used in various places in libata core and LLDs to index the port inside the host. The two fields feel quite similar and sometimes ap->id is used in place of ap->port_no, which is very difficult to spot. This patch renames ap->id to ap->print_id to reduce the possibility of such bugs. Some printk messages are adjusted such that id string (ata%u[.%u]) isn't printed twice and/or to use ata_*_printk() instead of hardcoded id format. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/libata.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/linux/libata.h b/include/linux/libata.h index 5233e47eeb8..1f2099de051 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -536,8 +536,8 @@ struct ata_port { spinlock_t *lock; unsigned long flags; /* ATA_FLAG_xxx */ unsigned int pflags; /* ATA_PFLAG_xxx */ - unsigned int id; /* unique id req'd by scsi midlyr */ - unsigned int port_no; /* unique port #; from zero */ + unsigned int print_id; /* user visible unique port ID */ + unsigned int port_no; /* 0 based port no. inside the host */ struct ata_prd *prd; /* our SG list */ dma_addr_t prd_dma; /* and its DMA mapping */ @@ -892,10 +892,10 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, * printk helpers */ #define ata_port_printk(ap, lv, fmt, args...) \ - printk(lv"ata%u: "fmt, (ap)->id , ##args) + printk(lv"ata%u: "fmt, (ap)->print_id , ##args) #define ata_dev_printk(dev, lv, fmt, args...) \ - printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) + printk(lv"ata%u.%02u: "fmt, (dev)->ap->print_id, (dev)->devno , ##args) /* * ata_eh_info helpers -- cgit v1.2.3 From 32d90911568f67fad3f73623e106667a37c6e7ed Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 21 Feb 2007 20:25:08 +0900 Subject: libata: test major version in ata_id_is_sata() Test major version in ata_id_is_sata() not separately. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/ata.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/ata.h b/include/linux/ata.h index 272736e3799..c331da2da5f 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -282,7 +282,6 @@ struct ata_taskfile { }; #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) -#define ata_id_is_sata(id) ((id)[93] == 0) #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) #define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10)) @@ -324,6 +323,11 @@ static inline unsigned int ata_id_major_version(const u16 *id) return mver; } +static inline int ata_id_is_sata(const u16 *id) +{ + return ata_id_major_version(id) >= 5 && id[93] == 0; +} + static inline int ata_id_current_chs_valid(const u16 *id) { /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command @@ -350,7 +354,7 @@ static inline int ata_id_is_cfa(const u16 *id) static inline int ata_drive_40wire(const u16 *dev_id) { - if (ata_id_major_version(dev_id) >= 5 && ata_id_is_sata(dev_id)) + if (ata_id_is_sata(dev_id)) return 0; /* SATA */ if ((dev_id[93] & 0xE000) == 0x6000) return 0; /* 80 wire */ -- cgit v1.2.3 From 10305f0f8e642590c69674d08bd22accef610aed Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 20 Feb 2007 18:01:59 +0000 Subject: Add id_to_dma_mode function for printing DMA modes Also export dev_disable as this is needed by drivers doing slave decode filtering, which will follow shortly Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- include/linux/libata.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/libata.h b/include/linux/libata.h index 1f2099de051..045fb3a72d5 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -788,10 +788,12 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, unsigned int n_elem); extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); +extern void ata_dev_disable(struct ata_device *adev); extern void ata_id_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len); extern void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs, unsigned int len); +extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown); extern unsigned long ata_device_blacklisted(const struct ata_device *dev); extern void ata_bmdma_setup (struct ata_queued_cmd *qc); extern void ata_bmdma_start (struct ata_queued_cmd *qc); -- cgit v1.2.3