Patchwork [v1] driver/FSL SATA:Fix wrong Device Error Register usage

login
register
mail settings
Submitter Prabhakar Kushwaha
Date Feb. 21, 2011, 3:31 a.m.
Message ID <1298259096-3426-1-git-send-email-prabhakar@freescale.com>
Download mbox | patch
Permalink /patch/83774/
State Superseded
Headers show

Comments

Prabhakar Kushwaha - Feb. 21, 2011, 3:31 a.m.
When a single device error is detected, the device under the error is indicated
by the error bit set in the DER. There is a one to one mapping between register
bit and devices on Port multiplier(PMP) i.e. bit 0 represents PMP device 0 and
bit 1 represents PMP device 1 etc.

Current implementation treats Device error register value as device number not
set of bits representing multiple device on PMP. It is changed to consider bit
level.
No need to check for each set bit as all command is going to be aborted.

Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
Signed-off-by: Ashish Kalra <B00888@freescale.com>
---
 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git (branch master)

 Changes for v1: Incorporated David Laight's comment
 	- Single usage of ffs()

 drivers/ata/sata_fsl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
David Laight - Feb. 21, 2011, 9:21 a.m.
The patch changes the code to:

>  		if (ap->nr_pmp_links) {
> +			int dev_num;
>  			dereg = ioread32(hcr_base + DE);
...
> +			dev_num = ffs(dereg)-1;
> +			if (dev_num < ap->nr_pmp_links) {
> +				link = &ap->pmp_link[dev_num];

On the off chance that no bits are set in 'DE' this
code depends on nr_pmp_links being unsigned (since
dev_num becomes -1.

Changing 'dev_num' to 'unsigned int' would be better.

	David

Patch

diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index b0214d0..895771c 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1040,12 +1040,14 @@  static void sata_fsl_error_intr(struct ata_port *ap)
 
 		/* find out the offending link and qc */
 		if (ap->nr_pmp_links) {
+			int dev_num;
 			dereg = ioread32(hcr_base + DE);
 			iowrite32(dereg, hcr_base + DE);
 			iowrite32(cereg, hcr_base + CE);
 
-			if (dereg < ap->nr_pmp_links) {
-				link = &ap->pmp_link[dereg];
+			dev_num = ffs(dereg)-1;
+			if (dev_num < ap->nr_pmp_links) {
+				link = &ap->pmp_link[dev_num];
 				ehi = &link->eh_info;
 				qc = ata_qc_from_tag(ap, link->active_tag);
 				/*