Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp749305rwl; Wed, 5 Apr 2023 07:16:09 -0700 (PDT) X-Google-Smtp-Source: AKy350YNyCHSs9Pk2qBR22eSJMs2mQTxscsbedA/+DFNtD6mUYxRE+YmG3fzdWHvI+Tl8LZ+TvPg X-Received: by 2002:a17:903:2806:b0:19f:a694:6d3c with SMTP id kp6-20020a170903280600b0019fa6946d3cmr5690375plb.55.1680704169221; Wed, 05 Apr 2023 07:16:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680704169; cv=pass; d=google.com; s=arc-20160816; b=Hs2YGUJV1mVNNIft8iHpR0aGDQnrXpTHdVOBPfDmEbmsrw9ZyL/HXnTt3dHKqc3KcG UvwkAOqkOaDwmXBbVSH9vmD8vJoZKiT2Yg7/qlJ8wxVe8D934PJqX0mi4P9vGpfmkIzD h9KFeCVAKXiAfCqIxTdVxGIuWjvAKppIaWQ/AXLTeN4M/ME4zamBPnUPSsmyBKnHUf5y gJ/vP6yYKMhibzIOLTIRVTGCnxCL3ksPq9sWK2eznvWkZ20pAV9smCFRBUtbsOqNsR6S hVkZ7QoE95iqlqqIjABmwhdMRC8wyHAkuPNCByYY2PdomPwZs3Tf7rHuReCq0diFkurX FUcA== 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:to:content-language:subject:user-agent :date:message-id:dkim-signature; bh=INSvVes12oim6c/N1vy4SGbvRUSVDv11ZE30GMkAWOU=; b=zQsHbbg9hYsBTFpdpmP05yyolFd2jkN2WenlauLxjIOXthIvEXMFZC9W3DqUPsbYj7 3OE4lqrC8msQC/ZCuQ+CKH3D4AbZX/fJ5tTtSXvENcfz0vRWlk6zcpl4C8m21L2ZH/BL wdu+rFy4ZVsc7yRdrzE3L4sM7x8drBKFLCfckLy5xfbaMmFzrPjG/dNPC82mLKipBlom aKF7VcMcf9w5Sb/8lms84U7PTx1KtWW2vGOBmsDnVELDrAWoV2ipaRAPEBeExNQmj/EC v/wfSzSfuhMX3g92UQpm52AzDJT8YVJCz70zpSsgUhlBPwY0Y6+0r9ZybQ2yq4SjHcTW mElQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="Nk7Ueb4/"; 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a170903120f00b001a05a78f952si12855067plh.272.2023.04.05.07.15.37; Wed, 05 Apr 2023 07:16:09 -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=pass header.i=@amd.com header.s=selector1 header.b="Nk7Ueb4/"; 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238446AbjDEOPM (ORCPT + 99 others); Wed, 5 Apr 2023 10:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238339AbjDEOPK (ORCPT ); Wed, 5 Apr 2023 10:15:10 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 291A959D8; Wed, 5 Apr 2023 07:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QCYn8g0b2AbMx/0C9yU/Ph43xr3JKznmlVtn7Nz+ZNKe4bTjcLLDnFsZsx5D/QClPhDytVFzb7lIxAr/PPrWb7iIMWJSQ3y2C4X4cfJX8rD/IgaHNfnown+hkG4ngWd+irEO+SWftr2DWLcjAlCk0Lzv26rGvgz0+f8AntmTLudDtgbRvebxh+a7IEzcM6WRQWMWWm3U61PO8iaTt72jDX4k7x4FC8MfnosSzDoDj35ZplR+D/JuUaMjiFBEVksSI4BUu+jaLnEO2FDzRFkbH4vc0gyQ6t2ftorlCtwZIb84Ryo3yuDfcBpVp6sw6ukrbRsMfnzRuCA8cYh6brcV3A== 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=INSvVes12oim6c/N1vy4SGbvRUSVDv11ZE30GMkAWOU=; b=JYw58WLAPVuBnZTFBd90ca6YTC57rjZnFljAWsuG9npYKc1n4MmWVSm9nj8OWD7KrPdNWaJ1v7XR+6aHGpztamJCAELYz0uBzrdgvk73g5BpgeF9wQMQtcbY8ZkWRqod2PAn2cdFHlhwp+fOpg4mvW5ZNN/vftvJhhNeHIN5uqxoKTsslz8JDDdED5RbSY7DNCRha6Pbv7gIFr8hki2N+qb4Rj08BxwXV0z8Tc0IU7zeIw+kTYHBrrUuKIQVvv5ZhePq1NvjjLECy5QZ3VlpVNQ/bt6BhuEHe7yCtsB0gFPvqb83lPGI+QnY+43xJsLDSgUzKokMw0Q/VAtZk2vXwQ== 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=INSvVes12oim6c/N1vy4SGbvRUSVDv11ZE30GMkAWOU=; b=Nk7Ueb4/JPB4x07LgQOR1uo6L/oD9SzncQel9iYVAshSVdFh9bda1l926rUI9gh3glreBscpL4F0iekrrgyAfz4dNmZXyEbTiA39fBD+P3Y9XSx3JIbc8PVKomGV9ARXNqu9Z1hk/ZqOlxNgAEedHY8GVTwrIkb/aHfP8F9d7Wg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by DS7PR12MB8250.namprd12.prod.outlook.com (2603:10b6:8:db::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Wed, 5 Apr 2023 14:14:19 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::4624:dc39:943e:6ae]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::4624:dc39:943e:6ae%5]) with mapi id 15.20.6254.035; Wed, 5 Apr 2023 14:14:19 +0000 Message-ID: <20502c4c-c987-3117-119a-2fd38ae5f607@amd.com> Date: Wed, 5 Apr 2023 16:14:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH RFC 10/18] drm/scheduler: Add can_run_job callback Content-Language: en-US To: Asahi Lina , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= , Sumit Semwal , Luben Tuikov , Jarkko Sakkinen , Dave Hansen , Alyssa Rosenzweig , Karol Herbst , Ella Stanforth , Faith Ekstrand , Mary , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-sgx@vger.kernel.org, asahi@lists.linux.dev References: <20230307-rust-drm-v1-0-917ff5bc80a8@asahilina.net> <20230307-rust-drm-v1-10-917ff5bc80a8@asahilina.net> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR2P281CA0185.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::18) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|DS7PR12MB8250:EE_ X-MS-Office365-Filtering-Correlation-Id: 8893a67c-cc2a-48ae-24ee-08db35e00bd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XhIcQy0YBAxRM6hrAWIZTRgtPXS/EbsbxjQM5yetl2NuyS629JB1WnEOwstmkZc1QI+06zwWQiCyWzgLc3ZpVwFFYHctD8vc2sSGXAxTKO+6ZQhaRIT10YJ9MGH49Hh1aGrKPaJkysggvNZ5fZflZwRfCHq0C37XJ6ltRGUDgotRo9wMTRb1O2nOEw0DcRxHllX8jVeLilDVdl3cSkkRK8JA9oc0fbmMHlWy+VTEqTduW9UbF7y19cJWg6PBo1cmcChV40M4LfT33pztpBZ3/1irn6WXM8jXbVks40926UyAtRd3dkbwvL+GZg9Y3eGgnRM60KnCygy8Q5SUvxCzefTESD/1s8Zea3k/9/zk/Vhjwb/37tazK0IYUnA7qFpjKyTKT5zCrLKt0P7xIsVwehTBY7fBCdBeVjfFGfOen8oqK0cLQYTXbQ5kD5XYV7CZejKfY6CpbbwTHpW0xUv6HMAoGJ9gsiMQv/9ZHMrpii6QStYqsHei7tTTGiIVy9GEJ32LixCXiM7pvRRRfW6JunGvsu7XD+HBcZG5drCLLLTd3i0Q0mp7d2KUwBEkZC+tweFNPfAOL7f8le48HwlBMMpmhRp+n4VoHogBzoo25RTDZ8SlvH4T9/T/47EYRkCq9Kh5nuyGw13wc/A+ubd6ygp/BUMV5Vjv+asO0qQ9I7KF1M0Bdja5W9WZX81mBdJP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(346002)(376002)(396003)(136003)(451199021)(31686004)(2906002)(86362001)(5660300002)(38100700002)(66946007)(7416002)(478600001)(66476007)(66556008)(8936002)(110136005)(41300700001)(186003)(316002)(36756003)(8676002)(31696002)(6512007)(6506007)(83380400001)(921005)(966005)(6486002)(2616005)(6666004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Vnh5c0RVM3dBQVZVSi84aEh5ZlZYNHhSNmIyMUh0SVpyaCtiN3ZCMzNrOG90?= =?utf-8?B?Q0ZiWnEwU3VORlZQaGVoL2hya1dkMzZWTmRPSzZuNUxwU2M5MHhvRXU5YkYr?= =?utf-8?B?R29sdzFuNmMwUkh5ZXRzcXBsd05BTDJwQ1JqSGR5MCtMYnkzRUdnM0NaM01s?= =?utf-8?B?NHV0aytza1VUeUFncUNyRll1YnpFMm5SSTQ1WmpaUW5pWnhCNDFEWFFIMVFz?= =?utf-8?B?dTdXdHRtUnp2Z2J1REFoVllRNjQzZENKekpwM2x5M3hhQlA1d3pMdmcy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WVzNWlxd2JkWDAwaEk3NnVJeFJ6aXo5Rmg1ekU4UlM5?= =?utf-8?B?eFc2aFRBTXpJTFlLbFFBdTR4UlBhV3JCczBONlMzZ0doRkU1eGM0UTlwc2Qy?= =?utf-8?Q?QsJIb08Aqlbtd+x/hmwWfVdKRsDZUbtuE+1kWrHDFTg1?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8893a67c-cc2a-48ae-24ee-08db35e00bd1 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 14:14:19.1971 (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: WuN51GNP278rC9aU/qcPvn+vuwJYq8yjL0qcuqZaxbfZEoKE1zZFsPCMOsDQ4VMI X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8250 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_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 Am 05.04.23 um 15:40 schrieb Daniel Vetter: > On Tue, Mar 07, 2023 at 11:25:35PM +0900, Asahi Lina wrote: >> Some hardware may require more complex resource utilization accounting >> than the simple job count supported by drm_sched internally. Add a >> can_run_job callback to allow drivers to implement more logic before >> deciding whether to run a GPU job. >> >> Signed-off-by: Asahi Lina > Ok scheduler rules, or trying to summarize the entire discussion: > > dma_fence rules are very tricky. The two main chapters in the docs are > > https://dri.freedesktop.org/docs/drm/driver-api/dma-buf.html?highlight=dma_buf#dma-fence-cross-driver-contract > https://dri.freedesktop.org/docs/drm/driver-api/dma-buf.html?highlight=dma_buf#indefinite-dma-fences > > Unforutunately I don't think it's possible to check this at compile time, > thus far all we can do is validate at runtime. I've posted two patches for > this: > > https://lore.kernel.org/dri-devel/20201023122216.2373294-17-daniel.vetter@ffwll.ch/ > https://lore.kernel.org/dri-devel/20201023122216.2373294-20-daniel.vetter@ffwll.ch/ > > Unfortunately most drivers are buggy and get this completely wrong, so > realistically we'd need to make this a per-driver opt-out and annotate all > current drivers. Well except amdgpu is correct by now I think (they'd > still need to test that). There is still one potential memory allocation in the run_job callback in amdgpu which I wasn't able to fix yet. But that one is purely academic and could potentially be trivially replaced with using GFP_ATOMIC if we ever have to. Christian. > And Rob Clark is working on patches to fix up > msm. > > I think best here is if you work together with Rob to make sure these > annotations are mandatory for any rust drivers (I don't want new buggy > drivers at least). Would also be great to improve the kerneldoc for all > the driver hooks to explain these restrictions and link to the relevant > kerneldocs (there's also one for the dma_fence signalling annotations > which might be worth linking too). > > I don't see any way to make this explicit in rust types, it's really only > something runtime tests (using lockdep) can catch. Somewhat disappointing. > > For the other things discussed here: > > - Option as the return value for ->prepare_job makes sense to > me. > > - I don't see any way a driver can use ->can_run_job without breaking the > above rules, that really doesn't sound like a good idea to me. > > Cheers, Daniel > >> --- >> drivers/gpu/drm/scheduler/sched_main.c | 10 ++++++++++ >> include/drm/gpu_scheduler.h | 8 ++++++++ >> 2 files changed, 18 insertions(+) >> >> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c >> index 4e6ad6e122bc..5c0add2c7546 100644 >> --- a/drivers/gpu/drm/scheduler/sched_main.c >> +++ b/drivers/gpu/drm/scheduler/sched_main.c >> @@ -1001,6 +1001,16 @@ static int drm_sched_main(void *param) >> if (!entity) >> continue; >> >> + if (sched->ops->can_run_job) { >> + sched_job = to_drm_sched_job(spsc_queue_peek(&entity->job_queue)); >> + if (!sched_job) { >> + complete_all(&entity->entity_idle); >> + continue; >> + } >> + if (!sched->ops->can_run_job(sched_job)) >> + continue; >> + } >> + >> sched_job = drm_sched_entity_pop_job(entity); >> >> if (!sched_job) { >> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h >> index 9db9e5e504ee..bd89ea9507b9 100644 >> --- a/include/drm/gpu_scheduler.h >> +++ b/include/drm/gpu_scheduler.h >> @@ -396,6 +396,14 @@ struct drm_sched_backend_ops { >> struct dma_fence *(*prepare_job)(struct drm_sched_job *sched_job, >> struct drm_sched_entity *s_entity); >> >> + /** >> + * @can_run_job: Called before job execution to check whether the >> + * hardware is free enough to run the job. This can be used to >> + * implement more complex hardware resource policies than the >> + * hw_submission limit. >> + */ >> + bool (*can_run_job)(struct drm_sched_job *sched_job); >> + >> /** >> * @run_job: Called to execute the job once all of the dependencies >> * have been resolved. This may be called multiple times, if >> >> -- >> 2.35.1 >>