From patchwork Mon Apr 24 01:43:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 86825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2465761vqo; Sun, 23 Apr 2023 19:30:37 -0700 (PDT) X-Google-Smtp-Source: AKy350bePGvhQ31tQk4qWKCPIEIV5Kll7UO9u7yBEO4Cdet1S5JlVZB6gwktEF/pwKgy5x3gtJG4 X-Received: by 2002:a17:90b:1d08:b0:23f:d487:1bc8 with SMTP id on8-20020a17090b1d0800b0023fd4871bc8mr19562172pjb.13.1682303437352; Sun, 23 Apr 2023 19:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682303437; cv=none; d=google.com; s=arc-20160816; b=qW4yFVB66WqkRcZdPlHi0yzU1bt8fuTtMVhQzOPDLql8yx3mYKD3nwe3jS3pQa46sL zps13YDAUw4mCHEr+XT50WoGNIJ/SRcPcCmCM2O1SjUul+M+a9WfWxYS/8+rSqWYRICB zuAhbKwSyWo11HlTOMTrP5QPt/wnprWEsmgje5Vsv4/+nzCbojPd4mp64HCAAQTtRSb2 jPSgY/uwZR57o+HNihDLBW5HsZBMUed7Ot416z3PYkYxP6siDDGuk1Cyyg1imp8XxMwi W+uEB4MwKIFi8LknlEpIhS/xseyfqt/FtVmetNc+KDduUVwRK7oKAjKQWuuPd2b+LEnb WImg== 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=0Sf6LJiinXD0+Z04+CoBCjhP6xRPg9WnwCH4CvJn44g=; b=Q/5OOLUhclcx/R5oNxA+NWp7L5gyt6gREcm+98ALCcp9ehNyIcu69VW6owzIdpROq3 qVIOxZRGQXLHyvaoo4/xpl6JGTxQqDbYZ/v96+jdXCV7Hl1jLEeYGWjlV9Wsya92P83K D/CbL5WmW/V3JqNK0UJ7MTzjrLL63FuA+ooFJPgYbpEfXwdq+YTSRtDhptPliotkhAkm aQmQ38b46fh0NrKMLAQhV4RhCqVFbWtVd4ZstUV3ro6dRUJHeMUAaymY/sGe8Q3EKLQj rsojF6r7FXNvdpozuzp5aCcR7lB1zr8CdPJplC2ez+DCxZjoge070YZfh4jRC72o+1dG t92g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=JIcVwiky; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf14-20020a17090b1d8e00b0023f14c9a5fesi11109699pjb.100.2023.04.23.19.30.23; Sun, 23 Apr 2023 19:30:37 -0700 (PDT) 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=fail header.i=@igalia.com header.s=20170329 header.b=JIcVwiky; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbjDXBoT (ORCPT + 99 others); Sun, 23 Apr 2023 21:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbjDXBoS (ORCPT ); Sun, 23 Apr 2023 21:44:18 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD41E10CC for ; Sun, 23 Apr 2023 18:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0Sf6LJiinXD0+Z04+CoBCjhP6xRPg9WnwCH4CvJn44g=; b=JIcVwiky7ofsROMjxVeNT+AQEL gSU2A0P4XNRrWSyZwXgZi/+FOiKwNjUmXLgtMSC3hz+vOL4g/EYOnY170TdlZqVgSFfImBxA5+sFo iPTnAFTQhlifb5rJHjqGpyfhf49jz7pt0yN/UHMkYNQhAgwyslyIB6BdsBlZIenn4GiL/Fv98NYDA gDjFSgCcyQTeR6ls08+hXDWYDf3aGeA9zCejqkMaiEnzaEcH089aZc9Mdl5B++z2groTyLjc1dsvd uEwnjUDOTomCjEfvzlCCPNtq5LZI0vv+SN0/hE1Ll2yuZ85HzJY2PD2SVyNZWUA3DjgMnj0HnB+It xX5CGfEQ==; Received: from [152.249.146.45] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pqlFV-00AeE7-4w; Mon, 24 Apr 2023 03:44:13 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, =?utf-8?b?J01hcmVrIE9sxaHDoWsn?= , =?utf-8?q?Andr=C3=A9_A?= =?utf-8?q?lmeida?= Subject: [PATCH] drm/amdgpu: Mark contexts guilty for any reset type Date: Sun, 23 Apr 2023 22:43:24 -0300 Message-Id: <20230424014324.218531-1-andrealmeid@igalia.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764023009232767589?= X-GMAIL-MSGID: =?utf-8?q?1764023009232767589?= When a DRM job timeout, the GPU is probably hang and amdgpu have some ways to deal with that, ranging from soft recoveries to full device reset. Anyway, when userspace ask the kernel the state of the context (via AMDGPU_CTX_OP_QUERY_STATE), the kernel reports that the device was reset, regardless if a full reset happened or not. However, amdgpu only marks a context guilty in the ASIC reset path. This makes the userspace report incomplete, given that on soft recovery path the guilty context is not told that it's the guilty one. Fix this by marking the context guilty for every type of reset when a job timeouts. Signed-off-by: André Almeida --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 --- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index ac78caa7cba8..ea169d1689e2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4771,9 +4771,6 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev, amdgpu_fence_driver_isr_toggle(adev, false); - if (job && job->vm) - drm_sched_increase_karma(&job->base); - r = amdgpu_reset_prepare_hwcontext(adev, reset_context); /* If reset handler not implemented, continue; otherwise return */ if (r == -ENOSYS) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index c3d9d75143f4..097ed8f06865 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -51,6 +51,13 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) memset(&ti, 0, sizeof(struct amdgpu_task_info)); adev->job_hang = true; + amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); + + if (job && job->vm) { + DRM_INFO("marking %s context as guilty", ti.process_name); + drm_sched_increase_karma(&job->base); + } + if (amdgpu_gpu_recovery && amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) { DRM_ERROR("ring %s timeout, but soft recovered\n", @@ -58,7 +65,6 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) goto exit; } - amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); DRM_ERROR("ring %s timeout, signaled seq=%u, emitted seq=%u\n", job->base.sched->name, atomic_read(&ring->fence_drv.last_seq), ring->fence_drv.sync_seq);