Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4370626ioa; Wed, 27 Apr 2022 02:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqIQpPDWECp+hd8jCXWs3r+vEzl4wW97QlV7IpzQ/mxOAw8R3EwsGuwwelXK/y/oQNmwTj X-Received: by 2002:aa7:9522:0:b0:4e1:d277:ce8 with SMTP id c2-20020aa79522000000b004e1d2770ce8mr28780123pfp.16.1651050734153; Wed, 27 Apr 2022 02:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651050734; cv=pass; d=google.com; s=arc-20160816; b=s6NkFliEdGs/a4X484/gvExe8JHXGBuQqsSttgsEkoFkJQg2TZk4ZCVl8LN/8ITJ36 g3eKdEupqGvqkAoEhDrkMvRXgS/YKD9b6E2e9DMMExT9LO25V5xZtF/flBWS6y7VCCq9 ophpGzfHBnbnDddQ1WfvlFd6acldZD4DFG4HK5eL//tj1h+A4PSnjlLzeJaNnKwmXOlS cW8hSyb8Dmy17xnmnEMYKofYZht7VJEhA+rdPqQMqbwcyZVmxjJ3x+P5ByY6Bo2GYHsZ edMpNNULFgp85KRr6WOZJ1yY+eHfeAQcbEU92HFALkr3Auflos5Qb40p+uqZtif/Mb7K hwNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=RXVjliGmKXDl/LJVTHJiDkocbdSCQZqsBwNaeaQETtg=; b=B10XLogtGjacQ71iLl+vnsH/xhoJBxZubve9WSLGyIu1ltW3XmvU5I0AuTGiOpbDWi K6eXLTB5h/+aRMANIv33td3eFMz3271f+lRfEFuOYW5egDaKvCU6qzs9UUEOPeyjnOg6 W12skU4nUSG2+dFuQS6kT8XKTlQ+pPdUFzTR8YYF9+7fPDFFVNAbnWhCa1DNLysNHzKz mG5ptOb1HUPVeYoosMp/ft5dz0xniwiKghi9QKfiUG6ja/3QHAVJ7LcKaqt9QXFhs8ev WHV0LM5CwcwT0uCwdtzKL7OAVH49IQvICPaM5bYbivxSQUGM6b0f1nE0Yj4JGrO9WAgb UQIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z7YlnHta; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e185-20020a6369c2000000b003aa494b2954si924437pgc.107.2022.04.27.02.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z7YlnHta; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01C5020904E; Wed, 27 Apr 2022 02:03:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351825AbiDZO7H (ORCPT + 99 others); Tue, 26 Apr 2022 10:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351824AbiDZO6s (ORCPT ); Tue, 26 Apr 2022 10:58:48 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222121ADBC for ; Tue, 26 Apr 2022 07:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HDppPzwK5CHeW2blMZ5MWYNhK7JZ3Y2HsF2nKmuLnFi/W+y/GMFM31GNeaAVGRVpLY2RSpLKeVTd3T5LGUgPXNC+ruPP09IVHIpoPTt3QJWQYm9C/JKn/2rvRiSiPGvkwIHqyLY225hBIbJB1WwAAAZhhry8Dl8oqFb+pBeiorR1xI/nRiZuV83uDYMTQtiKUmjtol+qml1RHeANkepmhV2A5sij0qkKdfVMsy8x9wh8Z70DMYXeORuUaJjCHfC5InLPKnYpaWp02Q6TuinF5DmC6Qu5KunNkcMHXmJKM/KmXmoWf+gLmFzD0Hn0ZPXEmHcKr+HYhrx9ZHjHlwRk/w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RXVjliGmKXDl/LJVTHJiDkocbdSCQZqsBwNaeaQETtg=; b=YHf+zB5vZJd3At1OJxww2XBkbbsgY8USMfBJNqzKz96K3aq2v85AEINiTQ/xM38LsN1Mtzt33/UuOw4lUXnk6yhhK3bxy3kmbtKHV9Nzn3F9LGxCQBO2Y3tWx+iKlA5V117TiBvUZYwBbK7xpkF1FaADEeQBExZny4vDHBKx0lRyDxmn3k7JqXr8ekJji9RfdVR7EoJHTXBgyb5+ly6yWXoav9Jp/vajq61pceqG6IJCTu7CBHyb9MF8iPdVHC3IynnQjL9R+gmPKr8YcxyPlzLjAMAq2lyDdgDC9rNAWykudDC0GcRyEqC+apOS0DJxOuBfxcITaEd6kBWuwSaNCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RXVjliGmKXDl/LJVTHJiDkocbdSCQZqsBwNaeaQETtg=; b=Z7YlnHtaYqw8GrLmXzkLaS5s93wheQh+5WviBmvs8hf76EH6Kx+vQyLVlsVNPI3zj8N7k2ZpogsLDNHhP9vBNgZwTlqCaj1KN1TTP8cQFnJapvWB5u9f+M/pPCBX1c7NMn9ke5qre+81cavz9PTAIXfQj9W1t3rrJsNhfrcRynA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1947.namprd12.prod.outlook.com (2603:10b6:3:111::23) by DM4PR12MB5309.namprd12.prod.outlook.com (2603:10b6:5:390::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Tue, 26 Apr 2022 14:55:38 +0000 Received: from DM5PR12MB1947.namprd12.prod.outlook.com ([fe80::1ce8:827f:a09:f6e]) by DM5PR12MB1947.namprd12.prod.outlook.com ([fe80::1ce8:827f:a09:f6e%5]) with mapi id 15.20.5186.021; Tue, 26 Apr 2022 14:55:38 +0000 Message-ID: Date: Tue, 26 Apr 2022 10:55:34 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] gpu: drm: remove redundant dma_fence_put() when drm_sched_job_add_dependency() fails Content-Language: en-US To: Hangyu Hua , yuq825@gmail.com, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220425083645.25922-1-hbh25y@gmail.com> <79b198d0-eff2-d658-4b5e-9084a834fc93@gmail.com> From: Andrey Grodzovsky In-Reply-To: <79b198d0-eff2-d658-4b5e-9084a834fc93@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YT3PR01CA0098.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:85::9) To DM5PR12MB1947.namprd12.prod.outlook.com (2603:10b6:3:111::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55a930f3-6965-4054-bd83-08da2794d320 X-MS-TrafficTypeDiagnostic: DM4PR12MB5309:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vPuP7L2NFQyKia8PRlfs8OpmXGV4YjPWIVe3m5lzNlDC5+rcxAGtdJlm9bFUPiU/raVhBikGyG9CwCtYqOiEb4miFiIJtIrq9eCUJNks+MiCHitpjX6UmU4TUXaPVeSCoC63UqsAEA1foZ36EB4gX/soN0U1m1lxC1TFa17Jsdo3rBH6BA8crs58qa+KHeveEfSlY0n+NQYqjVfuy+NswjgJYdiFWSBYDIM+JnKYO3ithmMZa3gRlHhq+YD8M4U5HMLc7pEgZaKiW+OLJhbLWGgUu++jkpO+DPw7+G9OCJUP8/WGRZrcGMbC5G/MHhd2TV7h9RQP0AeStz9/1d30G3f8iezcGsPZSiiKtkNnOCD6znmsR45kdoHSlRCNKZHopFZRJi7NA5LUfg4JtBNEYDiqQakbprGTjZToLnU4S6ZVToCdVQATmClxw6cepLq2nfMcmga/Okl7pGta61PxQIcrABQTxtrrSez9h4Up9G6Q0FB5VAK/MYCivC2WL51RMy1EnpF7DYX2m702crPHRvchxwVtFVb/QneZbnmJhQ92o0ldx5eQwMqtDP0zbC4UhgmFDB+JtY5ZRqXvisktMTLtWIncTXvv35Uxq8VTAdbCenmuMuB1CRKoFCmhfgg8TU0T3qZCCiuivetNSeKfPLIX30MuryABrBByniBStkumLrY61xseQx0GmcAMCourdQyvDYKu8Ei1tdIYvWNAxhRf3r3WMJt6mjPdT9N5f7k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1947.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(44832011)(8936002)(4326008)(83380400001)(316002)(66946007)(8676002)(31696002)(86362001)(6486002)(508600001)(2906002)(38100700002)(5660300002)(66556008)(66476007)(186003)(2616005)(53546011)(6506007)(6512007)(6666004)(31686004)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T3BZbVRJTlpNcTF6ZnVUSCsvYkR5cDRhc1NKVEYyUll4UFFVRUFteTNkOHBR?= =?utf-8?B?V0ZFR1FCeE9id2Z2SEg1b0ZxdFdGMnJEWFlLVjExZVlCMDB3ME93cmdrNjBt?= =?utf-8?B?Q2xoWU5uMC9peHduMFNFbTVISlJqZ1hrNUttMVN1NU52RFVjMmhNQmROU2g2?= =?utf-8?B?a1MvTkUzZHlXdU0xSmcwcVA1cDdSOW9FakRzc2xPRGJCbkVwZzZRNGlQbmxR?= =?utf-8?B?YVR0RWxJSHFjMC9QSXordXM2ZnpxSGRYNFFJU2g5SVBiMHo2ZXZmNE10M2Nt?= =?utf-8?B?ZnJIRDc4VnNVNFd2Zk9nRnlrMXRvTG4xV1BFc1FOUC9HQ0VwQXRIV21WYThZ?= =?utf-8?B?cXRuQlVRS1VRa2VqV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RlWWp6WnRkbE1Xa1Bx?= =?utf-8?B?NjhOMjYyLzFEbTgrTmJ6QmxuTTh3MWsybG12QmZ6SDg2RjdIRnNhcVlNSUdW?= =?utf-8?B?NGxqUW1zcG1SWHB3SHMwUkg0NEhQZ25LUEZJNk40MWNxZW1zSmJlcUZLcE9G?= =?utf-8?B?Y05vTHVHQnhmVHIwcUJ3bG9scXNZMXB6a1gwTXlsNWZLTVlrc3ZjQnR0aVRR?= =?utf-8?Q?LWNZdpsNfrLjepIcStJLRkaoRJKBDq9C7hD0rAgDSDjpH?= X-MS-Exchange-AntiSpam-MessageData-1: Q1NWsJ5XvLA9GA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55a930f3-6965-4054-bd83-08da2794d320 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1947.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2022 14:55:37.9783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EIAwtq2I16vSUtrepKukoa6d/BdAyKPUeajNVWmwcMtb/jXxG5joDsOhf9SlE+H0bovkIWsHSJuoEUVkAAOMjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5309 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 On 2022-04-25 22:54, Hangyu Hua wrote: > On 2022/4/25 23:42, Andrey Grodzovsky wrote: >> On 2022-04-25 04:36, Hangyu Hua wrote: >> >>> When drm_sched_job_add_dependency() fails, dma_fence_put() will be >>> called >>> internally. Calling it again after drm_sched_job_add_dependency() >>> finishes >>> may result in a dangling pointer. >>> >>> Fix this by removing redundant dma_fence_put(). >>> >>> Signed-off-by: Hangyu Hua >>> --- >>>   drivers/gpu/drm/lima/lima_gem.c        | 1 - >>>   drivers/gpu/drm/scheduler/sched_main.c | 1 - >>>   2 files changed, 2 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/lima/lima_gem.c >>> b/drivers/gpu/drm/lima/lima_gem.c >>> index 55bb1ec3c4f7..99c8e7f6bb1c 100644 >>> --- a/drivers/gpu/drm/lima/lima_gem.c >>> +++ b/drivers/gpu/drm/lima/lima_gem.c >>> @@ -291,7 +291,6 @@ static int lima_gem_add_deps(struct drm_file >>> *file, struct lima_submit *submit) >>>           err = drm_sched_job_add_dependency(&submit->task->base, >>> fence); >>>           if (err) { >>> -            dma_fence_put(fence); >>>               return err; >> >> >> Makes sense here >> >> >>>           } >>>       } >>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c >>> b/drivers/gpu/drm/scheduler/sched_main.c >>> index b81fceb0b8a2..ebab9eca37a8 100644 >>> --- a/drivers/gpu/drm/scheduler/sched_main.c >>> +++ b/drivers/gpu/drm/scheduler/sched_main.c >>> @@ -708,7 +708,6 @@ int >>> drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, >>>           dma_fence_get(fence); >>>           ret = drm_sched_job_add_dependency(job, fence); >>>           if (ret) { >>> -            dma_fence_put(fence); >> >> >> >> Not sure about this one since if you look at the relevant commits - >> 'drm/scheduler: fix drm_sched_job_add_implicit_dependencies' and >> 'drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder' >> You will see that the dma_fence_put here balances the extra >> dma_fence_get >> above >> >> Andrey >> > > I don't think so. I checked the call chain and found no additional > dma_fence_get(). But dma_fence_get() needs to be called before > drm_sched_job_add_dependency() to keep the counter balanced. I don't say there is an additional get, I just say that drm_sched_job_add_dependency doesn't grab an extra reference to the fences it stores so this needs to be done outside and for that drm_sched_job_add_implicit_dependencies->dma_fence_get is called and, if this addition fails you just call dma_fence_put to keep the counter balanced. > On the other hand, dma_fence_get() and dma_fence_put() are meaningless > here if threre is an extra dma_fence_get() beacause counter will not > decrease to 0 during drm_sched_job_add_dependency(). > > I check the call chain as follows: > > msm_ioctl_gem_submit() > -> submit_fence_sync() > -> drm_sched_job_add_implicit_dependencies() Can you maybe trace or print one such example of problematic refcount that you are trying to fix ? I still don't see where is the problem. Andrey > > Thanks, > Hangyu > >> >>>               return ret; >>>           } >>>       }