From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 985D3C3B18D for ; Thu, 13 Feb 2020 16:01:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 701922073C for ; Thu, 13 Feb 2020 16:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581609684; bh=HIJ84k4kruDMoI/Z6AJum0brp2NtCyYGH6otIn3QTHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SNf62qmtszDAdsqxDmQuYyhRW+FD8GP9vyAWpl/G8uIem694CdbjwRghnle6LT6j7 RSlhRcU4SbbL6HJvc0bapNd+2IpAwhgGvi0DaSYyT0DhE05dwdCgLseZnz/TgnuWa1 VUImB7Bo+L0QjtXQquuvqihmdXPlc+wER0ZyeqTo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730085AbgBMQBF (ORCPT ); Thu, 13 Feb 2020 11:01:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:38880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgBMPYn (ORCPT ); Thu, 13 Feb 2020 10:24:43 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF7F224691; Thu, 13 Feb 2020 15:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607482; bh=HIJ84k4kruDMoI/Z6AJum0brp2NtCyYGH6otIn3QTHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieZUgpfReWhTSBPNPW4Pvd1ePKguuxF0LXry915gZhpwE9oK0YMYlMoQoIxDIN76i klCk8tqUMxkIa1SJiHhQcmW2Hm3sRohg91QP1tCudJGLQ1zik9NGR6kA2Vocu5b9Wq z/2BdMob86SfPY7ldgckOPqFFi0HRTjOe1Er1PUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Hubbard , Christoph Hellwig , Hans Verkuil , Mauro Carvalho Chehab , Alex Williamson , "Aneesh Kumar K.V" , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Daniel Vetter , Dan Williams , Ira Weiny , Jan Kara , Jason Gunthorpe , Jason Gunthorpe , Jens Axboe , Jerome Glisse , Jonathan Corbet , "Kirill A. Shutemov" , Leon Romanovsky , Mike Rapoport , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 026/173] media/v4l2-core: set pages dirty upon releasing DMA buffers Date: Thu, 13 Feb 2020 07:18:49 -0800 Message-Id: <20200213151940.023133261@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151931.677980430@linuxfoundation.org> References: <20200213151931.677980430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: John Hubbard commit 3c7470b6f68434acae459482ab920d1e3fabd1c7 upstream. 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. Link: http://lkml.kernel.org/r/20200107224558.2362728-11-jhubbard@nvidia.com Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig Acked-by: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: Cc: Alex Williamson Cc: Aneesh Kumar K.V Cc: Björn Töpel Cc: Daniel Vetter Cc: Dan Williams Cc: Ira Weiny Cc: Jan Kara Cc: Jason Gunthorpe Cc: Jason Gunthorpe Cc: Jens Axboe Cc: Jerome Glisse Cc: Jonathan Corbet Cc: Kirill A. Shutemov Cc: Leon Romanovsky Cc: Mike Rapoport Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/videobuf-dma-sg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -352,8 +352,11 @@ int videobuf_dma_free(struct videobuf_dm BUG_ON(dma->sglen); if (dma->pages) { - for (i = 0; i < dma->nr_pages; i++) + for (i = 0; i < dma->nr_pages; i++) { + if (dma->direction == DMA_FROM_DEVICE) + set_page_dirty_lock(dma->pages[i]); put_page(dma->pages[i]); + } kfree(dma->pages); dma->pages = NULL; }