Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp699509ybv; Thu, 13 Feb 2020 08:00:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzrWyklMlV53zMn6CWWWx560p+romqbWzjj/jNzCO0B0jsYOydajLoV1jt4OsVGC8dcGaGo X-Received: by 2002:aca:1011:: with SMTP id 17mr3478993oiq.72.1581609602886; Thu, 13 Feb 2020 08:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581609602; cv=none; d=google.com; s=arc-20160816; b=D2IxXOI7mXD1Kivq60MJaEDBCzsuCbrL1fV7Rln/TjPBzCdbZLuHSPZ7o9Hk60SdK+ emMdLPN7ptfo9SIFSfX8hzgFjiZlYcxr7Op56u0qoSav2kiG9+618zAT4ovIoo+9Iy/U 7ZzCnfclzKVQmN+nMuZByyHsibYkhAFRrcIHqU5as6xE5pCp1ABsjx+gE1qslsWw60fI m7j2qpx3fYGkQxgMdJB5d+7rcGS9r4EE/Ko6u+JVaXyrGXBXgo/RDOGCsRhMmQ+MoWmh bLRIawvj4E9XJ6bd0MjrLxHltdUF56F/R0Wpd/kEWOf88mcO7LF66bFfojz/2TLXCy7M v+0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lbTzT9MYjwfKTww3SCHStyOtMHN35bmEat4S0vgh968=; b=zBhe+52XC9jgi7seJpHU4ovpGEARGmUhNKnr7Z8bPBBHo3Bm0ny8YDoyXkwjRoxb9P A9EaW4KPMaTo4ciT+stHcRoysjJ4QapSexNK4gjTDknbSj5pohdNpKURbzqLB/4fMiTh wrXqxPtHT6fkzRxiQZj8/MekEFx/xj2WgJw/7ksTryvtqMhsojgiXn9UwNDjcHPE0CLJ XEhbwkYFgzhsfeDfwFbgXv/w1p5ou10bH3dSHeuhu3OSfnOyBL2Vp1I+D1nLcQ7tMSA9 BWSQbFNrmkn78lJd9yHCmyHAff9kJ3ab3AWS7TSJiBgC9Pet3R8Polz7dalOv+5rtF/z 7cZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dVy/sI16"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si1328204otk.321.2020.02.13.07.59.49; Thu, 13 Feb 2020 08:00:02 -0800 (PST) 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=@kernel.org header.s=default header.b="dVy/sI16"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728156AbgBMPZD (ORCPT + 99 others); Thu, 13 Feb 2020 10:25:03 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; }