Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1964602rwi; Fri, 28 Oct 2022 00:56:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VDtc21PwVmvq0YQAaFpcd1t5103b+PRjJWB1bYo2xaEsrgPmxsQi4fyHMKIuJxs9zDgp+ X-Received: by 2002:a17:907:7d8b:b0:78e:2534:4fd3 with SMTP id oz11-20020a1709077d8b00b0078e25344fd3mr47190684ejc.141.1666943755048; Fri, 28 Oct 2022 00:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666943755; cv=none; d=google.com; s=arc-20160816; b=ETWCxW7RD/Io+MvxDY4VmtOg9KbqwPAL7+EST5fF+OA2FzltGHgEGwpnMTDo1+cMLB aNZKSWql3xx9VWmYD7rJ1T2MJKbcAiVCEWnZzTSOxuOH13wmk4FuIY9CddmWk0KUQIHE PmnG74rtrxTufe9ack5lsF2ID/jVlLS1rpe2+sP2sTvspXalqcw1s2En9o5mIpBH1WcE weHrWq/Tilw5erew8diZJQHbQ+dB/1Tqjy6obWQzisWU2Nq2/82Hhc9ihjy4yShJVl+I aMqFZH5SdIBNEvnCPaw3sLJbVIei9Upbo1xTqW9l6oTfjRUuzl8mokWBZqG41nVOedsz t3Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-filter; bh=f5AeGuQ91kgMx+p1pLQmTx7L0CdNWT5cP5Evk4stoEw=; b=Y0ApSn9JowOl0ZH/IRmhMxo/54feLJoJcNwLDvrfCCV+2gctWGfveiCIz+ptLi82Gy iv5hfnEXNvfuX6PbDEv4WLs5AW6gM3lw6TevpVl9KLrH+ggzdNHd4Yr79tfur0vfAyy0 ZFbXID1IKO0KfrczstbABg0yCixf0MNocN2U6r13JLQACYqT2DMjtPYggpXpEfDLjcwc fkMM43X4tmvuYhhtiAX26uSJ0rbHkgyUomMLbTtReU9fjvGWP9LWjYAwzWCsqTt6sTYT 2rsyWB+xajbiL6kNgSJOikwLZUdZsBLKTFTf9rpS+3DTWiBeMcH4b4PjO+0svJJFkpe/ 09Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=qiOWMybR; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my42-20020a1709065a6a00b00781e17d3699si2958829ejc.203.2022.10.28.00.55.29; Fri, 28 Oct 2022 00:55:55 -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=@samsung.com header.s=mail20170921 header.b=qiOWMybR; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbiJ1G47 (ORCPT + 99 others); Fri, 28 Oct 2022 02:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiJ1G45 (ORCPT ); Fri, 28 Oct 2022 02:56:57 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5762AB803 for ; Thu, 27 Oct 2022 23:56:53 -0700 (PDT) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20221028065650epoutp04061486cb92ee26e8ebf36a7e3b21c280~iKUoOqeQT2418624186epoutp04M for ; Fri, 28 Oct 2022 06:56:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20221028065650epoutp04061486cb92ee26e8ebf36a7e3b21c280~iKUoOqeQT2418624186epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1666940210; bh=f5AeGuQ91kgMx+p1pLQmTx7L0CdNWT5cP5Evk4stoEw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qiOWMybRgq3FJ9o9w2R71LGH7d1Ze2at/oTtYmhJ0DkXHgt4uHFIvtXONAV+vZmdk Gh60NfM+QVNc+tut4ss5jxyRbIqK6KJYi5el90vtSSVmiVB5cfeqH/0WNknAdPV47J VW6UuoxMnHdYYxL2mrXIT7oinC2d2cXzH7DI//cA= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20221028065649epcas1p1009eb03e96ba85836aecb846f22f40d4~iKUnmJrvD0386903869epcas1p1n; Fri, 28 Oct 2022 06:56:49 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.38.235]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4MzCyS16qZz4x9Q7; Fri, 28 Oct 2022 06:56:48 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 21.45.07146.A2D7B536; Fri, 28 Oct 2022 15:56:42 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20221028065642epcas1p19a36e65931dc8e1a5fc56724c3852f40~iKUhLtIKI0604406044epcas1p1J; Fri, 28 Oct 2022 06:56:42 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221028065642epsmtrp2f569670b38dc450cbde5b7e9ea32ffdf~iKUhKeoVO2721527215epsmtrp2g; Fri, 28 Oct 2022 06:56:42 +0000 (GMT) X-AuditID: b6c32a35-47bfe70000021bea-a7-635b7d2a01d9 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 75.54.14392.A2D7B536; Fri, 28 Oct 2022 15:56:42 +0900 (KST) Received: from jiho-chu04.tn.corp.samsungelectronics.net (unknown [10.113.112.236]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20221028065642epsmtip2583922363b8ea09946dcd287d6000d2e~iKUg3orPI0626306263epsmtip2h; Fri, 28 Oct 2022 06:56:42 +0000 (GMT) Date: Fri, 28 Oct 2022 15:56:42 +0900 From: Jiho Chu To: Oded Gabbay Cc: 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 , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Yuji Ishikawa , Daniel Stone , Tvrtko Ursulin , Jeffrey Hugo , Christoph Hellwig , Kevin Hilman , Jagan Teki , Jacek Lawrynowicz , Maciej Kwapulinski Subject: Re: [RFC PATCH 3/3] drm: add dedicated minor for accelerator devices Message-Id: <20221028155642.460c2ece8a7abbfa52eb4539@samsung.com> In-Reply-To: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Tf1CTdRzH77tnezY07GFofKOC+aDnwTW2yQZfPfA0PXs6uZgZpdVJazwB N9jmnqH8qOSn8dMYYSIHhgRBJBFzLBg/7OBOEpEE50UkIXcpify04MQ5a+OR7L/35/N9fb7v 7+fzua8AE+bxfQUJWiNt0KoSSXwN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Ih9FAkRPjOpsdrzlp88F1+WoHnY5U4f9i7+3Wvch+4T+FSl2DWN5BKOh4n0eLrW8sQ Lnn/Z6PkEd1jeaHSZjwfZOUmxbU/nd0XFbLz5O8DnF/8Sh089FI0Tm+7rWr+iu3UI8fUj95F mossRTea6l3d+/jDxmSNp2EPLwtefaZnuTR/9+bu6sWB+YePNF1Q7U++lBn02v1r7X/vBuWy tt1S6dskF93aK37MIWOtWJvDkpn3D838b6bEUpyRaKjFXFScCABeoe+0bwMAAA== X-CMS-MailID: 20221028065642epcas1p19a36e65931dc8e1a5fc56724c3852f40 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221022214657epcas1p18a2625c84cd6470b5404cb71f9836cc8 References: <20221022214622.18042-1-ogabbay@kernel.org> <20221022214622.18042-4-ogabbay@kernel.org> <20221025154330.a3a839357363da6d5de96c89@samsung.com> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, 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 Wed, 26 Oct 2022 09:38:13 +0300 Oded Gabbay wrote: > On Tue, Oct 25, 2022 at 9:43 AM Jiho Chu wrote: > > > > > > On Sun, 23 Oct 2022 00:46:22 +0300 > > Oded Gabbay wrote: > > > > > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c > > > index b58ffb1433d6..c13701a8d4be 100644 > > > --- a/drivers/gpu/drm/drm_drv.c > > > +++ b/drivers/gpu/drm/drm_drv.c > > > @@ -56,6 +56,9 @@ MODULE_LICENSE("GPL and additional rights"); > > > static DEFINE_SPINLOCK(drm_minor_lock); > > > static struct idr drm_minors_idr; > > > > > > +static DEFINE_SPINLOCK(accel_minor_lock); > > > +static struct idr accel_minors_idr; > > > + > > > /* > > > * If the drm core fails to init for whatever reason, > > > * we should prevent any drivers from registering with it. > > > @@ -94,6 +97,8 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev, > > > return &dev->primary; > > > case DRM_MINOR_RENDER: > > > return &dev->render; > > > + case DRM_MINOR_ACCEL: > > > + return &dev->accel; > > > default: > > > BUG(); > > > } > > > @@ -108,9 +113,15 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data) > > > > > > put_device(minor->kdev); > > > > > > - spin_lock_irqsave(&drm_minor_lock, flags); > > > - idr_remove(&drm_minors_idr, minor->index); > > > - spin_unlock_irqrestore(&drm_minor_lock, flags); > > > + if (minor->type == DRM_MINOR_ACCEL) { > > > + spin_lock_irqsave(&accel_minor_lock, flags); > > > + idr_remove(&accel_minors_idr, minor->index); > > > + spin_unlock_irqrestore(&accel_minor_lock, flags); > > > + } else { > > > + spin_lock_irqsave(&drm_minor_lock, flags); > > > + idr_remove(&drm_minors_idr, minor->index); > > > + spin_unlock_irqrestore(&drm_minor_lock, flags); > > > + } > > > } > > > > > > static int drm_minor_alloc(struct drm_device *dev, unsigned int type) > > > @@ -127,13 +138,23 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type) > > > minor->dev = dev; > > > > > > idr_preload(GFP_KERNEL); > > > - spin_lock_irqsave(&drm_minor_lock, flags); > > > - r = idr_alloc(&drm_minors_idr, > > > - NULL, > > > - 64 * type, > > > - 64 * (type + 1), > > > - GFP_NOWAIT); > > > - spin_unlock_irqrestore(&drm_minor_lock, flags); > > > + if (type == DRM_MINOR_ACCEL) { > > > + spin_lock_irqsave(&accel_minor_lock, flags); > > > + r = idr_alloc(&accel_minors_idr, > > > + NULL, > > > + 64 * (type - DRM_MINOR_ACCEL), > > > + 64 * (type - DRM_MINOR_ACCEL + 1), > > > + GFP_NOWAIT); > > > + spin_unlock_irqrestore(&accel_minor_lock, flags); > > > + } else { > > > + spin_lock_irqsave(&drm_minor_lock, flags); > > > + r = idr_alloc(&drm_minors_idr, > > > + NULL, > > > + 64 * type, > > > + 64 * (type + 1), > > > + GFP_NOWAIT); > > > + spin_unlock_irqrestore(&drm_minor_lock, flags); > > > + } > > > > Hi, > > There are many functions which checks drm type and decides its behaviors. It's good to > > re-use exiting codes, but accel devices use totally different major/minor, and so it needs to be moved to > > /drvier/accel/ (maybe later..). How about seperating functions for alloc/release minor (accel_minor_alloc..)? > > also, for others which have drm type related codes. > My feeling was moving the minor code handling to a different file (in > addition to moving the major code handling) will cause too much > duplication. > My main theme is that an accel minor is another minor in drm, even if > a bit different. i.e. It uses the same drm_minor structure. > The driver declares he wants to use this minor using a drm driver feature flag. > imo, all of that indicates the code should be inside drm. > > > > > > > > > > > @@ -607,6 +652,14 @@ static int drm_dev_init(struct drm_device *dev, > > > /* no per-device feature limits by default */ > > > dev->driver_features = ~0u; > > > > > > + if (drm_core_check_feature(dev, DRIVER_COMPUTE_ACCEL) && > > > + (drm_core_check_feature(dev, DRIVER_RENDER) || > > > + drm_core_check_feature(dev, DRIVER_MODESET))) { > > > + > > > + DRM_ERROR("DRM driver can't be both a compute acceleration and graphics driver\n"); > > > + return -EINVAL; > > > + } > > > + > > > > It's fine for the device only for acceleration, but can't graphic devices have acceleration feature? > Of course they can :) In that case, and if they want to expose an > accel device char, they should write an accel driver and connect it to > their main graphics driver via auxiliary bus. > > I could have added two flags - compute_accel, and compute_accel_only > (similar to a patch that was sent to add render only flag), but imo it > would make the code more convoluted. I prefer the clean separation and > using standard auxiliary bus. > > Thanks, > Oded > I understood. Seperation would be good as you mentioned in other mail. This subsystem would be better choice for acceleration only devices, who need some features of drm, but deoesnot want to include whole graphics related considerations. I'll prepare Samsung's NPU driver using this after your reference driver is presented (maybe habana'). Thanks. Jiho Chu