Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3710449ybv; Mon, 10 Feb 2020 05:07:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzczZ1Ge8hJoITQIY8X0fK/8X6p7hoyaoA0jDCSh5cYVqPWDbRylTaow//UR68iy1AfcxdB X-Received: by 2002:aca:f20b:: with SMTP id q11mr733816oih.78.1581340063733; Mon, 10 Feb 2020 05:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581340063; cv=none; d=google.com; s=arc-20160816; b=ALRNueJNLEYYaWBp3xlnFIM56mQ5AKzgWmY1SbiHEmpPYILIZ3rGkUB0YOYg3rv5DN N0Rw4ltNOGJhksNdw9lKW21HInWhA1hX59RLkIHtuNQUv0iHgH+jVH1ClT2nDbttulCg Pnfpi/4t6Od+9uOGGz3lNaPF8XuzXZwGcU0foaTlKJ817UQbvizjOrN4c+okHxYxiibB /Nyh2YRSDyeWf0xSwQdwZJ+HXnHIf1dDdV8aVeiAWRcx30PMEiZpHxCzBM1tuHRF/lpZ xGlnkeSayQChrJ+rLyMVt6OoyAcaeDmN72QscSOV7ZFsUdp7dLYz/KNAMxrl0EGxhs3r yE/Q== 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=ILpeTMHTsVPazKifSy1g9SShP337hZ6iiYJpBgpMIFk=; b=SsxE/1XIcDkfznFu+eS/c1n9CNXMJIDEbBKXJ2eJRF/DTxRjPi0dExMKEQSbzoJ7S0 6LT85HLn/d0Fs4TWzgXovuekGxfQpP/yygvF0si9vptJyjaD+64wLL3r4SEWSzcnnIki rGr6rCDFO/VCtF3BA3VpvCwwomGZO/8tx+kswVx+yf/JsBwU2iL7oaZc73XFvESMo9Bi ymdqtyUrnWVc+7LAhqXmchr/7nZ2fxCmEeCUScyp3phR7fztbm70ube0on0BJTLwtyF1 iKEx0gHotFk7J/ORcMs9Ax5LAbV+ae+fypeeHj9QApYmHwv0N+Sw+uRPP5UFlCFdPpgt pnhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=16WrHD5A; 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 d15si155366otl.82.2020.02.10.05.07.31; Mon, 10 Feb 2020 05:07:43 -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=16WrHD5A; 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 S1729952AbgBJNH3 (ORCPT + 99 others); Mon, 10 Feb 2020 08:07:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:38068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729490AbgBJMjm (ORCPT ); Mon, 10 Feb 2020 07:39:42 -0500 Received: from localhost (unknown [209.37.97.194]) (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 7A84820661; Mon, 10 Feb 2020 12:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338381; bh=A95hlQ6AVMm6kpXa44K/lEBxP2TWcW8AepWKW9AqfRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=16WrHD5ALC6Nyc6dQvTFoH0L3cYsy6915ItQ7uc6QCOXugznA3/ZKQ10Ko4Ar9nNJ p+AHuxNgFd4DS5mBbt5/lsTo/qxL5pkMXP+lEeJPbvtBprvhBXV9FSxaEzZAgMjX89 bK9+tDr7ThdVJD4PmhvsK449ZZaQhGAufz9IYypg= 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 5.5 061/367] media/v4l2-core: set pages dirty upon releasing DMA buffers Date: Mon, 10 Feb 2020 04:29:34 -0800 Message-Id: <20200210122429.708255637@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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 @@ -349,8 +349,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; }