From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Yong Zhi <yong.zhi@intel.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Bingbu Cao <bingbu.cao@intel.com>,
Tian Shu Qiu <tian.shu.qiu@intel.com>,
linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 3/7] media: ipu2-cio2: Replace custom definition with PAGE_SIZE
Date: Fri, 14 Aug 2020 19:30:13 +0300 [thread overview]
Message-ID: <20200814163017.35001-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200814163017.35001-1-andriy.shevchenko@linux.intel.com>
It's quite unlikely the other page size will be supported, but in any case
there is still an inconsistency between custom page size definition and
generic macros used in the driver.
Switch over to generic PAGE_SIZE for sake of the consistency.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 29 +++++++++++-------------
drivers/media/pci/intel/ipu3/ipu3-cio2.h | 1 -
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 79641c79df25..2b3a865fa2da 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -96,12 +96,12 @@ static inline u32 cio2_bytesperline(const unsigned int width)
static void cio2_fbpt_exit_dummy(struct cio2_device *cio2)
{
if (cio2->dummy_lop) {
- dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE,
+ dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE,
cio2->dummy_lop, cio2->dummy_lop_bus_addr);
cio2->dummy_lop = NULL;
}
if (cio2->dummy_page) {
- dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE,
+ dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE,
cio2->dummy_page, cio2->dummy_page_bus_addr);
cio2->dummy_page = NULL;
}
@@ -111,12 +111,10 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2)
{
unsigned int i;
- cio2->dummy_page = dma_alloc_coherent(&cio2->pci_dev->dev,
- CIO2_PAGE_SIZE,
+ cio2->dummy_page = dma_alloc_coherent(&cio2->pci_dev->dev, PAGE_SIZE,
&cio2->dummy_page_bus_addr,
GFP_KERNEL);
- cio2->dummy_lop = dma_alloc_coherent(&cio2->pci_dev->dev,
- CIO2_PAGE_SIZE,
+ cio2->dummy_lop = dma_alloc_coherent(&cio2->pci_dev->dev, PAGE_SIZE,
&cio2->dummy_lop_bus_addr,
GFP_KERNEL);
if (!cio2->dummy_page || !cio2->dummy_lop) {
@@ -161,7 +159,7 @@ static void cio2_fbpt_entry_init_dummy(struct cio2_device *cio2,
entry[0].first_entry.first_page_offset = 0;
entry[1].second_entry.num_of_pages = CIO2_MAX_ENTRIES * CIO2_MAX_LOPS;
- entry[1].second_entry.last_page_available_bytes = CIO2_PAGE_SIZE - 1;
+ 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;
@@ -182,25 +180,25 @@ 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, CIO2_PAGE_SIZE);
+ DIV_ROUND_UP(remaining, PAGE_SIZE);
/*
* last_page_available_bytes has the offset of the last byte in the
* last page which is still accessible by DMA. DMA cannot access
* beyond this point. Valid range for this is from 0 to 4095.
* 0 indicates 1st byte in the page is DMA accessible.
- * 4095 (CIO2_PAGE_SIZE - 1) means every single byte in the last page
+ * 4095 (PAGE_SIZE - 1) means every single byte in the last page
* is available for DMA transfer.
*/
entry[1].second_entry.last_page_available_bytes =
(remaining & ~PAGE_MASK) ?
(remaining & ~PAGE_MASK) - 1 :
- CIO2_PAGE_SIZE - 1;
+ PAGE_SIZE - 1;
/* Fill FBPT */
remaining = length;
i = 0;
while (remaining > 0) {
entry->lop_page_addr = b->lop_bus_addr[i] >> PAGE_SHIFT;
- remaining -= CIO2_MAX_ENTRIES * CIO2_PAGE_SIZE;
+ remaining -= CIO2_MAX_ENTRIES * PAGE_SIZE;
entry++;
i++;
}
@@ -840,7 +838,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, CIO2_PAGE_SIZE);
+ unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, PAGE_SIZE);
unsigned int lops = DIV_ROUND_UP(pages + 1, CIO2_MAX_ENTRIES);
struct sg_table *sg;
struct sg_dma_page_iter sg_iter;
@@ -855,7 +853,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb)
memset(b->lop, 0, sizeof(b->lop));
/* Allocate LOP table */
for (i = 0; i < lops; i++) {
- b->lop[i] = dma_alloc_coherent(dev, CIO2_PAGE_SIZE,
+ b->lop[i] = dma_alloc_coherent(dev, PAGE_SIZE,
&b->lop_bus_addr[i], GFP_KERNEL);
if (!b->lop[i])
goto fail;
@@ -885,8 +883,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb)
return 0;
fail:
while (i--)
- dma_free_coherent(dev, CIO2_PAGE_SIZE,
- b->lop[i], b->lop_bus_addr[i]);
+ dma_free_coherent(dev, PAGE_SIZE, b->lop[i], b->lop_bus_addr[i]);
return -ENOMEM;
}
@@ -976,7 +973,7 @@ static void cio2_vb2_buf_cleanup(struct vb2_buffer *vb)
/* Free LOP table */
for (i = 0; i < CIO2_MAX_LOPS; i++) {
if (b->lop[i])
- dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE,
+ dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE,
b->lop[i], b->lop_bus_addr[i]);
}
}
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
index 6ee5919d913b..48da6f7eb218 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h
@@ -392,7 +392,6 @@ struct cio2_device {
sizeof(struct cio2_fbpt_entry))
#define CIO2_FBPT_SUBENTRY_UNIT 4
-#define CIO2_PAGE_SIZE 4096
/* cio2 fbpt first_entry ctrl status */
#define CIO2_FBPT_CTRL_VALID BIT(0)
--
2.28.0
next prev parent reply other threads:[~2020-08-14 16:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 16:30 [PATCH v1 1/7] media: ipu3-cio2: Simplify cleanup code Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 2/7] media: ipu3-cio2: Introduce CIO2_MAX_ENTRIES constant Andy Shevchenko
2020-08-14 20:18 ` Sakari Ailus
2020-08-17 11:46 ` Andy Shevchenko
2020-08-14 16:30 ` Andy Shevchenko [this message]
2020-08-14 16:30 ` [PATCH v1 4/7] media: ipu3-cio2: Use macros from pfn.h Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 5/7] media: ipu3-cio2: Replace infinite loop by one with clear exit condition Andy Shevchenko
2020-08-17 10:21 ` Bingbu Cao
2020-08-17 11:47 ` Andy Shevchenko
2020-08-14 16:30 ` [PATCH v1 6/7] media: ipu3-cio2: Use readl_poll_timeout() helper Andy Shevchenko
2020-08-17 9:27 ` Bingbu Cao
2020-08-17 9:44 ` Andy Shevchenko
2020-08-17 11:13 ` Sakari Ailus
2020-08-17 11:20 ` Andy Shevchenko
2020-08-17 11:27 ` Sakari Ailus
2020-08-17 11:33 ` Andy Shevchenko
2020-08-17 11:55 ` Sakari Ailus
2020-08-17 12:29 ` Andy Shevchenko
2020-08-17 12:44 ` Sakari Ailus
2020-08-14 16:30 ` [PATCH v1 7/7] media: ipu3-cio2: Update Copyright year and fix indentation issues Andy Shevchenko
2020-08-14 20:16 ` [PATCH v1 1/7] media: ipu3-cio2: Simplify cleanup code Sakari Ailus
2020-08-17 14:37 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200814163017.35001-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bingbu.cao@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tian.shu.qiu@intel.com \
--cc=yong.zhi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).