[coreboot-gerrit] New patch to review for coreboot: 7573993 AMD HyperTransport: Drop unused link optimisation

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Wed Feb 4 09:12:32 CET 2015


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8342

-gerrit

commit 757399353ad574eb51daa9a1aac9b48de1ec35f7
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Tue Feb 3 12:18:54 2015 +0200

    AMD HyperTransport: Drop unused link optimisation
    
    Change-Id: Ia4398f6eb013c69838487bdd02d094f97d7224b6
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/device/hypertransport.c | 162 +-------------------------------------------
 1 file changed, 1 insertion(+), 161 deletions(-)

diff --git a/src/device/hypertransport.c b/src/device/hypertransport.c
index b4c070f..d27e66b 100644
--- a/src/device/hypertransport.c
+++ b/src/device/hypertransport.c
@@ -30,13 +30,6 @@
 #include <device/pci.h>
 #include <device/pci_ids.h>
 #include <device/hypertransport.h>
-#include <cpu/amd/model_fxx_rev.h>
-
-/*
- * The hypertransport link is already optimized in pre-RAM code so don't do
- * it again.
- */
-#define RUN_HT_OPTIMIZE_LINK 0
 
 struct ht_link {
 	struct device *dev;
@@ -83,156 +76,9 @@ static device_t ht_scan_get_devs(device_t *old_devices)
 	return first;
 }
 
