Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp178163pxk; Wed, 30 Sep 2020 22:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4+Z/dKa19ARpjDwtXM+gDDqDnXcy7HFWoPQaLQq/C4vV+tt22SmNuSZeL3+WNvmH5dUIn X-Received: by 2002:a50:cd5d:: with SMTP id d29mr6630811edj.318.1601530641823; Wed, 30 Sep 2020 22:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601530641; cv=none; d=google.com; s=arc-20160816; b=RfXb4E3KgBkAVCa1qGJDz356c6qKvM+kETtG7g8dwuPSIFc762JdUT+bMcaCoAUWXa TiE5Bp1n7eHIYgYnTx0JBH1OtoOYT3mmcs9uoGLujjGQjD5rDV0r4XAtnHVdivwBUpgT l5wsaVXtxTzi1nSLplxfuFsN2e8866PurOXZyfSwhG1a2aF5GaQ9hApk48vUshOvyImb qtpGQpMAG5l7VWrvuBLEm8BpvDPW9r+/ehFjxU4TjbzUXtJjQk65U4LrHDNXP8V6r9Aa RcYHeiZZDegEXAMilvicWHTDl3OZZEKf/QuSCs1laR5VcxIK82CdhIOvoSSsgfnN79ay W3Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YaWzUhJBpv6JbLryjfJhobQdFdMa6mxNrCeIElFLS/Y=; b=xZeBpOfKEeF6iPldSmQfiM+9pRvBz0fNwhMCegnLyZUdCIMZRIbVD1YKsM4yatNth8 NEZkR8VwukKRNOjMLry8hbx91pJBANhKYTr7ucg19xlEAQ5kgmDVF2LeDMY62D3wEDMD h27krZHix3n17leghosN54/QbpvcAJio1LtTcoX3bqJjdtgOkeB/S94hA1OHbPIWlXuG sbKTLh2HWh+1R0w8NYieC5MidtMZHe6dNjUPSMP+Bvg1bpWYun3TdW3oRQGYQdthofS2 YRRLsAGa9w1iFOrKm0dZstGdeb0yl9qHZteh3O3Tu6A9MKFSUW1e7fBlfoA1a5A1dcUN 9GUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si2575923ejb.40.2020.09.30.22.36.59; Wed, 30 Sep 2020 22:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730679AbgJAFfN (ORCPT + 99 others); Thu, 1 Oct 2020 01:35:13 -0400 Received: from verein.lst.de ([213.95.11.211]:47487 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgJAFfM (ORCPT ); Thu, 1 Oct 2020 01:35:12 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id BC8D868B02; Thu, 1 Oct 2020 07:35:09 +0200 (CEST) Date: Thu, 1 Oct 2020 07:35:09 +0200 From: Christoph Hellwig To: Paul Cercueil Cc: Christoph Hellwig , Stephen Rothwell , Dave Airlie , DRI , Linux Next Mailing List , Linux Kernel Mailing List Subject: Re: [PATCH 3/3] drm/ingenic: Alloc cached GEM buffers with dma_alloc_noncoherent Message-ID: <20201001053509.GB19914@lst.de> References: <20200930165212.GA8833@lst.de> <20200930171644.299363-3-paul@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930171644.299363-3-paul@crapouillou.net> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 07:16:44PM +0200, Paul Cercueil wrote: > It turns out that if you want to mmap GEM buffers fully cached, then > they should be allocated as such as well. Who would have known? > > Introduce a custom .dumb_create callback, that will behave just like > drm_gem_cma_dumb_create(), except that it will allocate the GEM buffer > using dma_alloc_noncoherent() if non-coherent memory is what we want. I think you want to merge this with patch 2, then change patch 2 to still use dma_alloc_wc for the !ingenic_drm_cached_gem_buf and to get the phys address using virt_to_phys for the ingenic_drm_cached_gem_buf instead of abusing the dma address in ->paddr. The free side also needs to use dma_free_noncoherent. > +static int ingenic_drm_gem_cma_dumb_create(struct drm_file *file_priv, > + struct drm_device *drm, > + struct drm_mode_create_dumb *args) > +{ > + /* > + * This is basically a copy of drm_gem_cma_dumb_create, which supports > + * creating fully cached GEM buffers. > + */ What about adding this to the core GEM code instead? We'll probaby run into other potential users as well.