From patchwork Wed Feb 19 12:59:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11392009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4642F92A for ; Wed, 19 Feb 2020 16:56:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24D002464E for ; Wed, 19 Feb 2020 16:56:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="giRn9oVt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24D002464E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51A5F6E82B; Wed, 19 Feb 2020 16:56:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6AF26E5B2; Wed, 19 Feb 2020 12:59:17 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id z3so441206wru.3; Wed, 19 Feb 2020 04:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=hCeM9CJ6pzmi1o3KK+XpvWx7SxeTxw84lBGmVzLUTd8=; b=giRn9oVt2bLLBetMmwF1HDSw7QygLii+yESQB5yyQvHBoCUPNuhnnuCcO40866mAXl ZgzznsO+vKrBC+IcmIylWWYdRBFFIzr4HwBm1qyHfGjl8qFfWwtb3M+N4FT7V8mYFFcH NsI8ko5OmvLIaTfedhhSSDd1gQwJfwjRocqOg3wWBgKFcQykt78LG7Sn52D3XGKIPlNK tl11S5HhDJ2Gt7ZZrcMAJsDWjTh8UK7MGGlawsYsxffHGrX9LQwjthDrlY6FdXK5q6gh Sht+o8y9KkbLvmRyk348Ter9+EWz62i6Vx0g1R+1qwJH8foAUktVPR3WhQK6Yzyr4LLo s4/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hCeM9CJ6pzmi1o3KK+XpvWx7SxeTxw84lBGmVzLUTd8=; b=N2r9SI5AnLW6YsSM5B/TqycmDO3Ehp92T6pcOrfE9iZiYYcy/W11CxmYlEJOUq60z3 R2KLFDPluCwQISROLUdNrxsLqKzGIFpVDDYICdw8JW6tO7f01Ij/rPQSQQ/fjhRdUqIf rycgd0mBRX1RA048zPbphb0ftMKr3Bfm7O64QYU2QCPqKP/T6z9VOctk/uP4DbBbTI1t XCClWxhU0natvbEDkRj5fJ5KWrhJi4YV3se0bydnHWqVDJaezrfZhET52pGOTO8AwAS/ kgDQLtIXPk3vLGghme72+dyS2Y18Rs50jkRGQes1xVcDvVvDEDHQskTJiWg2YlarM1g7 /K+A== X-Gm-Message-State: APjAAAV8zdxZJJxGGGuj5OUBIH6gPcNN7R5PaJYMnFXTSA94IYGfXTEj 6zcPNdKh6nza2EiR/Nl5zwQIAOhq X-Google-Smtp-Source: APXvYqySOgedUHE0WIseUqC6YRH4GURoV+8ztV20bSWnbuN2/ag6oz0YQs44nziyGSFcOqFV5ziYRA== X-Received: by 2002:adf:dfcc:: with SMTP id q12mr35180842wrn.171.1582117156160; Wed, 19 Feb 2020 04:59:16 -0800 (PST) Received: from abel.fritz.box ([2a02:908:1252:fb60:90ea:9d7:18a3:895e]) by smtp.gmail.com with ESMTPSA id h2sm3079024wrt.45.2020.02.19.04.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 04:59:15 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, daniel@ffwll.ch Date: Wed, 19 Feb 2020 13:59:09 +0100 Message-Id: <20200219125910.89147-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200219125910.89147-1-christian.koenig@amd.com> References: <20200219125910.89147-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 19 Feb 2020 16:56:01 +0000 Subject: [Intel-gfx] [PATCH 6/7] dma-buf: drop dynamic_mapping flag X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Instead use the pin() callback to detect dynamic DMA-buf handling. Since amdgpu is now migrated it doesn't make much sense to keep the extra flag. Signed-off-by: Christian König --- drivers/dma-buf/dma-buf.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 1 - include/linux/dma-buf.h | 21 +++++---------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 5f10d1929476..6d0a82d1b23d 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -524,11 +524,10 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) } if (WARN_ON(exp_info->ops->cache_sgt_mapping && - exp_info->ops->dynamic_mapping)) + (exp_info->ops->pin || exp_info->ops->unpin))) return ERR_PTR(-EINVAL); - if (WARN_ON(!exp_info->ops->dynamic_mapping && - (exp_info->ops->pin || exp_info->ops->unpin))) + if (WARN_ON(!exp_info->ops->pin != !exp_info->ops->unpin)) return ERR_PTR(-EINVAL); if (!try_module_get(exp_info->owner)) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index 1a040ccf61bf..ffeb20f11c07 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -364,7 +364,6 @@ static int amdgpu_dma_buf_begin_cpu_access(struct dma_buf *dma_buf, } const struct dma_buf_ops amdgpu_dmabuf_ops = { - .dynamic_mapping = true, .attach = amdgpu_dma_buf_attach, .detach = amdgpu_dma_buf_detach, .pin = amdgpu_dma_buf_pin, diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index b38cea240b67..1ade486fc2bb 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -42,18 +42,6 @@ struct dma_buf_ops { */ bool cache_sgt_mapping; - /** - * @dynamic_mapping: - * - * If true the framework makes sure that the map/unmap_dma_buf - * callbacks are always called with the dma_resv object locked. - * - * If false the framework makes sure that the map/unmap_dma_buf - * callbacks are always called without the dma_resv object locked. - * Mutual exclusive with @cache_sgt_mapping. - */ - bool dynamic_mapping; - /** * @attach: * @@ -99,7 +87,8 @@ struct dma_buf_ops { * This is called by dma_buf_pin and lets the exporter know that the * DMA-buf can't be moved any more. * - * This is called with the dmabuf->resv object locked. + * This is called with the dmabuf->resv object locked and is mutual + * exclusive with @cache_sgt_mapping. * * This callback is optional and should only be used in limited use * cases like scanout and not for temporary pin operations. @@ -116,7 +105,8 @@ struct dma_buf_ops { * This is called by dma_buf_unpin and lets the exporter know that the * DMA-buf can be moved again. * - * This is called with the dmabuf->resv object locked. + * This is called with the dmabuf->resv object locked and is mutual + * exclusive with @cache_sgt_mapping. * * This callback is optional. */ @@ -455,8 +445,7 @@ static inline void get_dma_buf(struct dma_buf *dmabuf) */ static inline bool dma_buf_is_dynamic(struct dma_buf *dmabuf) { - /* TODO: switch to using pin/unpin functions as indicator. */ - return dmabuf->ops->dynamic_mapping; + return !!dmabuf->ops->pin; } /**