drm-openchrome: Branch 'drm-next-6.7' - 25 commits - drivers/gpu/drm

Kevin Brace kevinbrace at kemper.freedesktop.org
Tue Jan 16 00:21:04 UTC 2024


 drivers/gpu/drm/via/via_drv.h  |    4 
 drivers/gpu/drm/via/via_init.c |  788 +++++++++++++++++++++++------------------
 2 files changed, 457 insertions(+), 335 deletions(-)

New commits:
commit dc291cb344c2267b6415b830ec426f8e4dd49124
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:58 2024 -0600

    drm/via: Version bumped to 3.6.13
    
    Made improvements to via_vram_init().  P4M900 family will now properly
    recognize DDR2-667.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 0c035b907bf3..64ff475c1305 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -44,10 +44,10 @@
 
 #define DRIVER_MAJOR		3
 #define DRIVER_MINOR		6
-#define DRIVER_PATCHLEVEL	12
+#define DRIVER_PATCHLEVEL	13
 #define DRIVER_NAME		"via"
 #define DRIVER_DESC		"OpenChrome DRM for VIA Technologies Chrome"
-#define DRIVER_DATE		"20230929"
+#define DRIVER_DATE		"20240115"
 #define DRIVER_AUTHOR		"OpenChrome Project"
 
 
commit 0e19d2e209bb9edb1f10772d2bf22cee602ec128
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:58 2024 -0600

    drm/via: Detect VRAM size before detecting speed and memory type
    
    This reduces some redundant error checking code.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 39dda8bf81d5..be1c2783703b 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -952,58 +952,44 @@ static int via_vram_init(struct drm_device *dev)
 
 		/* CLE266 */
 		case PCI_DEVICE_ID_VIA_862X_0:
-			ret = cle266_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			ret = cle266_mem_type(dev);
 			break;
 
 		/* KM400(A) / KN400(A) */
 		case PCI_DEVICE_ID_VIA_8378_0:
-			ret = km400_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			ret = km400_mem_type(dev);
 			break;
 
 		/* P4M800 */
 		case PCI_DEVICE_ID_VIA_3296_0:
-			ret = p4m800_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			ret = p4m800_mem_type(dev);
 			break;
 
 		/* K8M800(A) / K8N800(A) */
 		case PCI_DEVICE_ID_VIA_8380_0:
 		/* K8M890 / K8N890 */
 		case PCI_DEVICE_ID_VIA_VT3336:
-			ret = km8xx_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
@@ -1015,21 +1001,19 @@ static int via_vram_init(struct drm_device *dev)
 				dev_priv->vram_size <<= 2;
 			}
 
+			ret = km8xx_mem_type(dev);
 			break;
 
 		/* CN400 / PM800 / PN800 / PM880 / PN880 */
 		case PCI_DEVICE_ID_VIA_PX8X0_0:
-			ret = cn400_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			ret = cn400_mem_type(dev);
 			break;
 
 		/* P4M800CE / P4M800 Pro / VN800 / CN700 */
@@ -1044,11 +1028,6 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_VX800_HB:
 		/* VX855 / VX875 */
 		case PCI_DEVICE_ID_VIA_VX855_HB:
-			ret = cn700_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
@@ -1060,21 +1039,19 @@ static int via_vram_init(struct drm_device *dev)
 				dev_priv->vram_size <<= 2;
 			}
 
+			ret = cn700_mem_type(dev);
 			break;
 
 		/* VX900(H) */
 		case PCI_DEVICE_ID_VIA_VX900_HB:
-			ret = vx900_mem_type(dev);
-			if (ret) {
-				goto exit;
-			}
-
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret) {
 				goto error_pci_cfg_read;
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
+
+			ret = vx900_mem_type(dev);
 			break;
 
 		default:
commit 8bcd1fcfb12a7ff8c21807630674a9b2a171bfd9
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:58 2024 -0600

    drm/via: Tweak VRAM size determination for K8M890 chipset family
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index c700c4b2ea59..39dda8bf81d5 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -1010,8 +1010,8 @@ static int via_vram_init(struct drm_device *dev)
 			}
 
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-			if (bridge_fn0_dev->device ==
-						PCI_DEVICE_ID_VIA_VT3336) {
+			if (bridge_fn0_dev->device !=
+						PCI_DEVICE_ID_VIA_8380_0) {
 				dev_priv->vram_size <<= 2;
 			}
 
commit fcf4b8dee10968878b5416708c3c3de091b7ecbc
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:57 2024 -0600

    drm/via: Tweaking the major switch statement inside via_vram_init()
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 41b71cd6053a..c700c4b2ea59 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -953,36 +953,45 @@ static int via_vram_init(struct drm_device *dev)
 		/* CLE266 */
 		case PCI_DEVICE_ID_VIA_862X_0:
 			ret = cle266_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
+			}
+
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
 		/* KM400(A) / KN400(A) */
 		case PCI_DEVICE_ID_VIA_8378_0:
 			ret = km400_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
+			}
+
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
 		/* P4M800 */
 		case PCI_DEVICE_ID_VIA_3296_0:
 			ret = p4m800_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
+			}
+
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -991,27 +1000,35 @@ static int via_vram_init(struct drm_device *dev)
 		/* K8M890 / K8N890 */
 		case PCI_DEVICE_ID_VIA_VT3336:
 			ret = km8xx_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
-			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			}
 
-			if (bridge_fn0_dev->device == PCI_DEVICE_ID_VIA_VT3336)
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			if (bridge_fn0_dev->device ==
+						PCI_DEVICE_ID_VIA_VT3336) {
 				dev_priv->vram_size <<= 2;
+			}
+
 			break;
 
 		/* CN400 / PM800 / PN800 / PM880 / PN880 */
 		case PCI_DEVICE_ID_VIA_PX8X0_0:
 			ret = cn400_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
+			}
+
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -1028,28 +1045,35 @@ static int via_vram_init(struct drm_device *dev)
 		/* VX855 / VX875 */
 		case PCI_DEVICE_ID_VIA_VX855_HB:
 			ret = cn700_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
-			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			}
 
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			if (bridge_fn0_dev->device !=
-						PCI_DEVICE_ID_VIA_P4M800CE)
+						PCI_DEVICE_ID_VIA_P4M800CE) {
 				dev_priv->vram_size <<= 2;
+			}
+
 			break;
 
 		/* VX900(H) */
 		case PCI_DEVICE_ID_VIA_VX900_HB:
 			ret = vx900_mem_type(dev);
-			if (ret)
+			if (ret) {
 				goto exit;
+			}
 
 			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
-			if (ret)
+			if (ret) {
 				goto error_pci_cfg_read;
+			}
+
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 			break;
 
@@ -1057,7 +1081,7 @@ static int via_vram_init(struct drm_device *dev)
 			ret = -ENODEV;
 			drm_err(dev, "Unknown Host Bridge device: 0x%04x\n",
 				bridge_fn0_dev->device);
-			goto exit;
+			break;
 		}
 
 		break;
commit 4a3cf24681f6dcbf8317fd4de89b461e44d945ea
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:54 2024 -0600

    drm/via: Stop the use of pci_get_slot() to find relevant PCI devices
    
    pci_get_domain_bus_and_slot() is easier to use and there is no need
    to call pci_dev_put() before exit.  This simplifies via_vram_init().
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 09bdd1e25fc1..41b71cd6053a 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -915,54 +915,50 @@ static void via_quirks_init(struct drm_device *dev)
 
 static int via_vram_init(struct drm_device *dev)
 {
-	struct pci_dev *pdev = to_pci_dev(dev->dev);
-	struct pci_bus *bus;
-	struct pci_dev *hb_fn0 = NULL;
-	struct pci_dev *hb_fn3 = NULL;
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn0_dev = NULL;
+	struct pci_dev *bridge_fn3_dev = NULL;
 	char *name = "unknown";
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
 	u8 size;
 	int ret = 0;
 
-	drm_dbg_driver(dev, "Entered %s.\n", __func__);
-
-	bus = pci_find_bus(0, 0);
-	if (!bus) {
-		ret = -ENODEV;
-		drm_err(dev, "PCI bus not found!\n");
-		goto exit;
-	}
-
-	hb_fn0 = pci_get_slot(bus, PCI_DEVFN(0, 0));
-	if (!hb_fn0) {
+	bridge_fn0_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 0));
+	if (!bridge_fn0_dev) {
 		ret = -ENODEV;
-		drm_err(dev, "Host Bridge Function 0 not found!\n");
+		drm_err(dev, "Host Bridge Function 0 not found! "
+				"errno: %d\n", ret);
 		goto exit;
 	}
 
-	if ((pdev->device != PCI_DEVICE_ID_VIA_CLE266_GFX) ||
-		(pdev->device != PCI_DEVICE_ID_VIA_KM400_GFX)) {
-		hb_fn3 = pci_get_slot(bus, PCI_DEVFN(0, 3));
-		if (!hb_fn3) {
+	if ((gfx_dev->device != PCI_DEVICE_ID_VIA_CLE266_GFX) ||
+		(gfx_dev->device != PCI_DEVICE_ID_VIA_KM400_GFX)) {
+		bridge_fn3_dev =
+			pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus),
+							0, PCI_DEVFN(0, 3));
+		if (!bridge_fn3_dev) {
 			ret = -ENODEV;
-			drm_err(dev, "Host Bridge Function 3 not found!\n");
-			goto error_hb_fn0;
+			drm_err(dev, "Host Bridge Function 3 not found! "
+					"errno: %d\n", ret);
+			goto exit;
 		}
 	}
 
-	switch (hb_fn0->vendor) {
+	switch (bridge_fn0_dev->vendor) {
 	case PCI_VENDOR_ID_VIA:
-		switch (hb_fn0->device) {
+		switch (bridge_fn0_dev->device) {
 
 		/* CLE266 */
 		case PCI_DEVICE_ID_VIA_862X_0:
 			ret = cle266_mem_type(dev);
 			if (ret)
-				goto error_hb_fn0;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
+			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
 			if (ret)
-				goto error_hb_fn0;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -970,11 +966,11 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_8378_0:
 			ret = km400_mem_type(dev);
 			if (ret)
-				goto error_hb_fn0;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
+			ret = pci_read_config_byte(bridge_fn0_dev, 0xe1, &size);
 			if (ret)
-				goto error_hb_fn0;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -982,11 +978,11 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_3296_0:
 			ret = p4m800_mem_type(dev);
 			if (ret)
-				goto error_hb_fn3;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret)
-				goto error_hb_fn3;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -996,14 +992,14 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_VT3336:
 			ret = km8xx_mem_type(dev);
 			if (ret)
-				goto error_hb_fn3;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret)
-				goto error_hb_fn3;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 
-			if (hb_fn0->device == PCI_DEVICE_ID_VIA_VT3336)
+			if (bridge_fn0_dev->device == PCI_DEVICE_ID_VIA_VT3336)
 				dev_priv->vram_size <<= 2;
 			break;
 
@@ -1011,11 +1007,11 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_PX8X0_0:
 			ret = cn400_mem_type(dev);
 			if (ret)
-				goto error_hb_fn3;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret)
-				goto error_hb_fn3;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 			break;
 
@@ -1033,14 +1029,15 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_VX855_HB:
 			ret = cn700_mem_type(dev);
 			if (ret)
-				goto error_hb_fn3;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret)
-				goto error_hb_fn3;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 
-			if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
+			if (bridge_fn0_dev->device !=
+						PCI_DEVICE_ID_VIA_P4M800CE)
 				dev_priv->vram_size <<= 2;
 			break;
 
@@ -1048,31 +1045,31 @@ static int via_vram_init(struct drm_device *dev)
 		case PCI_DEVICE_ID_VIA_VX900_HB:
 			ret = vx900_mem_type(dev);
 			if (ret)
-				goto error_hb_fn3;
+				goto exit;
 
-			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			ret = pci_read_config_byte(bridge_fn3_dev, 0xa1, &size);
 			if (ret)
-				goto error_hb_fn3;
+				goto error_pci_cfg_read;
 			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 			break;
 
 		default:
 			ret = -ENODEV;
 			drm_err(dev, "Unknown Host Bridge device: 0x%04x\n",
-				hb_fn0->device);
-			goto error_hb_fn3;
+				bridge_fn0_dev->device);
+			goto exit;
 		}
 
 		break;
 	default:
 		ret = -ENODEV;
 		drm_err(dev, "Unknown Host Bridge vendor: 0x%04x\n",
-			hb_fn0->vendor);
+			bridge_fn0_dev->vendor);
 		break;
 	}
 
 	if (ret) {
-		goto error_hb_fn3;
+		goto exit;
 	}
 
 	switch (dev_priv->vram_type) {
@@ -1136,22 +1133,18 @@ static int via_vram_init(struct drm_device *dev)
 
 	drm_dbg_driver(dev, "Found %s video RAM.\n", name);
 
-	if (pdev->device == PCI_DEVICE_ID_VIA_CHROME9_HD) {
-		dev_priv->vram_start = pci_resource_start(pdev, 2);
+	if (gfx_dev->device == PCI_DEVICE_ID_VIA_CHROME9_HD) {
+		dev_priv->vram_start = pci_resource_start(gfx_dev, 2);
 	} else {
-		dev_priv->vram_start = pci_resource_start(pdev, 0);
+		dev_priv->vram_start = pci_resource_start(gfx_dev, 0);
 	}
 
 	/* Add an MTRR for the video RAM. */
 	dev_priv->vram_mtrr = arch_phys_wc_add(dev_priv->vram_start,
 						dev_priv->vram_size);
 	goto exit;
-error_hb_fn3:
-	if (hb_fn3)
-		pci_dev_put(hb_fn3);
-error_hb_fn0:
-	if (hb_fn0)
-		pci_dev_put(hb_fn0);
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
 exit:
 	drm_dbg_driver(dev, "Exiting %s.\n", __func__);
 	return ret;
commit fb44aeb17b0879cfe47535c434f39e8208de3feb
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:47 2024 -0600

    drm/via: Set vram_start member of via_drm_priv{} after it is safe to do so
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 68308f463d07..09bdd1e25fc1 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -950,12 +950,6 @@ static int via_vram_init(struct drm_device *dev)
 		}
 	}
 
