Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp995465ybp; Fri, 4 Oct 2019 08:06:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDJSs+e4CS5q3wMpMdv4BU1z8rlZREQjAgKIua8tMEsUmYEFMuuQenv+vB8RDkQXTjXd1s X-Received: by 2002:a17:906:7f05:: with SMTP id d5mr5172597ejr.313.1570201560278; Fri, 04 Oct 2019 08:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570201560; cv=none; d=google.com; s=arc-20160816; b=RheIAU3aGkH+o/8pitCnspzvnsNbquyBeKDGxw/a9fIPlhOJBCHSDBqF0uFMFYAHUT Z9vltT2i+/yceMPkvvfuG0NdoAhtUcUz/0Sd3GFN55wlOdn0HRQv2wia9R1j5hHtuG5l upA5xHX/8c9/xUsouRhkKR3FrzE5+5AMvvktP3cRyZY/pkSiXKb5qXHkYt8blM+bsZQR BVB3bENwHP0vj+rLv4n9hNQP+7DZdghNiYCr0uIb3M/e78C3svDvS3MTx8koPlsNafuk MOFzEy3ai+YmFi/+Xz9EDJzK5zPE34ZFx/lhJF9kCP2RdM7W74dyi0COtua53Vdz1C7O 7xqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject:dkim-signature; bh=AFKYB40YJrX94dmbX2foh6YfCwAV4FqZbML1ow8KGBI=; b=FjsXoJ00XFPc1ebXAwkiwUksDIEEO0EmTRrXfgg5xVeziIClK4wqwjwUe/NT16vpQ8 ridRjLAoBNgShU/eW24uxQANESZzWq0aoi3vNxNVtDTmrNBnJPxSuwsUAyKKnFtZIuUn ZF9CJXGXo93MjgdwrcktQhkZK/Lj1B23xOk7JLn3kwqhgwe5aFGl+jmsw5rp/+TZPfik E/AO7tsQ5TRgQHjlS0MQmqjYAsoKZoRU1+gLTwtis4JvWOcAODFmO9omYLwTgWbTSurn fkN8O1NdyragsB0Fb5ZNe6Vti/9YNTeR6hRBYP8urW0HKdCjsIdjIi5EJVy9d3qDlj8a XtFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xIIB7t9a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si3083926ejr.33.2019.10.04.08.05.29; Fri, 04 Oct 2019 08:06:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xIIB7t9a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389378AbfJDPDW (ORCPT + 99 others); Fri, 4 Oct 2019 11:03:22 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35063 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388802AbfJDPDW (ORCPT ); Fri, 4 Oct 2019 11:03:22 -0400 Received: by mail-wm1-f65.google.com with SMTP id y21so6238194wmi.0 for ; Fri, 04 Oct 2019 08:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:openpgp:autocrypt:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=AFKYB40YJrX94dmbX2foh6YfCwAV4FqZbML1ow8KGBI=; b=xIIB7t9a9IEgXwx7XwYtSCW8uGEDloL9Jr3bD1Jeww0dSvYmv34gSriUIsVWUOIf+f lIUCf5QixvNlmPzRimX+PGRxaZS7ofJ+SkxlqqpdRhe9wGTEAi4Y4fd1QDK7NGLx+VTc E2YtvXzFaIhg7Re7kFL9RwAybUfVRZCkudTMuf7JxFriC+wW29c/mX8mp1wS/p/PO1rK LqINR0GbNmmPT4i+R+ljqbCl2YSn0fU2hy3slNoqaMmVB4cg/lj8rTVk9nxvrnjBT0FS yQ2HvoCYMoKAbl/MlNDfWKGalmk2Zd5d1BYgJrrn1K0zSdo+0QWz5NovRWOSqsgYWoFc 87Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=AFKYB40YJrX94dmbX2foh6YfCwAV4FqZbML1ow8KGBI=; b=EbDul8S73SEswHMQ2G6hTrK7aPU0bX062jjJrrzi2vDwgMgjRArtkfSzboiSERupgv xRvJLRmQqiEuSy/Ty2MkQTmuMFzBVvqAq+qcuJ4sEihfweB1uQwPOHbh3EHcv2KZJLO1 G/yzu6vN1n6BBd/W9i2K/x6rmJmjcJcQ1tdWWLa4LZxhNrJT2AGp6433LaRj7qCMFF8c vvVtRrVrCvSFe+4ZgTvZhFgh2KEpM8/YIIQ7Tww5f+D1868OH3DIy+Fb7R1NQ8nP8zdG X6HXwNbA79EhHUQwPssKHBpoE1g5WknelXbJ6LHhh1OXUh6RBo7iaKB35ZhF3GX7DHnw Rxfw== X-Gm-Message-State: APjAAAW7huiyqTNB5cvimMw/4Cs78QvW/mddsy39ijAMt5CjMFSc6cXI lqR6ZkD6ovv3fidT1NALPZrgBg== X-Received: by 2002:a1c:4085:: with SMTP id n127mr11738355wma.68.1570201396808; Fri, 04 Oct 2019 08:03:16 -0700 (PDT) Received: from [10.1.2.12] (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id n7sm6589320wrt.59.2019.10.04.08.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Oct 2019 08:03:16 -0700 (PDT) Subject: Re: drm_sched with panfrost crash on T820 To: "Grodzovsky, Andrey" , Hillf Danton Cc: "daniel@ffwll.ch" , "airlied@linux.ie" , "Koenig, Christian" , Erico Nunes , "linux-kernel@vger.kernel.org" , "steven.price@arm.com" , "dri-devel@lists.freedesktop.org" , Rob Herring , Tomeu Vizoso , "open list:ARM/Amlogic Meson..." References: <20190930145228.14000-1-hdanton@sina.com> <7339b7a1-2d1c-4379-89a0-daf8b28d81c8@baylibre.com> <94096e4e-0f60-79d1-69b5-c7c3e59a4d78@amd.com> From: Neil Armstrong Openpgp: preference=signencrypt Autocrypt: addr=narmstrong@baylibre.com; prefer-encrypt=mutual; keydata= mQENBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAG0KE5laWwgQXJtc3Ryb25nIDxuYXJtc3Ryb25nQGJheWxpYnJlLmNvbT6JATsEEwEKACUC GyMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheABQJXDO2CAhkBAAoJEBaat7Gkz/iubGIH/iyk RqvgB62oKOFlgOTYCMkYpm2aAOZZLf6VKHKc7DoVwuUkjHfI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dRGgMK0cZB3Xfe6sOp24PQTHAKGtjTHNP/THomkH24Fum9K3iM /4Wh4V2eqGEgpdeSp5K+LdaNyNgaqzMOtt4HYk86LYLSHfFXywdlbGrY9+TqiJ+ZVW4trmui NIJCOku8SYansq34QzYM0x3UFRwff+45zNBEVzctSnremg1mVgrzOfXU8rt+4N1b2MxorPF8 619aCwVP7U16qNSBaqiAJr4e5SNEnoAq18+1Gp8QsFG0ARY8xp+qaKBByWES7lRi3QbqAKZf yOHS6gmYo9gBmuAhc65/VtHMJtxwjpUeN4Bcs9HUpDMDVHdfeRa73wM+wY5potfQ5zkSp0Jp bxnv/cRBH6+c43stTffprd//4Hgz+nJcCgZKtCYIAPkUxABC85ID2CidzbraErVACmRoizhT KR2OiqSLW2x4xdmSiFNcIWkWJB6Qdri0Fzs2dHe8etD1HYaht1ZhZ810s7QOL7JwypO8dscN KTEkyoTGn6cWj0CX+PeP4xp8AR8ot4d0BhtUY34UPzjE1/xyrQFAdnLd0PP4wXxdIUuRs0+n WLY9Aou/vC1LAdlaGsoTVzJ2gX4fkKQIWhX0WVk41BSFeDKQ3RQ2pnuzwedLO94Bf6X0G48O VsbXrP9BZ6snXyHfebPnno/te5XRqZTL9aJOytB/1iUna+1MAwBxGFPvqeEUUyT+gx1l3Acl ZaTUOEkgIor5losDrePdPgE= Organization: Baylibre Message-ID: Date: Fri, 4 Oct 2019 17:03:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <94096e4e-0f60-79d1-69b5-c7c3e59a4d78@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/10/2019 16:53, Grodzovsky, Andrey wrote: > > On 10/3/19 4:34 AM, Neil Armstrong wrote: >> Hi Andrey, >> >> Le 02/10/2019 à 16:40, Grodzovsky, Andrey a écrit : >>> On 9/30/19 10:52 AM, Hillf Danton wrote: >>>> On Mon, 30 Sep 2019 11:17:45 +0200 Neil Armstrong wrote: >>>>> Did a new run from 5.3: >>>>> >>>>> [ 35.971972] Call trace: >>>>> [ 35.974391] drm_sched_increase_karma+0x5c/0xf0 >>>>> ffff000010667f38 FFFF000010667F94 >>>>> drivers/gpu/drm/scheduler/sched_main.c:335 >>>>> >>>>> The crashing line is : >>>>> if (bad->s_fence->scheduled.context == >>>>> entity->fence_context) { >>>>> >>>>> Doesn't seem related to guilty job. >>>> Bail out if s_fence is no longer fresh. >>>> >>>> --- a/drivers/gpu/drm/scheduler/sched_main.c >>>> +++ b/drivers/gpu/drm/scheduler/sched_main.c >>>> @@ -333,6 +333,10 @@ void drm_sched_increase_karma(struct drm >>>> >>>> spin_lock(&rq->lock); >>>> list_for_each_entry_safe(entity, tmp, &rq->entities, list) { >>>> + if (!smp_load_acquire(&bad->s_fence)) { >>>> + spin_unlock(&rq->lock); >>>> + return; >>>> + } >>>> if (bad->s_fence->scheduled.context == >>>> entity->fence_context) { >>>> if (atomic_read(&bad->karma) > >>>> @@ -543,7 +547,7 @@ EXPORT_SYMBOL(drm_sched_job_init); >>>> void drm_sched_job_cleanup(struct drm_sched_job *job) >>>> { >>>> dma_fence_put(&job->s_fence->finished); >>>> - job->s_fence = NULL; >>>> + smp_store_release(&job->s_fence, 0); >>>> } >>>> EXPORT_SYMBOL(drm_sched_job_cleanup); >> This fixed the problem on the 10 CI runs. >> >> Neil > > > These are good news but I still fail to see how this fixes the problem - > Hillf, do you mind explaining how you came up with this particular fix - > what was the bug you saw ? As Steven explained, seems the same job was submitted on both HW slots, and then when timeout occurs each thread calls panfrost_job_timedout which leads to drm_sched_stop() on the first call and on the second call the job was already freed. Steven proposed a working fix, and this one does the same but on the drm_sched side. This one looks cleaner, but panfrost should not call drm_sched_stop() twice for the same job. Neil > > Andrey > >> >>> Does this change help the problem ? Note that drm_sched_job_cleanup is >>> called from scheduler thread which is stopped at all times when work_tdr >>> thread is running and anyway the 'bad' job is still in the >>> ring_mirror_list while it's being accessed from >>> drm_sched_increase_karma so I don't think drm_sched_job_cleanup can be >>> called for it BEFORE or while drm_sched_increase_karma is executed. >>> >>> Andrey >>> >>> >>>> >>>> -- >>>>