Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2970371rdb; Mon, 4 Dec 2023 12:37:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5KTE+ZaqXOFkVi3owKrN+aCHao8CMqyMgZwMETyndm+gmEmRcj10xpM/ckWNMe2CQM/ut X-Received: by 2002:a05:6a20:9191:b0:18f:97c:823e with SMTP id v17-20020a056a20919100b0018f097c823emr2859241pzd.72.1701722235136; Mon, 04 Dec 2023 12:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722235; cv=none; d=google.com; s=arc-20160816; b=kgCMGPVmlD8NBBG8roxEiAurBj5NxK0wkUNYgtqnTBfaDvzpasodCGTdXRhrVrEC+j Qt1x2bxnQT6edkJ0R+3NFtq/WqB/Xh9wuMNSVhp6AP/k2VslTJgqNmC1iF1Eptq6IcqE oNoKvWQb9zQ/oMOyTWeYrI41U4dBMv8JUfRGCgq0IxbucIo5dyqD4Ua6Oj72IpXaY7m7 GHV+VEtlGlcFxQYwrJ7ykvKJ6/3MQxgrgPL+9hc5X/880K5YHpUaQY2oKRS1v9tJfFI0 qOxNydmvt8nFCXj/QxUm6xjhihoFMNRs6HnQNjP0UgUD1FVPmWrtf/S7yKqjVW/ulBb0 kMhA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2GkyEl2dZFO91e69iCHOvC3UuUI94BPNVxjSzSSZIv4=; fh=DNMn5jb/eTyaDTnoN4Pt9waTp55NKlB8WDQAr9xCXZI=; b=ToxoQPOH8rMyIucFkqzz7i5VSQ7CLH8VGWl8pqJb9tdoNPhoeAMBFi8LhbLqhXTJ4L hpVN1O9HQq68Lah2vZEtZc8mI3OQHuIMvEaAIko7ezIJX+8OtQUoEi75FGmLZRza0kr4 K5JBMWyUMGMSFsLZ3Y6cKlAMoYMUsD6B0wwkLYdDGAnbKPBVuUaDYxo+jGwWkIKyWAEf PF85BJlHfy5K6E8uozmCU3UP7ZL+h2Si3qArTKFP6/+Bzhk7K0n86aX3TU7gQiatd7SY KLrsRvDnc4GsuG7yRQXyVM+GmwKx4xcMRh28Mqn5Uh2iDlRG6fT7PnEe4s024/LKzYMK Ypjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PY8E8Pxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ck9-20020a056a02090900b005c612569dbcsi1064750pgb.457.2023.12.04.12.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:37:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PY8E8Pxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AE36C807799F; Mon, 4 Dec 2023 12:37:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346249AbjLDUgv (ORCPT + 99 others); Mon, 4 Dec 2023 15:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346225AbjLDUg2 (ORCPT ); Mon, 4 Dec 2023 15:36:28 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0D32D5B for ; Mon, 4 Dec 2023 12:34:57 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACBB4C433C9; Mon, 4 Dec 2023 20:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722097; bh=ow15m191T2FC0cIqsGJ4ULBd4rLZzTNHYOB2ZQL0wPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PY8E8Pxg5mOL9VHMgoPG+EeGcRbY2enwd0XO8kcbx48zvhh26sId77SRwIiqS0Cz8 HVOnxoCBR17Y8YZplK2zf3rWHzZwxGUiF0wvls6+yyocPcbCOTMhorNT5SFVngDDQo pMwsnG79gkvEM3p/67xTX5Xsh02jcjF28h726fifVg+Fe9aF85BXI6GhPZnlO2GbWa lUKFMLkdtnX9h4PdaQxK1oMqpF+WnDp/0dl9bSJXvySFAtYphDiXYT20M2s38ihKOD eFYzwNMhhox0lV5l+rdb5YKToWI/fABXUHOQQSo4MaXdHBivXnvX3jJZjq2RT4oNMt 4TFgnRzokdxWg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Felix Kuehling , =?UTF-8?q?Christian=20K=C3=B6nig?= , Thomas Zimmermann , Daniel Vetter , Alex Deucher , Sasha Levin , maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.6 30/32] Revert "drm/prime: Unexport helpers for fd/handle conversion" Date: Mon, 4 Dec 2023 15:32:50 -0500 Message-ID: <20231204203317.2092321-30-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204203317.2092321-1-sashal@kernel.org> References: <20231204203317.2092321-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:37:13 -0800 (PST) From: Felix Kuehling [ Upstream commit 0514f63cfff38a0dcb7ba9c5f245827edc0c5107 ] This reverts commit 71a7974ac7019afeec105a54447ae1dc7216cbb3. These helper functions are needed for KFD to export and import DMABufs the right way without duplicating the tracking of DMABufs associated with GEM objects while ensuring that move notifier callbacks are working as intended. CC: Christian König CC: Thomas Zimmermann Acked-by: Thomas Zimmermann Acked-by: Daniel Vetter Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_prime.c | 33 ++++++++++++++++++--------------- include/drm/drm_prime.h | 7 +++++++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 63b709a67471b..834a5e28abbe5 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -278,7 +278,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf) } EXPORT_SYMBOL(drm_gem_dmabuf_release); -/* +/** * drm_gem_prime_fd_to_handle - PRIME import function for GEM drivers * @dev: drm_device to import into * @file_priv: drm file-private structure @@ -292,9 +292,9 @@ EXPORT_SYMBOL(drm_gem_dmabuf_release); * * Returns 0 on success or a negative error code on failure. */ -static int drm_gem_prime_fd_to_handle(struct drm_device *dev, - struct drm_file *file_priv, int prime_fd, - uint32_t *handle) +int drm_gem_prime_fd_to_handle(struct drm_device *dev, + struct drm_file *file_priv, int prime_fd, + uint32_t *handle) { struct dma_buf *dma_buf; struct drm_gem_object *obj; @@ -360,6 +360,7 @@ static int drm_gem_prime_fd_to_handle(struct drm_device *dev, dma_buf_put(dma_buf); return ret; } +EXPORT_SYMBOL(drm_gem_prime_fd_to_handle); int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) @@ -408,7 +409,7 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev, return dmabuf; } -/* +/** * drm_gem_prime_handle_to_fd - PRIME export function for GEM drivers * @dev: dev to export the buffer from * @file_priv: drm file-private structure @@ -421,10 +422,10 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev, * The actual exporting from GEM object to a dma-buf is done through the * &drm_gem_object_funcs.export callback. */ -static int drm_gem_prime_handle_to_fd(struct drm_device *dev, - struct drm_file *file_priv, uint32_t handle, - uint32_t flags, - int *prime_fd) +int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle, + uint32_t flags, + int *prime_fd) { struct drm_gem_object *obj; int ret = 0; @@ -506,6 +507,7 @@ static int drm_gem_prime_handle_to_fd(struct drm_device *dev, return ret; } +EXPORT_SYMBOL(drm_gem_prime_handle_to_fd); int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) @@ -864,9 +866,9 @@ EXPORT_SYMBOL(drm_prime_get_contiguous_size); * @obj: GEM object to export * @flags: flags like DRM_CLOEXEC and DRM_RDWR * - * This is the implementation of the &drm_gem_object_funcs.export functions - * for GEM drivers using the PRIME helpers. It is used as the default for - * drivers that do not set their own. + * This is the implementation of the &drm_gem_object_funcs.export functions for GEM drivers + * using the PRIME helpers. It is used as the default in + * drm_gem_prime_handle_to_fd(). */ struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj, int flags) @@ -962,9 +964,10 @@ EXPORT_SYMBOL(drm_gem_prime_import_dev); * @dev: drm_device to import into * @dma_buf: dma-buf object to import * - * This is the implementation of the gem_prime_import functions for GEM - * drivers using the PRIME helpers. It is the default for drivers that do - * not set their own &drm_driver.gem_prime_import. + * This is the implementation of the gem_prime_import functions for GEM drivers + * using the PRIME helpers. Drivers can use this as their + * &drm_driver.gem_prime_import implementation. It is used as the default + * implementation in drm_gem_prime_fd_to_handle(). * * Drivers must arrange to call drm_prime_gem_destroy() from their * &drm_gem_object_funcs.free hook when using this function. diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h index a7abf9f3e6972..2a1d01e5b56b8 100644 --- a/include/drm/drm_prime.h +++ b/include/drm/drm_prime.h @@ -60,12 +60,19 @@ enum dma_data_direction; struct drm_device; struct drm_gem_object; +struct drm_file; /* core prime functions */ struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, struct dma_buf_export_info *exp_info); void drm_gem_dmabuf_release(struct dma_buf *dma_buf); +int drm_gem_prime_fd_to_handle(struct drm_device *dev, + struct drm_file *file_priv, int prime_fd, uint32_t *handle); +int drm_gem_prime_handle_to_fd(struct drm_device *dev, + struct drm_file *file_priv, uint32_t handle, uint32_t flags, + int *prime_fd); + /* helper functions for exporting */ int drm_gem_map_attach(struct dma_buf *dma_buf, struct dma_buf_attachment *attach); -- 2.42.0