Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3492172pxp; Tue, 8 Mar 2022 15:50:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHiQrzt2BCCal11dtxipu9jPM5rt7MwEztIK5COGFD6phBYErNCvEJVEtGRhXoP273tIqa X-Received: by 2002:a05:6a00:1991:b0:4f7:1322:ca04 with SMTP id d17-20020a056a00199100b004f71322ca04mr9832662pfl.85.1646783456010; Tue, 08 Mar 2022 15:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646783456; cv=none; d=google.com; s=arc-20160816; b=UOZ5vErqkfCo/vyvo957ZeOpJjeH0zjhS25/ZxbfJL3eEIbTAT+6Nb5AvVOIL3VN0I 03eTjN/NAk9UVO5xlj3ntE9Uv0XzA5mI3VweMsKhK/8/kAKZBukiTD/J6D1voESYqJED /JKRh8r1f1ArGaMhOCkqWOwgzcAtAQeW1eV16lyccgMDFbZhWzIVcNW90HWu+4gpLW6H t1VmNHmLDHjzSH9d0jybzEAHeKY7NAZLf+DGUWOU8zF8G1r1qfPdwttkdnQVtqY0Glum AUkngf6+ka3i7iyOnaoFMy6spfYYyQyEtcH36lOo9seTZHSEUIiJx/pu6hJEl89SO/er OKzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kmwLyD/dNxW2RzhMW7TqKOPG19gcSG2VPjcZNJ8YJ7Y=; b=zCYl4CvzopqIWetWuzt1BphLZVKNTgvGTyawzSRK8QBmLUSUpDvYbRb/osfj3eHPrn PNE9ss+LyzAaXiQC52DpXZd1pad+lPHGYV836pJXXUq42wDNDt7vwnHOTGV8rQLNq6hV SjuDHEK7GtfVCNm5Hg0pjfeQ0VZHkKD8HYFXWKRVRazQ5OFHii+xWtqXOPCOPHTjPgP1 WrzuvRYChigChQDVcN7FgbkaOyXMYAbdbQAeO7KiVvdlJ6mCd4MUbWyxcDOSbyqE1rR4 DUibJlrHEqAfWw2PpIuwN3ANAfSNWdrY2SDt77FsrU43JNRDaBD0/iP+mdmv9i08gdlg 5Glg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bBIeKK1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j190-20020a6380c7000000b00380b351617bsi259146pgd.745.2022.03.08.15.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:50:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bBIeKK1b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B3F5C8F95; Tue, 8 Mar 2022 15:30:47 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344873AbiCHStG (ORCPT + 99 others); Tue, 8 Mar 2022 13:49:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbiCHStF (ORCPT ); Tue, 8 Mar 2022 13:49:05 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE9549FB0; Tue, 8 Mar 2022 10:48:08 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id d187so126278pfa.10; Tue, 08 Mar 2022 10:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kmwLyD/dNxW2RzhMW7TqKOPG19gcSG2VPjcZNJ8YJ7Y=; b=bBIeKK1bY+Eml8HcFIdHzNO9ls55ISByO+JR0/BKyKu7ETxiYU3wfkI+0nbsk12IeQ 5LuDr9byAG4cZqgYdhaG6837t8v3xiTAufKyikjiVybPJ799E2pWHiXMbNTjTIp0a+iN KFveCYukqhXiBR9nlyEmoNxkT6j0F6SqRXU8QH01YNwaq5Cg5uyE09Ygt9XYV5SxD/oE kzzItxxjQDnQBV8jHhCjfIDR/l9j54XGRfFs1zqt9DEflfadd9Ahn1XN/u+RIJtucfHf hJhCIWNB4vAcRnI7W/ZPoDrp5yfwbZcdA04VWqt7CNq/bEjW1QpXLUqtRmfHqRFd3rPL JgdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kmwLyD/dNxW2RzhMW7TqKOPG19gcSG2VPjcZNJ8YJ7Y=; b=CqxkiwD0F5nuJaa74WnBG/C53g9rsKdbt3/yIMTkWvHk0i38D1nS42yUKfGe5nJDh8 fiWRnvxaYKDWLqUrozzbEVwmswmINopqGdRjeW5S2bT3PJwXo8kLRpxMI3PqwyiUk/A+ fppsfvp/VsiXdlJA6d5qmY8hcg6Z/wpa/k6vTpiukiX4yrpUABXNv/T2cwkzT3P44OTl yTyGY052XvqkRhRL95IRxF8teJioWPsbehCBglafnhUGaSo50qj5BRKXJA1jx4ZKzOPH U6D3F7EID1SScXtUIqd1UCKY2TT2FsRsyeOYpiUApCjsKqmpgGKC+CVwXc9EzdrXqs34 oEJA== X-Gm-Message-State: AOAM533Z55wOQKYJYpGUPYCMwkfu6hO9/0JVOSZFGsba3IFbciu+uSKj q8sriclrOTLF2uTARLm72fg= X-Received: by 2002:a05:6a00:ad0:b0:4e1:2d96:2ab0 with SMTP id c16-20020a056a000ad000b004e12d962ab0mr19664621pfl.3.1646765287869; Tue, 08 Mar 2022 10:48:07 -0800 (PST) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id d15-20020a056a00198f00b004f7109da1c4sm7129643pfl.205.2022.03.08.10.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 10:48:06 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , Linux Kernel Functional Testing , Anders Roxell , Rob Clark , Sean Paul , Abhinav Kumar , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/msm/gpu: Fix crash on devices without devfreq support (v2) Date: Tue, 8 Mar 2022 10:48:44 -0800 Message-Id: <20220308184844.1121029-1-robdclark@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Rob Clark Avoid going down devfreq paths on devices where devfreq is not initialized. v2: Change has_devfreq() logic [Dmitry] Reported-by: Linux Kernel Functional Testing Reported-by: Anders Roxell Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 30 ++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c index 9bf319be11f6..12641616acd3 100644 --- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c +++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c @@ -83,6 +83,12 @@ 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) +{ + struct msm_gpu_devfreq *df = &gpu->devfreq; + return !!df->devfreq; +} + void msm_devfreq_init(struct msm_gpu *gpu) { struct msm_gpu_devfreq *df = &gpu->devfreq; @@ -149,6 +155,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 +165,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 +202,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 +227,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 +273,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.35.1