Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7959245rwi; Tue, 25 Oct 2022 00:04:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XINmwGWABbQGwN0FwCxIPiQ/9z7Z3nsoREjxmfME/tVSYB7djZgCmHF7dWgD/Lq3x+jcZ X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr31029587eje.157.1666681446025; Tue, 25 Oct 2022 00:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666681446; cv=none; d=google.com; s=arc-20160816; b=jAgrPvKpQ8PWUEJtsiQ4LvNFItnRZy5qh6oDHQxXY2t8qVzgSjpbh4iJfDDidnf0iF iDzIC+tkmBRh1WMpMMHvaWbh898VXpE2c8DGWRkhM0jiD6rOqW+SaTAk61ZN3kK9WHz9 c8+Z1rsM9WNB3N1lGqhmEdjv6z70XkUe827RRoWvL+4RI+gXXxfOqXqJ4tfYiQtL943O B2Zex2xQbhV8HQtUNeNQvK67xDuTn31x+SWco5pywlCh+M61xT8nlOdNyVzmwMTFMdWV yOqAFcFKPvNg4AqxKk794P9FUoSpmGTr3L0jmmakLKdgHXPSuMxaSlUULzwa+MXSpNq9 v0uQ== 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=QvdlCHmxLDwLk/YfcGnvZ9WuodpOPFQncDCNAfh4N+c=; b=gwKiIWr7h20K/8A1EQ3yFfZFQrn5R5ZaSA6aOYZMolJQ/Dm7EFYGn8Qn7feZhIw7mS kqF62YafmLum/NPdzX8jzk+MF4zCcWMY9u/01MYv487quFOQoYjuXo7AYsA6neyczT62 AD/xLKLBe6T5WY4ZplGB8ixK+Ugz03sL0kYEWKHe+UNuUWQ0UTrMAD7CDivten3zj19Y gR58kdYgw1D701fS6kQJZR3gcCKxfs0JENu83nW8UPgEJKXyJUEQQK/GQf68jCROiLpt vTTkU5YEb0/cpbufV8rXyCWzz78DE1vrmo4fWY6Kyr0A+9PMNb9ZeVPuNW4FyVpVvHVs 85uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Yx4wvo2V; 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 qo14-20020a170907874e00b0073d8f141e76si1942456ejc.130.2022.10.25.00.03.40; Tue, 25 Oct 2022 00:04:06 -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=Yx4wvo2V; 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 S229824AbiJYGnq (ORCPT + 99 others); Tue, 25 Oct 2022 02:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiJYGnm (ORCPT ); Tue, 25 Oct 2022 02:43:42 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DEA13ECFE for ; Mon, 24 Oct 2022 23:43:38 -0700 (PDT) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20221025064333epoutp01beb4027b11c971d68b71cc5839b76f3d~hPNLTIvNx1068010680epoutp01L for ; Tue, 25 Oct 2022 06:43:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20221025064333epoutp01beb4027b11c971d68b71cc5839b76f3d~hPNLTIvNx1068010680epoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1666680213; bh=QvdlCHmxLDwLk/YfcGnvZ9WuodpOPFQncDCNAfh4N+c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Yx4wvo2VctJlZxRjLjWb+8tSDZpC47bUez02H9LAKCcqb6uXsvQyBwIHCTrL7rsTG BkB5fF6fmWYshPDV0d9QIEqLt7sG9vw53ezYHM4TxxksQSGMzMXwd+wIOcxcQAASFL 3X7bDhPubfqmn/MEIXcyaDrFiolWuLQgrORwj0SQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20221025064332epcas1p3c7eddf0bb91c73ef5b344db936132fa6~hPNKuYDkk1286312863epcas1p3b; Tue, 25 Oct 2022 06:43:32 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.38.235]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MxMpW55xkz4x9Q2; Tue, 25 Oct 2022 06:43:31 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id A7.CF.51827.39587536; Tue, 25 Oct 2022 15:43:31 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20221025064331epcas1p4a323241a653ad0dc9a582ad348a3b831~hPNJYAQ753176631766epcas1p4D; Tue, 25 Oct 2022 06:43:31 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20221025064331epsmtrp1f39e99f7e37cb7961714e661130eb576~hPNJW1S1G2748727487epsmtrp1L; Tue, 25 Oct 2022 06:43:31 +0000 (GMT) X-AuditID: b6c32a36-17bfa7000000ca73-3a-63578593f457 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 66.55.18644.29587536; Tue, 25 Oct 2022 15:43:31 +0900 (KST) Received: from jiho-chu04.tn.corp.samsungelectronics.net (unknown [10.113.112.236]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221025064330epsmtip16d6321c17f0df26a274de6d1447cc401~hPNI9HtaU1891818918epsmtip1Z; Tue, 25 Oct 2022 06:43:30 +0000 (GMT) Date: Tue, 25 Oct 2022 15:43:30 +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: <20221025154330.a3a839357363da6d5de96c89@samsung.com> In-Reply-To: <20221022214622.18042-4-ogabbay@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xTVxzHd3t7bwsTclcQzuoWa5kxsBQotHiYYOb7LsOMzSVmJq5r2jtg LW1pi9tkMVXkIa3S8lCsSgCRMYYgUMobDVUK6liQbjIjkCg+mLw3dPKQtV6c++/7+53P753D RjlZLC47SaWntCqp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jv27WOU1LX8EaV/8w31O1N7ZEaWsL5xA5nrkF9OqAJ98De82CHTcpxwVL zKXZ2cEZbcuHH943+ORoe7qa15iDByum+CtOTvhGZCp0x1tPeT7NgG5+WwJcLFrPBrRIX9Uf emKrxaoZakmkj5XRqXvcnpNzlMlGnnkQQh6Y+KxS7pA7N7n+cNLjQf3XDV1l1IGU9fdGyA4H H8vwDVOv1NtLp1k26hC4dtpaHz8xod4r9ZbgKrX0F0/PgZ5uAwAA X-CMS-MailID: 20221025064331epcas1p4a323241a653ad0dc9a582ad348a3b831 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> 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,URIBL_BLOCKED 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 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. > @@ -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? Thanks, Jiho Chu