Skip to contentSkip to conversation

ppc/sata-fsl: orphan config value: CONFIG_MPC8315_DS

DISCUSSION Scott Wood 3 participants 5 messages Aug 23, 2013 – Aug 27, 2013

lore
Share & tools
lore

Scott Wood

author
#0 lore raw

Bcc:
Subject: Re: ppc/sata-fsl: orphan config value: CONFIG_MPC8315_DS Reply-To:
In-Reply-To: <[email protected]>

Quoted 68 lines · Anthony Foiani
Quoted 4 lines · Anthony Foiani

Maybe I need to call ata_set_sata_spd as well. Can I do that before discovery, or should it be a part of the port_start callback? And if the latter, shouldn't it be handled within the ata core, instead of expecting each host driver to do that call?

My final version calls sata_set_spd from within the hard reset callback for the fsl sata driver.

If there's a better place to put it, please let me know.

With this patch (and an appropriate entry in the device tree), the machine comes up and reports:

  # cd /sys/devices/e0000000.immr/e0019000.sata
  # find * -name '*_spd*' -print | xargs grep .
  ata2/link2/ata_link/link2/sata_spd:1.5 Gbps
  ata2/link2/ata_link/link2/hw_sata_spd_limit:1.5 Gbps
  ata2/link2/ata_link/link2/sata_spd_limit:1.5 Gbps

Which is what I needed to see.

Thanks for the hints!

Best regards,
Anthony Foiani

---

Quoted 1 line

From 357c96b4f31b457eca0b96147c749c21d0f4f086 Mon Sep 17 00:00:00 2001

From: Anthony Foiani <[email protected]>
Date: Wed, 8 May 2013 05:24:20 -0600
Subject: [PATCH] sata: fsl: allow device tree to limit sata speed.

There used to be an "orphan" config symbol (CONFIG_MPC8315_DS) that would artificially limit SATA speed to generation 1 (1.5Gbps).

Since that config symbol got lost whenever any sort of configuration was done, we instead extract the limitation from the device tree, using a new name "sata-spd-limit".

---
 .../devicetree/bindings/powerpc/fsl/board.txt      | 23 ++++++++++++++++++
 drivers/ata/sata_fsl.c                             | 28 +++++++++++-----------
 2 files changed, 37 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/powerpc/fsl/board.txt +13 -0
index 380914e..9c9fed4 100644
@@ -67,3 +67,26 @@ Example:
 			gpio-controller;
 		};
 	};
+
+* Maximum SATA Generation workaround
+
+Some boards advertise SATA speeds that they cannot actually achieve.
+Previously, this was dealt with via the orphaned config symbol
+CONFIG_MPC8315_DS.  We now have a device tree property
+"sata-spd-limit" to control this.  It should live within the "sata"
+block.
+
+Example:
+
+		sata@18000 {
+			compatible = "fsl,mpc8315-sata", "fsl,pq-sata";

Documentation/devicetree/bindings/powerpc/fsl/board.txt Example:

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/fsl/board.txt +9 -0
+			reg = <0x18000 0x1000>;
+			cell-index = <1>;
+			interrupts = <44 0x8>;
+			interrupt-parent = <&ipic>;
+			sata-spd-limit = <1>;
+		};
 
+By default, there is no limitation; if a value is given, it indicates
+the maximum "generation" that should be negotiated.  Gen 1 is 1.5Gbps,
+Gen 2 is 3.0Gbps.

This should go in Documentation/devicetree/bindings/ata/fsl-sata.txt.

As for the property name, I'd prefer "fsl,sata-speed-limit" or "fsl,sata-max-generation". Shaohui, do the driver bits look OK?

This patch should go via the linux-scsi list (note that Tejun Heo is now the SATA maintainer).

-Scott

Quoted 53 lines
drivers/ata/sata_fsl.c +14 -14
index d6577b9..9e3f3ec 100644
@@ -726,20 +726,6 @@ static int sata_fsl_port_start(struct ata_port *ap)
 	VPRINTK("HControl = 0x%x\n", ioread32(hcr_base + HCONTROL));
 	VPRINTK("CHBA  = 0x%x\n", ioread32(hcr_base + CHBA));
 
-#ifdef CONFIG_MPC8315_DS
-	/*
-	 * Workaround for 8315DS board 3gbps link-up issue,
-	 * currently limit SATA port to GEN1 speed
-	 */
-	sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
-	temp &= ~(0xF << 4);
-	temp |= (0x1 << 4);
-	sata_fsl_scr_write(&ap->link, SCR_CONTROL, temp);
-
-	sata_fsl_scr_read(&ap->link, SCR_CONTROL, &temp);
-	dev_warn(dev, "scr_control, speed limited to %x\n", temp);
-#endif
-
 	return 0;
 }
 
@@ -836,6 +822,11 @@ try_offline_again:
 	 */
 	ata_msleep(ap, 1);
 
