Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1154990rwl; Wed, 5 Apr 2023 12:36:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQLIxZQ0kA2AVKRNKJq3e6EcL6kcC8m7HJAgqVLdQxo4TBQ3aZ9b+e95wialz91EkI9miM X-Received: by 2002:a17:90a:191:b0:23b:2c51:6e7 with SMTP id 17-20020a17090a019100b0023b2c5106e7mr8050858pjc.21.1680723418726; Wed, 05 Apr 2023 12:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680723418; cv=none; d=google.com; s=arc-20160816; b=gXltuNJoN0pD4Eb0hZFHkCIeJEMTTgzLUEBAKQCLQ+IAfMAfzADyX96AVFMq7Lk8G4 gXm1Rg1kleVAMop+RBy//Fo/bHSmfOoQgmydRvL1yeWiPET/f2AeKDnvcs1ee4iSCBvk yF+3n/4YcSjVYMze81xd5hHU+WXHb1a5UguwgD/wx8T9TaxsQ3rqjwe1azL6aOIXfGE2 tznHXkWPzIgwH1QmsY+AZ220+RSBr0VO46b1r0nRfLlpPjDmiKq5/aNlnLFl39DJQzIo +T8XD3cDG+GxkDIxiSAw22c0r61xl61Y83HmnE0Hx/FzXq36KpAknXcYRycaxKu1gM5/ 8cCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:to:from:date :dkim-signature; bh=HjS4xiLUH8Vl6mwX+ydicDNhQfS/HlIJ5pcb18flIFA=; b=gZcpG253xzKHNOykqoCMwFk3sEjjLGrUDmm2AYKQjhU00B/DhlxuomKepdc36HFm4d uf4HHbvre/GMdZKRlWAQZZSDYCjxPZ6DKsyG/4M2yPSOifkOuTRXKYCjmqoOabuqT8P0 re0n38CPGQvqFnZa0uH4QLETOvbDSJ++roQbzwtwIq79VftFKOEwO8f148oeCRAgaaC2 iHoKsDJnniiPH2GwbAqBNbydA3TtoXdxYsKZniAgi3xDhqFw8XkMHRKvfpqL7lbPjJ17 UUmBSDDJrmdoursbm9aljX7vW+AL5VR3CvkDwOO+4D/S8FBb0s1+CeJVpfOEGTNCeUij 35Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=FBmtIvVf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu12-20020a17090b1b0c00b0023f9cb51eaesi2063890pjb.84.2023.04.05.12.36.47; Wed, 05 Apr 2023 12:36:58 -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=@ffwll.ch header.s=google header.b=FBmtIvVf; 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 S233306AbjDET3K (ORCPT + 99 others); Wed, 5 Apr 2023 15:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjDET3I (ORCPT ); Wed, 5 Apr 2023 15:29:08 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C01FE5B90 for ; Wed, 5 Apr 2023 12:29:06 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-930bc91df7bso120827866b.1 for ; Wed, 05 Apr 2023 12:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1680722945; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=HjS4xiLUH8Vl6mwX+ydicDNhQfS/HlIJ5pcb18flIFA=; b=FBmtIvVfM4pGQI0Ecn5kpWqT9ewv/aw4Fo78eRrx1HwuZBp4iXUV5H057Luk2hvw2u ulz9ur/hM3WMIFn4fbzHBA2uvVARF0Kv0zsR5L7enELuauqiMc0abH4qMusRV/lI+9z6 rMCS6thBW9YJ4KbSlkrUTkyEBTGwzwnZC74V4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680722945; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HjS4xiLUH8Vl6mwX+ydicDNhQfS/HlIJ5pcb18flIFA=; b=DHqig7KznwTnFxFbcuuyD8mlDCsyqElKbmycbx9HRkDtP+C9Xy3Bj2BzaxlV3vm57a m5Ku4V3NTzhijqoAIqexpe5yPLo23/sy2+ETiMsKJvfwqpcOXJZqWN94WPPgM0IfmJFS MpgNHCnzKz1MTxtBB3//hE42/AKOzkZZXYzaWWgYJRktouWCnP++8TXBraZ9wY0StsuO puO7B7EiWR/l7lFkfO0AtZXY1i1eWyH7CLtQGQyE9tdC2Z2CaWozsB3JNzsHHcoLuOHH 0kL9ax+Q9wq81NUD2IadCVzZIDm4bTFGy7k1gnwNX37/fWa9ICggeysL0vAnYIRBn/UC qU6Q== X-Gm-Message-State: AAQBX9cDUsp90ZIxo+UU3jl6lTkFgTv79I4Vvy29v7FjUaEuh+81WcmL tMM549cPx3Q5Ryl8Z4JchvQT7w== X-Received: by 2002:a05:6402:524e:b0:500:3fd0:25a8 with SMTP id t14-20020a056402524e00b005003fd025a8mr3953373edd.0.1680722945234; Wed, 05 Apr 2023 12:29:05 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-33.fiber7.init7.net. [212.51.149.33]) by smtp.gmail.com with ESMTPSA id cq5-20020a056402220500b005023ddb37eesm7596632edb.8.2023.04.05.12.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 12:29:04 -0700 (PDT) Date: Wed, 5 Apr 2023 21:29:02 +0200 From: Daniel Vetter To: Asahi Lina , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , 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 Subject: Re: [PATCH RFC 12/18] rust: drm: sched: Add GPU scheduler abstraction Message-ID: Mail-Followup-To: Asahi Lina , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , 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-12-917ff5bc80a8@asahilina.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 6.1.0-7-amd64 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 On Wed, Apr 05, 2023 at 05:43:01PM +0200, Daniel Vetter wrote: > On Tue, Mar 07, 2023 at 11:25:37PM +0900, Asahi Lina wrote: > > +/// An armed DRM scheduler job (not yet submitted) > > +pub struct ArmedJob<'a, T: JobImpl>(Box>, PhantomData<&'a T>); > > + > > +impl<'a, T: JobImpl> ArmedJob<'a, T> { > > + /// Returns the job fences > > + pub fn fences(&self) -> JobFences<'_> { > > + JobFences(unsafe { &mut *self.0.job.s_fence }) > > + } > > + > > + /// Push the job for execution into the scheduler > > + pub fn push(self) { > > + // After this point, the job is submitted and owned by the scheduler > > + let ptr = match self { > > + ArmedJob(job, _) => Box::>::into_raw(job), > > + }; > > If I get this all right then this all makes sure that drivers can't use > the job after push and they don't forgot to call arm. > > What I'm not seeing is how we force drivers to call push once they've > called arm? I haven't check what the code does, but from the docs it > sounds like if you don't call push then drop will get called. Which wreaks > the book-keeping on an armed job. Or is there someting that prevents > ArmedJob from having the Drop trait and so the only way to not go boom > is by pushing it? > > Googling for "rust undroppable" seems to indicate that this isn't a thing > rust can do? Another thing that I just realized: The driver must ensure that the arm->push sequence on a given drm_sched_entity isn't interrupte by another thread doing the same, i.e. you need to wrap it all in a lock, and it always needs to be the same lock for a given entity. I have no idea how to guarantee that, but I guess somehow we should? -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch