Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14001639pxu; Mon, 4 Jan 2021 10:09:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQRjAXR3LfdnZCCpdpUONTHTd7UEVVv+xttlHdsIdcwRw5qJEGpkmvZwnDf/oczfTb7SH8 X-Received: by 2002:a05:6402:1c8a:: with SMTP id cy10mr18802419edb.151.1609783782071; Mon, 04 Jan 2021 10:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609783782; cv=none; d=google.com; s=arc-20160816; b=UgGS6dIxQHDjBgX2LIMoY9AkKAmfBB0lcNhxcLNzlNdgHSTYSAaobNfrdLoUu+asS1 /67hY1K7ZiE/B5QPhleBPSoN+GlWrY1pjdeH0rmyVrgUEcKr0XEcLpeKAzRUWRz0K/EH 06KQW7ATCUqryS+QKWhwcHjeP4eKi4bMUUnMyegnpxcXCQeLm3T29mrDSXJK8zvQnVpB Iv73zCZ+CzxYSAP30FQJIgih7twkVSUjBC98uFz4RfFmodw95yivErU70Yr7GmkZEzsw MrMggUjojXJWHR3JogPHpnadYCIl3Lu6dtobi5EoRnVKkD8gjs6dgzgHFGPrfq9xRmtc UJLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dmarc-filter:sender:dkim-signature; bh=txD1kK7c713c8W+M5K8v2Z4O5yjXvJH0xxaYw03By20=; b=di4gof6Z9P2jAgeG5oXYY0EAvURDi/zzod0Y1OarsrQk9O4OFcvn2cwRextcrlQ7Zi cixdjjHXLw7cIRVdibyo0oRAxoWRjqet4W+/G8kcatzT3CVGp485+7K1A0Q5E7YvtwC+ IkrBcKA/g+4uBZ7MlZludNwIXAkYFAN+ltkmwV3yzA0a5L4k1AHvqhGjmkJOtL31LMsC 3JkGSu78wU3nnIFDjN2kprzDIb/Z3NOr5bjBfQyWdwXPBjuWLmqUb9HfIn/x7CDV1MP7 Oeb3Mxmh56A46swAEQGXG7xqxLW+A4SMp7MwDnP2D/W09IF6BI9JaKWNO98Ir36W4Nki c2jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="E/seioZA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si29201351ejr.379.2021.01.04.10.09.19; Mon, 04 Jan 2021 10:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="E/seioZA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbhADSI1 (ORCPT + 99 others); Mon, 4 Jan 2021 13:08:27 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:47739 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbhADSI0 (ORCPT ); Mon, 4 Jan 2021 13:08:26 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609783682; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=txD1kK7c713c8W+M5K8v2Z4O5yjXvJH0xxaYw03By20=; b=E/seioZA7FdGAEqNhihTHD6juGNpov4zWv4dLSIb/XXTsdtnlJP9slv0S/qQMerjk54GSYdf u/XT7AeBDu2Q/qu/eT98lE+1LnGN/ZZsnmNYJVJY4dePMJi3+t/Hosdg7doKfFJ6BVOgMslp e5mR8mthLYEG9p8IGN6ayM4ERjk= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n08.prod.us-east-1.postgun.com with SMTP id 5ff3594e00a8b47219a7bcf5 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 04 Jan 2021 18:07:10 GMT Sender: jcrouse=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 05300C43461; Mon, 4 Jan 2021 18:07:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from jcrouse1-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse) by smtp.codeaurora.org (Postfix) with ESMTPSA id E3803C433CA; Mon, 4 Jan 2021 18:07:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E3803C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=jcrouse@codeaurora.org Date: Mon, 4 Jan 2021 11:07:04 -0700 From: Jordan Crouse To: Akhil P Oommen Cc: freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, robh@kernel.org, dri-devel@freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mka@chromium.org, robdclark@gmail.com, dianders@chromium.org Subject: Re: [PATCH v3 1/2] drm/msm: Add speed-bin support to a618 gpu Message-ID: <20210104180704.GA26690@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Akhil P Oommen , freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, robh@kernel.org, dri-devel@freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mka@chromium.org, robdclark@gmail.com, dianders@chromium.org References: <1607337728-11398-1-git-send-email-akhilpo@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1607337728-11398-1-git-send-email-akhilpo@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 07, 2020 at 04:12:07PM +0530, Akhil P Oommen wrote: > Some GPUs support different max frequencies depending on the platform. > To identify the correct variant, we should check the gpu speedbin > fuse value. Add support for this speedbin detection to a6xx family > along with the required fuse details for a618 gpu. > > Signed-off-by: Akhil P Oommen > --- > Changes from v2: > 1. Made the changes a6xx specific to save space. > Changes from v1: > 1. Added the changes to support a618 sku to the series. > 2. Avoid failing probe in case of an unsupported sku. (Rob) > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 74 +++++++++++++++++++++++++++++++++++ > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 2 + > 2 files changed, 76 insertions(+) > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > index 1306618..6304578 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > @@ -10,10 +10,13 @@ > > #include > #include > +#include > #include > > #define GPU_PAS_ID 13 > > +const u32 a618_speedbins[] = {0, 169, 174}; This still feels too generic to me - this could easily be something like: static u32 a618_get_speed_bin(int rev) { if (rev == 0) return 0; else if (rev == 169) return 1; else if (rev == 174) return 2; return UINT_MAX; } I know Akhil can see a future where there might be other "pro" targets but it is unclear to me when those will see upstream support and even if they do a handful of inline-able functions still seem better to me than a group of const arrays. > + > static inline bool _a6xx_check_idle(struct msm_gpu *gpu) > { > struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); > @@ -1208,6 +1211,10 @@ static void a6xx_destroy(struct msm_gpu *gpu) > a6xx_gmu_remove(a6xx_gpu); > > adreno_gpu_cleanup(adreno_gpu); > + > + if (a6xx_gpu->opp_table) > + dev_pm_opp_put_supported_hw(a6xx_gpu->opp_table); > + > kfree(a6xx_gpu); > } > > @@ -1264,6 +1271,67 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) > return ring->memptrs->rptr = gpu_read(gpu, REG_A6XX_CP_RB_RPTR); > } > > +static u32 fuse_to_supp_hw(struct device *dev, u32 revn, u32 fuse) > +{ > + int i; > + > + if (revn == 618) { > + for (i = 0; i < ARRAY_SIZE(a618_speedbins); i++) { > + if (fuse == a618_speedbins[i]) > + return (1 << i); > + } > + } u32 val = UINT_MAX; if (revn == 618) val = a618_get_speed_bin(fuse); if (val == UINT_MAX) DRM_DEV_ERROR(dev, "Missing support for speed-bin %u. Some OPPs may not be supported by hardware", fuse); return val; > + > + DRM_DEV_ERROR(dev, > + "missing support for speed-bin: %u. Some OPPs may not be supported by hardware", > + fuse); > + return ~0U; > +} > + > +static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu, > + u32 revn) > +{ > + > + struct opp_table *opp_table; > + struct nvmem_cell *cell; > + u32 supp_hw = ~0U; > + void *buf; > + > + cell = nvmem_cell_get(dev, "speed_bin"); > + /* > + * -ENOENT means that the platform doesn't support speedbin which is > + * fine > + */ > + if (PTR_ERR(cell) == -ENOENT) > + return 0; > + else if (IS_ERR(cell)) { > + DRM_DEV_ERROR(dev, > + "failed to read speed-bin. Some OPPs may not be supported by hardware"); > + goto done; > + } > + > + buf = nvmem_cell_read(cell, NULL); > + if (IS_ERR(buf)) { > + nvmem_cell_put(cell); > + DRM_DEV_ERROR(dev, > + "failed to read speed-bin. Some OPPs may not be supported by hardware"); > + goto done; > + } > + > + supp_hw = fuse_to_supp_hw(dev, revn, *((u32 *) buf)); > + > + kfree(buf); > + nvmem_cell_put(cell); > + > +done: > + opp_table = dev_pm_opp_set_supported_hw(dev, &supp_hw, 1); > + if (IS_ERR(opp_table)) > + return PTR_ERR(opp_table); > + > + a6xx_gpu->opp_table = opp_table; > + return 0; > +} Beyond the comments above, I think the rest of this is reasonable. Jordan > + > static const struct adreno_gpu_funcs funcs = { > .base = { > .get_param = adreno_get_param, > @@ -1325,6 +1393,12 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) > > a6xx_llc_slices_init(pdev, a6xx_gpu); > > + ret = a6xx_set_supported_hw(&pdev->dev, a6xx_gpu, info->revn); > + if (ret) { > + a6xx_destroy(&(a6xx_gpu->base.base)); > + return ERR_PTR(ret); > + } > + > ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1); > if (ret) { > a6xx_destroy(&(a6xx_gpu->base.base)); > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > index e793d32..ce0610c 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > @@ -33,6 +33,8 @@ struct a6xx_gpu { > void *llc_slice; > void *htw_llc_slice; > bool have_mmu500; > + > + struct opp_table *opp_table; > }; > > #define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base) > -- > 2.7.4 > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project