Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3606631pxb; Mon, 21 Feb 2022 01:38:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6Yx1g81qVvR5TdyNypHW7ga4wkg8nsmfepO3d8VN4jeRl7H7zTxOxYbQHkKW5FHfeapzZ X-Received: by 2002:a50:aadc:0:b0:40f:5c06:ebb7 with SMTP id r28-20020a50aadc000000b0040f5c06ebb7mr20245296edc.387.1645436337029; Mon, 21 Feb 2022 01:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645436337; cv=none; d=google.com; s=arc-20160816; b=y9jsF556cxnUSGZJicUoXk8A191CVyjJhz4VMgcFfmi9wfuwZyg+2cL7e/FM0hXeZV 2dRSzyAoAUU+N2uEqd8GJu6pHe4yfODtcgxwuXSPQ11H9WERAIpUN0Xy0lqaBtd04bs8 E4+nEl/+sVXTAQFbBhzaDR21PUvkkv1w4g5hUcOseDieb5yG3r0T2RvOVvyAx1D5kMFq JT8BoI3n79YBT+OV1ji+g042hSOkAX8wvOkXFLne3fMsXtcbtWUymooYbchYsmqkNYsL m32UhnXWrlKWUgqy16hO+ZwhgnBlInogJB6PkifuwLBJGSyDLU8dOiA15DHD69OmepHt bV0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pAZG7JbLQbeA7Yj+mlgqX0k/1mUajJPRecROZ8iw+8c=; b=zvgbcWes0wAMRVcNhxAlalackdALBS6mtgc6kupEfjzrXAnbiz8wrMxufAr1KHfLQV X7BDSHc8n+ZvHhgKxGfOoVb3W5BjMKg9AiHYFEnSA+Qrw35kH++3hQtZ4lKHs8v50rcf 5ltdfqRbDQkxRRyjJseKwwW5KXyBbRjJCzlUN2d978saNd42KbaHCxzNLHAUE8cdTVnG 7/6gutZU1lFnOTds1r1paDgN9FiQGrkhAymV/MiCKEz3K2y9WaBQ9OrdKoKsXvXFwNiA z2K3ZnxEDGRmEOPcnexa+9U8bx8mayeRKs8Vx5Ejf9JFy1YB16ik9LrXLAZxsPdwRQSC Nevg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OJkpULWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3si6548778ejo.154.2022.02.21.01.38.34; Mon, 21 Feb 2022 01:38:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OJkpULWy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbiBSShM (ORCPT + 99 others); Sat, 19 Feb 2022 13:37:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237333AbiBSShL (ORCPT ); Sat, 19 Feb 2022 13:37:11 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 307BB22BD7; Sat, 19 Feb 2022 10:36:51 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id j9-20020a05600c190900b0037bff8a24ebso10829347wmq.4; Sat, 19 Feb 2022 10:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pAZG7JbLQbeA7Yj+mlgqX0k/1mUajJPRecROZ8iw+8c=; b=OJkpULWy9BPv8scnQFQP2MQL1Ele2xge0o1Pj1x9KMbJpLTUJkfiqfOhC8PZShcBpk USH+xwYud1/tctwvjUFm4YSlNGlPl1+sidtvBa/dgyDHyKaOUuSfW3pczbOlDssg4cVp gzZa1HsPNwCi4Ih5A449CLnvRVQKmMQ7IeiaI90t+1NT1GBWQTitdtMDZOsjU5s9nLbh bZ1SUilCoBwTMCAMziP4GMfswYU39HlTxFDjXpgkX9tTPS7UPzqwjbYVuBjISxniMmI/ wah3lBe/4YtVwzOcDzO3QHVqPUxUBsyRHMuJP9qBc3YYLiTVZFSGNab2SxKJSLd2LC1x oD5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pAZG7JbLQbeA7Yj+mlgqX0k/1mUajJPRecROZ8iw+8c=; b=z7ooAE5GhhcJWneuisnLrdk4lZ8IDVYxqAIB+fi3/XY74r9vqaCBqErmdc4nVtPc0G ckIeNkBlJF4DGH9R564SHAtAmNKWRuKHbSvR4hP3vTOicAyswvtKjiKDevYbWCpcT1DU dhEohF3cJfH43jti2CBUqIg0/hfSE6OeUzzC1YzRM0ulvdYDK51ZTx0bN6yvgYyYi1ey lqjAddWDkNYLeR/uZtBZ0AeRPT56oabN69xiHZtSdnUy+fOxLKIi1ua9Wrecwnaz2lja RJ7i7/uTUnveVa3y1tdty4zIj4bo3w9GVe5X7tCcR1Q28kKwaX8inTWFuWv7fjURRezI pEsg== X-Gm-Message-State: AOAM5326dMo4WZBAlGu0sVkJoTQhad5uJh7uC7cJ6k2NB5Jhswetp8ps HL6A84opo43XDf6WfKaHobse7YnBcmpBvcJlT9M= X-Received: by 2002:a05:600c:1e0a:b0:37d:342c:36ac with SMTP id ay10-20020a05600c1e0a00b0037d342c36acmr11851160wmb.168.1645295809620; Sat, 19 Feb 2022 10:36:49 -0800 (PST) MIME-Version: 1.0 References: <20220219183310.557435-1-robdclark@gmail.com> In-Reply-To: <20220219183310.557435-1-robdclark@gmail.com> From: Rob Clark Date: Sat, 19 Feb 2022 10:37:09 -0800 Message-ID: Subject: Re: [PATCH] drm/msm/gpu: Fix crash on devices without devfreq support To: dri-devel Cc: freedreno , linux-arm-msm , Rob Clark , Linux Kernel Functional Testing , Anders Roxell , Sean Paul , Abhinav Kumar , David Airlie , Daniel Vetter , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 19, 2022 at 10:32 AM Rob Clark wrote: > > From: Rob Clark > > Avoid going down devfreq paths on devices where devfreq is not > initialized. > > Reported-by: Linux Kernel Functional Testing > Reported-by: Anders Roxell forgot to add: Fixes: 6aa89ae1fb04 ("drm/msm/gpu: Cancel idle/boost work on suspend") > Signed-off-by: Rob Clark > --- > drivers/gpu/drm/msm/msm_gpu_devfreq.c | 31 +++++++++++++++++++++------ > 1 file changed, 25 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c > index 9bf319be11f6..26a3669a97b3 100644 > --- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c > +++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c > @@ -83,12 +83,17 @@ static struct devfreq_dev_profile msm_devfreq_profile = { > static void msm_devfreq_boost_work(struct kthread_work *work); > static void msm_devfreq_idle_work(struct kthread_work *work); > > +static bool has_devfreq(struct msm_gpu *gpu) > +{ > + return !!gpu->funcs->gpu_busy; > +} > + > void msm_devfreq_init(struct msm_gpu *gpu) > { > struct msm_gpu_devfreq *df = &gpu->devfreq; > > /* We need target support to do devfreq */ > - if (!gpu->funcs->gpu_busy) > + if (!has_devfreq(gpu)) > return; > > dev_pm_qos_add_request(&gpu->pdev->dev, &df->idle_freq, > @@ -149,6 +154,9 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu) > { > struct msm_gpu_devfreq *df = &gpu->devfreq; > > + if (!has_devfreq(gpu)) > + return; > + > devfreq_cooling_unregister(gpu->cooling); > dev_pm_qos_remove_request(&df->boost_freq); > dev_pm_qos_remove_request(&df->idle_freq); > @@ -156,16 +164,24 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu) > > void msm_devfreq_resume(struct msm_gpu *gpu) > { > - gpu->devfreq.busy_cycles = 0; > - gpu->devfreq.time = ktime_get(); > + struct msm_gpu_devfreq *df = &gpu->devfreq; > > - devfreq_resume_device(gpu->devfreq.devfreq); > + if (!has_devfreq(gpu)) > + return; > + > + df->busy_cycles = 0; > + df->time = ktime_get(); > + > + devfreq_resume_device(df->devfreq); > } > > void msm_devfreq_suspend(struct msm_gpu *gpu) > { > struct msm_gpu_devfreq *df = &gpu->devfreq; > > + if (!has_devfreq(gpu)) > + return; > + > devfreq_suspend_device(df->devfreq); > > cancel_idle_work(df); > @@ -185,6 +201,9 @@ void msm_devfreq_boost(struct msm_gpu *gpu, unsigned factor) > struct msm_gpu_devfreq *df = &gpu->devfreq; > uint64_t freq; > > + if (!has_devfreq(gpu)) > + return; > + > freq = get_freq(gpu); > freq *= factor; > > @@ -207,7 +226,7 @@ void msm_devfreq_active(struct msm_gpu *gpu) > struct devfreq_dev_status status; > unsigned int idle_time; > > - if (!df->devfreq) > + if (!has_devfreq(gpu)) > return; > > /* > @@ -253,7 +272,7 @@ void msm_devfreq_idle(struct msm_gpu *gpu) > { > struct msm_gpu_devfreq *df = &gpu->devfreq; > > - if (!df->devfreq) > + if (!has_devfreq(gpu)) > return; > > msm_hrtimer_queue_work(&df->idle_work, ms_to_ktime(1), > -- > 2.34.1 >