Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2344756rwb; Mon, 7 Nov 2022 12:09:18 -0800 (PST) X-Google-Smtp-Source: AMsMyM6A7YEI0WGCD0jTQvIcoTVjdnJTSCCP8eEMpyqaljZroRi1+m3uFU2I5fqtpBAvWfYxeX8e X-Received: by 2002:a17:907:968d:b0:7a8:3bf6:4bd2 with SMTP id hd13-20020a170907968d00b007a83bf64bd2mr50778114ejc.673.1667851758151; Mon, 07 Nov 2022 12:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667851758; cv=none; d=google.com; s=arc-20160816; b=Fc3knJXEcmIQfGXhcvbk5f1DV4KmEkeSKsIQ73CWI2pbPxtplBcp7chYE2kBFbvErU Muvt2vTx19gRqOmEw5P86DgnF3UTwq6tr18IHRxvPxuIX3wmGqN/HUllOnLbmPTI3A/G KQdjz0K8TSm8U7Twi4uJPIUztKjGD350z++r4xrgqUQfGo3jqEkP+t4MAisFt2ZCM2Zq QkxAS0DJ7NPriTRKpBtnpV8kXDBld2Mn+f+RdzZUmLP6hmVDazTmE5MTcd3Gw7QXdSsc zTvAjNGvYVHiDTxBsh4r5vyQJyb6qt+vt04rPq4foy9iVrX6pHDhT/0HWHV9+3FsGwGO Iv1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TZKyIaX0u5nJ3UCma7bzPt1mKZ6/XSl9drIlz/9920I=; b=GiRxWMgmHsYgwkXfiAme7NC6AuxC8gsPOR5Tw142PxOFF7lXXB1mVAhA6qzSsUso8I YKxVmRAxisPKQiXwL0llmkezmw8c4buRgS4jf9KdCrpjKRUh0lv4WLfq7xMiaP810Mk9 HUDT7IC221l7ndmofrhj84E5hwxQ1Mwms/iWw07WSfzpCw7QGi2aOkdtIJJeimtEJz9c dmMK3JLzlKrc4V7ATOrYANjUHSGeWhlEIRfFVeBGzG0rUJr9Mtri1wfHrXbSoRa1mRfh 2eYNe35OWSHMFrFrs21HLpyy9txyzO4zQgVsOsn+cq/AbIckaIKloAD1ZXSqAgr0BgZN rRpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sXWkVldc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a170906151a00b007ae1874c142si7315190ejd.446.2022.11.07.12.08.50; Mon, 07 Nov 2022 12:09:18 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=sXWkVldc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbiKGT2V (ORCPT + 92 others); Mon, 7 Nov 2022 14:28:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiKGT2O (ORCPT ); Mon, 7 Nov 2022 14:28:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65D02AC7C for ; Mon, 7 Nov 2022 11:28:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 45FB561299 for ; Mon, 7 Nov 2022 19:28:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE368C43149 for ; Mon, 7 Nov 2022 19:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667849292; bh=TZKyIaX0u5nJ3UCma7bzPt1mKZ6/XSl9drIlz/9920I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sXWkVldcgB3q6cs/Wz7FXe2KoWwpioNLFzaTOmsrZerJ8v3hxPfwk21YXuqprbS6R mTpkEok0mR2rU+E52CySxPevkNICPzrenDdbDEslasbEJKFROGLzKSwWrpDk6jsZRd ftPmiARRNape3VGPO/niNQo9CFG0dZfuMKKEIDquAuLeoLCVrCObNikUmUH1rk99Mn 4S9JV84eYtgOzCn6CzGLAXIXhO89T+HoI2jkBFn+z72pKQnbL/F7czyOTb4sxAJxhU T8Yz3HRG8SbJmjVyHj+3Jf4GaWbDCsw8kW+BOPVjU+doCLHJP+xx+0e6TC/a3vQvCI GW/rpNOAOLhnQ== Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-370547b8ca0so114524977b3.0 for ; Mon, 07 Nov 2022 11:28:12 -0800 (PST) X-Gm-Message-State: ACrzQf132M0hgFsxVH8FjaGNiUUEMoXW9eAutxf44AohCFQsuGv5kmSu gPiwmk35q1goag3Yk1OdFhfkTfq+lSp8ppehXt4= X-Received: by 2002:a81:5f46:0:b0:370:2d8c:8193 with SMTP id t67-20020a815f46000000b003702d8c8193mr777050ywb.221.1667849291594; Mon, 07 Nov 2022 11:28:11 -0800 (PST) MIME-Version: 1.0 References: <20221102203405.1797491-2-ogabbay@kernel.org> In-Reply-To: From: Oded Gabbay Date: Mon, 7 Nov 2022 21:27:45 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 1/3] drivers/accel: define kconfig and register a new major To: Jason Gunthorpe Cc: Greg Kroah-Hartman , David Airlie , Daniel Vetter , Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, John Hubbard , Alex Deucher , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Yuji Ishikawa , Jiho Chu , Daniel Stone , Tvrtko Ursulin , Jeffrey Hugo , Christoph Hellwig , Kevin Hilman , Jagan Teki , Jacek Lawrynowicz , Maciej Kwapulinski , stanislaw.gruszka@intel.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Mon, Nov 7, 2022 at 6:31 PM Jason Gunthorpe wrote: > > On Mon, Nov 07, 2022 at 05:53:55PM +0200, Oded Gabbay wrote: > > On Mon, Nov 7, 2022 at 4:10 PM Jason Gunthorpe wrote: > > > > > > On Mon, Nov 07, 2022 at 04:02:01PM +0200, Oded Gabbay wrote: > > > > On Mon, Nov 7, 2022 at 3:10 PM Jason Gunthorpe wrote: > > > > > > > > > > On Mon, Nov 07, 2022 at 03:01:08PM +0200, Oded Gabbay wrote: > > > > > > I don't agree with your statement that it should be "a layer over top of DRM". > > > > > > Anything on top of DRM is a device driver. > > > > > > Accel is not a device driver, it is a new type of drm minor / drm driver. > > > > > > > > > > Yeah, I still think this is not the right way, you are getting almost > > > > > nothing from DRM and making everything more complicated in the > > > > > process. > > > > > > > > > > > The only alternative imo to that is to abandon the idea of reusing > > > > > > drm, and just make an independant accel core code. > > > > > > > > > > Not quite really, layer it properly and librarize parts of DRM into > > > > > things accel can re-use so they are not intimately tied to the DRM > > > > > struct device notion. > > > > > > > > > > IMHO this is much better, because accel has very little need of DRM to > > > > > manage a struct device/cdev in the first place. > > > > > > > > > > Jason > > > > I'm not following. How can an accel device be a new type of drm_minor, > > > > if it doesn't have access to all its functions and members ? > > > > > > "drm_minor" is not necessary anymore. Strictly managing minor numbers > > > lost its value years ago when /dev/ was reorganized. Just use > > > dynamic minors fully. > > drm minor is not just about handling minor numbers. It contains the > > entire code to manage devices that register with drm framework (e.g. > > supply callbacks to file operations), manage their lifecycle, > > resources (e.g. automatic free of resources on release), sysfs, > > debugfs, etc. > > This is why you are having such troubles, this is already good library > code. You don't need DRM to wrapper debugfs APIs, for instance. We > have devm, though maybe it is not a good idea, etc > > Greg already pointed out the sysfs was not being done correctly > anyhow. > > I don't think DRM is improving on these core kernel services. Just use > the normal stuff directly. I get what you are saying but if I do all that, then how is this subsystem related to DRM and re-using its code ? (at least at this stage) btw, using the basic stuff directly was my original intention, if you remember the original accel mail thread from July/August. And then we all decided in LPC that we shouldn't do that and instead accel should use the DRM code and just expose a new major+minor for the new drivers. So, something doesn't add up... imo, we need to choose between doing accel either as a small new feature in drm, or as an independent subsystem. I just don't see how I do the former without calling drm code directly and using all its wrappers. > > > > > How will accel device leverage, for example, the GEM code without > > > > being a drm_minor ? > > > > > > Split GEM into a library so it doesn't require that. > > I don't see the advantage of doing that over defining accel as a new > > type of drm minor. > > Making things into smaller libraries is recognized as a far better > kernel approach than trying to make a gigantic wide midlayer that stuffs > itself into everything. LWN called this the "midlayer mistake" and > wrote about the pitfalls a long time ago: > > https://lwn.net/Articles/336262/ > > It is exactly what you are experiencing trying to stretch a > midlayer even further out. > > Jason I'm all for breaking it down to smaller libraries, I completely agree with you. But as you wrote above, why do I even need to use the drm wrappers for the basic stuff ? I'll just call the kernel api directly. And if that's the case then I don't need to rip that code out of the heart of drm and make it a separate module. For GEM (as an example of something less basic) it might be a different story, but we are not there yet. Oded