-	if (pdev->device == PCI_DEVICE_ID_VIA_CHROME9_HD) {
-		dev_priv->vram_start = pci_resource_start(pdev, 2);
-	} else {
-		dev_priv->vram_start = pci_resource_start(pdev, 0);
-	}
-
 	switch (hb_fn0->vendor) {
 	case PCI_VENDOR_ID_VIA:
 		switch (hb_fn0->device) {
@@ -1142,6 +1136,12 @@ static int via_vram_init(struct drm_device *dev)
 
 	drm_dbg_driver(dev, "Found %s video RAM.\n", name);
 
+	if (pdev->device == PCI_DEVICE_ID_VIA_CHROME9_HD) {
+		dev_priv->vram_start = pci_resource_start(pdev, 2);
+	} else {
+		dev_priv->vram_start = pci_resource_start(pdev, 0);
+	}
+
 	/* Add an MTRR for the video RAM. */
 	dev_priv->vram_mtrr = arch_phys_wc_add(dev_priv->vram_start,
 						dev_priv->vram_size);
commit 5192b008c6473eca75d55bda18633d33503db7b2
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:38 2024 -0600

    drm/via: Check for VIA Technologies PCI Vendor ID before device detection
    
    Both Vendor ID and Device ID will be checked before memory size and
    type detection.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index ff8d2d3a5732..68308f463d07 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -956,114 +956,128 @@ static int via_vram_init(struct drm_device *dev)
 		dev_priv->vram_start = pci_resource_start(pdev, 0);
 	}
 
-	switch (hb_fn0->device) {
-
-	/* CLE266 */
-	case PCI_DEVICE_ID_VIA_862X_0:
-		ret = cle266_mem_type(dev);
-		if (ret)
-			goto error_hb_fn0;
-
-		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
-		if (ret)
-			goto error_hb_fn0;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-		break;
-
-	/* KM400(A) / KN400(A) */
-	case PCI_DEVICE_ID_VIA_8378_0:
-		ret = km400_mem_type(dev);
-		if (ret)
-			goto error_hb_fn0;
-
-		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
-		if (ret)
-			goto error_hb_fn0;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-		break;
+	switch (hb_fn0->vendor) {
+	case PCI_VENDOR_ID_VIA:
+		switch (hb_fn0->device) {
+
+		/* CLE266 */
+		case PCI_DEVICE_ID_VIA_862X_0:
+			ret = cle266_mem_type(dev);
+			if (ret)
+				goto error_hb_fn0;
+
+			ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
+			if (ret)
+				goto error_hb_fn0;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			break;
 
-	/* P4M800 */
-	case PCI_DEVICE_ID_VIA_3296_0:
-		ret = p4m800_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
+		/* KM400(A) / KN400(A) */
+		case PCI_DEVICE_ID_VIA_8378_0:
+			ret = km400_mem_type(dev);
+			if (ret)
+				goto error_hb_fn0;
 
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-		break;
+			ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
+			if (ret)
+				goto error_hb_fn0;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			break;
 
-	/* K8M800(A) / K8N800(A) */
-	case PCI_DEVICE_ID_VIA_8380_0:
-	/* K8M890 / K8N890 */
-	case PCI_DEVICE_ID_VIA_VT3336:
-		ret = km8xx_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
+		/* P4M800 */
+		case PCI_DEVICE_ID_VIA_3296_0:
+			ret = p4m800_mem_type(dev);
+			if (ret)
+				goto error_hb_fn3;
 
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			if (ret)
+				goto error_hb_fn3;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			break;
 
-		if (hb_fn0->device == PCI_DEVICE_ID_VIA_VT3336)
-			dev_priv->vram_size <<= 2;
-		break;
+		/* K8M800(A) / K8N800(A) */
+		case PCI_DEVICE_ID_VIA_8380_0:
+		/* K8M890 / K8N890 */
+		case PCI_DEVICE_ID_VIA_VT3336:
+			ret = km8xx_mem_type(dev);
+			if (ret)
+				goto error_hb_fn3;
+
+			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			if (ret)
+				goto error_hb_fn3;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			if (hb_fn0->device == PCI_DEVICE_ID_VIA_VT3336)
+				dev_priv->vram_size <<= 2;
+			break;
 
-	/* CN400 / PM800 / PN800 / PM880 / PN880 */
-	case PCI_DEVICE_ID_VIA_PX8X0_0:
-		ret = cn400_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
+		/* CN400 / PM800 / PN800 / PM880 / PN880 */
+		case PCI_DEVICE_ID_VIA_PX8X0_0:
+			ret = cn400_mem_type(dev);
+			if (ret)
+				goto error_hb_fn3;
 
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-		break;
+			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			if (ret)
+				goto error_hb_fn3;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+			break;
 
-	/* P4M800CE / P4M800 Pro / VN800 / CN700 */
-	case PCI_DEVICE_ID_VIA_P4M800CE:
-	/* P4M890 / VN890 / CN800 */
-	case PCI_DEVICE_ID_VIA_P4M890:
-	/* CX700(M / M2) / VX700(M / M2) */
-	case PCI_DEVICE_ID_VIA_VT3324:
-	/* P4M900 / VN896 / CN896 */
-	case PCI_DEVICE_ID_VIA_VT3364:
-	/* VX800 / VX820 */
-	case PCI_DEVICE_ID_VIA_VX800_HB:
-	/* VX855 / VX875 */
-	case PCI_DEVICE_ID_VIA_VX855_HB:
-		ret = cn700_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
+		/* P4M800CE / P4M800 Pro / VN800 / CN700 */
+		case PCI_DEVICE_ID_VIA_P4M800CE:
+		/* P4M890 / VN890 / CN800 */
+		case PCI_DEVICE_ID_VIA_P4M890:
+		/* CX700(M / M2) / VX700(M / M2) */
+		case PCI_DEVICE_ID_VIA_VT3324:
+		/* P4M900 / VN896 / CN896 */
+		case PCI_DEVICE_ID_VIA_VT3364:
+		/* VX800 / VX820 */
+		case PCI_DEVICE_ID_VIA_VX800_HB:
+		/* VX855 / VX875 */
+		case PCI_DEVICE_ID_VIA_VX855_HB:
+			ret = cn700_mem_type(dev);
+			if (ret)
+				goto error_hb_fn3;
+
+			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			if (ret)
+				goto error_hb_fn3;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+
+			if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
+				dev_priv->vram_size <<= 2;
+			break;
 
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
+		/* VX900(H) */
+		case PCI_DEVICE_ID_VIA_VX900_HB:
+			ret = vx900_mem_type(dev);
+			if (ret)
+				goto error_hb_fn3;
 
-		if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
-			dev_priv->vram_size <<= 2;
-		break;
+			ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+			if (ret)
+				goto error_hb_fn3;
+			dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
+			break;
 
-	/* VX900(H) */
-	case PCI_DEVICE_ID_VIA_VX900_HB:
-		ret = vx900_mem_type(dev);
-		if (ret)
+		default:
+			ret = -ENODEV;
+			drm_err(dev, "Unknown Host Bridge device: 0x%04x\n",
+				hb_fn0->device);
 			goto error_hb_fn3;
+		}
 
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 		break;
-
 	default:
 		ret = -ENODEV;
-		drm_err(dev, "Unknown Host Bridge device: 0x%04x\n",
-				hb_fn0->device);
+		drm_err(dev, "Unknown Host Bridge vendor: 0x%04x\n",
+			hb_fn0->vendor);
+		break;
+	}
+
+	if (ret) {
 		goto error_hb_fn3;
 	}
 
commit ca54e20c8ce4cdb37e65be267dae55c05486dde3
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:35 2024 -0600

    drm/via: Call *_mem_type() before figuring out the VRAM size
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index acea4e610609..ff8d2d3a5732 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -998,6 +998,10 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_8380_0:
 	/* K8M890 / K8N890 */
 	case PCI_DEVICE_ID_VIA_VT3336:
+		ret = km8xx_mem_type(dev);
+		if (ret)
+			goto error_hb_fn3;
+
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
@@ -1005,22 +1009,18 @@ static int via_vram_init(struct drm_device *dev)
 
 		if (hb_fn0->device == PCI_DEVICE_ID_VIA_VT3336)
 			dev_priv->vram_size <<= 2;
-
-		ret = km8xx_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
 		break;
 
 	/* CN400 / PM800 / PN800 / PM880 / PN880 */
 	case PCI_DEVICE_ID_VIA_PX8X0_0:
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+		ret = cn400_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 
-		ret = cn400_mem_type(dev);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
+		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 		break;
 
 	/* P4M800CE / P4M800 Pro / VN800 / CN700 */
@@ -1035,6 +1035,10 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_VX800_HB:
 	/* VX855 / VX875 */
 	case PCI_DEVICE_ID_VIA_VX855_HB:
+		ret = cn700_mem_type(dev);
+		if (ret)
+			goto error_hb_fn3;
+
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
@@ -1042,22 +1046,18 @@ static int via_vram_init(struct drm_device *dev)
 
 		if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
 			dev_priv->vram_size <<= 2;
-
-		ret = cn700_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
 		break;
 
 	/* VX900(H) */
 	case PCI_DEVICE_ID_VIA_VX900_HB:
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
+		ret = vx900_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 
-		ret = vx900_mem_type(dev);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
+		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 		break;
 
 	default:
commit 3a04a5d77489b7f34953ddb8aa28ea367885e99a
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:35 2024 -0600

    drm/via: Updates to vx900_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index ba713df8c7ad..acea4e610609 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -762,75 +762,100 @@ exit:
 	return ret;
 }
 
-static int vx900_mem_type(struct drm_device *dev,
-				struct pci_dev *fn3)
+static int vx900_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn3_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
+	u8 type, clock, volt;
 	int ret;
-	u8 clock, type, volt;
-
-	ret = pci_read_config_byte(fn3, 0x90, &clock);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(fn3, 0x6c, &type);
-	if (ret)
-		return ret;
+
+	bridge_fn3_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 3));
+	if (!bridge_fn3_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x6c, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x90, &clock);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
 	volt = type;
 	type &= 0xc0;
 	type >>= 6;
 	volt &= 0x20;
 	volt >>= 5;
