Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3127275pxk; Mon, 5 Oct 2020 01:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyudOz0Mmu192Oqzna9BDsZwXpVr2mAlucTFoxrfPrN8HgT6ydfmOcvprYSt5bAisf88taQ X-Received: by 2002:a50:ab59:: with SMTP id t25mr15273485edc.364.1601886753926; Mon, 05 Oct 2020 01:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601886753; cv=none; d=google.com; s=arc-20160816; b=uAasfKrPM3lEzPtQnm1CyyIab3hX82z7kmNXFl3ktEFLu8l/awU7wkokucP2ioqEVQ Rzwbd3tnt3NcXMgwM20GoMhG/iU7CKX/2tonCmLZ4DhVOToC5r8C4HRmjd0cvWWPhFHo QpSOyvs5WBGrWJHXDmG5QCD+G6CrSfeWWBVcdEmSagXSok56lEGiT3Va/rROjiRbRC8r QqFwAeNC8VFjt54MoQKV2cHh6bngqDo7GrRB1YVLubkySp+PnRb0j2gSewd8M6AVi+da yM1xwc0U48Ki/vB0XEHCCYppyu+dJa1zDeoipFgXnAQfkS6OFX2B246ky+S6CvN8nMSW sGvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kqzUKtK8GOb7bW4H3n/BFL1qICkSEHQYXjLgPEjS2CE=; b=oc3Phu4Ey0O/2U1i/2YP9vBHJeTTfdhfW/+X7Jn+t+Mov+U6JME71J3KXWt01V28cK iNIcoiN/0b8i4YHquypNDW6J59Fc9IEJN7OfZ0k9KZxgELa6weiRIvWw/kzQxozPhaFQ Mzt3do3WGJ69U/XZIXocSkn1vp74cfSNC8ZqDV8KGtI2gx39HrWQzgHPFkA/OrZtvRCg giGkuU+h2PDdMazFfbr5xXzIpkDRIznV9pYop53nNkwHed7/lQIV0xTgb80KT5Y22Bzg Hsk+yjBc8HuHHEArpxzR3V0z8YMl6glAG94mvNb3WZfG9dz52pEHIeDtB83BQBFrQrCb A+qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Glk+6xlf; 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 do12si6459822ejc.114.2020.10.05.01.32.11; Mon, 05 Oct 2020 01:32:33 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Glk+6xlf; 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 S1725981AbgJEI3V (ORCPT + 99 others); Mon, 5 Oct 2020 04:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgJEI3U (ORCPT ); Mon, 5 Oct 2020 04:29:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E145C0613CE; Mon, 5 Oct 2020 01:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kqzUKtK8GOb7bW4H3n/BFL1qICkSEHQYXjLgPEjS2CE=; b=Glk+6xlfldc5C47KvhK2HtCy16 5q1YyA1feL1tcE7Hzba/dTGO/FxmAE2DI74IF+5jWJiiOO59aBZnRDlV8g2D9Y1FO2655hlVoQw5b 3GWKGKcU1hQ4yqZqVolk105sJMA7jG5Fdi4BlYPhG0Kr3jv/YiyWiew4liHZYYCmLZunB1ODmTkQF IOK8DIAj9Pm4aePKRQdja4x/zTMTQjpl/3A5dva1fvbte/Aq8HFsnf3FTcSkp15MwLhCYSABHhomg r7fZkCLM89YznfPZ18GTqcE0XfvGjyoNVeQXzrX3oY6JROSZ6DYKlPxTAJzThg6XXVp3SuiT4Omre MlopKnsA==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPLru-0008Kj-3d; Mon, 05 Oct 2020 08:29:14 +0000 Date: Mon, 5 Oct 2020 09:29:14 +0100 From: Christoph Hellwig To: Jonathan Marek Cc: Christoph Hellwig , freedreno@lists.freedesktop.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , "open list:DRM DRIVER FOR MSM ADRENO GPU" , "open list:DRM DRIVER FOR MSM ADRENO GPU" , open list Subject: Re: [PATCH 2/3] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance Message-ID: <20201005082914.GA31702@infradead.org> References: <20201001002709.21361-1-jonathan@marek.ca> <20201001002709.21361-3-jonathan@marek.ca> <20201002075321.GA7547@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 02, 2020 at 08:46:35AM -0400, Jonathan Marek wrote: > > > +void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags, > > > + size_t range_start, size_t range_end) > > > +{ > > > + struct msm_gem_object *msm_obj = to_msm_bo(obj); > > > + > > > + /* TODO: sync only the required range, and don't invalidate on clean */ > > > + > > > + if (flags & MSM_GEM_SYNC_CACHE_CLEAN) > > > + sync_for_device(msm_obj); > > > + > > > + if (flags & MSM_GEM_SYNC_CACHE_INVALIDATE) > > > + sync_for_cpu(msm_obj); > > > > And make to these ones as well. They are complete abuses of the DMA > > API, and while we had to live with that for now to not cause regressions > > they absoutely must not be exposed in a userspace ABI like this. > > > > How do you propose that cached non-coherent memory be implemented? It is a > useful feature for userspace. If the driver is using the DMA API you need to use dma_alloc_noncoherent and friends as of 5.10 (see the iommu list for the discussion). If you use the raw IOMMU API (which I think the msm drm driver does) you need to work with the maintainers to implement a cache synchronization API that is not tied to the DMA API.