From patchwork Mon Oct 21 21:45:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 177138 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3977471ill; Mon, 21 Oct 2019 14:46:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJs5Mde5d8bQSjRv+OAlzVxEmDEyFWYBFDhNOTs2AGSq4ZQoq9kjozvp8MxuFmMQsIQq9z X-Received: by 2002:a17:902:724b:: with SMTP id c11mr146735pll.155.1571694366538; Mon, 21 Oct 2019 14:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571694366; cv=none; d=google.com; s=arc-20160816; b=K0VjJ68kPsoS+DDESASfeUbvzD36p9YujO1RBfgShxuKdQuhVDS3dGkSy0v7NJMC0s Sr7bwWJoUG7Q1+OgqkkI74RTb1iFVwlQjVOwDgVgdy3/kxxpD7T4+UsbAQFnpN9IJtJK druJpbf8KLoVj2sUOC6bA0vJ4NBWgv/nP5Kl29rMjaR5zBGAv2wTEp9EtZLP4jhJWTpa PXPg4dN7zR9nNMUGF20DzYrYMIniVOpPpyTfOhsu85m4pK7Zx7jpMZY6rgvyZwgsD2zh J64dBZn8zCbALk2fbrIQM9+Wpve2eUNxYZlVJqiJ3zZYVbAxD1Gb/E7s47dyK557lhPv Ig7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=dPv8kF+DtUC4ScI2MYAES/8tVjpxSYQ47iNDSWOde0Q=; b=tDFqscdTGMNz85F0b01B6exDBFWB7aPb3bgZFRJlEH8lEv6quO+MqJa77f6BQcOexF X1f9zegltoofGHoim0hJFOsHRlgRQLJCLrFANPwK89+P5OdiL30sHu07xnFqn4gxyuI2 FJ4g995VwhE7OHpoyiMQAoD2erOad/Ax7UjjvvkU2fWJXyr//a3Oe29B2Ya9GQySS4YK vnz2SJNpPKtd+cg3UwRox8+OcdtH/xz0t1yFNdmJM4XCkd4VcCkT6Wps4iI54mC/R1LR iza2FD2A7Dky8yPr6weZNtybl8Tyqcmd27U4ZwRbmYeptsiXaljwcqZvTAuOBXJm0RjB UP2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id a1si16069081pgw.544.2019.10.21.14.46.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Oct 2019 14:46:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D93C6E27A; Mon, 21 Oct 2019 21:46:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9C9D26E277 for ; Mon, 21 Oct 2019 21:46:00 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id 83so12446205oii.1 for ; Mon, 21 Oct 2019 14:46:00 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=dtmBYecTmxMYIL93VEKcTUybHl02f54X+UyJdNEnFs0=; b=fYet3nMNJj3F52K1ylvGd7+Lcgb9y8lKqSE8Zp+SQhZN9lqbFFkzblBxNmyVVabNLF jQNejhBIBF/bhPypb467IYPRQXqBdY+tJr9R118OIzPRShWuHnPwEx6ZHM0+zDNB3Clc GW2Xm8SUsnUQ9+V0KguV2MjhTN/gC+29axRqYnftnHRNl69gGA1SimRUHJeJjousSJJQ p7wRQMr2FtpaU+c+fvyaM0UPeDd0iOtcreAAwrQh7w9qHoIrpUCALV9z8qwwRFuxERQf Qohrpz7HoepMnhfrYxT0jGCzJe4RSQ9fzV+sKBtkNRxpkGZFuCVoNivE/If6cFXG+GY+ Myvw== X-Gm-Message-State: APjAAAWndQRK5P57hCw44s4zVVsSFELtxX5rfJfoPjXRlqxeBn8LUeO9 dfnvGJZ4ZBggMYBg1Aywx21CMaU= X-Received: by 2002:aca:bd08:: with SMTP id n8mr193003oif.107.1571694359449; Mon, 21 Oct 2019 14:45:59 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id u130sm4122676oib.56.2019.10.21.14.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 14:45:58 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] drm/cma-helper: Use the dma_*_attr API variant Date: Mon, 21 Oct 2019 16:45:47 -0500 Message-Id: <20191021214550.1461-4-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021214550.1461-1-robh@kernel.org> References: <20191021214550.1461-1-robh@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , David Airlie , Liviu Dudau , Laurent Pinchart , Yannick Fertre , Kevin Hilman , Xinwei Kong , Xinliang Liu , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Kieran Bingham , "James \(Qian\) Wang" , Alexandre Torgue , Chen Feng , linux-mediatek@lists.infradead.org, Matthias Brugger , Sean Paul , linux-arm-kernel@lists.infradead.org, Philippe Cornu , Vincent Abriou , Maxime Coquelin , Rongrong Zou Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In preparation to allow DRM CMA users to adjust the DMA_ATTR_* flags, convert the CMA helper code to use the dma_*_attr APIs instead of the dma_*_wc variants. Only the DMA_ATTR_WRITE_COMBINE and DMA_ATTR_NO_WARN attributes are set in this commit, so there's no functional change. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Rob Herring Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/drm_gem_cma_helper.c | 20 ++++++++++++-------- include/drm/drm_gem_cma_helper.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 12e98fb28229..4cebfe01e6ea 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -70,6 +70,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) goto error; } + cma_obj->dma_attrs |= DMA_ATTR_NO_WARN | DMA_ATTR_WRITE_COMBINE; return cma_obj; error: @@ -102,8 +103,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, if (IS_ERR(cma_obj)) return cma_obj; - cma_obj->vaddr = dma_alloc_wc(drm->dev, size, &cma_obj->paddr, - GFP_KERNEL | __GFP_NOWARN); + cma_obj->vaddr = dma_alloc_attrs(drm->dev, size, &cma_obj->paddr, + GFP_KERNEL | __GFP_NOWARN, + cma_obj->dma_attrs); if (!cma_obj->vaddr) { dev_dbg(drm->dev, "failed to allocate buffer with size %zu\n", size); @@ -184,8 +186,9 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj) dma_buf_vunmap(gem_obj->import_attach->dmabuf, cma_obj->vaddr); drm_prime_gem_destroy(gem_obj, cma_obj->sgt); } else if (cma_obj->vaddr) { - dma_free_wc(gem_obj->dev->dev, cma_obj->base.size, - cma_obj->vaddr, cma_obj->paddr); + dma_free_attrs(gem_obj->dev->dev, cma_obj->base.size, + cma_obj->vaddr, cma_obj->paddr, + cma_obj->dma_attrs); } drm_gem_object_release(gem_obj); @@ -279,8 +282,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj, vma->vm_flags &= ~VM_PFNMAP; vma->vm_pgoff = 0; - ret = dma_mmap_wc(cma_obj->base.dev->dev, vma, cma_obj->vaddr, - cma_obj->paddr, vma->vm_end - vma->vm_start); + ret = dma_mmap_attrs(cma_obj->base.dev->dev, vma, cma_obj->vaddr, + cma_obj->paddr, vma->vm_end - vma->vm_start, + cma_obj->dma_attrs); if (ret) drm_gem_vm_close(vma); @@ -434,8 +438,8 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj) if (!sgt) return ERR_PTR(-ENOMEM); - ret = dma_get_sgtable(obj->dev->dev, sgt, cma_obj->vaddr, - cma_obj->paddr, obj->size); + ret = dma_get_sgtable_attrs(obj->dev->dev, sgt, cma_obj->vaddr, + cma_obj->paddr, obj->size, cma_obj->dma_attrs); if (ret < 0) goto out; diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index 947ac95eb24a..d042213c3595 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h @@ -24,6 +24,7 @@ struct drm_gem_cma_object { /* For objects with DMA memory allocated by GEM CMA */ void *vaddr; + unsigned long dma_attrs; }; #define to_drm_gem_cma_obj(gem_obj) \