-
 	switch (type) {
-	case 1:
+	case 0x01:
 		switch (clock & 0x0f) {
-		case 0:
-			if (volt)
+		case 0x00:
+			if (volt) {
 				dev_priv->vram_type = VIA_MEM_DDR2_800;
-			else
+			} else {
 				dev_priv->vram_type = VIA_MEM_DDR2_533;
+			}
+
 			break;
-		case 4:
+		case 0x04:
 			dev_priv->vram_type = VIA_MEM_DDR2_533;
 			break;
-		case 5:
+		case 0x05:
 			dev_priv->vram_type = VIA_MEM_DDR2_667;
 			break;
-		case 6:
+		case 0x06:
 			dev_priv->vram_type = VIA_MEM_DDR2_800;
 			break;
-		case 7:
+		case 0x07:
 			dev_priv->vram_type = VIA_MEM_DDR2_1066;
 			break;
 		default:
 			break;
 		}
+
 		break;
-	case 2:
+	case 0x02:
 		switch (clock & 0x0f) {
-		case 0:
-			if (volt)
+		case 0x00:
+			if (volt) {
 				dev_priv->vram_type = VIA_MEM_DDR3_800;
-			else
+			} else {
 				dev_priv->vram_type = VIA_MEM_DDR3_533;
+			}
+
 			break;
-		case 4:
+		case 0x04:
 			dev_priv->vram_type = VIA_MEM_DDR3_533;
 			break;
-		case 5:
+		case 0x05:
 			dev_priv->vram_type = VIA_MEM_DDR3_667;
 			break;
-		case 6:
+		case 0x06:
 			dev_priv->vram_type = VIA_MEM_DDR3_800;
 			break;
-		case 7:
+		case 0x07:
 			dev_priv->vram_type = VIA_MEM_DDR3_1066;
 			break;
 		default:
 			break;
 		}
+
 		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -1023,14 +1048,14 @@ static int via_vram_init(struct drm_device *dev)
 			goto error_hb_fn3;
 		break;
 
-	/* VX900 */
+	/* VX900(H) */
 	case PCI_DEVICE_ID_VIA_VX900_HB:
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 
-		ret = vx900_mem_type(dev, hb_fn3);
+		ret = vx900_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
 		break;
commit 4b7c1dc483916ef9b78e56dd9868bd9991809567
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:31 2024 -0600

    drm/via: Merge cn700_mem_type() and p4m900_mem_type()
    
    p4m900_mem_type() code will be retained with cn700_mem_type() name.
    This should allow P4M900 chipset family to properly recognize DDR2-667.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index a434f9f94e3d..ba713df8c7ad 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -710,80 +710,6 @@ static int cn700_mem_type(struct drm_device *dev)
 		goto error_pci_cfg_read;
 	}
 
-	type &= 0x40;
-	type >>= 6;
-	switch (type) {
-	case 0x00:
-		switch (clock & 0x07) {
-		case 0x00:
-			dev_priv->vram_type = VIA_MEM_DDR_200;
-			break;
-		case 0x01:
-			dev_priv->vram_type = VIA_MEM_DDR_266;
-			break;
-		case 0x02:
-			dev_priv->vram_type = VIA_MEM_DDR_333;
-			break;
-		case 0x03:
-			dev_priv->vram_type = VIA_MEM_DDR_400;
-			break;
-		default:
-			break;
-		}
-
-		break;
-	case 0x01:
-		switch (clock & 0x07) {
-		case 0x03:
-			dev_priv->vram_type = VIA_MEM_DDR2_400;
-			break;
-		case 0x04:
-			dev_priv->vram_type = VIA_MEM_DDR2_533;
-			break;
-		default:
-			break;
-		}
-
-		break;
-	default:
-		break;
-	}
-
-	goto exit;
-error_pci_cfg_read:
-	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
-exit:
-	return ret;
-}
-
-static int p4m900_mem_type(struct drm_device *dev)
-{
-	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
-	struct pci_dev *bridge_fn3_dev;
-	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
-	u8 type, clock;
-	int ret;
-
-	bridge_fn3_dev =
-		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
-						PCI_DEVFN(0, 3));
-	if (!bridge_fn3_dev) {
-		ret = -ENODEV;
-		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
-			ret);
-		goto exit;
-	}
-
-	ret = pci_read_config_byte(bridge_fn3_dev, 0x6c, &type);
-	if (ret) {
-		goto error_pci_cfg_read;
-	}
-
-	ret = pci_read_config_byte(bridge_fn3_dev, 0x90, &clock);
-	if (ret) {
-		goto error_pci_cfg_read;
-	}
-
 	type &= 0x40;
 	type >>= 6;
 	switch (type) {
@@ -1078,19 +1004,6 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_P4M890:
 	/* CX700(M / M2) / VX700(M / M2) */
 	case PCI_DEVICE_ID_VIA_VT3324:
-		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
-		if (ret)
-			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
-
-		if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
-			dev_priv->vram_size <<= 2;
-
-		ret = cn700_mem_type(dev);
-		if (ret)
-			goto error_hb_fn3;
-		break;
-
 	/* P4M900 / VN896 / CN896 */
 	case PCI_DEVICE_ID_VIA_VT3364:
 	/* VX800 / VX820 */
@@ -1100,9 +1013,12 @@ static int via_vram_init(struct drm_device *dev)
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
-		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
+		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 
-		ret = p4m900_mem_type(dev);
+		if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
+			dev_priv->vram_size <<= 2;
+
+		ret = cn700_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
 		break;
commit 512c2ce3540acf63f200bd3a4bc5a7e97373fbe5
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:31 2024 -0600

    drm/via: Use cn700_mem_type() for P4M890 and CX700 chipset families
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 3c36a8b4252a..a434f9f94e3d 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -1074,6 +1074,10 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* P4M800CE / P4M800 Pro / VN800 / CN700 */
 	case PCI_DEVICE_ID_VIA_P4M800CE:
+	/* P4M890 / VN890 / CN800 */
+	case PCI_DEVICE_ID_VIA_P4M890:
+	/* CX700(M / M2) / VX700(M / M2) */
+	case PCI_DEVICE_ID_VIA_VT3324:
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
@@ -1087,10 +1091,6 @@ static int via_vram_init(struct drm_device *dev)
 			goto error_hb_fn3;
 		break;
 
-	/* CX700 / VX700 */
-	case PCI_DEVICE_ID_VIA_VT3324:
-	/* P4M890 / VN890 */
-	case PCI_DEVICE_ID_VIA_P4M890:
 	/* P4M900 / VN896 / CN896 */
 	case PCI_DEVICE_ID_VIA_VT3364:
 	/* VX800 / VX820 */
commit 6ba3573a4a111d1c0b2c6ce8499f07b21da9dcfb
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:31 2024 -0600

    drm/via: Rename cx700_mem_type() to p4m900_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index f242ce7da9a1..3c36a8b4252a 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -756,63 +756,83 @@ exit:
 	return ret;
 }
 
-static int cx700_mem_type(struct drm_device *dev,
-				struct pci_dev *fn3)
+static int p4m900_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn3_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
 	u8 type, clock;
 	int ret;
 
-	ret = pci_read_config_byte(fn3, 0x90, &clock);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(fn3, 0x6c, &type);
-	if (ret)
-		return ret;
+	bridge_fn3_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 3));
+	if (!bridge_fn3_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x6c, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x90, &clock);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
 	type &= 0x40;
 	type >>= 6;
