Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4615955pxj; Wed, 12 May 2021 09:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ6YJSWbcAGmA7AvJmc9ABgfyxV2qftQPyehjbKTqZeZR8ze3AD6WmSPGwdp72npj3IhQH X-Received: by 2002:a17:906:c211:: with SMTP id d17mr3429627ejz.247.1620836298429; Wed, 12 May 2021 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836298; cv=none; d=google.com; s=arc-20160816; b=djFtb1eCaFTG8CbVgpttMEUxe3nc2jJY40brRChkNmBOWJ2CIQqaKW3nlsO9OnAJkG uHbWpN5fuQYLAkD24XltVD/XL5fOajx49vZUly0BZ76J9St4kHY2n7VHLl6D+3LaZIQs rEeNW3LD99j1AnHHduOZ+KIR0qJ57nthWg9pwOeyYu976a/VQ/Xe+giAO3Ziesmub59O Qj7mG+onv0Bhebd9wixBMtjs0qGj8x7OG+BR2QTBhlupIp2qrlTdQB2OFaMs0g/DfKAi mK8nONhOoQzkA0GR0f1AW8HpvI+DB44u3AZ/mhFzPreTk4slJQuq7glLF4cDYMTGp+Ud QgHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kknwlkbxf7ZifsNI3qZ/vwece8bNM8FOFzSvIGeS6ww=; b=R5C785CsM28kN+RAmTSRZX/OBqmZpR1252n4wNxPAGw3wFbdVlm13JlbgArHflAAJK Q4paAJBdI7rZH2uauUil7iRUuDzUuQFU1SlIGYKy5xX1WYnKvZtfNoAOhnWGfXcMuCQt UZbDChpwsUgjoDUbx+pym1YZM8/jPoEPHd42VmaoLY8gO23hklyUujGkom8QUt2lGhh3 alzM83sCnOIO6xAZGlq1wblxq5yUIlxoUU8YaFeDQq4R2scjuBwz6PR0KLl5kWutey1C Jadumr1Cd2fYziE7GSyA4NqCF7Bvte2H6HBPvVa2H1ElHsI2z8pqF7U7gY5YZRMFBAWG ITkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AyHiP965; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cs15si323480ejc.258.2021.05.12.09.17.52; Wed, 12 May 2021 09:18:18 -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=@linuxfoundation.org header.s=korg header.b=AyHiP965; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237131AbhELQFb (ORCPT + 99 others); Wed, 12 May 2021 12:05:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235618AbhELP2k (ORCPT ); Wed, 12 May 2021 11:28:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 640516142E; Wed, 12 May 2021 15:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832456; bh=cJa+22vuue9E0aXPElJzH8UNA2uG5YSs+5Hdrw1UmEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AyHiP965iiSjb90omdqiy6AfYHTX1Z+5DD3GKkwDAPGhYzguZnfzMxdupRBiZs3/N yP84vGy8m6YWP7VbjCQ5RMa0FHba62IwDMv94IXlp3tw8M+zinBO/5gLDeUTVcZfF6 kkorfN+5WplTeO0DoWH1d3v7Gjbx0Fyem1LY+RAE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tasos Sahanidis , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 286/530] media: saa7146: use sg_dma_len when building pgtable Date: Wed, 12 May 2021 16:46:36 +0200 Message-Id: <20210512144829.209920174@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tasos Sahanidis [ Upstream commit e56429b09d5e0802b86f84ec7c24025886c9f88b ] The new AMD IOMMU DMA implementation concatenates sglist entries under certain conditions, and because saa7146 accessed the length member directly, it did not support this scenario. This fixes IO_PAGE_FAULTs by using the sg_dma_len macro. Fixes: be62dbf554c5 ("iommu/amd: Convert AMD iommu driver to the dma-iommu api") Signed-off-by: Tasos Sahanidis Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/common/saa7146/saa7146_core.c | 2 +- drivers/media/common/saa7146/saa7146_video.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c index 21fb16cc5ca1..e43edb0d76f4 100644 --- a/drivers/media/common/saa7146/saa7146_core.c +++ b/drivers/media/common/saa7146/saa7146_core.c @@ -253,7 +253,7 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt i, sg_dma_address(list), sg_dma_len(list), list->offset); */ - for (p = 0; p * 4096 < list->length; p++, ptr++) { + for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr++) { *ptr = cpu_to_le32(sg_dma_address(list) + p * 4096); nr_pages++; } diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index ccd15b4d4920..0d1be4042a40 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -247,9 +247,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu /* walk all pages, copy all page addresses to ptr1 */ for (i = 0; i < length; i++, list++) { - for (p = 0; p * 4096 < list->length; p++, ptr1++) { + for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr1++) *ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset); - } } /* ptr1 = pt1->cpu; -- 2.30.2