Received: by 10.192.165.156 with SMTP id m28csp1595480imm; Wed, 11 Apr 2018 23:29:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+7dB/S2TWZnnS8+SLBDfQsxaUDSJATnzyX55Rw9PS/Wyjmffh8TM7LvUfvZWVzAUjTUvHx X-Received: by 10.98.182.8 with SMTP id j8mr6609553pff.115.1523514576106; Wed, 11 Apr 2018 23:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523514576; cv=none; d=google.com; s=arc-20160816; b=Usc4Pps9JE7yv618JPysnxPqCW6y8La7BE0nGpRdvUX7A7xEEO7MySEPHLVpsyAp82 0SPcpFllVKRPDEdE4uUgLiF1eQPcAT3lykxbQoCosGzAVzwl1hlMlzjnqw68eiaQD85Q OAG8NJTW3WZPvsmqUviccPLPSGm9G7X4tKKli9PBN92/MZGUJoPfoEZeF1wmK9ChjvKX TPoymNmSbfatbIViuW6G1F2TnKlirpunpA5fPhT7HJyq0S1fOYoeZp8JR7bujkHzGyTV MFz87ZEmgwNALEH7/YyIPUgM1A/eTtKVYn9Nzp+DXqWCy9lDSW8Sowc2GSOH/MJg7ejG b7ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=nHI55iHCSFB1l7wVyBIRR+w0kgW4H9a8QbU7o+NoGmM=; b=jKN6ce10YrExRIPgF96A3Ltd9NCiNxmG6y4lwGdtcyHVHMKOzPbEolL0YbDHOeYCzp rmSQRrAVoQoR6gyzPt6bkyta8z7MM1TSD/zY0E6mwVxRu2SAkiJT+mVsO9eZR2nALedb 9eXP+ZTg32KG4IQAO5gyfLNzjmsYnTkzeQ4OHcHl369YKNeWue20UGTDUswrAdRDFlgE O8DW820CU6GzdDGIsPQgzvmZYKq5yl1f9CeTJGdPKoQt7zfN1L6MLlB9+VcgDRZyE9tV Nt1ICA2ApOGQTaZhGcbsXqSDxNhq1mxJ9cNEL2b3W8DNXuHOANwSKq8JFxAyxk0aXWh7 jfYA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12-v6si2680158plt.723.2018.04.11.23.28.59; Wed, 11 Apr 2018 23:29:36 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752521AbeDLG0D (ORCPT + 99 others); Thu, 12 Apr 2018 02:26:03 -0400 Received: from verein.lst.de ([213.95.11.211]:53781 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751768AbeDLG0B (ORCPT ); Thu, 12 Apr 2018 02:26:01 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 8020F6FA92; Thu, 12 Apr 2018 08:26:00 +0200 (CEST) Date: Thu, 12 Apr 2018 08:26:00 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Sinan Kaya , amd-gfx@lists.freedesktop.org, timur@codeaurora.org, sulrich@codeaurora.org, Tom St Denis , "David (ChunMing) Zhou" , Emily Deng , David Airlie , linux-arm-msm@vger.kernel.org, Felix Kuehling , open list , "open list:DRM DRIVERS" , David Panariti , Jim Qu , Huang Rui , Roger He , Monk Liu , Feifei Xu , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, hch@lst.de Subject: Re: [PATCH V2] drm/amdgpu: limit DMA size to PAGE_SIZE for scatter-gather buffers Message-ID: <20180412062600.GB30499@lst.de> References: <1523394001-4615-1-git-send-email-okaya@codeaurora.org> <32b82296-bba5-b5f1-266b-45c1ed66da94@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32b82296-bba5-b5f1-266b-45c1ed66da94@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 11, 2018 at 01:03:59PM +0100, Robin Murphy wrote: > On 10/04/18 21:59, Sinan Kaya wrote: >> Code is expecing to observe the same number of buffers returned from >> dma_map_sg() function compared to sg_alloc_table_from_pages(). This >> doesn't hold true universally especially for systems with IOMMU. > > So why not fix said code? It's clearly not a real hardware limitation, and > the map_sg() APIs have potentially returned fewer than nents since forever, > so there's really no excuse. Yes, relying on dma_map_sg returning the same number of entries as passed it is completely bogus. >> IOMMU driver tries to combine buffers into a single DMA address as much >> as it can. The right thing is to tell the DMA layer how much combining >> IOMMU can do. > > Disagree; this is a dodgy hack, since you'll now end up passing > scatterlists into dma_map_sg() which already violate max_seg_size to begin > with, and I think a conscientious DMA API implementation would be at rights > to fail the mapping for that reason (I know arm64 happens not to, but that > was a deliberate design decision to make my life easier at the time). Agreed.