Message ID | 20240229195532.7815-1-christian.gmeiner@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp643410dyb; Thu, 29 Feb 2024 11:56:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgnkQLVnHXTDYm9v1p5ZOCmC7BjEwBdGxnppoZNtW+cNUN6yP9TY3avs+Q1aNDFW0luyfpvL5fNUJedebZoa//bofLGw== X-Google-Smtp-Source: AGHT+IGsZq8ef1hJ7/WUd6YcSsrpvhy4Qml6326ipsZQxc++yYIILXBEcq8VSNBnIMYw0Jv9k0uK X-Received: by 2002:ac8:7d8f:0:b0:42e:aa68:a4b4 with SMTP id c15-20020ac87d8f000000b0042eaa68a4b4mr4416745qtd.13.1709236575906; Thu, 29 Feb 2024 11:56:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709236575; cv=pass; d=google.com; s=arc-20160816; b=O1vTw9PziLNtDPMLHEspuWP3Z2HQwAWU8mM3JdGkz0JIrVFca/6WpD0iRTTjaK+tdq HdfCX8m8cVS5WY3S5/OCE2aG6xxKkzDyw7p7PRJcXmvtqYb+v8eQ4oviD80lfMDctiJb RMxjE23dd0NG57YJFe5tbUz192GXYmYOkmG2fghOi4WP8KFcIeFQlIA1Yj0mrLOTv/a2 AOxyzK+DQOg7krUQc6QObb/7llDENuIZqcBqzIIsXT2yEozD8SxyBiNUMoxLqm+QERCR 5/62vO1Bk6lzElYPeOI23sJLak6ynUVnfNjpZwuk7HTmV7wl4HRLGkjws7di+fPobUb1 xiWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=y3dRCI30Cqlop6Z/piqJrZ5N5wWPVcx8trh55DUTij0=; fh=7XnaVhbzZtEnmjw559TLN8UWorVGYgX+iWEwKb5v+f8=; b=vpwGxugb9hndKymd574VwUWzSArg53oazjEESy1tBbJd0SwxqNqSULvoRIuCWhOuAm NFICYkf5tPJLeX9S8JudYYRIKDb8GLoUUokqpKfJ+E11rhJcyjkDMsJOW25Zd1tJTAnB ZDY9xQ1lKnxm6DFhhjU5c3W0EENWSsEMfwHH+2kbL/bkcD5KQUdgTZS5NfAfEkdN96XR IfhD3TRqVYLOUx0mDY5ofQ1Itack8tMGEMlTlH0OOfTY0PhafqcrZEZRFIdxuS2fLQbf bTR+MLc5mP/hB2Y3z7KZADoK8HEy0Jbdj6/qgoba19mWv8jhmS9FsYsvO9J9s/kl4BPD au5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ACdicXmw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o25-20020ac872d9000000b0042c4534b298si1915186qtp.263.2024.02.29.11.56.15 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 11:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ACdicXmw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87393-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D8931C21C55 for <ouuuleilei@gmail.com>; Thu, 29 Feb 2024 19:56:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6606213F454; Thu, 29 Feb 2024 19:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ACdicXmw" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31B9313C9F7; Thu, 29 Feb 2024 19:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709236563; cv=none; b=L5hNYnjmdk6lmqFyUUsWylErvX4BrtqrjER3/5SD5HkDySN78kmiDaOTNgbXWZhnhiT09u65zRcImxcSrVY5iYXv8uiybcTcveYfy9Xe5lAS+eBTwTpaASjQsfFvCbuJCSibSUBu+za86Fhe2FxOJup0Dfgox6ITzBQmov0R9Hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709236563; c=relaxed/simple; bh=NVI5WFKeuJH0tx6oWGjB5QE4SI3b+PhYHwaN02LOX7I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KUuMYxQxgQa3vYl0ZOn46NB5dvH1e37z8i5yQ3PENqMti4xlcmNJUemxHjOvMqr6MkcD7+61PvNyjdckjIS+BTTBEDmTIAFaGvSV5o90j3R0yFH5w/7B9wQ9qEuPlKm+gJOzWKAA8j8xzEj+tuLiFbavSmjvnurJCa6PWjZlaW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ACdicXmw; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a44665605f3so83288066b.2; Thu, 29 Feb 2024 11:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709236556; x=1709841356; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y3dRCI30Cqlop6Z/piqJrZ5N5wWPVcx8trh55DUTij0=; b=ACdicXmwY7VJDaymlfb8CmBOswjUhBDoKCTT/gGmdmEGNnyZZrDjFZ3GxzYq1eTPHP MsTpIoCbYktadsqeSetsb5F+UKIaUUN5q/FZ3XTMJI3vQPdyczfyRS86zLOcCbuJW00s cW/ogbCBWjM8UVtVAnBAvx4pnnuDOZzIUGLOjocovJOS+ANC5PS5q8kpNStIstlUG0+7 ikyFUSWPrbnFmi8mpzf31W6dTSrrAiqC/DuA467wit+i1u22URCqd/bW2m/DbDXvZgyE rJXUaX9CJZR9js5hMx8y5sOtT7XaK9N/dUnM0PeDVEDYweisbvdBGGlCoZv+pPlxcLIq j4UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709236556; x=1709841356; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y3dRCI30Cqlop6Z/piqJrZ5N5wWPVcx8trh55DUTij0=; b=g0AxiyNYG9pRaNa5IyRHtmFcNHuRWPnxBJ9hAgnF9pOA/r1B2WzwOOmdsWGYl/rSnW ycATGh6upDsZ7NXaxZtm1j1XEskw8Goy8p0Bic9aY6NDL8sdqdyA+E7z8IbL+MEWT0Eo r5D++B+XWGZPDRu5sTnZQTYb//EfXk3ERnIOf/O6/FI1bwohcLeVD2QQRIsEc9JC663P 0A8+5An0FJPVOt3UjLuG00QGTJ2DcrVjnnPJWdl8+4nxRHtC9+SEvPf6YabDbsrQeMkb mzaK8XAi0ip0gs56FnFGX88bveISglGObhSOTccHuBgwKE0ZUdJAcDhS1F4zRFZ0j5Wz Wgqw== X-Forwarded-Encrypted: i=1; AJvYcCXKo7TIXbXKWZeTQlyOComTHSoV4mz3KqLqiWkYsS5O8aqTbEjlBe0tQgSXpbCVB9VOVkASm2emw6/mbicnmfva+T0//3hgKA1Jn+JsEoetlTAvpZsyKjFMJPVczx5SuRQEsCuH X-Gm-Message-State: AOJu0YxUfJu5hShmhI+vqhY4PbtKrp/1uOKAYFsx2BJItYnKiFo82Iwc PDFtLHGYqvVvAAuCWhLUUH9ZrQJr0HxXV03KXO4I4FGMRYQyTddU X-Received: by 2002:a17:906:71d8:b0:a41:2f5e:f9b4 with SMTP id i24-20020a17090671d800b00a412f5ef9b4mr2226517ejk.59.1709236556351; Thu, 29 Feb 2024 11:55:56 -0800 (PST) Received: from localhost.localdomain (80-108-76-242.cable.dynamic.surfer.at. [80.108.76.242]) by smtp.gmail.com with ESMTPSA id ti9-20020a170907c20900b00a43a4e405bbsm983214ejc.115.2024.02.29.11.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 11:55:55 -0800 (PST) From: Christian Gmeiner <christian.gmeiner@gmail.com> To: Lucas Stach <l.stach@pengutronix.de>, Russell King <linux+etnaviv@armlinux.org.uk>, Christian Gmeiner <christian.gmeiner@gmail.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: Christian Gmeiner <cgmeiner@igalia.com>, stable@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] etnaviv: Restore some id values Date: Thu, 29 Feb 2024 20:55:31 +0100 Message-ID: <20240229195532.7815-1-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792264451843704535 X-GMAIL-MSGID: 1792264451843704535 |
Series |
etnaviv: Restore some id values
|
|
Commit Message
Christian Gmeiner
Feb. 29, 2024, 7:55 p.m. UTC
From: Christian Gmeiner <cgmeiner@igalia.com> 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> --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- drivers/gpu/drm/etnaviv/etnaviv_hwdb.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
Comments
On Thu, Feb 29, 2024 at 8:55 PM Christian Gmeiner <christian.gmeiner@gmail.com> wrote: > > From: Christian Gmeiner <cgmeiner@igalia.com> > > 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 Oops. Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net> Cheers, Tomeu > Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> > --- > drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- > drivers/gpu/drm/etnaviv/etnaviv_hwdb.c | 14 ++++++++++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > index 6228ce603248..9a2965741dab 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > @@ -494,7 +494,7 @@ static const struct drm_driver etnaviv_drm_driver = { > .desc = "etnaviv DRM", > .date = "20151214", > .major = 1, > - .minor = 3, > + .minor = 4, > }; > > /* > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > index 67201242438b..1e38d66702f1 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > @@ -265,6 +265,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++) { > @@ -278,6 +281,17 @@ 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 if ~0U aka 'don't care' is used. */ > + if (etnaviv_chip_identities[i].product_id == ~0U) > + ident->product_id = product_id; > + > + if (etnaviv_chip_identities[i].customer_id == ~0U) > + ident->customer_id = customer_id; > + > + if (etnaviv_chip_identities[i].eco_id == ~0U) > + ident->eco_id = eco_id; > + > return true; > } > } > -- > 2.44.0 >
Hi Christian, prefix for etnaviv kernel patches should be "drm/etnaviv: ..." Am Donnerstag, dem 29.02.2024 um 20:55 +0100 schrieb Christian Gmeiner: > From: Christian Gmeiner <cgmeiner@igalia.com> > > 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. Uh, right. Lying to userspace about the GPU identity doesn't seem like a good idea. > > Fixes: 4078a1186dd3 ("drm/etnaviv: update hwdb selection logic") > Cc: stable@vger.kernel.org > Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> > --- > drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- > drivers/gpu/drm/etnaviv/etnaviv_hwdb.c | 14 ++++++++++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > index 6228ce603248..9a2965741dab 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > @@ -494,7 +494,7 @@ static const struct drm_driver etnaviv_drm_driver = { > .desc = "etnaviv DRM", > .date = "20151214", > .major = 1, > - .minor = 3, > + .minor = 4, > }; > > /* > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > index 67201242438b..1e38d66702f1 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > @@ -265,6 +265,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++) { > @@ -278,6 +281,17 @@ 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 if ~0U aka 'don't care' is used. */ > + if (etnaviv_chip_identities[i].product_id == ~0U) You can drop all those if clauses. Either the hwdb value is an exact match and the value is the same or it's the don't care value and you want to restore it, so a simple unconditional assignment would make this a bit more compact. Regards, Lucas > + ident->product_id = product_id; > + > + if (etnaviv_chip_identities[i].customer_id == ~0U) > + ident->customer_id = customer_id; > + > + if (etnaviv_chip_identities[i].eco_id == ~0U) > + ident->eco_id = eco_id; > + > return true; > } > }
Hi Lucas, > > prefix for etnaviv kernel patches should be "drm/etnaviv: ..." Ah yeah .. corrected in v2. > > Am Donnerstag, dem 29.02.2024 um 20:55 +0100 schrieb Christian Gmeiner: > > From: Christian Gmeiner <cgmeiner@igalia.com> > > > > 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. > > Uh, right. Lying to userspace about the GPU identity doesn't seem like > a good idea. > > > > > Fixes: 4078a1186dd3 ("drm/etnaviv: update hwdb selection logic") > > Cc: stable@vger.kernel.org > > Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> > > --- > > drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +- > > drivers/gpu/drm/etnaviv/etnaviv_hwdb.c | 14 ++++++++++++++ > > 2 files changed, 15 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > > index 6228ce603248..9a2965741dab 100644 > > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c > > @@ -494,7 +494,7 @@ static const struct drm_driver etnaviv_drm_driver = { > > .desc = "etnaviv DRM", > > .date = "20151214", > > .major = 1, > > - .minor = 3, > > + .minor = 4, > > }; > > > > /* > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > > index 67201242438b..1e38d66702f1 100644 > > --- a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c > > @@ -265,6 +265,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++) { > > @@ -278,6 +281,17 @@ 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 if ~0U aka 'don't care' is used. */ > > + if (etnaviv_chip_identities[i].product_id == ~0U) > > You can drop all those if clauses. Either the hwdb value is an exact > match and the value is the same or it's the don't care value and you > want to restore it, so a simple unconditional assignment would make > this a bit more compact. > Makes sense - thanks for your review!
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 6228ce603248..9a2965741dab 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -494,7 +494,7 @@ static const struct drm_driver etnaviv_drm_driver = { .desc = "etnaviv DRM", .date = "20151214", .major = 1, - .minor = 3, + .minor = 4, }; /* diff --git a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c index 67201242438b..1e38d66702f1 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_hwdb.c @@ -265,6 +265,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++) { @@ -278,6 +281,17 @@ 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 if ~0U aka 'don't care' is used. */ + if (etnaviv_chip_identities[i].product_id == ~0U) + ident->product_id = product_id; + + if (etnaviv_chip_identities[i].customer_id == ~0U) + ident->customer_id = customer_id; + + if (etnaviv_chip_identities[i].eco_id == ~0U) + ident->eco_id = eco_id; + return true; } }