Message ID | 20200817160734.12402-2-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,01/10] media: ipu3-cio2: Simplify cleanup code | expand |
Hi Andy, Thank you for the patch. On Mon, Aug 17, 2020 at 07:07:25PM +0300, Andy Shevchenko wrote: > This constant is used in several places in the code, define it > for better maintenance. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > v2: renamed CIO2_MAX_ENTRIES -> CIO2_LOP_ENTRIES (Sakari) > drivers/media/pci/intel/ipu3/ipu3-cio2.c | 13 +++++-------- > drivers/media/pci/intel/ipu3/ipu3-cio2.h | 3 +++ > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > index cb74d49934f1..a89cb3c7e0dc 100644 > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > @@ -127,7 +127,7 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2) > * List of Pointers(LOP) contains 1024x32b pointers to 4KB page each > * Initialize each entry to dummy_page bus base address. > */ > - for (i = 0; i < CIO2_PAGE_SIZE / sizeof(*cio2->dummy_lop); i++) > + for (i = 0; i < CIO2_LOP_ENTRIES; i++) > cio2->dummy_lop[i] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; > > return 0; > @@ -160,8 +160,7 @@ static void cio2_fbpt_entry_init_dummy(struct cio2_device *cio2, > unsigned int i; > > entry[0].first_entry.first_page_offset = 0; > - entry[1].second_entry.num_of_pages = > - CIO2_PAGE_SIZE / sizeof(u32) * CIO2_MAX_LOPS; > + entry[1].second_entry.num_of_pages = CIO2_LOP_ENTRIES * CIO2_MAX_LOPS; > entry[1].second_entry.last_page_available_bytes = CIO2_PAGE_SIZE - 1; > > for (i = 0; i < CIO2_MAX_LOPS; i++) > @@ -201,7 +200,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, > i = 0; > while (remaining > 0) { > entry->lop_page_addr = b->lop_bus_addr[i] >> PAGE_SHIFT; > - remaining -= CIO2_PAGE_SIZE / sizeof(u32) * CIO2_PAGE_SIZE; > + remaining -= CIO2_LOP_ENTRIES * CIO2_PAGE_SIZE; > entry++; > i++; > } > @@ -841,10 +840,8 @@ 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); > - static const unsigned int entries_per_page = > - CIO2_PAGE_SIZE / sizeof(u32); > unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, CIO2_PAGE_SIZE); > - unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); > + unsigned int lops = DIV_ROUND_UP(pages + 1, CIO2_LOP_ENTRIES); > struct sg_table *sg; > struct sg_dma_page_iter sg_iter; > unsigned int i, j; > @@ -878,7 +875,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) > break; > b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; > j++; > - if (j == entries_per_page) { > + if (j == CIO2_LOP_ENTRIES) { > i++; > j = 0; > } > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h > index 7caab9b8c2b9..a64a829acc34 100644 > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h > @@ -4,6 +4,8 @@ > #ifndef __IPU3_CIO2_H > #define __IPU3_CIO2_H > > +#include <linux/types.h> > + > #define CIO2_NAME "ipu3-cio2" > #define CIO2_DEVICE_NAME "Intel IPU3 CIO2" > #define CIO2_ENTITY_NAME "ipu3-csi2" > @@ -17,6 +19,7 @@ > /* 32MB = 8xFBPT_entry */ > #define CIO2_MAX_LOPS 8 > #define CIO2_MAX_BUFFERS (PAGE_SIZE / 16 / CIO2_MAX_LOPS) > +#define CIO2_LOP_ENTRIES (PAGE_SIZE / sizeof(u32)) Shouldn't this be CIO2_PAGE_SIZE instead of PAGE_SIZE ? > > #define CIO2_PAD_SINK 0 > #define CIO2_PAD_SOURCE 1
On Fri, Oct 9, 2020 at 4:10 AM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > On Mon, Aug 17, 2020 at 07:07:25PM +0300, Andy Shevchenko wrote: > > This constant is used in several places in the code, define it > > for better maintenance. > > #define CIO2_MAX_BUFFERS (PAGE_SIZE / 16 / CIO2_MAX_LOPS) > > +#define CIO2_LOP_ENTRIES (PAGE_SIZE / sizeof(u32)) > > Shouldn't this be CIO2_PAGE_SIZE instead of PAGE_SIZE ? I don't think it makes sense to define this. Then you need to define all others as well and they will be the same as for the CPU/MMU. As I explained in another patch it's quite unlikely that these two will be different.
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index cb74d49934f1..a89cb3c7e0dc 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -127,7 +127,7 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2) * List of Pointers(LOP) contains 1024x32b pointers to 4KB page each * Initialize each entry to dummy_page bus base address. */ - for (i = 0; i < CIO2_PAGE_SIZE / sizeof(*cio2->dummy_lop); i++) + for (i = 0; i < CIO2_LOP_ENTRIES; i++) cio2->dummy_lop[i] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; return 0; @@ -160,8 +160,7 @@ static void cio2_fbpt_entry_init_dummy(struct cio2_device *cio2, unsigned int i; entry[0].first_entry.first_page_offset = 0; - entry[1].second_entry.num_of_pages = - CIO2_PAGE_SIZE / sizeof(u32) * CIO2_MAX_LOPS; + entry[1].second_entry.num_of_pages = CIO2_LOP_ENTRIES * CIO2_MAX_LOPS; entry[1].second_entry.last_page_available_bytes = CIO2_PAGE_SIZE - 1; for (i = 0; i < CIO2_MAX_LOPS; i++) @@ -201,7 +200,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, i = 0; while (remaining > 0) { entry->lop_page_addr = b->lop_bus_addr[i] >> PAGE_SHIFT; - remaining -= CIO2_PAGE_SIZE / sizeof(u32) * CIO2_PAGE_SIZE; + remaining -= CIO2_LOP_ENTRIES * CIO2_PAGE_SIZE; entry++; i++; } @@ -841,10 +840,8 @@ 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); - static const unsigned int entries_per_page = - CIO2_PAGE_SIZE / sizeof(u32); unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, CIO2_PAGE_SIZE); - unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); + unsigned int lops = DIV_ROUND_UP(pages + 1, CIO2_LOP_ENTRIES); struct sg_table *sg; struct sg_dma_page_iter sg_iter; unsigned int i, j; @@ -878,7 +875,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) break; b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; j++; - if (j == entries_per_page) { + if (j == CIO2_LOP_ENTRIES) { i++; j = 0; } diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h index 7caab9b8c2b9..a64a829acc34 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h @@ -4,6 +4,8 @@ #ifndef __IPU3_CIO2_H #define __IPU3_CIO2_H +#include <linux/types.h> + #define CIO2_NAME "ipu3-cio2" #define CIO2_DEVICE_NAME "Intel IPU3 CIO2" #define CIO2_ENTITY_NAME "ipu3-csi2" @@ -17,6 +19,7 @@ /* 32MB = 8xFBPT_entry */ #define CIO2_MAX_LOPS 8 #define CIO2_MAX_BUFFERS (PAGE_SIZE / 16 / CIO2_MAX_LOPS) +#define CIO2_LOP_ENTRIES (PAGE_SIZE / sizeof(u32)) #define CIO2_PAD_SINK 0 #define CIO2_PAD_SOURCE 1
This constant is used in several places in the code, define it for better maintenance. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v2: renamed CIO2_MAX_ENTRIES -> CIO2_LOP_ENTRIES (Sakari) drivers/media/pci/intel/ipu3/ipu3-cio2.c | 13 +++++-------- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 3 +++ 2 files changed, 8 insertions(+), 8 deletions(-)