Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1096160imu; Wed, 28 Nov 2018 04:39:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/U51/svXCclGI2voYZ+/tDr2yeLZgsP7qy9f7Q4I7Vf4XnyGj1As0I40a4Y4ulDDkP9Wile X-Received: by 2002:a17:902:503:: with SMTP id 3mr28641636plf.233.1543408792840; Wed, 28 Nov 2018 04:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543408792; cv=none; d=google.com; s=arc-20160816; b=pn591+N43gqiAuY2KMPKnvRuwSyCDALecXCc7/xfc8lyRYQAb4GMVCT+d7xeBNG1o0 TnBUwSnXcFEgGMQJgpMKCC17YbkdEq7niP6RXOssvCLuZltpwUMFb2ivHx5KeO9PR499 fEzwjv4BsFS8sASPjSbMNbnI99jkL8G0hx81uGhKe7GaI5dLzkkY0JVXzn8gh19SqnYV XbwqYNv2BJcI2VvBY6L+A00Exutol3qKoTXe7ZcKEef5YfjDOoc6FlwD+Sb4uO0YKwJH zCw8eNKLDB5SUGuDIraevVExeuffBhsN1R/836q1k/K0CU473xC5A2Zvs91k2xHi+yBt fOGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2LkPlolDCNEbJcPcn0tERISjVQncXnltlFvA9jTLqKA=; b=YZoNpqcKFFUkTLLZa41gXvQM1Xnum4GJp9rVaDhd5UOgk58SntXaBRoPBRRj+ui0eA S9q/lKTj8FOR8g6wEjIS1aUBcT9BjjVbzEYmX73JbOSbuyOR81xJZL/z+tdtcx79amVD FVKpm7jk3zYuXerW0jlcBbPJQRqIpAB98onqKX/6WM7Xw+u12yPN97Qmqm4lF47yNbyc L80dBa4ZODMbn83I67/VZWsuV+Tl/T/OwPWp83Q1dwQ3rKjTX5wMD+f/t0/qa9jwQw6f nlRbV88CpOIIZV1GsUgBCc5KDkcYzPDaX/7h6U6SX+X7adpWQlfIl+I5mIhSBLX7v6K1 U5Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dnPev4MJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si6914858pgl.209.2018.11.28.04.39.37; Wed, 28 Nov 2018 04:39:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dnPev4MJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728220AbeK1Xk2 (ORCPT + 99 others); Wed, 28 Nov 2018 18:40:28 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:52899 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbeK1Xk2 (ORCPT ); Wed, 28 Nov 2018 18:40:28 -0500 Received: by mail-it1-f194.google.com with SMTP id i7so4074962iti.2; Wed, 28 Nov 2018 04:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2LkPlolDCNEbJcPcn0tERISjVQncXnltlFvA9jTLqKA=; b=dnPev4MJaiM8UOwrDEHufF5KcCpaxs2nqlUXoW9/xKoj4yKU27txDFT68kOXigHdvg 0X+zpk//kxpTpAOPpwb7bBTEZ0ntGQboBBtmlV1ctAkTFMkElxyZuOD3AB9WogaYwHxC gfnKGCINFC6CkiWS9VI/Eyr8ceEOaRw3/ecnWriLVmldimRgoAzcbhOFCAKWI1+j6Thn h2Wuxe/ONFwqWvenQGu+OZrU7DLoGmzbZFIYIfxr6OmIJVBfAZ23yKi4nh5jgTEchI53 CeIVwyVnlpRMuTRm60oJWiy+MrMlwLOB1KOX7BzGRYZHEfed+Xt06fnrmc05fCUi37d7 M3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2LkPlolDCNEbJcPcn0tERISjVQncXnltlFvA9jTLqKA=; b=g2thbr3+Bsez+UN3IkvQhqyCzXRYSpT9+YJD8HWqywh+8PhBp1wwtEBUzhUPTaCPqz kWX+ve9z30yD+9pNWtLdI8EV+ax2WY8wammRdpX+prckdGYgh+/aWnHBt7OLNbuR+SFB 6gcbVkbzrDGR7alqu0bO15BBK8EJK5ibPJ9S+rD/LE1RirvgF1+SFZNG2VzJxPoTsaKb Gzr18Vgvyzwv5H3769KThham2OurOBmkoyrI1tt7UHxjkuId5odvlxfKhMG7i7mKKsw2 dgy+CoBAmT+aanSwmeZsiZzxitv+SxpsH+c6P/vVZMSFf7j+yH1B9/Myp4K3WllPaIcR tYmQ== X-Gm-Message-State: AA+aEWYBq2xfS/OwsFR3wZBHC9dOYGHz0yep8W1f5uL6BHnV95llcGCM tv8EkNLMUtmEeRRjQlLaQP2gxreXd0O6TJc3oWE= X-Received: by 2002:a02:242b:: with SMTP id f43mr11004385jaa.144.1543408735977; Wed, 28 Nov 2018 04:38:55 -0800 (PST) MIME-Version: 1.0 References: <20181126213710.3084-1-vivek.gautam@codeaurora.org> <20181128073940.GA13072@infradead.org> In-Reply-To: <20181128073940.GA13072@infradead.org> From: Rob Clark Date: Wed, 28 Nov 2018 07:38:44 -0500 Message-ID: Subject: Re: [PATCH v2 1/1] drm: msm: Replace dma_map_sg with dma_sync_sg* To: hch@infradead.org Cc: Vivek Gautam , David Airlie , Tomasz Figa , Linux Kernel Mailing List , freedreno , dri-devel , linux-arm-msm , Jordan Crouse , Sean Paul Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 28, 2018 at 2:39 AM Christoph Hellwig wrote: > > > + /* > > + * dma_sync_sg_*() flush the physical pages, so point > > + * sg->dma_address to the physical ones for the right behavior. > > + */ > > + for_each_sg(msm_obj->sgt->sgl, s, msm_obj->sgt->nents, i) > > + sg_dma_address(s) = sg_phys(s); > > + > > I'm sorry, but this is completely bogus and not acceptable. > > The only place that is allowed to initialize sg_dma_address is > dma_map_sg. If the default dma ops don't work for your setup we have > major a problem and need to fix the dma api / iommu integration instead > of hacking around it. I agree that the dma/iommu integration is very problematic for drm (in particular, gpu drivers that use the iommu as an gpu mmu).. Really we need a way that a driver can opt-out of this, and access the cpu cache APIs directly, skipping the dma API entirely. But as it is, we've had to hack around the dma API. I'm not really sure this hack is any worse than abusing dma_(un)map_sg() for doing cache operations. I probably should have paid more attention and nak'd the dma/iommu integration before it landed. But given that now we are stuck in this situation, while I'm certainly interested if anyone has some ideas about how to let drivers opt out of the dma/iommu integration and bypass the dma API layer, I'm ok with replacing a hack with a less-bad hack. BR, -R