Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4968398pxb; Tue, 28 Sep 2021 07:56:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5uKtW2zmmwDES8WCRAwwc6iNtKyTqVREoI0LVT4n+w8RD/YkDN00d0/NeR+Nyr12as/2A X-Received: by 2002:aa7:9823:0:b0:43c:6454:92b0 with SMTP id q3-20020aa79823000000b0043c645492b0mr5753627pfl.68.1632840971226; Tue, 28 Sep 2021 07:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632840971; cv=none; d=google.com; s=arc-20160816; b=F1+LlviN85Q+wZyaRNwFOddxHd/xfkWGeiNqqAxbO8xX8YfA9IgWo47gyJR8yY6j++ w5vCLhMwT/eZxkGe7TSxI2J09snb4varQbFgT3IhTzrSpEjeuCDPvd8EU/dNG49TEVNS XscappXioK8u5/oHm/+O8EAON531jA9hYDGYiDsqHYYrGm+0Byu9luAaM2rBQgVI3WuY o9POjznRKGGgDCXXkAWksX6rHZTV41Igwq3IqcCMt9IE03wTwJaH8mR+cma+xKj27NIF NUlXA+Vj1GgJyS+w+7Gwd1QvhPgz/qu1IafenM/saGa3nyBpJSUAyS0qgiFFQNy+vNsp uiXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dmarc-filter:sender:dkim-signature; bh=f4WFcVRXiFJASWpKKkg7ZPFGull7j3liSd4EXDLOK4g=; b=IywFtd+oENK7YDHjM0WXxBuziE6rp93btuc12a2NNmrvSmPNbwIVSWoE3CQsYb2qjQ zMl/deMNeyrbcg/RTu8fJut11465XmuHFVs73+bi+0MDykzbnrX1tTyHaaabCI/qSigE OnVG1UB4qDecjT1RQE1ALQaQVB/f2qNGZhO5i6DSFErKGAafJc+/URV6PuE9lNBJM19q 4bB9ylvhvwwC50pWnN/Kqq2SoAaa3rHN5mICS2+uJUGmIrMcvFW3phajLLvD5X7EX1p6 y3knOh4OI8sxGPrhpxByiJFFkBOG6+m355Gb0UPxaxY0+hMVq7YUNC6v7EfsqkQUGdS8 FXXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=bEU3F7jE; 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 e5si3490314pjm.26.2021.09.28.07.55.54; Tue, 28 Sep 2021 07:56:11 -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=@mg.codeaurora.org header.s=smtp header.b=bEU3F7jE; 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 S241443AbhI1Oyl (ORCPT + 99 others); Tue, 28 Sep 2021 10:54:41 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:56574 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241176AbhI1Oy2 (ORCPT ); Tue, 28 Sep 2021 10:54:28 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1632840769; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: From: References: Cc: To: Subject: MIME-Version: Date: Message-ID: Sender; bh=f4WFcVRXiFJASWpKKkg7ZPFGull7j3liSd4EXDLOK4g=; b=bEU3F7jEKKoct+u2SEA/T21M6NWOev+eWa9fUGJ3QL4VJmkV6LZ962IjttF6hSPJGIfKZ3y0 pEuTKWPP5O16bDC1bNzLsDeyVYTLxVOdErjMF4Yo96dqA91TTTtcraLg+EhOfbJhRP+SImDa V6EfLpeb4p5mwKS/o0ORcbnebEo= X-Mailgun-Sending-Ip: 198.61.254.9 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-n01.prod.us-east-1.postgun.com with SMTP id 61532c249ffb413149dd6a67 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 28 Sep 2021 14:52:20 GMT Sender: akhilpo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A573DC43460; Tue, 28 Sep 2021 14:52:19 +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=-5.5 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.1.10] (unknown [59.89.231.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akhilpo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 69BF7C43617; Tue, 28 Sep 2021 14:52:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 69BF7C43617 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=codeaurora.org Message-ID: Date: Tue, 28 Sep 2021 20:22:11 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH] drm/msm: Switch ordering of runpm put vs devfreq_idle Content-Language: en-US To: Rob Clark , dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , open list References: <20210927152928.831245-1-robdclark@gmail.com> From: Akhil P Oommen In-Reply-To: <20210927152928.831245-1-robdclark@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/27/2021 8:59 PM, Rob Clark wrote: > From: Rob Clark > > I've seen a few crashes like: > > Internal error: synchronous external abort: 96000010 [#1] PREEMPT SMP > Modules linked in: snd_seq_dummy snd_seq snd_seq_device bridge stp llc tun nf_nat_tftp nf_conntrack_tftp nf_nat_ftp nf_conntrack_ftp esp6 ah6 ip6t_REJECT ip6t_ipv6header vhost_vsock vhost vmw_vsock_virtio_transport_common vsock rfcomm algif_hash algif_skcipher af_alg uinput veth xt_cgroup xt_MASQUERADE venus_enc venus_dec videobuf2_dma_contig qcom_spmi_adc5 qcom_spmi_adc_tm5 hci_uart qcom_vadc_common cros_ec_typec qcom_spmi_temp_alarm typec btqca snd_soc_rt5682_i2c snd_soc_rt5682 snd_soc_sc7180 bluetooth snd_soc_qcom_common snd_soc_rl6231 ecdh_generic ecc venus_core v4l2_mem2mem snd_soc_lpass_sc7180 snd_soc_lpass_hdmi snd_soc_lpass_cpu snd_soc_lpass_platform snd_soc_max98357a ip6table_nat fuse iio_trig_sysfs cros_ec_lid_angle cros_ec_sensors cros_ec_sensors_core industrialio_triggered_buffer kfifo_buf cros_ec_sensorhub lzo_rle ath10k_snoc lzo_compress ath10k_core ath zram mac80211 cfg80211 ax88179_178a usbnet mii uvcvideo videobuf2_vmalloc joydev > CPU: 3 PID: 212 Comm: A618-worker Tainted: G W 5.4.139-16300-g88d8e1285982 #1 > Hardware name: Google Pompom (rev1) with LTE (DT) > pstate: 60c00009 (nZCv daif +PAN +UAO) > pc : a6xx_gmu_set_oob+0x114/0x200 > lr : a6xx_gmu_set_oob+0x10c/0x200 > sp : ffffffc011b7bc20 > x29: ffffffc011b7bc20 x28: ffffffdad27c5000 > x27: 0000000000000001 x26: ffffffdad1521044 > x25: ffffffbef7498338 x24: 0000000000000018 > x23: 0000000000000002 x22: 0000000000014648 > x21: 0000033732fe638b x20: 0000000080000000 > x19: ffffffbef7433bc8 x18: 0000000040000000 > x17: 000000243508d982 x16: 000000000000b67e > x15: 00000000000090d4 x14: 0000000000000024 > x13: 0000000000000024 x12: 0000000000017521 > x11: 0000000000000b48 x10: 0000000000326a48 > x9 : 1a130d33f6371600 x8 : ffffffc011e54648 > x7 : 614948e00005003c x6 : ffffffbe3cd17e60 > x5 : 0000000000000040 x4 : 0000000000000004 > x3 : 0000000000000000 x2 : ffffffbef7488000 > x1 : ffffffbef7488000 x0 : 0000000000000000 > Call trace: > a6xx_gmu_set_oob+0x114/0x200 > a6xx_gmu_set_freq+0xe0/0x1fc > msm_devfreq_target+0x80/0x13c > msm_devfreq_idle+0x54/0x94 > retire_submit+0x170/0x254 > retire_submits+0xa4/0xdc > retire_worker+0x1c/0x28 > kthread_worker_fn+0xf4/0x1bc > kthread+0x140/0x158 > ret_from_fork+0x10/0x18 > Code: 52800c81 9415bbe5 f9400a68 8b160108 (b9400108) > ---[ end trace 16b871df2482cd61 ]--- > Kernel panic - not syncing: Fatal exception > SMP: stopping secondary CPUs > Kernel Offset: 0x1ac1400000 from 0xffffffc010000000 > PHYS_OFFSET: 0xffffffc280000000 > CPU features: 0x88102e,2a80aa38 > Memory Limit: none > > Which smells a lot like touching hw after power collapse. I'm not > *entirely* sure how it could have taken 66ms (the autosuspend delay) > before we get to a6xx_gmu_set_oob(), but to be safe we should move > the pm_runtime_put_autosuspend() after msm_devfreq_idle(). https://elixir.bootlin.com/linux/v5.15-rc1/source/drivers/gpu/drm/msm/adreno/a6xx_gmu.c#L132 We have this check in the gmu freq set path which should avoid this scenario. I might be a bit pedantic here, but I feel that the original code is more accurate. We should immediately mark last busy and put runtime_pm refcount. -Akhil. > > Fixes: 9bc95570175a ("drm/msm: Devfreq tuning") > Signed-off-by: Rob Clark > --- > drivers/gpu/drm/msm/msm_gpu.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > index d1a16642ecd5..2b2bbe7499e6 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.c > +++ b/drivers/gpu/drm/msm/msm_gpu.c > @@ -667,9 +667,6 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > > msm_submit_retire(submit); > > - pm_runtime_mark_last_busy(&gpu->pdev->dev); > - pm_runtime_put_autosuspend(&gpu->pdev->dev); > - > spin_lock_irqsave(&ring->submit_lock, flags); > list_del(&submit->node); > spin_unlock_irqrestore(&ring->submit_lock, flags); > @@ -683,6 +680,9 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > mutex_unlock(&gpu->active_lock); > > msm_gem_submit_put(submit); > + > + pm_runtime_mark_last_busy(&gpu->pdev->dev); > + pm_runtime_put_autosuspend(&gpu->pdev->dev); > } > > static void retire_submits(struct msm_gpu *gpu) >