From patchwork Thu Jan 11 21:44:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10158655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 376EE605F8 for ; Thu, 11 Jan 2018 21:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 282DE28772 for ; Thu, 11 Jan 2018 21:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C0E2287A3; Thu, 11 Jan 2018 21:44:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A806028772 for ; Thu, 11 Jan 2018 21:44:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D84266E4C5; Thu, 11 Jan 2018 21:44:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 185A06E4C0; Thu, 11 Jan 2018 21:44:34 +0000 (UTC) Received: by mail-qk0-x243.google.com with SMTP id a8so6250044qkb.8; Thu, 11 Jan 2018 13:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ylZccpcX9WkFX7w6Xn+VIsUOIp0NK5NAKcx1syprxSA=; b=iS1mCfH9TM4JRtg4cefY1mHGeWUfSfHa1K84h5iiCkzwXsaRLHViGuzRt0ZJ84xo7V VJ+/N9fTez3N3whGv5O7Z97XmPjDrtOCNwblA+5J5f+Oak5RydhmhBWNHPaTTMMIBdg1 UqYnLPx8nlMWP+tJDE+yWq1vjFPNSwxZ80+EuRzV0DKfIEQrP/AdAzKndU7baffeLi/f qjS4rHqll9fxacfE1TY4JkXBEA/a8iDw4UbjSY0S90IpoOyPZUx4IB1oxvZZ08FAK/xr TI07Fh4hY0JlvLlSaKf/oaFTHxGpHBsxp0GmarmDuJPHQg/XRRAcr3iqcG4Gxhmwk/nV QqNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ylZccpcX9WkFX7w6Xn+VIsUOIp0NK5NAKcx1syprxSA=; b=HLQJMAPz81uqu2LyTXGMz0zYTLyaRxQubFqOBl1KCXO71kIBol1XAHvSU8ABBoctx0 DorKbLORPrR8sPvKQz9u4GCxERt2JIz4nMmXTqpM2Pj6fU8Ol5IiU/SMuABU0k5IxA7n 7QFypqQm/pQcT2rWPpfWD6rpHsUArGWEdBN81qTZKiawXr8qI+Tgs01nJeEBv1yQl+X6 71TI3eT1AyI+qULoCS4+VHn2B4WAvyN3RlLlcTDG5HrtDjPqJf+/pFNNhxqxMWsLmEnQ 8F0Rk6bD8IN1wTTYouRIq8Tg9AVmCEet9F+bVv/dcAvM0BMfszOwKKuRvVxdsvfusy9P zLjQ== X-Gm-Message-State: AKwxyteu8C9KF6d4IrLyC+0IwLNCZDibelZXZeXT/Y9QUvMsPBQjMoEG vlnqNdVezPM6qTF8hyhF/iQ= X-Google-Smtp-Source: ACJfBouJbFDFFxZ9qGzA2f/E+joFQvY5wrWPoSQMeMklJdqlKfAQJnm6p9TKqZ1hJZkGl6VtgHSIIg== X-Received: by 10.55.186.130 with SMTP id k124mr34240857qkf.153.1515707072722; Thu, 11 Jan 2018 13:44:32 -0800 (PST) Received: from localhost (p200300E41F21CF00227DB10B7BBDB590.dip0.t-ipconnect.de. [2003:e4:1f21:cf00:227d:b10b:7bbd:b590]) by smtp.gmail.com with ESMTPSA id j49sm3060724qtc.61.2018.01.11.13.44.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2018 13:44:32 -0800 (PST) From: Thierry Reding To: Ben Skeggs Subject: [PATCH 5/5] drm/nouveau: prime: Implement cache maintenance Date: Thu, 11 Jan 2018 22:44:20 +0100 Message-Id: <20180111214420.26203-5-thierry.reding@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180111214420.26203-1-thierry.reding@gmail.com> References: <20180111214420.26203-1-thierry.reding@gmail.com> Cc: linux-tegra@vger.kernel.org, Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Implement the ->begin_cpu_access() and ->end_cpu_access() callbacks to allow userspace to invalidate the cache before accessing a buffer that is exported using PRIME and flush the cache after modifying the buffer through its userspace mapping. Signed-off-by: Thierry Reding --- drivers/gpu/drm/nouveau/nouveau_prime.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c index 5d885d7cb059..a3a586ce864c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c @@ -29,6 +29,26 @@ #include "nouveau_drv.h" #include "nouveau_gem.h" +static int nouveau_gem_prime_begin_cpu_access(struct dma_buf *buf, + enum dma_data_direction direction) +{ + struct nouveau_bo *bo = nouveau_gem_object(buf->priv); + + nouveau_bo_sync_for_cpu(bo); + + return 0; +} + +static int nouveau_gem_prime_end_cpu_access(struct dma_buf *buf, + enum dma_data_direction direction) +{ + struct nouveau_bo *bo = nouveau_gem_object(buf->priv); + + nouveau_bo_sync_for_device(bo); + + return 0; +} + static void *nouveau_gem_prime_kmap_atomic(struct dma_buf *buf, unsigned long page) { @@ -106,6 +126,8 @@ static const struct dma_buf_ops nouveau_gem_prime_dmabuf_ops = { .map_dma_buf = drm_gem_map_dma_buf, .unmap_dma_buf = drm_gem_unmap_dma_buf, .release = drm_gem_dmabuf_release, + .begin_cpu_access = nouveau_gem_prime_begin_cpu_access, + .end_cpu_access = nouveau_gem_prime_end_cpu_access, .map_atomic = nouveau_gem_prime_kmap_atomic, .unmap_atomic = nouveau_gem_prime_kunmap_atomic, .map = nouveau_gem_prime_kmap,