-static unsigned ht_read_freq_cap(device_t dev, unsigned pos)
-{
-	/* Handle bugs in valid hypertransport frequency reporting. */
-	unsigned freq_cap;
-
-	freq_cap = pci_read_config16(dev, pos);
-	freq_cap &= ~(1 << HT_FREQ_VENDOR); /* Ignore Vendor HT frequencies. */
-
-	/* AMD 8131 Errata 48. */
-	if ((dev->vendor == PCI_VENDOR_ID_AMD) &&
-	    (dev->device == PCI_DEVICE_ID_AMD_8131_PCIX)) {
-		freq_cap &= ~(1 << HT_FREQ_800Mhz);
-	}
-
-	/* AMD 8151 Errata 23. */
-	if ((dev->vendor == PCI_VENDOR_ID_AMD) &&
-	    (dev->device == PCI_DEVICE_ID_AMD_8151_SYSCTRL)) {
-		freq_cap &= ~(1 << HT_FREQ_800Mhz);
-	}
-
-	/* AMD K8 unsupported 1GHz? */
-	if ((dev->vendor == PCI_VENDOR_ID_AMD) && (dev->device == 0x1100)) {
-		if (!IS_ENABLED(CONFIG_K8_HT_FREQ_1G_SUPPORT))
-			freq_cap &= ~(1 << HT_FREQ_1000Mhz);
-
-		/* Only e0 later support 1GHz HT. */
-		if (!IS_ENABLED(CONFIG_K8_REV_F_SUPPORT) && is_cpu_pre_e0())
-			freq_cap &= ~(1 << HT_FREQ_1000Mhz);
-	}
-
-	return freq_cap;
-}
-
-static int ht_optimize_link()
-{
-	static const u8 link_width_to_pow2[] = { 3, 4, 0, 5, 1, 2, 0, 0 };
-	static const u8 pow2_to_link_width[] = { 7, 4, 5, 0, 1, 3 };
-	unsigned present_width_cap, upstream_width_cap;
-	unsigned present_freq_cap, upstream_freq_cap;
-	unsigned ln_present_width_in, ln_upstream_width_in;
-	unsigned ln_present_width_out, ln_upstream_width_out;
-	unsigned freq, old_freq;
-	unsigned present_width, upstream_width, old_width;
-	int reset_needed = 0;
-
-	/* Read the capabilities. */
-	present_freq_cap =
-		ht_read_freq_cap(cur->dev, cur->pos + cur->freq_cap_off);
-	upstream_freq_cap =
-		ht_read_freq_cap(prev->dev, prev->pos + prev->freq_cap_off);
-	present_width_cap =
-		pci_read_config8(cur->dev, cur->pos + cur->config_off);
-	upstream_width_cap =
-		pci_read_config8(prev->dev, prev->pos + prev->config_off);
-
-	/* Calculate the highest usable frequency. */
-	freq = log2(present_freq_cap & upstream_freq_cap);
-
-	/* Calculate the highest width. */
-	ln_upstream_width_in = link_width_to_pow2[upstream_width_cap & 7];
-	ln_present_width_out = link_width_to_pow2[(present_width_cap >> 4) & 7];
-	if (ln_upstream_width_in > ln_present_width_out)
-		ln_upstream_width_in = ln_present_width_out;
-	upstream_width = pow2_to_link_width[ln_upstream_width_in];
-	present_width  = pow2_to_link_width[ln_upstream_width_in] << 4;
-
-	ln_upstream_width_out =
-		link_width_to_pow2[(upstream_width_cap >> 4) & 7];
-	ln_present_width_in = link_width_to_pow2[present_width_cap & 7];
-	if (ln_upstream_width_out > ln_present_width_in)
-		ln_upstream_width_out = ln_present_width_in;
-	upstream_width |= pow2_to_link_width[ln_upstream_width_out] << 4;
-	present_width  |= pow2_to_link_width[ln_upstream_width_out];
-
-	/* Set the current device. */
-	old_freq = pci_read_config8(cur->dev, cur->pos + cur->freq_off);
-	old_freq &= 0x0f;
-	if (freq != old_freq) {
-		unsigned new_freq;
-		pci_write_config8(cur->dev, cur->pos + cur->freq_off, freq);
-		reset_needed = 1;
-		printk(BIOS_SPEW, "HyperT FreqP old %x new %x\n",old_freq,freq);
-		new_freq = pci_read_config8(cur->dev, cur->pos + cur->freq_off);
-		new_freq &= 0x0f;
-		if (new_freq != freq) {
-			printk(BIOS_ERR, "%s Hypertransport frequency would "
-			       "not set. Wanted: %x, got: %x\n",
-			       dev_path(dev), freq, new_freq);
-		}
-	}
-	old_width = pci_read_config8(cur->dev, cur->pos + cur->config_off + 1);
-	if (present_width != old_width) {
-		unsigned new_width;
-		pci_write_config8(cur->dev, cur->pos + cur->config_off + 1,
-				  present_width);
-		reset_needed = 1;
-		printk(BIOS_SPEW, "HyperT widthP old %x new %x\n",
-		       old_width, present_width);
-		new_width = pci_read_config8(cur->dev,
-					     cur->pos + cur->config_off + 1);
-		if (new_width != present_width) {
-			printk(BIOS_ERR, "%s Hypertransport width would not "
-			       "set. Wanted: %x, got: %x\n",
-			       dev_path(dev), present_width, new_width);
-		}
-	}
-
-	/* Set the upstream device. */
-	old_freq = pci_read_config8(prev->dev, prev->pos + prev->freq_off);
-	old_freq &= 0x0f;
-	if (freq != old_freq) {
-		unsigned new_freq;
-		pci_write_config8(prev->dev, prev->pos + prev->freq_off, freq);
-		reset_needed = 1;
-		printk(BIOS_SPEW, "HyperT freqU old %x new %x\n",
-		       old_freq, freq);
-		new_freq =
-		  pci_read_config8(prev->dev, prev->pos + prev->freq_off);
-		new_freq &= 0x0f;
-		if (new_freq != freq) {
-			printk(BIOS_ERR, "%s Hypertransport frequency would "
-			       "not set. Wanted: %x, got: %x\n",
-			       dev_path(prev->dev), freq, new_freq);
-		}
-	}
-	old_width =
-		pci_read_config8(prev->dev, prev->pos + prev->config_off + 1);
-	if (upstream_width != old_width) {
-		unsigned new_width;
-		pci_write_config8(prev->dev, prev->pos + prev->config_off + 1,
-				  upstream_width);
-		reset_needed = 1;
-		printk(BIOS_SPEW, "HyperT widthU old %x new %x\n", old_width,
-		       upstream_width);
-		new_width = pci_read_config8(prev->dev,
-					     prev->pos + prev->config_off + 1);
-		if (new_width != upstream_width) {
-			printk(BIOS_ERR, "%s Hypertransport width would not "
-			       "set. Wanted: %x, got: %x\n",
-			       dev_path(prev->dev), upstream_width, new_width);
-		}
-	}
-
-	return reset_needed;
-}
-
 static int ht_setup_link(struct ht_link *prev, device_t dev, unsigned pos)
 {
 	struct ht_link cur[1];
-	int reset_needed = 0;
 	int linkb_to_host;
 
 	/* Set the hypertransport link width and frequency. */
@@ -258,9 +104,6 @@ static int ht_setup_link(struct ht_link *prev, device_t dev, unsigned pos)
 		cur->freq_cap_off = PCI_HT_CAP_SLAVE_FREQ_CAP1;
 	}
 
-	if (RUN_HT_OPTIMIZE_LINK)
-		reset_needed = ht_optimize_link(cur, prev);
-
 	/*
 	 * Remember the current link as the previous link, but look at the
 	 * other offsets.
@@ -279,7 +122,7 @@ static int ht_setup_link(struct ht_link *prev, device_t dev, unsigned pos)
 		prev->freq_cap_off = PCI_HT_CAP_SLAVE_FREQ_CAP0;
 	}
 
-	return reset_needed;
+	return 0;
 }
 
 static unsigned ht_lookup_slave_capability(struct device *dev)
@@ -578,9 +421,6 @@ unsigned int hypertransport_scan_chain(struct bus *bus, unsigned min_devfn,
 
 end_of_chain:
 
-	if (bus->reset_needed)
-		printk(BIOS_INFO, "HyperTransport reset needed\n");
-
 #if CONFIG_HT_CHAIN_END_UNITID_BASE != 0x20
 	if (offset_unitid && (ht_dev_num > 1)
 	    && (real_last_unitid != CONFIG_HT_CHAIN_END_UNITID_BASE)



More information about the coreboot-gerrit mailing list