Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2016644pxk; Tue, 1 Sep 2020 13:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHdHaxAxe08E779V1mksyqm0MHbjDkZT9lZyfkEib6mAM4j2hbUUEMI0Ua5tRUl1bhITOf X-Received: by 2002:a17:906:69c1:: with SMTP id g1mr3140481ejs.285.1598992197611; Tue, 01 Sep 2020 13:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598992197; cv=none; d=google.com; s=arc-20160816; b=AzHwTtdyi17ncUrVN0jKxA9pjfOnJZ1lWlZpbUWM62t2TYcCOaTKhYuoEi6EvP7h5W 3O6iGlVNI97Y9dvEiz5J7fLhKUxtPCgQdnr/X9vbxarBqWosXAwoflgB9dkgiYZ//ZS9 SCFgj4VamT/UFup50KWRetXCv1txb1G3oU5UgOE1MbIUGNFxHmcY1mhe6gaubjtxb0q4 +zcJQB2zMP3dzgsxx61GuZ1uq+Kvemeic6goYyTNi8RvZ0CTIANhFeLsLfyZu+Jw69DT HEkec8D5uB6qherXG0CTJQW8jTw7lWlSbTOWokOnL+w07lU+qB+Knrkbq29ToSuTCNap 7gyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=VaPOZRXOm7goebYpJkVpj1T5AyFlejtxVF9MOuvA224=; b=nygGhxsr2wPU4YqJk/NFM5xjy2FIsExBKkO5hnDr+fHA3Uc8iLwuA09JshhDrTx3eR vK1Yf9V9I2gjMIL5iosd7tOItdmbEOVf8v+fd0J9HsaSuG+8M0wzOm9R5z9He9KX//36 NmDkm3QS8izYNCaRTfyU8HUOn43b0tJOXtzAQzqg9cxBLxjqpEFlxyX2U4fyDl+yrrJI 28eI4Ru8/P3Hbpku0T/02rjMU4tmatvlEOP+16HDcMFCr4ScLKzQOrDwESiyz6Stwg/t wmlxq1mWRd4hx/hrHIh5TWmhOCmXceVyFXa6k1ZLhgpRTt9xiCNbZfkrYIP5ocTL2MC3 e66w== 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 lz20si1314359ejb.179.2020.09.01.13.29.08; Tue, 01 Sep 2020 13:29:57 -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 S1728064AbgIAUYu (ORCPT + 99 others); Tue, 1 Sep 2020 16:24:50 -0400 Received: from foss.arm.com ([217.140.110.172]:49856 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbgIAUYt (ORCPT ); Tue, 1 Sep 2020 16:24:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3BAF91063; Tue, 1 Sep 2020 13:24:49 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C94E3F66F; Tue, 1 Sep 2020 13:24:47 -0700 (PDT) Subject: Re: [PATCH v9 31/32] media: pci: fix common ALSA DMA-mapping related codes To: Marek Szyprowski , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Bartlomiej Zolnierkiewicz , linux-arm-kernel@lists.infradead.org, David Airlie , Daniel Vetter , Mauro Carvalho Chehab , linux-media@vger.kernel.org References: <20200826063316.23486-1-m.szyprowski@samsung.com> <20200826063316.23486-32-m.szyprowski@samsung.com> From: Robin Murphy Message-ID: <925232f3-7371-c7eb-ad31-4b041cbbca4f@arm.com> Date: Tue, 1 Sep 2020 21:24:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200826063316.23486-32-m.szyprowski@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-26 07:33, Marek Szyprowski wrote: > The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the > numer of the created entries in the DMA address space. However the > subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be > called with the original number of entries passed to dma_map_sg. The > sg_table->nents in turn holds the result of the dma_map_sg call as stated > in include/linux/scatterlist.h. Adapt the code to obey those rules. > > Signed-off-by: Marek Szyprowski > --- > drivers/media/pci/cx23885/cx23885-alsa.c | 2 +- > drivers/media/pci/cx25821/cx25821-alsa.c | 2 +- > drivers/media/pci/cx88/cx88-alsa.c | 2 +- > drivers/media/pci/saa7134/saa7134-alsa.c | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c > index df44ed7393a0..3f366e4e4685 100644 > --- a/drivers/media/pci/cx23885/cx23885-alsa.c > +++ b/drivers/media/pci/cx23885/cx23885-alsa.c > @@ -129,7 +129,7 @@ static int cx23885_alsa_dma_unmap(struct cx23885_audio_dev *dev) > if (!buf->sglen) > return 0; > > - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); > + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, PCI_DMA_FROMDEVICE); If we're touching these lines anyway, we should update them to use the modern DMA_FROM_DEVICE definitions too. Robin. > buf->sglen = 0; > return 0; > } > diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c > index 301616426d8a..c40304d33776 100644 > --- a/drivers/media/pci/cx25821/cx25821-alsa.c > +++ b/drivers/media/pci/cx25821/cx25821-alsa.c > @@ -193,7 +193,7 @@ static int cx25821_alsa_dma_unmap(struct cx25821_audio_dev *dev) > if (!buf->sglen) > return 0; > > - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); > + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, PCI_DMA_FROMDEVICE); > buf->sglen = 0; > return 0; > } > diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c > index 7d7aceecc985..3c6fe6ceb0b7 100644 > --- a/drivers/media/pci/cx88/cx88-alsa.c > +++ b/drivers/media/pci/cx88/cx88-alsa.c > @@ -332,7 +332,7 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev) > if (!buf->sglen) > return 0; > > - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, > + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, > PCI_DMA_FROMDEVICE); > buf->sglen = 0; > return 0; > diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c > index 544ca57eee75..398c47ff473d 100644 > --- a/drivers/media/pci/saa7134/saa7134-alsa.c > +++ b/drivers/media/pci/saa7134/saa7134-alsa.c > @@ -313,7 +313,7 @@ static int saa7134_alsa_dma_unmap(struct saa7134_dev *dev) > if (!dma->sglen) > return 0; > > - dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->sglen, PCI_DMA_FROMDEVICE); > + dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->nr_pages, PCI_DMA_FROMDEVICE); > dma->sglen = 0; > return 0; > } >