Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3438827pxa; Tue, 25 Aug 2020 23:38:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyic1ybCypcxjZvrOf3qr/dCch1EsPMQ0saHL0YgeI1PERSrV6aoYEms+VqeBx67Gm1GiY8 X-Received: by 2002:a17:906:bb06:: with SMTP id jz6mr5109529ejb.275.1598423891272; Tue, 25 Aug 2020 23:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598423891; cv=none; d=google.com; s=arc-20160816; b=yVR4QTdAmU2c8lle+Mx6U8seVAObiHKEn28UhLx8N0v6WXKey8i+H5WMssoZykW5XH R7JyBPgmlLHbmZnWsOHZFKpAovUHsXf8xFphix3v0AJHpyiTh+hNoCv4tozTgDm2dU1n 1d/bVjdBySDBB2Rclk582crSoc6Jn8Hynk+8zdgCGruAU2+8nF2ba5IM8NjldEgMQ6mb bRBsmjAyRHEzdVbKCy4GaTXxNZ2DgPDzTpAsEG/RyDlxHzqOH/8t/ZJGUj3SGlILHlyH geXpceCOi+HCGocVhzZqVOQZynGGVpwyvVzUqWgBLAjfxSqHJl6UJjJIb2bnpCWkuxSs jtHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=kbdu9i1ky3V53J/j8HYin75jAIlE4fk1hTbkVYKJ63U=; b=rnJyclR7rLxSZeHnPs6G/fV6Qy4p8JU3AyCkFAY4OpqGxRHHIMMcV21prMcD5J4BUD 4QsA5GnLewvhDjWJpdK+c/PuWe0F6QpEnld13Q7vyI4D+8Weqk3JccfiDH7bvC/H2oCu 7fuJQtS/yNduQTkDp3gPEC3y53ZE4roL10CSUgFqH159MPe2ol/QblXrVtz0Hjnb6Cji MjjW0GwWacq+iv3sHqatmR635CMmq0ZcWlZ/iboUMKlXHP3DaFi5xXz4kHuG3Je9snau +/SYWENYTis9B1LgIsF5tO0a8hhj3wVWCdJF+h6EHBUnBIavqm0oiIcdOptsppnysIHU e+8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nGc3wybV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si1037474ejq.427.2020.08.25.23.37.46; Tue, 25 Aug 2020 23:38:11 -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=@samsung.com header.s=mail20170921 header.b=nGc3wybV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726128AbgHZGgo (ORCPT + 99 others); Wed, 26 Aug 2020 02:36:44 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39933 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbgHZGgc (ORCPT ); Wed, 26 Aug 2020 02:36:32 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200826063630euoutp0245efa18f31e20f066187c2e918201e2c~uvffdseYb1512715127euoutp023 for ; Wed, 26 Aug 2020 06:36:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200826063630euoutp0245efa18f31e20f066187c2e918201e2c~uvffdseYb1512715127euoutp023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1598423790; bh=kbdu9i1ky3V53J/j8HYin75jAIlE4fk1hTbkVYKJ63U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGc3wybVYMV5ZlFp86ZmA2JYYoNeCoOwaHUs/asIVUqhm0lFkgM7/1tA5+iVfQwN9 Tf6Gb1zIlpI4PbwBEspqEkhYub3N8T7rPzEzIgbVNz4ONA9uLiJ1+c/DggNXDamZ74 vwDVnyxsT4ZESoLqWMNuJ8xTOj00zVJDQtCgPau0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200826063629eucas1p17af18485cd101f2dbde76a07e3777e70~uvffKiKSZ1612416124eucas1p19; Wed, 26 Aug 2020 06:36:29 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 26.DD.05997.DE2064F5; Wed, 26 Aug 2020 07:36:29 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200826063629eucas1p1a3c9c93e281b4c432a6d9940e734e3c4~uvferOOJK1612416124eucas1p18; Wed, 26 Aug 2020 06:36:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200826063629eusmtrp2b4efaa81707a94d9995acc3a8a6bc40b~uvfeqaKXz0466204662eusmtrp2e; Wed, 26 Aug 2020 06:36:29 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-61-5f4602ed2f4f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D4.F0.06314.DE2064F5; Wed, 26 Aug 2020 07:36:29 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200826063545eusmtip2c8c042b88f2793200ec3eeb737bb4947~uve2bH14Z0302303023eusmtip23; Wed, 26 Aug 2020 06:35:45 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Christoph Hellwig , Robin Murphy , Bartlomiej Zolnierkiewicz , linux-arm-kernel@lists.infradead.org, David Airlie , Daniel Vetter , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH v9 31/32] media: pci: fix common ALSA DMA-mapping related codes Date: Wed, 26 Aug 2020 08:33:15 +0200 Message-Id: <20200826063316.23486-32-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826063316.23486-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSfSxVYRzuPeeec4+Py3EpbxjrtrTaIqntLGVp1PmnLVurVaRbzpDr6x5X UZs70rg+umpFZtxhlO8urnw0H4ubyc0waVh0rYaMRlTsynHQf8/v+Xif3357CVTciDkQYZGx jDxSKpPg5gJd9x/DkTnkXNDRZ8kHqUxDD0K9zq3BqHVdNkoN/ZrHqVcVXQilafOiloYmEUpr HMaoweZ8nMqobcCoqnfjQqpUu4ZQHQtT2BkRXVlQCei3yxoBrS1Pw+nG5QmM/pKuR+i6kkR6 1GRE6acjZYBu+azE6az6ckAvap0vWlwzPxXMyMLiGLm7903z0G85TVj0jz33GmZNqBJM26qA GQHJ41CpH8JVwJwQky8BXF6tEvDDEoClq/lbyiKA+t8v8O3IQOs6wgtlAFa31YGdSGqGDuFc OOkBVXOqzYQdmQLg+0xLzoSSRgRqaoY3BVvSH84PfAQcFpAHoCGlXqgCBCEiveHDoli+zQVW 1LajHDbboPXpjzdXgmS3EK5MtWO8yRcWlCRtrWcLZ/TcOxx2gutNhQgfSAZw0lAl5IcMAAeT cgHv8oJjhr8414ySh2BNsztP+8D2pUKUoyFpBUfmb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7RA4GCMkkJ5YkpqdmlqQWgTTx8TBKdXAyCuRkxr7+nLGsulVa0Wd eV8GF1oqWc297hDKNGfCf8M456OBWSqNB6KWyehcli/IYzkpUPq3XeDaxN+sD1TSuotrr8bM 4fjM9e7yisCmkKXZHFfLD+6bHHd7ezGv4my7WU9+9il1Oa1sjL/9cppaLlenuvfe0CmbRbh7 7DKUNX/YLr/+fW+lEktxRqKhFnNRcSIAu19n2aoCAAA= X-CMS-MailID: 20200826063629eucas1p1a3c9c93e281b4c432a6d9940e734e3c4 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200826063629eucas1p1a3c9c93e281b4c432a6d9940e734e3c4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200826063629eucas1p1a3c9c93e281b4c432a6d9940e734e3c4 References: <20200826063316.23486-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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; } -- 2.17.1