Message ID | 20230127093631.2132187-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp743522wrn; Fri, 27 Jan 2023 01:43:49 -0800 (PST) X-Google-Smtp-Source: AK7set/BLrBu6TZF7TbVX2tND8cauPqCSffdAh0fcUdJjXnnLSP9Pm9lIMt5ZEPWVjYHgZUO9rs/ X-Received: by 2002:a17:906:7851:b0:878:4edf:4e06 with SMTP id p17-20020a170906785100b008784edf4e06mr7529162ejm.62.1674812629768; Fri, 27 Jan 2023 01:43:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674812629; cv=none; d=google.com; s=arc-20160816; b=z41JN9hlMkF9za5LKge8VpEScjUh3L8Oz5F0EeBcTehiAfJWXebuzE0ZaBcXBLi3EG FqZdTCjo95AjP2Y7yU0rCfsUrrRvZXpHhY31q27ZhFPiNSCqGI6r8y29AsjrW3ft0XnB T8tUWbq5NjFo6a9LNJcSeCj32pgWe0eRv2FTxLZj8y+7/DhJvrV0LcDjFDzJB60+3E2J gsWnPmUHj0vIkZxbv0KIF/vWb2bEIyV5gpGSICRwvo9Vd39g+9PKlWLq5O/OR2+4mHCg f4ZEtJMdoYQ/DWeNGYuzaaD9ZYAkzZjjMQrZnZgsj2sEd+BqlRyXSPlzPWQsq9humq+G KIfA== 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=OJqWXNrTsKlJlGZzZtQes24PCA53971nKjtKnVXBLao=; b=w4a2r7LWsQ+WuPlI9t4bhatPfCGz8LBLUCoSKxmb2ndWivZGilIkgXatjqSPKlBTBB 0Jd/gmFezKQRbamVau63d5305bVAbM7HeRtzAga9JKxiPVO7z/F7KVmvHyp9Cd6qJcxD GMHJf2VxS0TVxJQ690mb0EPCiyZE8gS2VjzYYfZbV96YZvldAISBmmQJ55bVCY1vGm/Y WvX+Un9ArGcCqP2mmYS1NZDzOxdGHwUV7RlNOODbgzv2y5b4LTV4CJoXzoJcWJDakTWT NpU3/F/X+OVYVwKFYSAjssxODu44DUoO3Gg/yA+y8BtVuvm4dsXECpUy/tP6RQyjd81L nJ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tir3d55g; 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 e24-20020a170906749800b0087bd76ce97dsi1550639ejl.112.2023.01.27.01.43.26; Fri, 27 Jan 2023 01:43:49 -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=Tir3d55g; 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 S233089AbjA0Jgm (ORCPT <rfc822;lekhanya01809@gmail.com> + 99 others); Fri, 27 Jan 2023 04:36:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjA0Jgk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 27 Jan 2023 04:36:40 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89772C9 for <linux-kernel@vger.kernel.org>; Fri, 27 Jan 2023 01:36:39 -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 sin.source.kernel.org (Postfix) with ESMTPS id CC618CE26E2 for <linux-kernel@vger.kernel.org>; Fri, 27 Jan 2023 09:36:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3989C433EF; Fri, 27 Jan 2023 09:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674812196; bh=wlz6HIVQ/GgIj0YbTS0RXKypfcVwy2vvEGBqBClsFuo=; h=From:To:Cc:Subject:Date:From; b=Tir3d55g29BmdExqeS9YYdmYN3bB9BIsEcfWaB4gHjRQgIO8DPGdyUbu8a/h5jel7 wqVAdY0QxPgzZ8nAJrUxKX2rkHn0ipkyfFP73Eg4NTygD1wosC1bd5jRxEdSmWMzNq PUGnUrXSQ2AMGsUKfkRZsrWwOUOt7C89Ou7P4a6320syjhHDnqOH1KHDRKYDFMAwMP dEMELwYPsl0pM0VEfTXtHIT3HgN1pF4TDrlJ57QDkqodr9+Gp+bXLa2RRI6EfUyQ/J mT8tXwQvo5u9E+ImLVjmuudBFc69W/JU8nIwqBH79cGtmkHp37C8hqFqG040dnIh9E G+fwgYcmFJh3g== From: Arnd Bergmann <arnd@kernel.org> To: Oded Gabbay <ogabbay@kernel.org>, Jeffrey Hugo <quic_jhugo@quicinc.com>, Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>, Dave Airlie <airlied@redhat.com>, Thomas Zimmermann <tzimmermann@suse.de>, Melissa Wen <mwen@igalia.com> Cc: Arnd Bergmann <arnd@arndb.de>, Daniel Vetter <daniel.vetter@ffwll.ch>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] accel: work around DRM_ACCEL dependencies Date: Fri, 27 Jan 2023 10:36:20 +0100 Message-Id: <20230127093631.2132187-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756168327992251866?= X-GMAIL-MSGID: =?utf-8?q?1756168327992251866?= |
Series |
accel: work around DRM_ACCEL dependencies
|
|
Commit Message
Arnd Bergmann
Jan. 27, 2023, 9:36 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> At the moment, accel drivers can be built-in even with CONFIG_DRM=m, but this causes a link failure: x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_dev_init': ivpu_drv.c:(.text+0x1535): undefined reference to `drmm_kmalloc' x86_64-linux-ld: ivpu_drv.c:(.text+0x1562): undefined reference to `drmm_kmalloc' x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_remove': ivpu_drv.c:(.text+0x1faa): undefined reference to `drm_dev_unregister' x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_probe': ivpu_drv.c:(.text+0x1fef): undefined reference to `__devm_drm_dev_alloc' This could be avoided by making DRM_ACCEL a tristate symbol, which would mean that every ACCEL driver is guarantee to be able to link against DRM as well. However, having both as =m causes another link failure because the DRM core code also links against the accel driver: x86_64-linux-ld: drivers/gpu/drm/drm_drv.o: in function `drm_minor_register': drm_drv.c:(.text+0x259): undefined reference to `accel_debugfs_init' x86_64-linux-ld: drm_drv.c:(.text+0x298): undefined reference to `accel_minor_replace' I think it will be necessary to establish a link hierarchy between drm.ko and drm_accel.ko to avoid circular dependencies like this, but until then the only way that both can be used is to have both subsystems built into the kernel. Enforce this using a Kconfig dependency. Fixes: 8bf4889762a8 ("drivers/accel: define kconfig and register a new major") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/accel/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi On Fri, Jan 27, 2023 at 10:36:20AM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > At the moment, accel drivers can be built-in even with CONFIG_DRM=m, > but this causes a link failure: > > x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_dev_init': > ivpu_drv.c:(.text+0x1535): undefined reference to `drmm_kmalloc' > x86_64-linux-ld: ivpu_drv.c:(.text+0x1562): undefined reference to `drmm_kmalloc' > x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_remove': > ivpu_drv.c:(.text+0x1faa): undefined reference to `drm_dev_unregister' > x86_64-linux-ld: drivers/accel/ivpu/ivpu_drv.o: in function `ivpu_probe': > ivpu_drv.c:(.text+0x1fef): undefined reference to `__devm_drm_dev_alloc' Ehh, this should not happen. > This could be avoided by making DRM_ACCEL a tristate symbol, which > would mean that every ACCEL driver is guarantee to be able to link > against DRM as well. However, having both as =m causes another link > failure because the DRM core code also links against the accel driver: > > x86_64-linux-ld: drivers/gpu/drm/drm_drv.o: in function `drm_minor_register': > drm_drv.c:(.text+0x259): undefined reference to `accel_debugfs_init' > x86_64-linux-ld: drm_drv.c:(.text+0x298): undefined reference to `accel_minor_replace' > > I think it will be necessary to establish a link hierarchy between drm.ko > and drm_accel.ko to avoid circular dependencies like this, but until then > the only way that both can be used is to have both subsystems built into > the kernel. Enforce this using a Kconfig dependency. Hmm, it was discussed a bit before and conclusion was that accel will be compiled in drm.ko to avoid circular dependencies. There should be no drm_accel.ko module. > Fixes: 8bf4889762a8 ("drivers/accel: define kconfig and register a new major") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/accel/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig > index 834863902e16..dd18d3b2028c 100644 > --- a/drivers/accel/Kconfig > +++ b/drivers/accel/Kconfig > @@ -8,7 +8,7 @@ > # > menuconfig DRM_ACCEL > bool "Compute Acceleration Framework" > - depends on DRM > + depends on DRM=y Would making ivpu Kconfig: depends on DRM select DRM_ACCEL solve the problem and still allow to drm to be build as module ? Regards Stanislaw
On Fri, Jan 27, 2023, at 11:17, Stanislaw Gruszka wrote: > On Fri, Jan 27, 2023 at 10:36:20AM +0100, Arnd Bergmann wrote: >> I think it will be necessary to establish a link hierarchy between drm.ko >> and drm_accel.ko to avoid circular dependencies like this, but until then >> the only way that both can be used is to have both subsystems built into >> the kernel. Enforce this using a Kconfig dependency. > > Hmm, it was discussed a bit before and conclusion was that accel will be > compiled in drm.ko to avoid circular dependencies. There should be > no drm_accel.ko module. Ok, got it. This does not sounds like a great solution as it ties the two modules closer together than most users want, but it should work as long as we control the dependencies for the individual drivers. >> diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig >> index 834863902e16..dd18d3b2028c 100644 >> --- a/drivers/accel/Kconfig >> +++ b/drivers/accel/Kconfig >> @@ -8,7 +8,7 @@ >> # >> menuconfig DRM_ACCEL >> bool "Compute Acceleration Framework" >> - depends on DRM >> + depends on DRM=y > > Would making ivpu Kconfig: > > depends on DRM > select DRM_ACCEL > > solve the problem and still allow to drm to be build as module ? Right, that should work, I'll send a v2 patch to add an "if DRM" around the entire drivers/accel/Kconfig file, which should have the effect. Arnd
diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig index 834863902e16..dd18d3b2028c 100644 --- a/drivers/accel/Kconfig +++ b/drivers/accel/Kconfig @@ -8,7 +8,7 @@ # menuconfig DRM_ACCEL bool "Compute Acceleration Framework" - depends on DRM + depends on DRM=y help Framework for device drivers of compute acceleration devices, such as, but not limited to, Machine-Learning and Deep-Learning