From patchwork Thu Oct 24 19:57:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 11210661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC891913 for ; Thu, 24 Oct 2019 19:57:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4B052070B for ; Thu, 24 Oct 2019 19:57:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4B052070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53D5C6E784; Thu, 24 Oct 2019 19:57:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810048.outbound.protection.outlook.com [40.107.81.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECA076E784; Thu, 24 Oct 2019 19:57:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BfdFKTayFRnbv2TiAv26Iw6Uw4lNwJPJ6a4y60wf/r4DnCt5z6jHlwvBj5jaGbIBqByDwT5miXIAK36H9JshiHJLeQ7MmjMFTQeK2S4M4qFEiKaBocVd4ZH86LqVIlHI2h3+ozKQ0rIgWw2+iobEvNNVYY0ulxrj6RdhX5EC9IaSmNRokskbcHlv6geO7HZNj7RNJqP0CVO0xtnRj3SkNvtX7pzaGuqGfMT/sc1ArHokVR0Cp7Q0iUiXmA1ndv9AEiS93ZrJPDeWTmrjW1p+2qW62TlKJwfY92JFduTL+72VefHDUEii7MWfi5SX5fQ13OeSB+idEvULBFf6dKgJYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dFNaNjE/tStoe8fOKoLYHB68C3bdfg7hp/zjaW5jLdY=; b=TAP9POVtDiPuoiZkCkqhvV4qQG0UbvIWbwBnY59vsF7bBoGnnM8doZKaFbG4LD641pLzEEHEkvMRSfRcox5ylEJZqUOYUWr2Lpu5gmql4ctJllv+aBK3eAPI1SmrpdDB791hzU/sRZiF8h60dJuv6IRersJUN/aJytXcVxjEbedfqJNDe5+tWaDUg9PGQ4zzbMXL1vS6RWj/UmxTa4/lFpt8QAuYIfI62SFt7t4OujIK/urTiKhIGO1Mhw04xIUuH8gmyghrhPF077EcHumKeW+nyG3AAdgu0xtQiOkxLbCPIsHmjHjFhfQA+UdPjr/S/jOi20Nn2/edWhYfIFRAKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from SN1PR12CA0091.namprd12.prod.outlook.com (2603:10b6:802:21::26) by BN6PR12MB1153.namprd12.prod.outlook.com (2603:10b6:404:19::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2367.24; Thu, 24 Oct 2019 19:57:34 +0000 Received: from DM3NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::200) by SN1PR12CA0091.outlook.office365.com (2603:10b6:802:21::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20 via Frontend Transport; Thu, 24 Oct 2019 19:57:34 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by DM3NAM03FT020.mail.protection.outlook.com (10.152.82.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2387.20 via Frontend Transport; Thu, 24 Oct 2019 19:57:34 +0000 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 24 Oct 2019 14:57:33 -0500 Received: from agrodzovsky-All-Series.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 24 Oct 2019 14:57:33 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH 1/2] drm/sched: Set error to s_fence if HW job submission failed. Date: Thu, 24 Oct 2019 15:57:29 -0400 Message-ID: <1571947050-26276-1-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(136003)(396003)(376002)(346002)(428003)(189003)(199004)(48376002)(8676002)(186003)(50466002)(70206006)(70586007)(26005)(2906002)(8936002)(50226002)(47776003)(53416004)(81156014)(4326008)(336012)(81166006)(6666004)(110136005)(44832011)(426003)(36756003)(54906003)(16586007)(2616005)(476003)(126002)(486006)(305945005)(5660300002)(86362001)(478600001)(7696005)(51416003)(316002)(356004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1153; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e214cbfd-3135-442b-fc40-08d758bc695e X-MS-TrafficTypeDiagnostic: BN6PR12MB1153: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-Forefront-PRVS: 0200DDA8BE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4udein9ngI4ON4FnQXbwJFgUXZOXECYDggCh2uEjS0MYbd1kZ5ZB8HcdwtJ51yOEbOP3bwoX4YB5dIV6So3nosbaEFco+6QjvVZ7vtENvckV2OVveO+6PGBmFHdX2r81BHJ2WYgrF8PqAqAlR2I4poCor1IFLCSz7/O++aCGvIbnktMoZecir5FUVvI5boXV7mnMXKW7ZpYCFg9QledwAUZmW7Nba8gLxTL9uoKdr6Kq4znBMKFe/jcWzVwoRlT8Bv+5NhS483sYeii+4Si/9xY5M9JkFrnyyXLudbURf0GOF4Kt5EzsS1ntgjz4L/bCGf6rfAGocLEjj9cItPI+E8wxel1UMPMvB8QPNLDcmoxfR7ld/I8aUKZNaQ7U51k3BDqpY96nIuN80BJ8IQCn8eQxNWqIv8BS71lslp+nKtyUEj1xW/P/7FRdv4urrOk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2019 19:57:34.0292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e214cbfd-3135-442b-fc40-08d758bc695e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1153 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dFNaNjE/tStoe8fOKoLYHB68C3bdfg7hp/zjaW5jLdY=; b=A4DnhLq1ZF97C2krEh1Z0xXzP0PerQIh4p994Z+yftm2krAYRi+89ggDHwwZKjQeHPPrkJ0TTLwRI1XotzO/Dw6mCaY5w5MPp2gu5ui8OXQ1uazMtsLcRWvJMEIb3hgzYaqoOS2lJcpIYBMUauHPweJpoW4e74Md2u7JErf5f/I= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckoenig.leichtzumerken@gmail.com, Shirish.S@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Problem: When run_job fails and HW fence returned is NULL we still signal the s_fence to avoid hangs but the user has no way of knowing if the actual HW job was ran and finished. Fix: Allow .run_job implementations to return ERR_PTR in the fence pointer returned and then set this error for s_fence->finished fence so whoever wait on this fence can inspect the signaled fence for an error. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/scheduler/sched_main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 9a0ee74..f39b97e 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -479,6 +479,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched) struct drm_sched_job *s_job, *tmp; uint64_t guilty_context; bool found_guilty = false; + struct dma_fence *fence; list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { struct drm_sched_fence *s_fence = s_job->s_fence; @@ -492,7 +493,16 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched) dma_fence_set_error(&s_fence->finished, -ECANCELED); dma_fence_put(s_job->s_fence->parent); - s_job->s_fence->parent = sched->ops->run_job(s_job); + fence = sched->ops->run_job(s_job); + + if (IS_ERR_OR_NULL(fence)) { + s_job->s_fence->parent = NULL; + dma_fence_set_error(&s_fence->finished, PTR_ERR(fence)); + } else { + s_job->s_fence->parent = fence; + } + + } } EXPORT_SYMBOL(drm_sched_resubmit_jobs); @@ -720,7 +730,7 @@ static int drm_sched_main(void *param) fence = sched->ops->run_job(sched_job); drm_sched_fence_scheduled(s_fence); - if (fence) { + if (!IS_ERR_OR_NULL(fence)) { s_fence->parent = dma_fence_get(fence); r = dma_fence_add_callback(fence, &sched_job->cb, drm_sched_process_job); @@ -730,8 +740,11 @@ static int drm_sched_main(void *param) DRM_ERROR("fence add callback failed (%d)\n", r); dma_fence_put(fence); - } else + } else { + + dma_fence_set_error(&s_fence->finished, PTR_ERR(fence)); drm_sched_process_job(NULL, &sched_job->cb); + } wake_up(&sched->job_scheduled); }