Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7106840rwi; Mon, 24 Oct 2022 09:54:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60EOnhy0si0qS365/Gxcp21vS+Io0VJVkeu1gKW1Ka8bK+vt3s0hX3t/DsuHuc7XszUZqc X-Received: by 2002:a17:907:720e:b0:78e:2b59:fdf1 with SMTP id dr14-20020a170907720e00b0078e2b59fdf1mr29431637ejc.659.1666630468731; Mon, 24 Oct 2022 09:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666630468; cv=none; d=google.com; s=arc-20160816; b=T3gdVUEtAcH6VwnT8or2CmbagNFXC0/j4lkuUl0GLJKB6Yp8h2AEJ0TTdqbqymO4pq OhMyQGLRVNbs2fsUER31OESMuQHs7LBEjVP/Ul6Kgho/uJUwN10MnRx7NzJTObLPbG68 L5/0fP6J5o88EjcMpBQ2nEdnliGI7R/khCaObgRQ5Cnjd9/3JRrv2B/3DjvqmqOb4/EU pOoAi3GtHv2NJpjYvKCOm/o9TWRfrwGoZXe7feNAkylBol90+lMy2tbUZ5XQASdjX3nw 0luluXq1V8MUot3InSqlpv28qd4qCi+PD671JNdiFeM5bF2ZX8kZv+oRXAFsH1iVfJ0c PKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xPfZHWn5BjNX1+I617jnln0xrq+61Y5jHhnLZ2Rzmfg=; b=jp23VCLd9+UNbWo4pRDyR5yknt1sGqGclTJsYqdy1HdAuQuXSQJkDxtYsNvo0vthxB n2arrSs0fQ5rOk6Hx54OTAwh8fvaR7ai7XNPOCjm17GGvQ4LXlFMRW6GC/VaQVO2ObuD Vx2VmTwFGLBlJuEWGPrE3T0c3OJwqUSmX9BG+6tHG1u6xfwDyfP+D1bVf+RhnfblUWEp HLoJ6/2NF+6+yUHVzfJUfxfauvx2I8kGdpwgHUrk2CJBdonzsWF4C3asixPmbBuWaktm AxUjNUuuQlMi5MoPYjkqNDNuzMRWUzq548kbbmIfWktcebp5Gtj7VKsGIe7//UGnmLg5 lY8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=W8zlbKxm; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y23-20020a50e617000000b004605f289f68si277545edm.158.2022.10.24.09.54.03; Mon, 24 Oct 2022 09:54:28 -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=@quicinc.com header.s=qcppdkim1 header.b=W8zlbKxm; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234233AbiJXQgs (ORCPT + 99 others); Mon, 24 Oct 2022 12:36:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233948AbiJXQgT (ORCPT ); Mon, 24 Oct 2022 12:36:19 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E56A517F99C for ; Mon, 24 Oct 2022 08:23:55 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29OF0Qlh031384; Mon, 24 Oct 2022 15:21:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=xPfZHWn5BjNX1+I617jnln0xrq+61Y5jHhnLZ2Rzmfg=; b=W8zlbKxmPYvi7eUIKlWUTINrJJz4acVoGER7mu4MtWqKXZVIXEw436qVUAQfcokjoQLt xDCX86jdJvBbEKz4vBcBERH9zPOsj/VXwrBGIJT+F0kAlNxHWGUn1hBUtVL4+VMdPlUH Y8vYEuu4rOkk7Y4w8hiSvS3wctGoASXvFTblMa4sBFYz2o1QkYVtQyCkiWtfZVm8LlYN cWCyvyq4ILR+SoWhqE/da6p2ytkUEtXYFKyxTxHY80EsDYxSQJv/YKivaFcSyshDCtWU 6d4iSZpc4caAsr3Zghk0Tgom3IMPED62MvAunKepc9LJioNO0f8Ae+cnvfwZv0uTEwCt /A== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3kc67pmjng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Oct 2022 15:21:22 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 29OFLMBl018414 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Oct 2022 15:21:22 GMT Received: from [10.226.59.182] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Mon, 24 Oct 2022 08:21:20 -0700 Message-ID: Date: Mon, 24 Oct 2022 09:21:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [RFC PATCH 3/3] drm: add dedicated minor for accelerator devices Content-Language: en-US To: Oded Gabbay , David Airlie , Daniel Vetter , Arnd Bergmann , Greg Kroah-Hartman , , , Jason Gunthorpe , John Hubbard , Alex Deucher CC: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Yuji Ishikawa , Jiho Chu , Daniel Stone , Tvrtko Ursulin , Christoph Hellwig , Kevin Hilman , Jagan Teki , Jacek Lawrynowicz , Maciej Kwapulinski References: <20221022214622.18042-1-ogabbay@kernel.org> <20221022214622.18042-4-ogabbay@kernel.org> From: Jeffrey Hugo In-Reply-To: <20221022214622.18042-4-ogabbay@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: lBShfejFmUYvNpYyNQpcmxDz9QS-iVwR X-Proofpoint-ORIG-GUID: lBShfejFmUYvNpYyNQpcmxDz9QS-iVwR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-24_04,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 malwarescore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210240093 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, 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 10/22/2022 3:46 PM, Oded Gabbay wrote: > The accelerator devices are exposed to user-space using a dedicated > major. In addition, they are represented in /dev with new, dedicated > device char names: /dev/accel/accel*. This is done to make sure any > user-space software that tries to open a graphic card won't open > the accelerator device by mistake. > > The above implies that the minor numbering should be separated from > the rest of the drm devices. However, to avoid code duplication, we > want the drm_minor structure to be able to represent the accelerator > device. > > To achieve this, we add a new drm_minor* to drm_device that represents > the accelerator device. This pointer is initialized for drivers that > declare they handle compute accelerator, using a new driver feature > flag called DRIVER_COMPUTE_ACCEL. It is important to note that this > driver feature is mutually exclusive with DRIVER_RENDER. Devices that > want to expose both graphics and compute device char files should be > handled by two drivers that are connected using the auxiliary bus > framework. > > In addition, we define a different idr to handle the accelerators > minors. This is done to make the minor's index be identical to the > device index in /dev/. In most places, this is hidden inside the drm > core functions except when calling drm_minor_acquire(), where I had to > add an extra parameter to specify the idr to use (because the > accelerators minors index and the drm primary minor index both begin > at 0). > > Signed-off-by: Oded Gabbay > --- > drivers/gpu/drm/drm_drv.c | 171 +++++++++++++++++++++++++-------- > drivers/gpu/drm/drm_file.c | 69 +++++++++---- > drivers/gpu/drm/drm_internal.h | 2 +- > drivers/gpu/drm/drm_sysfs.c | 29 ++++-- > include/drm/drm_device.h | 3 + > include/drm/drm_drv.h | 8 ++ > include/drm/drm_file.h | 21 +++- > 7 files changed, 235 insertions(+), 68 deletions(-) Can we please add something to Documentation? I know this leverages DRM a lot, but I believe that a new subsystem should not be introduced without documentation. A lot of the info in the commit message is very good, but should not be buried in the git log. Besides, imagine this has been in mainline for N years, and someone completely new to the kernel wants to write an accel driver. They should be able to get started with something from Documentation that at-least gives that person some insight into what to grep the code for. > > 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; IDR is deprecated. XArray is the preferred mechanism. Yes, there already is IDR here, but I believe we should not be adding new uses. Maybe at some point, the current IDR will be converted. Also with XArray, I think you don't need the spinlock since XArray has internal locking already.