drm/etnaviv: Restore some id values
authorChristian Gmeiner <cgmeiner@igalia.com>
Fri, 1 Mar 2024 13:28:11 +0000 (14:28 +0100)
committerLucas Stach <l.stach@pengutronix.de>
Thu, 7 Mar 2024 09:57:54 +0000 (10:57 +0100)
The hwdb selection logic as a feature that allows it to mark some fields
as 'don't care'. If we match with such a field we memcpy(..)
the current etnaviv_chip_identity into ident.

This step can overwrite some id values read from the GPU with the
'don't care' value.

Fix this issue by restoring the affected values after the memcpy(..).

As this is crucial for user space to know when this feature works as
expected increment the minor version too.

Fixes: 4078a1186dd3 ("drm/etnaviv: update hwdb selection logic")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
drivers/gpu/drm/etnaviv/etnaviv_drv.c
drivers/gpu/drm/etnaviv/etnaviv_hwdb.c

index 4bdfb1c81eff7fc3b823e38c432c641cbdf627c6..491da486c4e53805671b3eede854c78ffef114a9 100644 (file)
@@ -505,7 +505,7 @@ static const struct drm_driver etnaviv_drm_driver = {
        .desc               = "etnaviv DRM",
        .date               = "20151214",
        .major              = 1,
-       .minor              = 3,
+       .minor              = 4,
 };
 
 /*
index 9eb8ca7c5034075958b08f80dbe4fa9c5704e66a..d8e7334de8ceac8d608ad97c04c8c3184db9267b 100644 (file)
@@ -299,6 +299,9 @@ static const struct etnaviv_chip_identity etnaviv_chip_identities[] = {
 bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu)
 {
        struct etnaviv_chip_identity *ident = &gpu->identity;
+       const u32 product_id = ident->product_id;
+       const u32 customer_id = ident->customer_id;
+       const u32 eco_id = ident->eco_id;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(etnaviv_chip_identities); i++) {
@@ -312,6 +315,12 @@ bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu)
                         etnaviv_chip_identities[i].eco_id == ~0U)) {
                        memcpy(ident, &etnaviv_chip_identities[i],
                               sizeof(*ident));
+
+                       /* Restore some id values as ~0U aka 'don't care' might been used. */
+                       ident->product_id = product_id;
+                       ident->customer_id = customer_id;
+                       ident->eco_id = eco_id;
+
                        return true;
                }
        }