Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4149722pxu; Mon, 12 Oct 2020 10:43:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEwo/5Kv+4Zo9kIHm59xux7wr5edwWlt9TzS684G5YM5W3nKhPEDUdpb7O93qdkHbvrqyi X-Received: by 2002:a17:906:a282:: with SMTP id i2mr29034204ejz.39.1602524635683; Mon, 12 Oct 2020 10:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602524635; cv=none; d=google.com; s=arc-20160816; b=wJORXL/QJQRiOIkrF4vMT+Vhhegq86sQJiuzx4KZxFm468bJuuNyJ75nm3QOkNG7ka BNNX2TLHG2AtqWdmsS8w8VEze2bqr/zcomkr8HjjMgCeGeqTxUG0U6ShMB9L3SEOZwW5 vuyzhg9y2y7Bhyeu1LaR7oPdNDuAakzKY1Fo5xymskZeKLQCX78gk3zVi372jAQdOILh 5wFA63JjFV+TsL1qJ6/WXA+nY2VS1EUScVQCFQ+3mKmaSyWubDbOYrJmVIFE5UFPCmPS qNoEK1yKayOfBdzMWmWie1I/ifQTijrHyEZhBtYF+MnnHhkOKhl/bd+4V8ytzFuAUJ3T q40w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KPCBQGJFn0SxOT5QAxB8SIDlgbbUMf897x10D8eAgl4=; b=bNgyLPqorYcwXamiEkmXF9/DyabZdrj+AhWXoOgTZwGa2TcX1Q2n17d7oygnB4ncBE /4FcalJLsTicFlpEckEHqg7xFi6lHcMRZhnAcxW/wMZUg8T72NMnxVWC+LP6+VYFGhL2 xaNdbpSv9HTPHq5YozF4r4+LksoP9kjEh/kKAE/stt+7uGsJ0biHhnwx3g/zvwUYRU4E PH6xX+jmO7b4sRxh5o6EmY+wfufis+VY4Ecot/OL29d3b3j+A+dTDRFB6i7K37TGgQQ3 GN1BI15W0Is9bKSVEprBo2f9dIKVTkv8zX4fE+KpcxdPvDASVQFSeYcO7VG8SEGnG46/ 1skg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FvsoGzfE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si12836136edy.575.2020.10.12.10.43.32; Mon, 12 Oct 2020 10:43:55 -0700 (PDT) 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=@chromium.org header.s=google header.b=FvsoGzfE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390751AbgJLRki (ORCPT + 99 others); Mon, 12 Oct 2020 13:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389562AbgJLRki (ORCPT ); Mon, 12 Oct 2020 13:40:38 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2FEC0613D0 for ; Mon, 12 Oct 2020 10:40:38 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id k8so14170196pfk.2 for ; Mon, 12 Oct 2020 10:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KPCBQGJFn0SxOT5QAxB8SIDlgbbUMf897x10D8eAgl4=; b=FvsoGzfEMAk7KCFRI3bHDorDFAvOk6IoDRmR44X64G369voHZ2IeqDSdfjZildjfP0 RZZWKR2sJelEXoAwAsaPQaX6yTj4panBgXDHYIZbKV3H/3GIY/RypYvGctGRov0L0ehN BNuf+At3a39634/FaSGSTwgyMcM0EF42V5ZMc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KPCBQGJFn0SxOT5QAxB8SIDlgbbUMf897x10D8eAgl4=; b=ds7DRvDoi9Vxb+nl95YIt8RdboZG5h65iTySiy7xQQMSBqW9bggwTaVX2ddDOVLLSE qQgK+PnSYXVB0gCDow7rXjKq/MN3nQFk9se0f8yZUKPq26qYW1YIVwSB03zkYACLaZap 0oO8ZiWdDtFSTEMddRtrOXkcdp1obKbgPUhvhcLuC8a89yJwiz3qxSWOZcKG4uQFTrJl 3n94c5lpu8jA+LyhXdwX3LzN44JTMDOrzH3u9sjRLvMzwXEWHxa/2eo+CFIxnXHOQKty JAY3mLIiErpR1c22iddChjDjU7y1PysSApzzP42TEg1yR6jbrawKD7cjkXsgHVxqEgUl newQ== X-Gm-Message-State: AOAM533PmSwsTi4NTuTpaMnSjSYrRjl5X5YItxjJYhez9FFq7fjX2EiA mWi33hb34kXz3A+YKxdx8+ZjDA== X-Received: by 2002:a17:90a:5881:: with SMTP id j1mr11925578pji.56.1602524438208; Mon, 12 Oct 2020 10:40:38 -0700 (PDT) Received: from localhost ([2620:15c:202:1:f693:9fff:fef4:e70a]) by smtp.gmail.com with ESMTPSA id w74sm6240640pff.200.2020.10.12.10.40.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Oct 2020 10:40:37 -0700 (PDT) Date: Mon, 12 Oct 2020 10:40:35 -0700 From: mka@chromium.org To: Akhil P Oommen Cc: freedreno@lists.freedesktop.org, robh@kernel.org, robdclark@gmail.com, linux-arm-msm@vger.kernel.org, dri-devel@freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [2/2] drm/msm: Add support for GPU cooling Message-ID: <20201012174035.GA44627@google.com> References: <1602176947-17385-2-git-send-email-akhilpo@codeaurora.org> <20201009183640.GB1292413@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2020 at 07:03:51PM +0530, Akhil P Oommen wrote: > On 10/10/2020 12:06 AM, mka@chromium.org wrote: > > Hi Akhil, > > > > On Thu, Oct 08, 2020 at 10:39:07PM +0530, Akhil P Oommen wrote: > > > Register GPU as a devfreq cooling device so that it can be passively > > > cooled by the thermal framework. > > > > > > Signed-off-by: Akhil P Oommen > > > --- > > > drivers/gpu/drm/msm/msm_gpu.c | 13 ++++++++++++- > > > drivers/gpu/drm/msm/msm_gpu.h | 2 ++ > > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > > > index 55d1648..93ffd66 100644 > > > --- a/drivers/gpu/drm/msm/msm_gpu.c > > > +++ b/drivers/gpu/drm/msm/msm_gpu.c > > > @@ -14,6 +14,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > @@ -107,9 +108,18 @@ static void msm_devfreq_init(struct msm_gpu *gpu) > > > if (IS_ERR(gpu->devfreq.devfreq)) { > > > DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n"); > > > gpu->devfreq.devfreq = NULL; > > > + return; > > > } > > > devfreq_suspend_device(gpu->devfreq.devfreq); > > > + > > > + gpu->cooling = of_devfreq_cooling_register(gpu->pdev->dev.of_node, > > > + gpu->devfreq.devfreq); > > > + if (IS_ERR(gpu->cooling)) { > > > + DRM_DEV_ERROR(&gpu->pdev->dev, > > > + "Couldn't register GPU cooling device\n"); > > > + gpu->cooling = NULL; > > > + } > > > } > > > static int enable_pwrrail(struct msm_gpu *gpu) > > > @@ -926,7 +936,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, > > > msm_devfreq_init(gpu); > > > - > > > gpu->aspace = gpu->funcs->create_address_space(gpu, pdev); > > > if (gpu->aspace == NULL) > > > @@ -1005,4 +1014,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu) > > > gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu); > > > msm_gem_address_space_put(gpu->aspace); > > > } > > > + > > > + devfreq_cooling_unregister(gpu->cooling); > > > > Resources should be released in reverse order, otherwise the cooling device > > could use resources that have already been freed. > > Why do you think this is not the correct order? If you are thinking > about devfreq struct, it is managed device resource. I did not check specifically if changing the frequency really uses any of the resources that are released previously, In any case it's not a good idea to allow other parts of the kernel to use a half initialized/torn down device. Even if it isn't a problem today someone could change the driver to use any of these resources (or add a new one) in a frequency change, without even thinking about the cooling device, just (rightfully) asuming that things are set up and torn down in a sane order.