From patchwork Tue Aug 29 11:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 9927169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30C0A60383 for ; Tue, 29 Aug 2017 11:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A6F6288BB for ; Tue, 29 Aug 2017 11:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F353B288BD; Tue, 29 Aug 2017 11:26:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3556288BC for ; Tue, 29 Aug 2017 11:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337AbdH2L0W (ORCPT ); Tue, 29 Aug 2017 07:26:22 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34929 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbdH2L0T (ORCPT ); Tue, 29 Aug 2017 07:26:19 -0400 Received: by mail-wm0-f48.google.com with SMTP id y71so18865413wmd.0 for ; Tue, 29 Aug 2017 04:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=YeIBXx8jd/bq7PZcrGv26ygDX7zXGpqUTXj2BcdbV8E=; b=RwrPVnYnevK72lleFBsXlX1jmx4VV2yj+L0Ipcyw1/0pIA+jQqf/o4GeRLanVr7PMF 0X9bNUyhN4sWSsaBl8m4YwLukPFM5tRGqfWrdskBn+3eFYtLXrJlifXphpbgKuq/alrU Om1xNtO1W/4VYerO2iYReN5OCIPJXPPZMbpRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YeIBXx8jd/bq7PZcrGv26ygDX7zXGpqUTXj2BcdbV8E=; b=CQ04WICbPy4f5Y4wt+5pzGxG6Lzhgggus3vP4/rmhasamSwI7PGqZacCPOAB01zWNT jSb5V6yYmawWTJkx4qzOah6v7SGDkCX5frckY7w0DCBDsBTEhigbauCEfYRx63lclceY LHIqYdAgehgyCUHO/1fshXVZK4vC2R+QDN3VOCw6syGuLcymzBMR7vCEp1VtWU1puWhH 4UdNNWHoBsfieNM/wwCq47nf2S1yYpjidU9SaTY/vAuNJaOhymdkvJ7veM1q08pKgxwv GoPOiEhzp19M49hQRBr6CwMa3v8Fdmj5QHWdoQMuiar5DaByRMsic72BAOvbWAT7Lg3j WhsQ== X-Gm-Message-State: AHYfb5hGBytrROKyOJKlUw6nwlnRiLY+TVGrUfkZ31DmvMbmmVzwgXoX NuB2lkWCJcgzUPEp X-Received: by 10.28.28.75 with SMTP id c72mr1254590wmc.176.1504005977725; Tue, 29 Aug 2017 04:26:17 -0700 (PDT) Received: from localhost.localdomain ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id n13sm2252007wmg.2.2017.08.29.04.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 04:26:17 -0700 (PDT) From: Stanimir Varbanov To: Mauro Carvalho Chehab Cc: Pawel Osciak , Marek Szyprowski , Kyungmin Park , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Stanimir Varbanov Subject: [PATCH] media: vb2: unify calling of set_page_dirty_lock Date: Tue, 29 Aug 2017 14:26:03 +0300 Message-Id: <20170829112603.32732-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently videobuf2-dma-sg checks for dma direction for every single page and videobuf2-dc lacks any dma direction checks and calls set_page_dirty_lock unconditionally. Thus unify and align the invocations of set_page_dirty_lock for videobuf2-dc, videobuf2-sg memory allocators with videobuf2-vmalloc, i.e. the pattern used in vmalloc has been copied to dc and dma-sg. Suggested-by: Marek Szyprowski Signed-off-by: Stanimir Varbanov Acked-by: Marek Szyprowski Acked-by: Sakari Ailus --- drivers/media/v4l2-core/videobuf2-dma-contig.c | 6 ++++-- drivers/media/v4l2-core/videobuf2-dma-sg.c | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 9f389f36566d..696e24f9128d 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -434,8 +434,10 @@ static void vb2_dc_put_userptr(void *buf_priv) pages = frame_vector_pages(buf->vec); /* sgt should exist only if vector contains pages... */ BUG_ON(IS_ERR(pages)); - for (i = 0; i < frame_vector_count(buf->vec); i++) - set_page_dirty_lock(pages[i]); + if (buf->dma_dir == DMA_FROM_DEVICE || + buf->dma_dir == DMA_BIDIRECTIONAL) + for (i = 0; i < frame_vector_count(buf->vec); i++) + set_page_dirty_lock(pages[i]); sg_free_table(sgt); kfree(sgt); } diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 6808231a6bdc..753ed3138dcc 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -292,11 +292,10 @@ static void vb2_dma_sg_put_userptr(void *buf_priv) if (buf->vaddr) vm_unmap_ram(buf->vaddr, buf->num_pages); sg_free_table(buf->dma_sgt); - while (--i >= 0) { - if (buf->dma_dir == DMA_FROM_DEVICE || - buf->dma_dir == DMA_BIDIRECTIONAL) + if (buf->dma_dir == DMA_FROM_DEVICE || + buf->dma_dir == DMA_BIDIRECTIONAL) + while (--i >= 0) set_page_dirty_lock(buf->pages[i]); - } vb2_destroy_framevec(buf->vec); kfree(buf); }