From: Thomas Zimmermann <tzimmermann@suse.de>
To: Jammy Huang <jammy_huang@aspeedtech.com>,
Dave Airlie <airlied@redhat.com>,
Jocelyn Falempe <jfalempe@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/ast: Get VRAM size from PCI BAR0
Date: Fri, 20 Nov 2026 16:34:12 +0100 [thread overview]
Message-ID: <c93a89cd-2af3-485f-9549-c288fe327c42@suse.de> (raw)
In-Reply-To: <20261111-ast-vram-size-from-bar0-v1-1-dff97e2f8ccd@aspeedtech.com>
Am 11.11.26 um 07:16 schrieb Jammy Huang:
> ast_get_vram_size() decodes the VRAM size from VGACRAA[1:0]. The size
> of PCI BAR0, the framebuffer aperture, already reflects the VGA memory
> size configured in hardware, so the separate register lookup is
> redundant. Using the BAR size also guarantees that the VRAM mapping
> never extends beyond the aperture that the device decodes.
>
> Take the VRAM size from BAR0 and keep subtracting the reserved region
> given by VGACR99[1:0].
>
> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> The ast driver currently determines the VRAM size by decoding
> VGACRAA[1:0]. Since the size of PCI BAR0 already reflects the VGA
> memory size configured in hardware, use it directly and drop the
> register lookup. The reserved region reported in VGACR99[1:0] is still
> subtracted from the result.
> ---
> drivers/gpu/drm/ast/ast_mm.c | 27 +++++----------------------
> 1 file changed, 5 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_mm.c b/drivers/gpu/drm/ast/ast_mm.c
> index 0bc14031946..6ef686cca5b 100644
> --- a/drivers/gpu/drm/ast/ast_mm.c
> +++ b/drivers/gpu/drm/ast/ast_mm.c
> @@ -33,26 +33,10 @@
>
> #include "ast_drv.h"
>
> -static u32 ast_get_vram_size(struct ast_device *ast)
> +static resource_size_t ast_get_vram_size(struct ast_device *ast, resource_size_t bar_size)
> {
> - u32 vram_size;
> - u8 vgacr99, vgacraa;
> -
> - vgacraa = ast_get_index_reg(ast, AST_IO_VGACRI, 0xaa);
> - switch (vgacraa & AST_IO_VGACRAA_VGAMEM_SIZE_MASK) {
> - case 0:
> - vram_size = SZ_8M;
> - break;
> - case 1:
> - vram_size = SZ_16M;
> - break;
> - case 2:
> - vram_size = SZ_32M;
> - break;
> - case 3:
> - vram_size = SZ_64M;
> - break;
> - }
> + resource_size_t vram_size = bar_size;
> + u8 vgacr99;
>
> vgacr99 = ast_get_index_reg(ast, AST_IO_VGACRI, 0x99);
> switch (vgacr99 & AST_IO_VGACR99_VGAMEM_RSRV_MASK) {
> @@ -74,8 +58,7 @@ int ast_mm_init(struct ast_device *ast)
> {
> struct drm_device *dev = &ast->base;
> struct pci_dev *pdev = to_pci_dev(dev->dev);
> - resource_size_t base, size;
> - u32 vram_size;
> + resource_size_t base, size, vram_size;
>
> base = pci_resource_start(pdev, 0);
> size = pci_resource_len(pdev, 0);
> @@ -84,7 +67,7 @@ int ast_mm_init(struct ast_device *ast)
> devm_arch_io_reserve_memtype_wc(dev->dev, base, size);
> devm_arch_phys_wc_add(dev->dev, base, size);
>
> - vram_size = ast_get_vram_size(ast);
> + vram_size = ast_get_vram_size(ast, size);
>
> ast->vram = devm_ioremap_wc(dev->dev, base, vram_size);
> if (!ast->vram)
>
> ---
> base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
> change-id: 20261111-ast-vram-size-from-bar0-13819df1df24
>
> Best regards,
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
prev parent reply other threads:[~2026-11-20 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 6:16 Jammy Huang
2026-11-20 15:34 ` Thomas Zimmermann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c93a89cd-2af3-485f-9549-c288fe327c42@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jammy_huang@aspeedtech.com \
--cc=jfalempe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®