Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10107841ybi; Wed, 24 Jul 2019 16:10:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqze55zgAC7NR3rbB2vnrBGIMH+Q/sR1/HzED123LiatZEQXc25vA5qpapJBDALy/IyA73+5 X-Received: by 2002:a17:902:1486:: with SMTP id k6mr86674340pla.177.1564009844588; Wed, 24 Jul 2019 16:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564009844; cv=none; d=google.com; s=arc-20160816; b=JIUZYBC6bt388HVp4YQIygW69eOCljh42Nn4+VH9w7EAakyi0MyYWybdy3V/mjg47z WRq60jqj6y6ZPBiOdCNx9a6L6d+VltLE2Y+RdBxbifp53M6ssIgh5AufMM/dpw8bK51R jGX4hashuw0KHi8iwIlkE8Jso9bU07eS04drLKkTQh2hrv0QHly14/oZu2a7NurylN6z 7hSlFZuVUQiGIzGOAmTFgXuWHdRF5jlWuuCr4ePY5UZhT5mE1oWjkrAZVmvBxUBMev+g sY9cc0Pg6V2HJZnQtRd+3F8GIpPqdja0DbzBjevpF+m+ugrm3AEUxI1CkLHlvziI5bbl AE0g== 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=vDX37YPNnDUXIcMyxQLrgdGh0/kgT+bIRvHDwnhL75g=; b=ZwQjCmspGBUBXliF9HFVrZs7zPImjlQUvwJy8HXt90FFwvVkmlrsdcU5puVoVmoASR awjSkGf5a50S0z8iNf0ZC4FPeW9czeL9akqV3cWjIozY3WlCilf5bxI6PaOqh754X2MV zfuwyGX50Bwx7L5yIRzPp5wvRPnGRSSOGpVrbOlPDo02ztAh+tX4/1CA5Hux6rscEBUE wx/yxnePnJD2jR8p0PKjVv1ekr3U7QNI9vMbuIPRzpm9UYgGYRgbvoQNyWQY5KFBncDO Nwli7bNHl1TE5C4quJGlWueekaVIowd3oiEkWF6z9Pzx6vbSiOqctreS2Ca1/dnO1kUo Y3Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=slhi2l3w; 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 68si14846051plc.269.2019.07.24.16.10.18; Wed, 24 Jul 2019 16:10:44 -0700 (PDT) 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=slhi2l3w; 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 S2387881AbfGXTXx (ORCPT + 99 others); Wed, 24 Jul 2019 15:23:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:39554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387846AbfGXTXn (ORCPT ); Wed, 24 Jul 2019 15:23:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 24D44218F0; Wed, 24 Jul 2019 19:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996222; bh=yzQR5qFdRmj/ohGCBqlXS4151JYe9WbzTKvOIg/rLbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slhi2l3ww8Yz0nUf4Ae6CEljlxPLFp9125Tf+KyFulMonciK8xLY2k9n1FPwf6lsQ QJgFP5I7j0vX8Z18duXHPHSPDGfS4EEzGBUwWYoOEU3s0+4q0rgJkJUzswUUtuzxCJ s8Em2rAENHeUdSKZUO8IA6NnH0Q3UnK4F0EZDfGY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lubomir Rintel , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.2 022/413] media: marvell-ccic: fix DMA s/g desc number calculation Date: Wed, 24 Jul 2019 21:15:13 +0200 Message-Id: <20190724191737.034896722@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 [ Upstream commit 0c7aa32966dab0b8a7424e1b34c7f206817953ec ] The commit d790b7eda953 ("[media] vb2-dma-sg: move dma_(un)map_sg here") left dma_desc_nent unset. It previously contained the number of DMA descriptors as returned from dma_map_sg(). We can now (since the commit referred to above) obtain the same value from the sg_table and drop dma_desc_nent altogether. Tested on OLPC XO-1.75 machine. Doesn't affect the OLPC XO-1's Cafe driver, since that one doesn't do DMA. [mchehab+samsung@kernel.org: fix a checkpatch warning] Fixes: d790b7eda953 ("[media] vb2-dma-sg: move dma_(un)map_sg here") Signed-off-by: Lubomir Rintel Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/marvell-ccic/mcam-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index f1b301810260..0a6411b877e9 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -200,7 +200,6 @@ struct mcam_vb_buffer { struct list_head queue; struct mcam_dma_desc *dma_desc; /* Descriptor virtual address */ dma_addr_t dma_desc_pa; /* Descriptor physical address */ - int dma_desc_nent; /* Number of mapped descriptors */ }; static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_v4l2_buffer *vb) @@ -608,9 +607,11 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame) static void mcam_sg_next_buffer(struct mcam_camera *cam) { struct mcam_vb_buffer *buf; + struct sg_table *sg_table; buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue); list_del_init(&buf->queue); + sg_table = vb2_dma_sg_plane_desc(&buf->vb_buf.vb2_buf, 0); /* * Very Bad Not Good Things happen if you don't clear * C1_DESC_ENA before making any descriptor changes. @@ -618,7 +619,7 @@ static void mcam_sg_next_buffer(struct mcam_camera *cam) mcam_reg_clear_bit(cam, REG_CTRL1, C1_DESC_ENA); mcam_reg_write(cam, REG_DMA_DESC_Y, buf->dma_desc_pa); mcam_reg_write(cam, REG_DESC_LEN_Y, - buf->dma_desc_nent*sizeof(struct mcam_dma_desc)); + sg_table->nents * sizeof(struct mcam_dma_desc)); mcam_reg_write(cam, REG_DESC_LEN_U, 0); mcam_reg_write(cam, REG_DESC_LEN_V, 0); mcam_reg_set_bit(cam, REG_CTRL1, C1_DESC_ENA); -- 2.20.1