+	/* if the device tree forces a speed limit, set it here. */
+	ata_link_info(link, "setting speed (in hard reset)\n");
+	DPRINTK("setting spd_limit\n");
+	sata_set_spd(link);
+
 	/*
 	 * Now, bring the host controller online again, this can take time
 	 * as PHY reset and communication establishment, 1st D2H FIS and
@@ -1444,6 +1435,15 @@ static int sata_fsl_probe(struct platform_device *ofdev)
 		goto error_exit_with_cleanup;
 	}
 
+	/* record speed limit if requested by device tree */
+	if (!of_property_read_u32(ofdev->dev.of_node, "sata-spd-limit",
+				  &temp)) {
+		int i;
+		for (i = 0; i < SATA_FSL_MAX_PORTS; ++i)
+			host->ports[i]->link.hw_sata_spd_limit = temp;
+		dev_warn(&ofdev->dev, "speed limit set to gen %u\n", temp);
+	}
+
 	/* host->iomap is not used currently */
 	host->private_data = host_priv;
 
#1 lore raw
Quoted 4 lines · Scott Wood

Documentation/devicetree/bindings/powerpc/fsl/board.txt

Quoted 2 lines
Documentation/devicetree/bindings/powerpc/fsl/board.txt +0 -0

This should go in Documentation/devicetree/bindings/ata/fsl-sata.txt.

Ok, will change.

Quoted 2 lines

As for the property name, I'd prefer "fsl,sata-speed-limit" or "fsl,sata-max-generation".

In my original patch:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/58710

I used "fsl,sata-max-gen". I thought Jeff disliked it, so I changed it be more generic -- but maybe I misread his complaint. (And while his opinions are still respected, new maintainers might have different tastes.)

I think my logic was that there exist "sata_spd_limit" and related functions in the ata core, so I should mirror that in the dev tree. No guarantees, though -- it's been a while since I wrote that code.

Quoted 4 lines

Shaohui, do the driver bits look OK?

This patch should go via the linux-scsi list (note that Tejun Heo is now the SATA maintainer).

linux-scsi, or linux-ide? My other recent change to sata_fsl went through the latter.

Thanks for the review / comments. Let me know how you'd like to proceed on the above points, and I can resubmit (as a proper patch for easier tracking).

Best regards,
Anthony Foiani

author
#2 lore raw
Quoted 12 lines · Anthony Foiani
Quoted 4 lines · Scott Wood

Documentation/devicetree/bindings/powerpc/fsl/board.txt

Quoted 2 lines
Documentation/devicetree/bindings/powerpc/fsl/board.txt +0 -0

This should go in Documentation/devicetree/bindings/ata/fsl-sata.txt.

Ok, will change.

Quoted 2 lines

As for the property name, I'd prefer "fsl,sata-speed-limit" or "fsl,sata-max-generation".

Quoted 8 lines

In my original patch:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/58710

I used "fsl,sata-max-gen". I thought Jeff disliked it, so I changed it be more generic -- but maybe I misread his complaint. (And while his opinions are still respected, new maintainers might have different tastes.)

I didn't see anything to that effect from Jeff in that thread -- maybe it was elsewhere.

Quoted 3 lines

I think my logic was that there exist "sata_spd_limit" and related functions in the ata core, so I should mirror that in the dev tree. No guarantees, though -- it's been a while since I wrote that code.

The device tree describes the hardware, not the driver -- and thus should be free to use clearer wording. :-)

As for fsl-specific versus generic, generic is fine but then it needs to be documented in a generic place.

Quoted 7 lines
Quoted 4 lines

Shaohui, do the driver bits look OK?

This patch should go via the linux-scsi list (note that Tejun Heo is now the SATA maintainer).

linux-scsi, or linux-ide? My other recent change to sata_fsl went through the latter.

Sorry, linux-ide.

-Scott

#3 lore raw
Quoted 8 lines · Scott Wood
Quoted 4 lines · Anthony Foiani

In my original patch [...] I used "fsl,sata-max-gen". I thought Jeff disliked it, so I changed it be more generic -- but maybe I misread his complaint. (And while his opinions are still respected, new maintainers might have different tastes.)

I didn't see anything to that effect from Jeff in that thread -- maybe it was elsewhere.

I think I'm referring to this message:

http://article.gmane.org/gmane.linux.ports.ppc.embedded/58720

As he was referring me to generic methods, I inferred that I should be providing generic knobs...

Quoted 2 lines

The device tree describes the hardware, not the driver -- and thus should be free to use clearer wording. :-)

*nod*

Quoted 2 lines

As for fsl-specific versus generic, generic is fine but then it needs to be documented in a generic place.

Agreed. I actually prefer the "generation" nomenclature, as it has a more direct/straightforward interpretation. ("speed=1" vs "generation=1"; the latter is a much bigger clue, IMHO.)

Quoted 1 line

Sorry, linux-ide.

Ok, thanks.

I'll wait a few days to see if there are any other comments or concerns, then I'll spin a final version

As always, thanks for the review and insight!

Best regards,
Anthony Foiani

#4 lore raw
In reply to Scott Wood
Quoted 3 lines

As for the property name, I'd prefer "fsl,sata-speed-limit" or "fsl,sata- max-generation". Shaohui, do the driver bits look OK?

[S.H] The driver part is OK.=20
I also tested it on p5040, the SATA worked as expected.

Best Regards,=20
Shaohui Xie