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 5ADD7C3B18C for ; Thu, 13 Feb 2020 16:06:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 318DF206ED for ; Thu, 13 Feb 2020 16:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581609992; bh=HIJ84k4kruDMoI/Z6AJum0brp2NtCyYGH6otIn3QTHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ykHHTEL5157O+AAxZmb+FWXS21ZdwqMNzab5mB3aQ3ZIhaHDqPxEGx2mc8pKKtzei oCpHrXC0gp5HLA7s/pW79q92Fjs2V/0M0fz0B5txj/22wOp55t1BvC2EFZBdFI5My0 Ma+3eEhpRPMnzg1sofatWlalhqaECL+loJ31uqjU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgBMPXh (ORCPT ); Thu, 13 Feb 2020 10:23:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:35080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728423AbgBMPXg (ORCPT ); Thu, 13 Feb 2020 10:23:36 -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 AA157246B5; Thu, 13 Feb 2020 15:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607415; bh=HIJ84k4kruDMoI/Z6AJum0brp2NtCyYGH6otIn3QTHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVy/sI16Yoa4B57w59LxTw1CAuWZ36h30QEW6Qyfdt+Zn1KUkuA6TjTzLKYniLGcV V0tkRTB5AV/0AAMW5B6TItc8jzmhJBRp4cfaix8s0yQCixe4mKMjaCUkIticUj9rGj eSXItSb5srktvqgMWNy2fMJMkFU15d21pUjOKS/M= 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.9 022/116] media/v4l2-core: set pages dirty upon releasing DMA buffers Date: Thu, 13 Feb 2020 07:19:26 -0800 Message-Id: <20200213151851.546420791@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151842.259660170@linuxfoundation.org> References: <20200213151842.259660170@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; }