-
 	switch (type) {
-	case 0:
+	case 0x00:
 		switch (clock & 0x07) {
-		case 0:
+		case 0x00:
 			dev_priv->vram_type = VIA_MEM_DDR_200;
 			break;
-		case 1:
+		case 0x01:
 			dev_priv->vram_type = VIA_MEM_DDR_266;
 			break;
-		case 2:
+		case 0x02:
 			dev_priv->vram_type = VIA_MEM_DDR_333;
 			break;
-		case 3:
+		case 0x03:
 			dev_priv->vram_type = VIA_MEM_DDR_400;
 			break;
 		default:
 			break;
 		}
-		break;
 
-	case 1:
+		break;
+	case 0x01:
 		switch (clock & 0x07) {
-		case 3:
+		case 0x03:
 			dev_priv->vram_type = VIA_MEM_DDR2_400;
 			break;
-		case 4:
+		case 0x04:
 			dev_priv->vram_type = VIA_MEM_DDR2_533;
 			break;
-		case 5:
+		case 0x05:
 			dev_priv->vram_type = VIA_MEM_DDR2_667;
 			break;
-		case 6:
+		case 0x06:
 			dev_priv->vram_type = VIA_MEM_DDR2_800;
 			break;
 		default:
 			break;
 		}
+
 		break;
 	default:
 		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -1054,8 +1074,6 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* P4M800CE / P4M800 Pro / VN800 / CN700 */
 	case PCI_DEVICE_ID_VIA_P4M800CE:
-	/* P4M900 / VN896 / CN896 */
-	case PCI_DEVICE_ID_VIA_VT3364:
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
@@ -1073,6 +1091,8 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_VT3324:
 	/* P4M890 / VN890 */
 	case PCI_DEVICE_ID_VIA_P4M890:
+	/* P4M900 / VN896 / CN896 */
+	case PCI_DEVICE_ID_VIA_VT3364:
 	/* VX800 / VX820 */
 	case PCI_DEVICE_ID_VIA_VX800_HB:
 	/* VX855 / VX875 */
@@ -1082,7 +1102,7 @@ static int via_vram_init(struct drm_device *dev)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
 
-		ret = cx700_mem_type(dev, hb_fn3);
+		ret = p4m900_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
 		break;
commit 0fd6d34d55a13656bc4ef9c5e77dfe6c65119cdd
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:30 2024 -0600

    drm/via: Updates to cn700_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 40b130a921cf..f242ce7da9a1 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -682,16 +682,39 @@ exit:
 	return ret;
 }
 
-static int cn700_mem_type(struct drm_device *dev,
-				struct pci_dev *fn3)
+static int cn700_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn3_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
+	u8 type, clock;
 	int ret;
-	u8 tmp;
 
-	ret = pci_read_config_byte(fn3, 0x90, &tmp);
-	if (!ret) {
-		switch (tmp & 0x07) {
+	bridge_fn3_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 3));
+	if (!bridge_fn3_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x6c, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x90, &clock);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	type &= 0x40;
+	type >>= 6;
+	switch (type) {
+	case 0x00:
+		switch (clock & 0x07) {
 		case 0x00:
 			dev_priv->vram_type = VIA_MEM_DDR_200;
 			break;
@@ -704,16 +727,32 @@ static int cn700_mem_type(struct drm_device *dev,
 		case 0x03:
 			dev_priv->vram_type = VIA_MEM_DDR_400;
 			break;
-		case 0x04:
+		default:
+			break;
+		}
+
+		break;
+	case 0x01:
+		switch (clock & 0x07) {
+		case 0x03:
 			dev_priv->vram_type = VIA_MEM_DDR2_400;
 			break;
-		case 0x05:
+		case 0x04:
 			dev_priv->vram_type = VIA_MEM_DDR2_533;
 			break;
 		default:
 			break;
 		}
+
+		break;
+	default:
+		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -1025,7 +1064,7 @@ static int via_vram_init(struct drm_device *dev)
 		if (hb_fn0->device != PCI_DEVICE_ID_VIA_P4M800CE)
 			dev_priv->vram_size <<= 2;
 
-		ret = cn700_mem_type(dev, hb_fn3);
+		ret = cn700_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
 		break;
commit a2ead3a908c4db754939c669ec9436eef7ef4667
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:29 2024 -0600

    drm/via: Drop recognizing 166 MHz FSB base clock inside cn400_mem_type()
    
    This frequency was never officially supported by this chipset, so
    stop recognizing it.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 97a89bbe7412..40b130a921cf 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -636,9 +636,6 @@ static int cn400_mem_type(struct drm_device *dev)
 	case 0x01:
 		freq = 0x04; /* 133 MHz */
 		break;
-	case 0x03:
-		freq = 0x05; /* 166 MHz */
-		break;
 	case 0x02:
 		freq = 0x06; /* 200 MHz */
 		break;
commit bbd499fc9da0d695e22695ff4d892f387b4c3ee3
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:28 2024 -0600

    drm/via: Updates to cn400_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 6ff53508c50e..97a89bbe7412 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -594,51 +594,72 @@ exit:
 	return ret;
 }
 
-static int cn400_mem_type(struct drm_device *dev,
-				struct pci_bus *bus,
-				struct pci_dev *fn3)
+static int cn400_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn2_dev, *bridge_fn3_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
-	struct pci_dev *fn2 = pci_get_slot(bus, PCI_DEVFN(0, 2));
-	int ret, freq = 0;
-	u8 type, fsb;
+	int freq = 0;
+	u8 fsb, type;
+	int ret;
+
+	bridge_fn2_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 2));
+	if (!bridge_fn2_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 2 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	bridge_fn3_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 3));
+	if (!bridge_fn3_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
 
-	ret = pci_read_config_byte(fn2, 0x54, &fsb);
+	ret = pci_read_config_byte(bridge_fn2_dev, 0x54, &fsb);
 	if (ret) {
-		pci_dev_put(fn2);
-		return ret;
+		goto error_pci_cfg_read;
 	}
 
-	switch (fsb >> 5) {
-	case 0:
-		freq = 3; /* 100 MHz */
+	fsb >>= 5;
+	switch (fsb) {
+	case 0x00:
+		freq = 0x03; /* 100 MHz */
 		break;
-	case 1:
-		freq = 4; /* 133 MHz */
+	case 0x01:
+		freq = 0x04; /* 133 MHz */
 		break;
-	case 3:
-		freq = 5; /* 166 MHz */
+	case 0x03:
+		freq = 0x05; /* 166 MHz */
 		break;
-	case 2:
-		freq = 6; /* 200 MHz */
+	case 0x02:
+		freq = 0x06; /* 200 MHz */
 		break;
-	case 4:
-		freq = 7; /* 233 MHz */
+	case 0x04:
+		freq = 0x07; /* 233 MHz */
 		break;
 	default:
 		break;
 	}
-	pci_dev_put(fn2);
 
-	ret = pci_read_config_byte(fn3, 0x68, &type);
-	if (ret)
-		return ret;
-	type &= 0x0f;
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x68, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
-	if (type & 0x01)
+	type &= 0x0f;
+	if (type & 0x01) {
 		freq += 1 + (type >> 2);
-	else
+	} else {
 		freq -= 1 + (type >> 2);
+	}
 
 	switch (freq) {
 	case 0x03:
@@ -656,6 +677,11 @@ static int cn400_mem_type(struct drm_device *dev,
 	default:
 		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -978,14 +1004,14 @@ static int via_vram_init(struct drm_device *dev)
 			goto error_hb_fn3;
 		break;
 
-	/* CN400 / PM800 / PM880 */
+	/* CN400 / PM800 / PN800 / PM880 / PN880 */
 	case PCI_DEVICE_ID_VIA_PX8X0_0:
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 
-		ret = cn400_mem_type(dev, bus, hb_fn3);
+		ret = cn400_mem_type(dev);
 		if (ret)
 			goto error_hb_fn3;
 		break;
commit 0365615533920e4a90bb796692a22a687cde3065
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:25 2024 -0600

    drm/via: Updates to km8xx_mem_type()
    
    Minor updates to the function.  Improved its error handling
    within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index d25d21af0c4c..6ff53508c50e 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -443,20 +443,28 @@ exit:
 
 static int km8xx_mem_type(struct drm_device *dev)
 {
-	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
 	struct pci_dev *dram, *misc = NULL;
-	int ret = -ENXIO;
+	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
 	u8 type, tmp;
+	int ret = -ENXIO;
 
 	dram = pci_get_device(PCI_VENDOR_ID_AMD,
-			PCI_DEVICE_ID_AMD_K8_NB_MEMCTL, NULL);
+				PCI_DEVICE_ID_AMD_K8_NB_MEMCTL, NULL);
 	if (dram) {
 		misc = pci_get_device(PCI_VENDOR_ID_AMD,
-				PCI_DEVICE_ID_AMD_K8_NB_MISC, NULL);
+					PCI_DEVICE_ID_AMD_K8_NB_MISC, NULL);
 
 		ret = pci_read_config_byte(misc, 0xfd, &type);
+		if (ret) {
+			goto error_pci_cfg_read;
+		}
+
 		if (type) {
 			pci_read_config_byte(dram, 0x94, &type);
+			if (ret) {
+				goto error_pci_cfg_read;
+			}
+
 			switch (type & 0x03) {
 			case 0x00:
 				dev_priv->vram_type = VIA_MEM_DDR2_400;
@@ -475,8 +483,10 @@ static int km8xx_mem_type(struct drm_device *dev)
 			}
 		} else {
 			ret = pci_read_config_byte(dram, 0x96, &type);
-			if (ret)
-				return ret;
+			if (ret) {
+				goto error_pci_cfg_read;
+			}
+
 			type >>= 4;
 			type &= 0x07;
 
@@ -501,14 +511,17 @@ static int km8xx_mem_type(struct drm_device *dev)
 
 	/* AMD 10h DRAM Controller */
 	dram = pci_get_device(PCI_VENDOR_ID_AMD,
-			PCI_DEVICE_ID_AMD_10H_NB_DRAM, NULL);
+				PCI_DEVICE_ID_AMD_10H_NB_DRAM, NULL);
 	if (dram) {
 		ret = pci_read_config_byte(misc, 0x94, &tmp);
-		if (ret)
-			return ret;
+		if (ret) {
+			goto error_pci_cfg_read;
+		}
+
 		ret = pci_read_config_byte(misc, 0x95, &type);
-		if (ret)
-			return ret;
+		if (ret) {
+			goto error_pci_cfg_read;
+		}
 
 		if (type & 0x01) {	/* DDR3 */
 			switch (tmp & 0x07) {
@@ -555,8 +568,9 @@ static int km8xx_mem_type(struct drm_device *dev)
 				PCI_DEVICE_ID_AMD_11H_NB_DRAM, NULL);
 	if (dram) {
 		ret = pci_read_config_byte(misc, 0x94, &type);
-		if (ret)
-			return ret;
+		if (ret) {
+			goto error_pci_cfg_read;
+		}
 
 		switch (tmp & 0x07) {
 		case 0x01:
@@ -572,6 +586,11 @@ static int km8xx_mem_type(struct drm_device *dev)
 			break;
 		}
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -942,9 +961,9 @@ static int via_vram_init(struct drm_device *dev)
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 		break;
 
-	/* K8M800 / K8N800 */
+	/* K8M800(A) / K8N800(A) */
 	case PCI_DEVICE_ID_VIA_8380_0:
-	/* K8M890 */
+	/* K8M890 / K8N890 */
 	case PCI_DEVICE_ID_VIA_VT3336:
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
commit 729126f721e55d6204c34a3bafbe1435d8e95949
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:25 2024 -0600

    drm/via: Check for error after calling p4m800_mem_type()
    
    This was never added by the original developer.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index d1ee2668addc..d25d21af0c4c 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -933,6 +933,8 @@ static int via_vram_init(struct drm_device *dev)
 	/* P4M800 */
 	case PCI_DEVICE_ID_VIA_3296_0:
 		ret = p4m800_mem_type(dev);
+		if (ret)
+			goto error_hb_fn3;
 
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
commit ea6e426716afe9cfc88da9a64ae69786ab555a37
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:25 2024 -0600

    drm/via: Drop recognizing 233 MHz FSB base clock inside p4m800_mem_type()
    
    This frequency was never officially supported by this chipset, so
    stop recognizing it.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 82942aa7052e..d1ee2668addc 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -399,9 +399,6 @@ static int p4m800_mem_type(struct drm_device *dev)
 	case 0x02:
 		freq = 0x06; /* 200 MHz */
 		break;
-	case 0x04:
-		freq = 0x07; /* 233 MHz */
-		break;
 	default:
 		break;
 	}
commit 5feb0841ddf832778e59b9f90e68c20d4de81588
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:20 2024 -0600

    drm/via: Drop recognizing 166 MHz FSB base clock inside p4m800_mem_type()
    
    This frequency was never officially supported by this chipset, so
    stop recognizing it.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index d692e3bcbbe7..82942aa7052e 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -396,9 +396,6 @@ static int p4m800_mem_type(struct drm_device *dev)
 	case 0x01:
 		freq = 0x04; /* 133 MHz */
 		break;
-	case 0x03:
-		freq = 0x05; /* 166 MHz */
-		break;
 	case 0x02:
 		freq = 0x06; /* 200 MHz */
 		break;
commit 219279a2cb02140203a054c439e751ffeb8c12b2
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:18 2024 -0600

    drm/via: Updates to p4m800_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 370c74051938..d692e3bcbbe7 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -353,51 +353,71 @@ exit:
 	return ret;
 }
 
-static int p4m800_mem_type(struct drm_device *dev,
-				struct pci_bus *bus,
-				struct pci_dev *fn3)
+static int p4m800_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn3_dev, *bridge_fn4_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
-	struct pci_dev *fn4 = pci_get_slot(bus, PCI_DEVFN(0, 4));
-	int ret, freq = 0;
-	u8 type, fsb;
+	int freq = 0;
+	u8 fsb, type;
+	int ret;
+
+	bridge_fn3_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 3));
+	if (!bridge_fn3_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 3 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	bridge_fn4_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 4));
+	if (!bridge_fn4_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 4 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
 
 	/* VIA Scratch region */
-	ret = pci_read_config_byte(fn4, 0xf3, &fsb);
+	ret = pci_read_config_byte(bridge_fn4_dev, 0xf3, &fsb);
 	if (ret) {
-		pci_dev_put(fn4);
-		return ret;
+		goto error_pci_cfg_read;
 	}
 
-	switch (fsb >> 5) {
-	case 0:
-		freq = 3; /* 100 MHz */
+	fsb >>= 5;
+	switch (fsb) {
+	case 0x00:
+		freq = 0x03; /* 100 MHz */
 		break;
-	case 1:
-		freq = 4; /* 133 MHz */
+	case 0x01:
+		freq = 0x04; /* 133 MHz */
 		break;
-	case 3:
-		freq = 5; /* 166 MHz */
+	case 0x03:
+		freq = 0x05; /* 166 MHz */
 		break;
-	case 2:
-		freq = 6; /* 200 MHz */
+	case 0x02:
+		freq = 0x06; /* 200 MHz */
 		break;
-	case 4:
-		freq = 7; /* 233 MHz */
+	case 0x04:
+		freq = 0x07; /* 233 MHz */
 		break;
 	default:
 		break;
 	}
-	pci_dev_put(fn4);
 
-	ret = pci_read_config_byte(fn3, 0x68, &type);
-	if (ret)
-		return ret;
-	type &= 0x0f;
+	ret = pci_read_config_byte(bridge_fn3_dev, 0x68, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
-	if (type & 0x02)
+	type &= 0x0f;
+	if (type & 0x02) {
 		freq -= type >> 2;
-	else {
+	} else {
 		freq += type >> 2;
 		if (type & 0x01)
 			freq++;
@@ -419,6 +439,11 @@ static int p4m800_mem_type(struct drm_device *dev,
 	default:
 		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -913,7 +938,7 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* P4M800 */
 	case PCI_DEVICE_ID_VIA_3296_0:
-		ret = p4m800_mem_type(dev, bus, hb_fn3);
+		ret = p4m800_mem_type(dev);
 
 		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
commit 602a11a97064530867d2f9e699e222a0fb3c6c03
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:18 2024 -0600

    drm/via: Check for error after calling km400_mem_type()
    
    This was never added by the original developer.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 39a59d7787ed..370c74051938 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -902,6 +902,8 @@ static int via_vram_init(struct drm_device *dev)
 	/* KM400(A) / KN400(A) */
 	case PCI_DEVICE_ID_VIA_8378_0:
 		ret = km400_mem_type(dev);
+		if (ret)
+			goto error_hb_fn0;
 
 		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
 		if (ret)
commit c291677fdc9fdcbafdfb3a7cb1d8738312ae675d
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:16 2024 -0600

    drm/via: Updates to km400_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index d3a52035a202..39a59d7787ed 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -168,25 +168,41 @@ exit:
 	return ret;
 }
 
-static int km400_mem_type(struct drm_device *dev,
-				struct pci_dev *bridge)
+static int km400_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn0_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
 	u8 fsb, freq, rev;
 	int ret;
 
-	ret = pci_read_config_byte(bridge, 0xf6, &rev);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(bridge, 0x54, &fsb);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(bridge, 0x69, &freq);
-	if (ret)
-		return ret;
+	bridge_fn0_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 0));
+	if (!bridge_fn0_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 0 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0x54, &fsb);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0x69, &freq);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
-	freq >>= 6;
 	fsb >>= 6;
+	freq >>= 6;
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0xf6, &rev);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
 	/* KM400 */
 	if (rev < 0x80) {
@@ -209,8 +225,8 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
-			break;
 
+			break;
 		case 0x01:
 			switch (freq) {
 			case 0x00:
@@ -225,8 +241,8 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
-			break;
 
+			break;
 		case 0x02:
 		case 0x03:
 			switch (freq) {
@@ -242,15 +258,18 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
+
 			break;
 		default:
 			break;
 		}
 	} else {
 		/* KM400A */
-		ret = pci_read_config_byte(bridge, 0x67, &rev);
-		if (ret)
-			return ret;
+		ret = pci_read_config_byte(bridge_fn0_dev, 0x67, &rev);
+		if (ret) {
+			goto error_pci_cfg_read;
+		}
+
 		if (rev & 0x80)
 			freq |= 0x04;
 
@@ -270,11 +289,10 @@ static int km400_mem_type(struct drm_device *dev,
 				dev_priv->vram_type = VIA_MEM_DDR_400;
 				break;
 			default:
-				dev_priv->vram_type = VIA_MEM_NONE;
 				break;
 			}
-			break;
 
+			break;
 		case 0x01:
 			switch (freq) {
 			case 0x00:
@@ -289,8 +307,8 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
-			break;
 
+			break;
 		case 0x02:
 			switch (freq) {
 			case 0x00:
@@ -305,8 +323,8 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
-			break;
 
+			break;
 		case 0x03:
 			switch (freq) {
 			case 0x00:
@@ -321,11 +339,17 @@ static int km400_mem_type(struct drm_device *dev,
 			default:
 				break;
 			}
+
 			break;
 		default:
 			break;
 		}
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -875,9 +899,9 @@ static int via_vram_init(struct drm_device *dev)
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
 		break;
 
-	/* KM400 / KN400 / KM400A / KN400A */
+	/* KM400(A) / KN400(A) */
 	case PCI_DEVICE_ID_VIA_8378_0:
-		ret = km400_mem_type(dev, hb_fn0);
+		ret = km400_mem_type(dev);
 
 		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
 		if (ret)
commit a564b40eb70a734b099ff2012d3aeb0e254dee8b
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:15:03 2024 -0600

    drm/via: Updates to cle266_mem_type()
    
    The function will now acquire a pointer to the relevant PCI bridge
    device within it.  Improved its error handling within the function.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 79bbc05a98df..d3a52035a202 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -41,22 +41,36 @@
 #include "via_drv.h"
 
 
-static int cle266_mem_type(struct drm_device *dev,
-				struct pci_dev *bridge)
+static int cle266_mem_type(struct drm_device *dev)
 {
+	struct pci_dev *gfx_dev = to_pci_dev(dev->dev);
+	struct pci_dev *bridge_fn0_dev;
 	struct via_drm_priv *dev_priv = to_via_drm_priv(dev);
-	u8 type, fsb, freq;
+	u8 fsb, freq, type;
 	int ret;
 
-	ret = pci_read_config_byte(bridge, 0x54, &fsb);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(bridge, 0x69, &freq);
-	if (ret)
-		return ret;
+	bridge_fn0_dev =
+		pci_get_domain_bus_and_slot(pci_domain_nr(gfx_dev->bus), 0,
+						PCI_DEVFN(0, 0));
+	if (!bridge_fn0_dev) {
+		ret = -ENODEV;
+		drm_err(dev, "Host Bridge Function 0 not found! errno: %d\n",
+			ret);
+		goto exit;
+	}
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0x54, &fsb);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0x69, &freq);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
-	freq >>= 6;
 	fsb >>= 6;
+	freq >>= 6;
 
 	/* FSB frequency */
 	switch (fsb) {
@@ -75,8 +89,8 @@ static int cle266_mem_type(struct drm_device *dev,
 			freq = 0;
 			break;
 		}
-		break;
 
+		break;
 	case 0x02: /* 133 MHz */
 	case 0x03:
 		switch (freq) {
@@ -90,22 +104,27 @@ static int cle266_mem_type(struct drm_device *dev,
 			freq = 0;
 			break;
 		}
+
 		break;
 	default:
 		freq = 0;
 		break;
 	}
 
-	ret = pci_read_config_byte(bridge, 0x60, &fsb);
-	if (ret)
-		return ret;
-	ret = pci_read_config_byte(bridge, 0xe3, &type);
-	if (ret)
-		return ret;
+	ret = pci_read_config_byte(bridge_fn0_dev, 0x60, &fsb);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
+
+	ret = pci_read_config_byte(bridge_fn0_dev, 0xe3, &type);
+	if (ret) {
+		goto error_pci_cfg_read;
+	}
 
 	/* On bank 2/3 */
-	if (type & 0x02)
+	if (type & 0x02) {
 		fsb >>= 2;
+	}
 
 	/* Memory type */
 	switch (fsb & 0x03) {
@@ -123,8 +142,8 @@ static int cle266_mem_type(struct drm_device *dev,
 		default:
 			break;
 		}
-		break;
 
+		break;
 	case 0x02: /* DDR */
 		switch (freq) {
 		case 100:
@@ -136,10 +155,16 @@ static int cle266_mem_type(struct drm_device *dev,
 		default:
 			break;
 		}
+
 		break;
 	default:
 		break;
 	}
+
+	goto exit;
+error_pci_cfg_read:
+	drm_err(dev, "PCI configuration space read error! errno: %d\n", ret);
+exit:
 	return ret;
 }
 
@@ -840,7 +865,7 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* CLE266 */
 	case PCI_DEVICE_ID_VIA_862X_0:
-		ret = cle266_mem_type(dev, hb_fn0);
+		ret = cle266_mem_type(dev);
 		if (ret)
 			goto error_hb_fn0;
 
commit dfaf1d5016105d03f66d2f6137be1fa3e3151589
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:14:55 2024 -0600

    drm/via: Convert uppercase hexadecimals to lowercase inside via_init.c
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 48ad32ed56cf..79bbc05a98df 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -99,7 +99,7 @@ static int cle266_mem_type(struct drm_device *dev,
 	ret = pci_read_config_byte(bridge, 0x60, &fsb);
 	if (ret)
 		return ret;
-	ret = pci_read_config_byte(bridge, 0xE3, &type);
+	ret = pci_read_config_byte(bridge, 0xe3, &type);
 	if (ret)
 		return ret;
 
@@ -150,7 +150,7 @@ static int km400_mem_type(struct drm_device *dev,
 	u8 fsb, freq, rev;
 	int ret;
 
-	ret = pci_read_config_byte(bridge, 0xF6, &rev);
+	ret = pci_read_config_byte(bridge, 0xf6, &rev);
 	if (ret)
 		return ret;
 	ret = pci_read_config_byte(bridge, 0x54, &fsb);
@@ -314,7 +314,7 @@ static int p4m800_mem_type(struct drm_device *dev,
 	u8 type, fsb;
 
 	/* VIA Scratch region */
-	ret = pci_read_config_byte(fn4, 0xF3, &fsb);
+	ret = pci_read_config_byte(fn4, 0xf3, &fsb);
 	if (ret) {
 		pci_dev_put(fn4);
 		return ret;
@@ -386,7 +386,7 @@ static int km8xx_mem_type(struct drm_device *dev)
 		misc = pci_get_device(PCI_VENDOR_ID_AMD,
 				PCI_DEVICE_ID_AMD_K8_NB_MISC, NULL);
 
-		ret = pci_read_config_byte(misc, 0xFD, &type);
+		ret = pci_read_config_byte(misc, 0xfd, &type);
 		if (type) {
 			pci_read_config_byte(dram, 0x94, &type);
 			switch (type & 0x03) {
@@ -617,7 +617,7 @@ static int cx700_mem_type(struct drm_device *dev,
 	ret = pci_read_config_byte(fn3, 0x90, &clock);
 	if (ret)
 		return ret;
-	ret = pci_read_config_byte(fn3, 0x6C, &type);
+	ret = pci_read_config_byte(fn3, 0x6c, &type);
 	if (ret)
 		return ret;
 	type &= 0x40;
@@ -677,18 +677,18 @@ static int vx900_mem_type(struct drm_device *dev,
 	ret = pci_read_config_byte(fn3, 0x90, &clock);
 	if (ret)
 		return ret;
-	ret = pci_read_config_byte(fn3, 0x6C, &type);
+	ret = pci_read_config_byte(fn3, 0x6c, &type);
 	if (ret)
 		return ret;
 	volt = type;
-	type &= 0xC0;
+	type &= 0xc0;
 	type >>= 6;
 	volt &= 0x20;
 	volt >>= 5;
 
 	switch (type) {
 	case 1:
-		switch (clock & 0x0F) {
+		switch (clock & 0x0f) {
 		case 0:
 			if (volt)
 				dev_priv->vram_type = VIA_MEM_DDR2_800;
@@ -712,7 +712,7 @@ static int vx900_mem_type(struct drm_device *dev,
 		}
 		break;
 	case 2:
-		switch (clock & 0x0F) {
+		switch (clock & 0x0f) {
 		case 0:
 			if (volt)
 				dev_priv->vram_type = VIA_MEM_DDR3_800;
@@ -844,7 +844,7 @@ static int via_vram_init(struct drm_device *dev)
 		if (ret)
 			goto error_hb_fn0;
 
-		ret = pci_read_config_byte(hb_fn0, 0xE1, &size);
+		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
 		if (ret)
 			goto error_hb_fn0;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -854,7 +854,7 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_8378_0:
 		ret = km400_mem_type(dev, hb_fn0);
 
-		ret = pci_read_config_byte(hb_fn0, 0xE1, &size);
+		ret = pci_read_config_byte(hb_fn0, 0xe1, &size);
 		if (ret)
 			goto error_hb_fn0;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -864,7 +864,7 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_3296_0:
 		ret = p4m800_mem_type(dev, bus, hb_fn3);
 
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -874,7 +874,7 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_8380_0:
 	/* K8M890 */
 	case PCI_DEVICE_ID_VIA_VT3336:
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -889,7 +889,7 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* CN400 / PM800 / PM880 */
 	case PCI_DEVICE_ID_VIA_PX8X0_0:
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -903,7 +903,7 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_P4M800CE:
 	/* P4M900 / VN896 / CN896 */
 	case PCI_DEVICE_ID_VIA_VT3364:
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 20;
@@ -924,7 +924,7 @@ static int via_vram_init(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_VX800_HB:
 	/* VX855 / VX875 */
 	case PCI_DEVICE_ID_VIA_VX855_HB:
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
@@ -936,7 +936,7 @@ static int via_vram_init(struct drm_device *dev)
 
 	/* VX900 */
 	case PCI_DEVICE_ID_VIA_VX900_HB:
-		ret = pci_read_config_byte(hb_fn3, 0xA1, &size);
+		ret = pci_read_config_byte(hb_fn3, 0xa1, &size);
 		if (ret)
 			goto error_hb_fn3;
 		dev_priv->vram_size = (1 << ((size & 0x70) >> 4)) << 22;
@@ -1097,8 +1097,8 @@ static void via_graphics_unlock(struct drm_device *dev)
 	/*
 	 * Enable VGA subsystem.
 	 */
-	temp = vga_io_r(0x03C3);
-	vga_io_w(0x03C3, temp | 0x01);
+	temp = vga_io_r(0x03c3);
+	vga_io_w(0x03c3, temp | 0x01);
 	svga_wmisc_mask(VGABASE, BIT(0), BIT(0));
 
 	/*
@@ -1128,16 +1128,16 @@ static void via_chip_revision_info(struct drm_device *dev)
 	/* CLE266 Chipset */
 	case PCI_DEVICE_ID_VIA_CLE266_GFX:
 		/* CR4F only defined in CLE266.CX chipset. */
-		tmp = vga_rcrt(VGABASE, 0x4F);
-		vga_wcrt(VGABASE, 0x4F, 0x55);
-		if (vga_rcrt(VGABASE, 0x4F) != 0x55) {
+		tmp = vga_rcrt(VGABASE, 0x4f);
+		vga_wcrt(VGABASE, 0x4f, 0x55);
+		if (vga_rcrt(VGABASE, 0x4f) != 0x55) {
 			dev_priv->revision = CLE266_REVISION_AX;
 		} else {
 			dev_priv->revision = CLE266_REVISION_CX;
 		}
 
 		/* Restore original CR4F value. */
-		vga_wcrt(VGABASE, 0x4F, tmp);
+		vga_wcrt(VGABASE, 0x4f, tmp);
 		break;
 	/* CX700 / VX700 Chipset */
 	case PCI_DEVICE_ID_VIA_UNICHROME_PRO_II:
@@ -1158,7 +1158,7 @@ static void via_chip_revision_info(struct drm_device *dev)
 	case PCI_DEVICE_ID_VIA_CHROME9_HCM:
 	/* VX900 Chipset */
 	case PCI_DEVICE_ID_VIA_CHROME9_HD:
-		dev_priv->revision = vga_rseq(VGABASE, 0x3B);
+		dev_priv->revision = vga_rseq(VGABASE, 0x3b);
 		break;
 	default:
 		break;
commit 9562dde1367b8d4840ccfd60f1e014267cb3e287
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Mon Jan 15 18:14:44 2024 -0600

    drm/via: Unknown Host Bidge typo
    
    It should be Unknown Host Bridge.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/drivers/gpu/drm/via/via_init.c b/drivers/gpu/drm/via/via_init.c
index 661bf6e199fc..48ad32ed56cf 100644
--- a/drivers/gpu/drm/via/via_init.c
+++ b/drivers/gpu/drm/via/via_init.c
@@ -948,7 +948,7 @@ static int via_vram_init(struct drm_device *dev)
 
 	default:
 		ret = -ENODEV;
-		drm_err(dev, "Unknown Host Bidge device: 0x%04x\n",
+		drm_err(dev, "Unknown Host Bridge device: 0x%04x\n",
 				hb_fn0->device);
 		goto error_hb_fn3;
 	}


More information about the openchrome-devel mailing list