From patchwork Mon Aug 17 16:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 256134 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 02BBEC433E4 for ; Mon, 17 Aug 2020 18:06:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA9FA20789 for ; Mon, 17 Aug 2020 18:06:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388484AbgHQQIz (ORCPT ); Mon, 17 Aug 2020 12:08:55 -0400 Received: from mga06.intel.com ([134.134.136.31]:20641 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388464AbgHQQIp (ORCPT ); Mon, 17 Aug 2020 12:08:45 -0400 IronPort-SDR: FTnNcr5/UCG3w7KyQ3KbKlVm+dLnlE5MwpxSrnJseRXn2pBmqlV8Z9wYTT4KqBCwqQ6NYZkrL6 UFrPybXOfZ3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="216264528" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="216264528" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:08:36 -0700 IronPort-SDR: VfStKSPlBwaXtG6S8SU21yUfMJ8N9IV4At10zyYjJ/8o2yLHYkWruVac9Dfj5tAmptyD827N65 79XEGeMYnHiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="496528929" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 17 Aug 2020 09:08:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7689B16D; Mon, 17 Aug 2020 19:08:33 +0300 (EEST) From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Mauro Carvalho Chehab Subject: [PATCH v2 01/10] media: ipu3-cio2: Simplify cleanup code Date: Mon, 17 Aug 2020 19:07:24 +0300 Message-Id: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The code looks more nicer if we use: while (i--) instead: for (i = i - 1; i >= 0; i--) This would also allow making 'i' unsigned again. Signed-off-by: Andy Shevchenko Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- v2: converted i to unsigned (Sakari) drivers/media/pci/intel/ipu3/ipu3-cio2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 92f5eadf2c99..cb74d49934f1 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -847,7 +847,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); struct sg_table *sg; struct sg_dma_page_iter sg_iter; - int i, j; + unsigned int i, j; if (lops <= 0 || lops > CIO2_MAX_LOPS) { dev_err(dev, "%s: bad buffer size (%i)\n", __func__, @@ -887,7 +887,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) b->lop[i][j] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; return 0; fail: - for (i--; i >= 0; i--) + while (i--) dma_free_coherent(dev, CIO2_PAGE_SIZE, b->lop[i], b->lop_bus_addr[i]); return -ENOMEM; From patchwork Mon Aug 17 16:07:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 256133 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 739D4C433E1 for ; Mon, 17 Aug 2020 18:06:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 646482072E for ; Mon, 17 Aug 2020 18:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390288AbgHQSG0 (ORCPT ); Mon, 17 Aug 2020 14:06:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:20289 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388305AbgHQQIw (ORCPT ); Mon, 17 Aug 2020 12:08:52 -0400 IronPort-SDR: vQ4pYZqyC6qokUzGGKS55rtmAtJqYfjF0ILFEAkaghbFJgqXFeL3v7XTM4wgIkydgazNoOd1K0 bLbOkqaBjdeA== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="219062287" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="219062287" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:08:42 -0700 IronPort-SDR: 42tdZwnhG2xZsTnZswr8Wf5gfNqUEm5A4YxV0i7NEfdDIzJw+ng1rEqj8doyUSgMwSbQ8j8dNz j3gJcmCEX43Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="336321298" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 17 Aug 2020 09:08:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 583D91A3; Mon, 17 Aug 2020 19:08:39 +0300 (EEST) From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Mauro Carvalho Chehab Subject: [PATCH v2 04/10] media: ipu3-cio2: Use macros from pfn.h Date: Mon, 17 Aug 2020 19:07:27 +0300 Message-Id: <20200817160734.12402-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> References: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There are few nice macros in pfn.h, some of which we may use here. Signed-off-by: Andy Shevchenko --- v2: no change drivers/media/pci/intel/ipu3/ipu3-cio2.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 0cb5461bfb1e..35bf05de5d5d 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -126,7 +127,7 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2) * Initialize each entry to dummy_page bus base address. */ for (i = 0; i < CIO2_LOP_ENTRIES; i++) - cio2->dummy_lop[i] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; + cio2->dummy_lop[i] = PFN_DOWN(cio2->dummy_page_bus_addr); return 0; } @@ -162,7 +163,7 @@ static void cio2_fbpt_entry_init_dummy(struct cio2_device *cio2, entry[1].second_entry.last_page_available_bytes = PAGE_SIZE - 1; for (i = 0; i < CIO2_MAX_LOPS; i++) - entry[i].lop_page_addr = cio2->dummy_lop_bus_addr >> PAGE_SHIFT; + entry[i].lop_page_addr = PFN_DOWN(cio2->dummy_lop_bus_addr); cio2_fbpt_entry_enable(cio2, entry); } @@ -179,8 +180,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, entry[0].first_entry.first_page_offset = b->offset; remaining = length + entry[0].first_entry.first_page_offset; - entry[1].second_entry.num_of_pages = - DIV_ROUND_UP(remaining, PAGE_SIZE); + entry[1].second_entry.num_of_pages = PFN_UP(remaining); /* * last_page_available_bytes has the offset of the last byte in the * last page which is still accessible by DMA. DMA cannot access @@ -196,7 +196,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, remaining = length; i = 0; while (remaining > 0) { - entry->lop_page_addr = b->lop_bus_addr[i] >> PAGE_SHIFT; + entry->lop_page_addr = PFN_DOWN(b->lop_bus_addr[i]); remaining -= CIO2_LOP_ENTRIES * PAGE_SIZE; entry++; i++; @@ -205,7 +205,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, /* * The first not meaningful FBPT entry should point to a valid LOP */ - entry->lop_page_addr = cio2->dummy_lop_bus_addr >> PAGE_SHIFT; + entry->lop_page_addr = PFN_DOWN(cio2->dummy_lop_bus_addr); cio2_fbpt_entry_enable(cio2, entry); } @@ -471,8 +471,7 @@ static int cio2_hw_init(struct cio2_device *cio2, struct cio2_queue *q) } /* Enable DMA */ - writel(q->fbpt_bus_addr >> PAGE_SHIFT, - base + CIO2_REG_CDMABA(CIO2_DMA_CHAN)); + writel(PFN_DOWN(q->fbpt_bus_addr), base + CIO2_REG_CDMABA(CIO2_DMA_CHAN)); writel(num_buffers1 << CIO2_CDMAC0_FBPT_LEN_SHIFT | FBPT_WIDTH << CIO2_CDMAC0_FBPT_WIDTH_SHIFT | @@ -837,7 +836,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) struct device *dev = &cio2->pci_dev->dev; struct cio2_buffer *b = container_of(vb, struct cio2_buffer, vbb.vb2_buf); - unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, PAGE_SIZE); + unsigned int pages = PFN_UP(vb->planes[0].length); unsigned int lops = DIV_ROUND_UP(pages + 1, CIO2_LOP_ENTRIES); struct sg_table *sg; struct sg_dma_page_iter sg_iter; @@ -870,7 +869,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) for_each_sg_dma_page (sg->sgl, &sg_iter, sg->nents, 0) { if (!pages--) break; - b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; + b->lop[i][j] = PFN_DOWN(sg_page_iter_dma_address(&sg_iter)); j++; if (j == CIO2_LOP_ENTRIES) { i++; @@ -878,7 +877,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) } } - b->lop[i][j] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; + b->lop[i][j] = PFN_DOWN(cio2->dummy_page_bus_addr); return 0; fail: while (i--) From patchwork Mon Aug 17 16:07:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 256136 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 D5C9CC433E1 for ; Mon, 17 Aug 2020 16:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A377020760 for ; Mon, 17 Aug 2020 16:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388487AbgHQQI6 (ORCPT ); Mon, 17 Aug 2020 12:08:58 -0400 Received: from mga11.intel.com ([192.55.52.93]:29629 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388468AbgHQQIv (ORCPT ); Mon, 17 Aug 2020 12:08:51 -0400 IronPort-SDR: RQWOS7Fe+xXNlG+2V2hr6eXXL4TENH+OdoAfnKa88dLEgChd8pEaABdpMooAowj19xuQWeqCd8 Z7Wx7hidIR6w== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152379910" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152379910" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:08:43 -0700 IronPort-SDR: YKVw3TvsPr5cnn6mHJ9P5BtgcvDNbPUrz3h9g+FUvRjfF2bD+fYVOfooMmkz/WkG5eYlxD6OFy ni/cU2IxsZqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="370610454" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 17 Aug 2020 09:08:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9FC921C5; Mon, 17 Aug 2020 19:08:40 +0300 (EEST) From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Mauro Carvalho Chehab Subject: [PATCH v2 05/10] media: ipu3-cio2: Replace infinite loop by one with clear exit condition Date: Mon, 17 Aug 2020 19:07:28 +0300 Message-Id: <20200817160734.12402-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> References: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Refactor cio2_buffer_done() to get rid of infinite loop by replacing it by one with clear exit condition. This change also allows to check for an error ahead. Signed-off-by: Andy Shevchenko --- v2: Dropped const (Bingbu) drivers/media/pci/intel/ipu3/ipu3-cio2.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 35bf05de5d5d..36b4c7730f43 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -540,7 +540,7 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) { struct device *dev = &cio2->pci_dev->dev; struct cio2_queue *q = cio2->cur_queue; - int buffers_found = 0; + struct cio2_fbpt_entry *entry; u64 ns = ktime_get_ns(); if (dma_chan >= CIO2_QUEUES) { @@ -548,15 +548,18 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) return; } + entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; + if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID) { + dev_warn(&cio2->pci_dev->dev, + "no ready buffers found on DMA channel %u\n", + dma_chan); + return; + } + /* Find out which buffer(s) are ready */ do { - struct cio2_fbpt_entry *const entry = - &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; struct cio2_buffer *b; - if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID) - break; - b = q->bufs[q->bufs_first]; if (b) { unsigned int bytes = entry[1].second_entry.num_of_bytes; @@ -578,13 +581,8 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) atomic_inc(&q->frame_sequence); cio2_fbpt_entry_init_dummy(cio2, entry); q->bufs_first = (q->bufs_first + 1) % CIO2_MAX_BUFFERS; - buffers_found++; - } while (1); - - if (buffers_found == 0) - dev_warn(&cio2->pci_dev->dev, - "no ready buffers found on DMA channel %u\n", - dma_chan); + entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; + } while (!(entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID)); } static void cio2_queue_event_sof(struct cio2_device *cio2, struct cio2_queue *q) From patchwork Mon Aug 17 16:07:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 256131 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 958DFC433E1 for ; Mon, 17 Aug 2020 18:07:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EDD62075B for ; Mon, 17 Aug 2020 18:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390331AbgHQSHO (ORCPT ); Mon, 17 Aug 2020 14:07:14 -0400 Received: from mga03.intel.com ([134.134.136.65]:8065 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388470AbgHQQIv (ORCPT ); Mon, 17 Aug 2020 12:08:51 -0400 IronPort-SDR: SXZJE9+WG1nsOycEVfw/BilqXEQI+Z2ZthMTtCXxOuHtOyPzu1rNR83tQhpI1eoa05cmUFwPov wu+TXZLoWPZQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="154715334" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="154715334" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:08:44 -0700 IronPort-SDR: Ekp55ySh+p3rDs/TcMHiY9E8weQ5rFqW1GcEuGJ/eh17mMD2s+zvK/Wj8OQhocofmwBiraRJ2R V5WoUjnYPPtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="277796305" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 17 Aug 2020 09:08:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E0437250; Mon, 17 Aug 2020 19:08:41 +0300 (EEST) From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Mauro Carvalho Chehab Subject: [PATCH v2 06/10] media: ipu3-cio2: Use readl_poll_timeout() helper Date: Mon, 17 Aug 2020 19:07:29 +0300 Message-Id: <20200817160734.12402-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> References: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We may use special helper macro to poll IO till condition or timeout occurs. Signed-off-by: Andy Shevchenko Reviewed-by: Laurent Pinchart --- v2: wrapped long line (Bingbu) drivers/media/pci/intel/ipu3/ipu3-cio2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 36b4c7730f43..7bcde3ba8f6e 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -507,8 +508,10 @@ static int cio2_hw_init(struct cio2_device *cio2, struct cio2_queue *q) static void cio2_hw_exit(struct cio2_device *cio2, struct cio2_queue *q) { - void __iomem *base = cio2->base; - unsigned int i, maxloops = 1000; + void __iomem *const base = cio2->base; + unsigned int i; + u32 value; + int ret; /* Disable CSI receiver and MIPI backend devices */ writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_MASK); @@ -518,13 +521,10 @@ static void cio2_hw_exit(struct cio2_device *cio2, struct cio2_queue *q) /* Halt DMA */ writel(0, base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN)); - do { - if (readl(base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN)) & - CIO2_CDMAC0_DMA_HALTED) - break; - usleep_range(1000, 2000); - } while (--maxloops); - if (!maxloops) + ret = readl_poll_timeout(base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN), + value, value & CIO2_CDMAC0_DMA_HALTED, + 4000, 2000000); + if (ret) dev_err(&cio2->pci_dev->dev, "DMA %i can not be halted\n", CIO2_DMA_CHAN); From patchwork Mon Aug 17 16:07:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 256132 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=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 E97C4C433DF for ; Mon, 17 Aug 2020 18:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D00A320758 for ; Mon, 17 Aug 2020 18:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390307AbgHQSGx (ORCPT ); Mon, 17 Aug 2020 14:06:53 -0400 Received: from mga11.intel.com ([192.55.52.93]:29636 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388476AbgHQQIv (ORCPT ); Mon, 17 Aug 2020 12:08:51 -0400 IronPort-SDR: B0J0vBbiDeK3/G6VhEXMlPGHx4isQafXRx8+ezDyNF/oMXogPEKyTdVvFTRICb+rAdsppqwR08 DSj0Vsnv0vDQ== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152379917" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152379917" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:08:49 -0700 IronPort-SDR: uP1F40sPgMc7skDAiP0uvjaKZLqGPdzFZfc40CYaSQlCd7Pk9mWGEIzWyvVt8RvQiQjtpO3Opz vdJexDlKFoOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="370610482" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 17 Aug 2020 09:08:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DEDAB1A3; Mon, 17 Aug 2020 19:08:46 +0300 (EEST) From: Andy Shevchenko To: linux-media@vger.kernel.org Cc: Andy Shevchenko , Yong Zhi , Sakari Ailus , Bingbu Cao , Tian Shu Qiu , Mauro Carvalho Chehab Subject: [PATCH v2 10/10] media: ipu3-cio2: Update Copyright year and fix indentation issues Date: Mon, 17 Aug 2020 19:07:33 +0300 Message-Id: <20200817160734.12402-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> References: <20200817160734.12402-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Update Copyright year to cover the previous changes and at the same time address indentation issues. Signed-off-by: Andy Shevchenko Acked-by: Laurent Pinchart --- v2: one more indentation fix drivers/media/pci/intel/ipu3/ipu3-cio2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index f3ec2d62cace..9a8c6e99d3ac 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2017 Intel Corporation + * Copyright (C) 2017,2020 Intel Corporation * * Based partially on Intel IPU4 driver written by * Sakari Ailus @@ -9,7 +9,6 @@ * Jouni Ukkonen * Antti Laakso * et al. - * */ #include @@ -292,7 +291,7 @@ static int cio2_csi2_calc_timing(struct cio2_device *cio2, struct cio2_queue *q, struct cio2_csi2_timing *timing) { struct device *dev = &cio2->pci_dev->dev; - struct v4l2_querymenu qm = {.id = V4L2_CID_LINK_FREQ, }; + struct v4l2_querymenu qm = { .id = V4L2_CID_LINK_FREQ }; struct v4l2_ctrl *link_freq; s64 freq; int r; @@ -864,7 +863,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) b->offset = sg->sgl->offset; i = j = 0; - for_each_sg_dma_page (sg->sgl, &sg_iter, sg->nents, 0) { + for_each_sg_dma_page(sg->sgl, &sg_iter, sg->nents, 0) { if (!pages--) break; b->lop[i][j] = PFN_DOWN(sg_page_iter_dma_address(&sg_iter));