diff mbox series

[1/2] video: fbdev: intelfb: Use aperture size from pci_resource_len

Message ID 2a722588-e41d-75f7-dad6-944b2b1daa4a@gmail.com
State New
Headers show
Series [1/2] video: fbdev: intelfb: Use aperture size from pci_resource_len | expand

Commit Message

Petr Cvek June 17, 2022, 1:38 p.m. UTC
Aperture size for i9x5 variants is determined from PCI base address.

	if (pci_resource_start(pdev, 2) & 0x08000000)
		*aperture_size = MB(128);
	...

This condition is incorrect as 128 MiB address can have the address
set as 0x?8000000 or 0x?0000000. Also the code can be simplified to just
use pci_resource_len().

The true settings of the aperture size is in the MSAC register, which
could be used instead. However the value is used only as an info message,
so it doesn't matter.

Signed-off-by: Petr Cvek <petrcvekcz@gmail.com>
---
 drivers/video/fbdev/intelfb/intelfbhw.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Helge Deller June 20, 2022, 12:34 p.m. UTC | #1
On 6/17/22 15:38, Petr Cvek wrote:
> Aperture size for i9x5 variants is determined from PCI base address.
>
> 	if (pci_resource_start(pdev, 2) & 0x08000000)
> 		*aperture_size = MB(128);
> 	...
>
> This condition is incorrect as 128 MiB address can have the address
> set as 0x?8000000 or 0x?0000000. Also the code can be simplified to just
> use pci_resource_len().
>
> The true settings of the aperture size is in the MSAC register, which
> could be used instead. However the value is used only as an info message,
> so it doesn't matter.
>
> Signed-off-by: Petr Cvek <petrcvekcz@gmail.com>

applied both patches to the fbdev tree.

Thanks!
Helge


> ---
>  drivers/video/fbdev/intelfb/intelfbhw.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/video/fbdev/intelfb/intelfbhw.c b/drivers/video/fbdev/intelfb/intelfbhw.c
> index 57aff7450bce..2086e06532ee 100644
> --- a/drivers/video/fbdev/intelfb/intelfbhw.c
> +++ b/drivers/video/fbdev/intelfb/intelfbhw.c
> @@ -201,13 +201,11 @@ int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
>  	case PCI_DEVICE_ID_INTEL_945GME:
>  	case PCI_DEVICE_ID_INTEL_965G:
>  	case PCI_DEVICE_ID_INTEL_965GM:
> -		/* 915, 945 and 965 chipsets support a 256MB aperture.
> -		   Aperture size is determined by inspected the
> -		   base address of the aperture. */
> -		if (pci_resource_start(pdev, 2) & 0x08000000)
> -			*aperture_size = MB(128);
> -		else
> -			*aperture_size = MB(256);
> +		/*
> +		 * 915, 945 and 965 chipsets support 64MB, 128MB or 256MB
> +		 * aperture. Determine size from PCI resource length.
> +		 */
> +		*aperture_size = pci_resource_len(pdev, 2);
>  		break;
>  	default:
>  		if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)
diff mbox series

Patch

diff --git a/drivers/video/fbdev/intelfb/intelfbhw.c b/drivers/video/fbdev/intelfb/intelfbhw.c
index 57aff7450bce..2086e06532ee 100644
--- a/drivers/video/fbdev/intelfb/intelfbhw.c
+++ b/drivers/video/fbdev/intelfb/intelfbhw.c
@@ -201,13 +201,11 @@  int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
 	case PCI_DEVICE_ID_INTEL_945GME:
 	case PCI_DEVICE_ID_INTEL_965G:
 	case PCI_DEVICE_ID_INTEL_965GM:
-		/* 915, 945 and 965 chipsets support a 256MB aperture.
-		   Aperture size is determined by inspected the
-		   base address of the aperture. */
-		if (pci_resource_start(pdev, 2) & 0x08000000)
-			*aperture_size = MB(128);
-		else
-			*aperture_size = MB(256);
+		/*
+		 * 915, 945 and 965 chipsets support 64MB, 128MB or 256MB
+		 * aperture. Determine size from PCI resource length.
+		 */
+		*aperture_size = pci_resource_len(pdev, 2);
 		break;
 	default:
 		if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)