From patchwork Wed Nov 2 20:34:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 1052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp132214wru; Wed, 2 Nov 2022 13:45:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GlKR5S53/peoJQBlw3BOa7l0EDYsxXPYrOcZ+go4+zQt/l2I81yqO1vKX108qdmnVj0P4 X-Received: by 2002:a17:907:a4a:b0:77b:c1b2:479a with SMTP id be10-20020a1709070a4a00b0077bc1b2479amr26838394ejc.109.1667421922715; Wed, 02 Nov 2022 13:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667421922; cv=none; d=google.com; s=arc-20160816; b=vz2/ZSbtQtqfvcZS9pC7i3l3p0g7aTVSvxytBYR1QwrpKa0YQZszSRRwhpAB7ecVee /WIPUPAzenaIXakp80zxUDjKrBfnnccPEsUsHrWlx7VI4ogKzMXJSWVpkNrDSar7Wws3 nhIzhSLLq3G30QPnS0SW6cJ/V8720QcS0TCL8cYoeoijiUkYQaHQPaPumUNTRY6hEzLa KonjlMs5N1qY+MwbUHslg7iOgX+KbCUFtVFB2kKTRJKgenRUJMRh5xjR1GVe9uG3lre4 tEOOha9bGud2oKvrNHNEXFX75T1vJXHNIs5L1PQVPjkigUdP2Lh5BZKBXXgiHMNY1CjR fhmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wAc6cdDcinIwvCWfZijlC2eN18EGjOnJE6/423sFHjU=; b=PDP2p7txgcWhH19vpkhhxlrmYCsobjF812rQkNyIkMEfeD39Ktbky/ZaS0sXAFS1PI b7+J5oX37CczUASV4innEtvpoHkDXYfhF2KbiF2Hp5buYN+75LwHQChNn53eCndJBa4y y9Nzb8WyGgVt0W6ce5ixglfGwsCjnSgIRIbf0tiesNnlo7Ba+xAaV/CUCFfdhIk7ZzS8 Hrui1qWST6708iEt6dX0bvOl/ZOMtb44Ss/E7W2jRrcF7Z2XblYa/Bf4dqBs+DC+6vlz 1b2zV/++Nai/bWdbdGC76UilQmjbnplaVeNrhBc7o+jZGwP4WRzDpW++kw/OuYGG0MPA 2ALw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JLJU5v0W; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a056402358300b00462848f0cdbsi19527346edc.299.2022.11.02.13.44.55; Wed, 02 Nov 2022 13:45:22 -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=@kernel.org header.s=k20201202 header.b=JLJU5v0W; 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 S231174AbiKBUeS (ORCPT + 99 others); Wed, 2 Nov 2022 16:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiKBUeP (ORCPT ); Wed, 2 Nov 2022 16:34:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4316C559C for ; Wed, 2 Nov 2022 13:34:15 -0700 (PDT) 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 D33E761BFD for ; Wed, 2 Nov 2022 20:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22D23C433D6; Wed, 2 Nov 2022 20:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667421254; bh=Yy6Mwdb7/j4vB86rzZF4wVb0nPq2hqeNtWXnpbDy+vE=; h=From:To:Cc:Subject:Date:From; b=JLJU5v0WCvU7/zr4PuJ04bvmVEC8Qs3YbsHg4xOb4OIDCh7uoiHwJaAUQmLx27qxY GWsvN3FJLTt30n6HVkU0p6/tSU6EqhhTuqayuhY3in5Gr3sDJuKZ6g+/KG0+l3ykB3 WlvXac38ku/hTvCYeKGTVVhPL4Ay+nv6iQJUUTmkoY82Htay/vA/yfmolmMU5IoGeR IKnXbA6Qhwtgem0A14j1oTmuAY4d1wIGlC6g4Tn/YYSzEslOJRwjDt/kJ3KgVSuJ2b iEodvIRQyJ9yiGciy73uQQ2suVufx6ta5KIZlgIVaoiTpSQD9KMuX6jmpj3TP2isM4 Jb3i4sdt4Zaww== From: Oded Gabbay To: David Airlie , Daniel Vetter , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jason Gunthorpe , John Hubbard , Alex Deucher Cc: 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 Subject: [RFC PATCH v2 0/3] new subsystem for compute accelerator devices Date: Wed, 2 Nov 2022 22:34:02 +0200 Message-Id: <20221102203405.1797491-1-ogabbay@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-8.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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748418609605026340?= X-GMAIL-MSGID: =?utf-8?q?1748418609605026340?= This is the second version of the RFC following the comments given on the first version. Nothing materially has changed in regard to how accel devices are registered and exposed to user-space. The changes are mostly re-factoring according to the comments. Changes since v1: - Instead of embedding the accel code inside drm core functions, create accel_drv.c to hold all the new core code and call that code from DRM core. - Replace deprecated IDR with xarray to manage the accel minors. - Remove all #ifdef from drm_drv.c. Instead, there are empty inline implementations in a new header file drm_accel.h (in include/drm/) that will be compiled in case CONFIG_ACCEL is set to 'N'. - Patch-set organization is a bit different: - Patch 1 introduces the accel major code and the new Kconfig. - Patch 2 introduces the accel minor code. - Patch 3 adds the call to accel functions from DRM core code. I still haven't added formal documentation as I want to make sure the general design of the new version is acceptable. If there won't be any major comments, I'll add the documentation and send the next version as the version to be merged to drm-next. The patches are in the following repo: https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/accel.git/log/?h=accel_v2 The HEAD of that branch is a commit adding a dummy driver that registers an accel device using the new framework. This can be served as a simple reference. v1 cover letter: https://lkml.org/lkml/2022/10/22/544 Thanks, Oded. Oded Gabbay (3): drivers/accel: define kconfig and register a new major accel: add dedicated minor for accelerator devices drm: initialize accel framework Documentation/admin-guide/devices.txt | 5 + MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 3 + drivers/accel/Kconfig | 24 +++ drivers/accel/Makefile | 10 + drivers/accel/accel_drv.c | 281 ++++++++++++++++++++++++++ drivers/gpu/drm/drm_drv.c | 98 ++++++--- drivers/gpu/drm/drm_file.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 24 ++- include/drm/drm_accel.h | 58 ++++++ include/drm/drm_device.h | 3 + include/drm/drm_drv.h | 8 + include/drm/drm_file.h | 21 +- 14 files changed, 513 insertions(+), 34 deletions(-) create mode 100644 drivers/accel/Kconfig create mode 100644 drivers/accel/Makefile create mode 100644 drivers/accel/accel_drv.c create mode 100644 include/drm/drm_accel.h --- 2.25.1