Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp86549rdb; Thu, 25 Jan 2024 08:59:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+ocbax6xev3wupt6Jj/XMRdjNdBhK4ZygfbjODsA57hoVyd0asWQWN0tFxBRXApJbt3+Z X-Received: by 2002:a05:6214:410:b0:685:8d00:da1 with SMTP id z16-20020a056214041000b006858d000da1mr1558859qvx.41.1706201993769; Thu, 25 Jan 2024 08:59:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706201993; cv=pass; d=google.com; s=arc-20160816; b=l/EE8OylJ6JcokHWNW708EoPjlCQGokMRU703IKskfeMd0qZhADIb6JF911wlZRWoB ArJlFFNYnssSa+QfWvw9z2+B9E6ti45QVnRS+/RGzi6sjr0LXXns2Ac+IRQpck455LQE pTkfyvRRpj58hOq8FTRtgiOKiMQ+nuJzfmOx/mdWCsjlOeW4sabnnNlK7kd4wAg/arkB KHVVycByZimX47fIT/Ro4eic0T3uUKR5CjQKrP7hsZMVDBuotIC471ZjfoeYwXexOTRP DU1/XxmLbbdGqIzuNOjjVbkI9y0PKWLWRKMfR+KAsJuf2xTtw2op0XL/ZSGHVnhPo78S gSPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=S9rWoQeDX+lWtCrKkroB8Tne0RuqN55jRQ/sYZ+1j40=; fh=LNWxkbfWBwu7JSwvrpJSKzAeuRT9CgdWfLyPTEPrmno=; b=YHlq+/iD5etVyqx9mtKWUCnxUYEdeQ+MLIdp1mU3cAbqVRXPZT41zKCGqrS0tKzvqg rlUz9TwAlK9mVzFNroRPwPdvQICcpplM32mi5gB3T/sUp+rM6WnzlzNqKI3HNZDzsoye udDO283KTjn4dhmEX6zDroCC21JlAvOskb7mLBSmB+lS5rvIOa2JrhwA2b53N0EgElKE xU1MrXyWPPdXUYyrZDuJ2Wm5yS1APTPv4KrUwWUUtN4NQVXDCmz4x+egPxBENYgeR/J+ R0WY28qjo7WvW9YFl2rPyhnZmJjg76087Mk6mzdRVRAJZMf5ES2AC7tUdMj2cB+sWmQo 5C4A== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-38958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38958-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n4-20020a0c9d44000000b006818be20423si12550617qvf.385.2024.01.25.08.59.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:59:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-38958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38958-linux.lists.archive=gmail.com@vger.kernel.org" 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 78BE01C246A2 for ; Thu, 25 Jan 2024 16:59:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8290A130E28; Thu, 25 Jan 2024 16:51:08 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21D6B12FF9E for ; Thu, 25 Jan 2024 16:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201467; cv=none; b=jkHGQokuLbmP/+fgmnpqNcGc0bkJvOWtW5AudHrxPvHfPJkk/HYPQqaOON6IIL/KUEtj9q5HKAL9B9w8E9ip+kV7MKP/3sHGNzEc9Li/3lQkkS5ghP6NGXWT/l+yVuHsaPuMUcptkRjQLCcKZQBwyUFJmkcUZbWL+Klv2JmCKtE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706201467; c=relaxed/simple; bh=wtfmjZJ7KPghvO4LXTkav9h9b3fxApgrQWu4FggxN3A=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=CAEoSffkPuji4IdphHCDM6U+7wNC5f7bGT09pnhWiuq9ws4Yzsk4DrXNLKId9c3U2HPgnPEI4tUfIg0hdOIlY8n0VFnwkOm4uNSxPiP8fsoIGHVAFiXUP5Vx2r37AmnWwRb0hOfxcM+9DO0lJfs1HX5m64ZwuEkhHCD/Xox2DO0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[IPv6:::1]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rT2wM-0003IL-A5; Thu, 25 Jan 2024 17:50:58 +0100 Message-ID: <516b95eaabc64b4b6c37e7a5840b32203ebcb062.camel@pengutronix.de> Subject: Re: [PATCH v2 2/3] drm/etnaviv: Turn etnaviv_is_model_rev() into a function From: Lucas Stach To: Christian Gmeiner , Philipp Zabel Cc: Russell King , David Airlie , Daniel Vetter , etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Thu, 25 Jan 2024 17:50:57 +0100 In-Reply-To: References: <20240125-etnaviv-npu-v2-0-ba23c9a32be1@pengutronix.de> <20240125-etnaviv-npu-v2-2-ba23c9a32be1@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Am Donnerstag, dem 25.01.2024 um 17:27 +0100 schrieb Christian Gmeiner: > Hi Philipp >=20 > >=20 > > Turn the etnaviv_is_model_rev() macro into a static inline function. > > Use the raw model number as a parameter instead of the chipModel_GCxxxx > > defines. This reduces synchronization requirements for the generated > > headers. For newer hardware, the GCxxxx names are not the correct model > > names anyway. For example, model 0x8000 NPUs are called VIPNano-QI/SI(+= ) > > by VeriSilicon. >=20 > To catch up with your NPU example Vivante's kernel driver has such > lines in its hw database [0] >=20 > /* vipnano-si+ */ > { > 0x8000, /* ChipID */ > 0x8002, /* ChipRevision */ > 0x5080009, /* ProductID */ > 0x6000000, /* EcoID */ > 0x9f, /* CustomerID */ > ... >=20 > I think in reality this function should be called > etnaviv_is_chip_rev(..) or etnaviv_is_id_rev(..). That would be > semantically correct and we could even stick the the current macro > (that gets renamed) and with the current > GCxxx defines. The value for what is called ChipID in the downstream driver is read from a register which is called VIVS_HI_CHIP_MODEL in rnndb. I would like to stay consistent by calling this model in the etnaviv driver. I don't see any value in the GCxxx defines, which only add a (pretty) prefix to a perfectly readable hex number, so I'm fine with changing the current macro and getting rid of any usage of those defines in the driver. Regards, Lucas >=20 > [0]: https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/drivers/mxc/gpu-v= iv/hal/kernel/inc/gc_feature_database.h#L22373 >=20 > >=20 > > Signed-off-by: Philipp Zabel > > --- > > drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 66 ++++++++++++++++++---------= -------- > > 1 file changed, 34 insertions(+), 32 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/et= naviv/etnaviv_gpu.c > > index 9b8445d2a128..c61d50dd3829 100644 > > --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > > @@ -172,10 +172,12 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu= , u32 param, u64 *value) > > return 0; > > } > >=20 > > +static inline bool etnaviv_is_model_rev(struct etnaviv_gpu *gpu, u32 m= odel, u32 revision) > > +{ > > + return gpu->identity.model =3D=3D model && > > + gpu->identity.revision =3D=3D revision; > > +} > >=20 > > -#define etnaviv_is_model_rev(gpu, mod, rev) \ > > - ((gpu)->identity.model =3D=3D chipModel_##mod && \ > > - (gpu)->identity.revision =3D=3D rev) > > #define etnaviv_field(val, field) \ > > (((val) & field##__MASK) >> field##__SHIFT) > >=20 > > @@ -281,7 +283,7 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gp= u) > >=20 > > switch (gpu->identity.instruction_count) { > > case 0: > > - if (etnaviv_is_model_rev(gpu, GC2000, 0x5108) || > > + if (etnaviv_is_model_rev(gpu, 0x2000, 0x5108) || > > gpu->identity.model =3D=3D chipModel_GC880) > > gpu->identity.instruction_count =3D 512; > > else > > @@ -315,17 +317,17 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *= gpu) > > * For some cores, two varyings are consumed for position, so t= he > > * maximum varying count needs to be reduced by one. > > */ > > - if (etnaviv_is_model_rev(gpu, GC5000, 0x5434) || > > - etnaviv_is_model_rev(gpu, GC4000, 0x5222) || > > - etnaviv_is_model_rev(gpu, GC4000, 0x5245) || > > - etnaviv_is_model_rev(gpu, GC4000, 0x5208) || > > - etnaviv_is_model_rev(gpu, GC3000, 0x5435) || > > - etnaviv_is_model_rev(gpu, GC2200, 0x5244) || > > - etnaviv_is_model_rev(gpu, GC2100, 0x5108) || > > - etnaviv_is_model_rev(gpu, GC2000, 0x5108) || > > - etnaviv_is_model_rev(gpu, GC1500, 0x5246) || > > - etnaviv_is_model_rev(gpu, GC880, 0x5107) || > > - etnaviv_is_model_rev(gpu, GC880, 0x5106)) > > + if (etnaviv_is_model_rev(gpu, 0x5000, 0x5434) || > > + etnaviv_is_model_rev(gpu, 0x4000, 0x5222) || > > + etnaviv_is_model_rev(gpu, 0x4000, 0x5245) || > > + etnaviv_is_model_rev(gpu, 0x4000, 0x5208) || > > + etnaviv_is_model_rev(gpu, 0x3000, 0x5435) || > > + etnaviv_is_model_rev(gpu, 0x2200, 0x5244) || > > + etnaviv_is_model_rev(gpu, 0x2100, 0x5108) || > > + etnaviv_is_model_rev(gpu, 0x2000, 0x5108) || > > + etnaviv_is_model_rev(gpu, 0x1500, 0x5246) || > > + etnaviv_is_model_rev(gpu, 0x880, 0x5107) || > > + etnaviv_is_model_rev(gpu, 0x880, 0x5106)) > > gpu->identity.varyings_count -=3D 1; > > } > >=20 > > @@ -351,7 +353,7 @@ static void etnaviv_hw_identify(struct etnaviv_gpu = *gpu) > > * Reading these two registers on GC600 rev 0x19 result= in a > > * unhandled fault: external abort on non-linefetch > > */ > > - if (!etnaviv_is_model_rev(gpu, GC600, 0x19)) { > > + if (!etnaviv_is_model_rev(gpu, 0x600, 0x19)) { > > gpu->identity.product_id =3D gpu_read(gpu, VIVS= _HI_CHIP_PRODUCT_ID); > > gpu->identity.eco_id =3D gpu_read(gpu, VIVS_HI_= CHIP_ECO_ID); > > } > > @@ -368,7 +370,7 @@ static void etnaviv_hw_identify(struct etnaviv_gpu = *gpu) > > } > >=20 > > /* Another special case */ > > - if (etnaviv_is_model_rev(gpu, GC300, 0x2201)) { > > + if (etnaviv_is_model_rev(gpu, 0x300, 0x2201)) { > > u32 chipTime =3D gpu_read(gpu, VIVS_HI_CHIP_TIM= E); > >=20 > > if (chipDate =3D=3D 0x20080814 && chipTime =3D= =3D 0x12051100) { > > @@ -387,15 +389,15 @@ static void etnaviv_hw_identify(struct etnaviv_gp= u *gpu) > > * Fix model/rev here, so all other places can refer to= this > > * core by its real identity. > > */ > > - if (etnaviv_is_model_rev(gpu, GC2000, 0xffff5450)) { > > + if (etnaviv_is_model_rev(gpu, 0x2000, 0xffff5450)) { > > gpu->identity.model =3D chipModel_GC3000; > > gpu->identity.revision &=3D 0xffff; > > } > >=20 > > - if (etnaviv_is_model_rev(gpu, GC1000, 0x5037) && (chipD= ate =3D=3D 0x20120617)) > > + if (etnaviv_is_model_rev(gpu, 0x1000, 0x5037) && (chipD= ate =3D=3D 0x20120617)) > > gpu->identity.eco_id =3D 1; > >=20 > > - if (etnaviv_is_model_rev(gpu, GC320, 0x5303) && (chipDa= te =3D=3D 0x20140511)) > > + if (etnaviv_is_model_rev(gpu, 0x320, 0x5303) && (chipDa= te =3D=3D 0x20140511)) > > gpu->identity.eco_id =3D 1; > > } > >=20 > > @@ -630,14 +632,14 @@ static void etnaviv_gpu_enable_mlcg(struct etnavi= v_gpu *gpu) > > pmc |=3D BIT(15); /* Unknown bit */ > >=20 > > /* Disable TX clock gating on affected core revisions. */ > > - if (etnaviv_is_model_rev(gpu, GC4000, 0x5222) || > > - etnaviv_is_model_rev(gpu, GC2000, 0x5108) || > > - etnaviv_is_model_rev(gpu, GC2000, 0x6202) || > > - etnaviv_is_model_rev(gpu, GC2000, 0x6203)) > > + if (etnaviv_is_model_rev(gpu, 0x4000, 0x5222) || > > + etnaviv_is_model_rev(gpu, 0x2000, 0x5108) || > > + etnaviv_is_model_rev(gpu, 0x2000, 0x6202) || > > + etnaviv_is_model_rev(gpu, 0x2000, 0x6203)) > > pmc |=3D VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_G= ATING_TX; > >=20 > > /* Disable SE and RA clock gating on affected core revisions. *= / > > - if (etnaviv_is_model_rev(gpu, GC7000, 0x6202)) > > + if (etnaviv_is_model_rev(gpu, 0x7000, 0x6202)) > > pmc |=3D VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_G= ATING_SE | > > VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GAT= ING_RA; > >=20 > > @@ -690,14 +692,14 @@ static void etnaviv_gpu_setup_pulse_eater(struct = etnaviv_gpu *gpu) > > */ > > u32 pulse_eater =3D 0x01590880; > >=20 > > - if (etnaviv_is_model_rev(gpu, GC4000, 0x5208) || > > - etnaviv_is_model_rev(gpu, GC4000, 0x5222)) { > > + if (etnaviv_is_model_rev(gpu, 0x4000, 0x5208) || > > + etnaviv_is_model_rev(gpu, 0x4000, 0x5222)) { > > pulse_eater |=3D BIT(23); > >=20 > > } > >=20 > > - if (etnaviv_is_model_rev(gpu, GC1000, 0x5039) || > > - etnaviv_is_model_rev(gpu, GC1000, 0x5040)) { > > + if (etnaviv_is_model_rev(gpu, 0x1000, 0x5039) || > > + etnaviv_is_model_rev(gpu, 0x1000, 0x5040)) { > > pulse_eater &=3D ~BIT(16); > > pulse_eater |=3D BIT(17); > > } > > @@ -718,8 +720,8 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu = *gpu) > > WARN_ON(!(gpu->state =3D=3D ETNA_GPU_STATE_IDENTIFIED || > > gpu->state =3D=3D ETNA_GPU_STATE_RESET)); > >=20 > > - if ((etnaviv_is_model_rev(gpu, GC320, 0x5007) || > > - etnaviv_is_model_rev(gpu, GC320, 0x5220)) && > > + if ((etnaviv_is_model_rev(gpu, 0x320, 0x5007) || > > + etnaviv_is_model_rev(gpu, 0x320, 0x5220)) && > > gpu_read(gpu, VIVS_HI_CHIP_TIME) !=3D 0x2062400) { > > u32 mc_memory_debug; > >=20 > > @@ -745,7 +747,7 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu = *gpu) > > VIVS_HI_AXI_CONFIG_ARCACHE(2)); > >=20 > > /* GC2000 rev 5108 needs a special bus config */ > > - if (etnaviv_is_model_rev(gpu, GC2000, 0x5108)) { > > + if (etnaviv_is_model_rev(gpu, 0x2000, 0x5108)) { > > u32 bus_config =3D gpu_read(gpu, VIVS_MC_BUS_CONFIG); > > bus_config &=3D ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MAS= K | > > VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK)= ; > >=20 > > -- > > 2.39.2 > >=20 >=20 >=20