[PATCH v3 9/9] drm/loongson: Add an implement for the is_primary_gpu function callback

From: Sui Jingfeng
Date: Tue Jul 11 2023 - 12:44:59 EST


From: Sui Jingfeng <suijingfeng@xxxxxxxxxxx>

Signed-off-by: Sui Jingfeng <suijingfeng@xxxxxxxxxxx>
---
drivers/gpu/drm/loongson/lsdc_drv.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/loongson/lsdc_drv.c b/drivers/gpu/drm/loongson/lsdc_drv.c
index d10a28c2c494..92ef07d6a534 100644
--- a/drivers/gpu/drm/loongson/lsdc_drv.c
+++ b/drivers/gpu/drm/loongson/lsdc_drv.c
@@ -257,6 +257,14 @@ static unsigned int lsdc_vga_set_decode(struct pci_dev *pdev, bool state)
return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
}

+static bool lsdc_is_primary_gpu(struct pci_dev *pdev)
+{
+ struct drm_device *ddev = pci_get_drvdata(pdev);
+ struct lsdc_device *ldev = to_lsdc(ddev);
+
+ return drm_aperture_contain_firmware_fb(ldev->vram_base, ldev->vram_size);
+}
+
static int lsdc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
const struct lsdc_desc *descp;
@@ -289,7 +297,7 @@ static int lsdc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

pci_set_drvdata(pdev, ddev);

- vga_client_register(pdev, lsdc_vga_set_decode, NULL);
+ vga_client_register(pdev, lsdc_vga_set_decode, lsdc_is_primary_gpu);

drm_kms_helper_poll_init(ddev);

--
2.25.1