Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp324759ybx; Wed, 30 Oct 2019 15:56:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVNdcLuyRRP2gyoF2cqK9buNGsHLQJ9fImC/1X4Pw1QTKPWh6OXZUp+ikSTtZs3HCxhyIY X-Received: by 2002:a17:906:3ec8:: with SMTP id d8mr775171ejj.40.1572476192349; Wed, 30 Oct 2019 15:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572476192; cv=none; d=google.com; s=arc-20160816; b=t5Mw6uhI5VJN2xKe2MFN4XFqeQnR+l9gsPdjIGW029F1Ihal39jvF+sfO1mvLOosOX Jk+jtJW4cBIRj4+lyKuK8xC6BqbN1ar6qDnXdHIWn7zis1bRr4qRUnK52a8NdLuCCRI3 x1+KerubhGnuW6ObXaF8FBw9MSkp8zgxv33ZvpxkEwZumPqNkcsmctBMJClu1faEcMIC VAFyJAVHDDcYQMCLL5x3M2m9uP6F4eLZwCnjeDxsR4VgHIIuisv4ct+nXXhxhdzfUv6G HnkGhxdyGjXdEXOwWJ7VPnN3rmrZw+d5EtMpnT1JHWqAssHVBxiAdUFD3yZTm8Phq2HM iqIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=XaBaipSsjoikJvkLH7RaOydN/WuSGfkJsZAiwvM/xPE=; b=ugW/x/YurFSqosEjpmyOp+XfkvmwxY7CADRzFxWdgoQh8mFTtDOkP+xcusS59umvQW 6pVBA0akTRCk3TDyZh1sLmvgchaJlIEwLyWBhTF7ho2Ug9r+T0W/EDCYUlGngUp2hBdw FZ1/XV5XaL3ib9ZtnztNjFN3bbA1PWSXVe4ThPK/a9NCUweQiwOnTGKISBiyyeA99akY 4wJ2fARivjGirCGrmTMjZGT8RxO6TQTBodxOlROdsgsIyyyTnHlvTIsi/XGbu7KS2jWd EwX+4wRHGQpwNH0F1Fro7+jxAL5RtvbmF/lqjcpmisUS40Qj3Dro0ZsBuSAadOTEQcey iLkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TDqU50c8; 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nr20si2147475ejb.387.2019.10.30.15.56.08; Wed, 30 Oct 2019 15:56:32 -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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TDqU50c8; 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727524AbfJ3Wtm (ORCPT + 99 others); Wed, 30 Oct 2019 18:49:42 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:10798 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727250AbfJ3Wtm (ORCPT ); Wed, 30 Oct 2019 18:49:42 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 30 Oct 2019 15:49:45 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 30 Oct 2019 15:49:39 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 30 Oct 2019 15:49:39 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 30 Oct 2019 22:49:39 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 30 Oct 2019 22:49:38 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 30 Oct 2019 15:49:38 -0700 From: John Hubbard To: Andrew Morton CC: Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jason Gunthorpe , Jens Axboe , Jonathan Corbet , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , , , , , , , , , , , , , LKML , John Hubbard Subject: [PATCH 04/19] media/v4l2-core: set pages dirty upon releasing DMA buffers Date: Wed, 30 Oct 2019 15:49:15 -0700 Message-ID: <20191030224930.3990755-5-jhubbard@nvidia.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191030224930.3990755-1-jhubbard@nvidia.com> References: <20191030224930.3990755-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1572475785; bh=XaBaipSsjoikJvkLH7RaOydN/WuSGfkJsZAiwvM/xPE=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=TDqU50c8TwyKmMgf/QDOTe3Vi1bVOitaLNonh0qiMoxrjojMp0wTfRux4Swk2FHl5 JJGYBcwT3ZevDeLVWf4S6QuZMQ0Lgc76irFx0ekQH8Fnv8kyfOshtxUwj3keS3tCY7 F5D1m4A2EQr/qED8mKHWtZbO0i+cEcxHpr70Q6RxWH8mk6sYhzR72caMlrH7U/2DJ9 cwN4vjQSS67t9JZPJ0DxjZGJhW0NmpX9Xjg5px4Z3HhCMFeEogkJ4W63rXbQ49reo0 Ta0Ru6XcEQojtc0AiLrAqhP/0gk5Gf5yaXkfGpmKAPqaQeMlSaBzLhwCOZG/jsUpVJ ChKFrWebViYAg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After DMA is complete, and the device and CPU caches are synchronized, it's still required to mark the CPU pages as dirty, if the data was coming from the device. However, this driver was just issuing a bare put_page() call, without any set_page_dirty*() call. Fix the problem, by calling set_page_dirty_lock() if the CPU pages were potentially receiving data from the device. Cc: Mauro Carvalho Chehab Signed-off-by: John Hubbard --- drivers/media/v4l2-core/videobuf-dma-sg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2= -core/videobuf-dma-sg.c index 66a6c6c236a7..28262190c3ab 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -349,8 +349,11 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) BUG_ON(dma->sglen); =20 if (dma->pages) { - for (i =3D 0; i < dma->nr_pages; i++) + for (i =3D 0; i < dma->nr_pages; i++) { + if (dma->direction =3D=3D DMA_FROM_DEVICE) + set_page_dirty_lock(dma->pages[i]); put_page(dma->pages[i]); + } kfree(dma->pages); dma->pages =3D NULL; } --=20 2.23.0