Hi,
On Sat, 5 Oct 2024 at 23:40, Pintu Kumar <quic_pintu(a)quicinc.com> wrote:
>
> These warnings/errors are reported by checkpatch.
> Fix them with minor changes to make it clean.
> No other functional changes.
>
> WARNING: Block comments use * on subsequent lines
> + /* only support discovering the end of the buffer,
> + but also allow SEEK_SET to maintain the idiomatic
>
> WARNING: Block comments use a trailing */ on a separate line
> + SEEK_END(0), SEEK_CUR(0) pattern */
>
> WARNING: Block comments use a trailing */ on a separate line
> + * before passing the sgt back to the exporter. */
>
> ERROR: "foo * bar" should be "foo *bar"
> +static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,
>
> WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
> + d = debugfs_create_file("bufinfo", S_IRUGO, dma_buf_debugfs_dir,
>
> total: 1 errors, 4 warnings, 1746 lines checked
>
> Signed-off-by: Pintu Kumar <quic_pintu(a)quicinc.com>
>
> ---
> Changes in V1 suggested by Sumit Semwal:
> Change commit title, and mention exact reason of fix in commit log.
> V1: https://lore.kernel.org/all/CAOuPNLg1=YCUFXW-76A_gZm_PE1MFSugNvg3dEdkfujXV_…
> ---
> drivers/dma-buf/dma-buf.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 8892bc701a66..2e63d50e46d3 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -176,8 +176,9 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
> dmabuf = file->private_data;
>
> /* only support discovering the end of the buffer,
> - but also allow SEEK_SET to maintain the idiomatic
> - SEEK_END(0), SEEK_CUR(0) pattern */
> + * but also allow SEEK_SET to maintain the idiomatic
> + * SEEK_END(0), SEEK_CUR(0) pattern.
> + */
> if (whence == SEEK_END)
> base = dmabuf->size;
> else if (whence == SEEK_SET)
> @@ -782,13 +783,14 @@ static void mangle_sg_table(struct sg_table *sg_table)
> /* To catch abuse of the underlying struct page by importers mix
> * up the bits, but take care to preserve the low SG_ bits to
> * not corrupt the sgt. The mixing is undone in __unmap_dma_buf
> - * before passing the sgt back to the exporter. */
> + * before passing the sgt back to the exporter.
> + */
> for_each_sgtable_sg(sg_table, sg, i)
> sg->page_link ^= ~0xffUL;
> #endif
>
> }
> -static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,
> +static struct sg_table *__map_dma_buf(struct dma_buf_attachment *attach,
> enum dma_data_direction direction)
> {
> struct sg_table *sg_table;
> @@ -1694,7 +1696,7 @@ static int dma_buf_init_debugfs(void)
>
> dma_buf_debugfs_dir = d;
>
> - d = debugfs_create_file("bufinfo", S_IRUGO, dma_buf_debugfs_dir,
> + d = debugfs_create_file("bufinfo", 0444, dma_buf_debugfs_dir,
> NULL, &dma_buf_debug_fops);
> if (IS_ERR(d)) {
> pr_debug("dma_buf: debugfs: failed to create node bufinfo\n");
> --
Pushed V2 here. Any further comment on this ?
Thanks,
Pintu
On Tue, Oct 1, 2024 at 7:51 PM Pintu Kumar <quic_pintu(a)quicinc.com> wrote:
>
> Use of kmap_atomic/kunmap_atomic is deprecated, use
> kmap_local_page/kunmap_local instead.
>
> This is reported by checkpatch.
> Also fix repeated word issue.
>
> WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
> + void *vaddr = kmap_atomic(page);
>
> WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
> + kunmap_atomic(vaddr);
>
> WARNING: Possible repeated word: 'by'
> + * has been killed by by SIGKILL
>
> total: 0 errors, 3 warnings, 405 lines checked
>
> Signed-off-by: Pintu Kumar <quic_pintu(a)quicinc.com>
Reviewed-by: T.J. Mercier <tjmercier(a)google.com>
The Android kernels have been doing this for over a year, so should be
pretty well tested at this point:
https://r.android.com/c/kernel/common/+/2500840
> ---
> drivers/dma-buf/heaps/cma_heap.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
> index 93be88b805fe..8c55431cc16c 100644
> --- a/drivers/dma-buf/heaps/cma_heap.c
> +++ b/drivers/dma-buf/heaps/cma_heap.c
> @@ -309,13 +309,13 @@ static struct dma_buf *cma_heap_allocate(struct dma_heap *heap,
> struct page *page = cma_pages;
>
> while (nr_clear_pages > 0) {
> - void *vaddr = kmap_atomic(page);
> + void *vaddr = kmap_local_page(page);
>
> memset(vaddr, 0, PAGE_SIZE);
> - kunmap_atomic(vaddr);
> + kunmap_local(vaddr);
> /*
> * Avoid wasting time zeroing memory if the process
> - * has been killed by by SIGKILL
> + * has been killed by SIGKILL.
> */
> if (fatal_signal_pending(current))
> goto free_cma;
> --
> 2.17.1
>
Hello Pintu,
On Tue, 1 Oct 2024 at 23:16, Pintu Kumar <quic_pintu(a)quicinc.com> wrote:
>
> Symbolic permissions are not preferred, instead use the octal.
> Also, fix other warnings/errors as well for cleanup.
>
> WARNING: Block comments use * on subsequent lines
> + /* only support discovering the end of the buffer,
> + but also allow SEEK_SET to maintain the idiomatic
>
> WARNING: Block comments use a trailing */ on a separate line
> + SEEK_END(0), SEEK_CUR(0) pattern */
>
> WARNING: Block comments use a trailing */ on a separate line
> + * before passing the sgt back to the exporter. */
>
> ERROR: "foo * bar" should be "foo *bar"
> +static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,
>
> WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
> + d = debugfs_create_file("bufinfo", S_IRUGO, dma_buf_debugfs_dir,
>
> total: 1 errors, 4 warnings, 1746 lines checked
>
> Signed-off-by: Pintu Kumar <quic_pintu(a)quicinc.com>
Thanks for this patch - could you please also mention in the commit
log how did you find this? It looks like you ran checkpatch, but it's
not clear from the commit log.
Since this patch does multiple things related to checkpatch warnings
(change S_IRUGO to 0444, comments correction, function declaration
correction), can I please ask you to change the commit title to also
reflect that?
> ---
> drivers/dma-buf/dma-buf.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 8892bc701a66..2e63d50e46d3 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -176,8 +176,9 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
> dmabuf = file->private_data;
>
> /* only support discovering the end of the buffer,
> - but also allow SEEK_SET to maintain the idiomatic
> - SEEK_END(0), SEEK_CUR(0) pattern */
> + * but also allow SEEK_SET to maintain the idiomatic
> + * SEEK_END(0), SEEK_CUR(0) pattern.
> + */
> if (whence == SEEK_END)
> base = dmabuf->size;
> else if (whence == SEEK_SET)
> @@ -782,13 +783,14 @@ static void mangle_sg_table(struct sg_table *sg_table)
> /* To catch abuse of the underlying struct page by importers mix
> * up the bits, but take care to preserve the low SG_ bits to
> * not corrupt the sgt. The mixing is undone in __unmap_dma_buf
> - * before passing the sgt back to the exporter. */
> + * before passing the sgt back to the exporter.
> + */
> for_each_sgtable_sg(sg_table, sg, i)
> sg->page_link ^= ~0xffUL;
> #endif
>
> }
> -static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,
> +static struct sg_table *__map_dma_buf(struct dma_buf_attachment *attach,
> enum dma_data_direction direction)
> {
> struct sg_table *sg_table;
> @@ -1694,7 +1696,7 @@ static int dma_buf_init_debugfs(void)
>
> dma_buf_debugfs_dir = d;
>
> - d = debugfs_create_file("bufinfo", S_IRUGO, dma_buf_debugfs_dir,
> + d = debugfs_create_file("bufinfo", 0444, dma_buf_debugfs_dir,
> NULL, &dma_buf_debug_fops);
> if (IS_ERR(d)) {
> pr_debug("dma_buf: debugfs: failed to create node bufinfo\n");
> --
> 2.17.1
>
Best,
Sumit.
On 02/10/2024 09:38, Boris Brezillon wrote:
> On Tue, 24 Sep 2024 00:06:21 +0100
> Adrián Larumbe <adrian.larumbe(a)collabora.com> wrote:
>
>> +static u32 calc_profiling_ringbuf_num_slots(struct panthor_device *ptdev,
>> + u32 cs_ringbuf_size)
>> +{
>> + u32 min_profiled_job_instrs = U32_MAX;
>> + u32 last_flag = fls(PANTHOR_DEVICE_PROFILING_ALL);
>> +
>> + /*
>> + * We want to calculate the minimum size of a profiled job's CS,
>> + * because since they need additional instructions for the sampling
>> + * of performance metrics, they might take up further slots in
>> + * the queue's ringbuffer. This means we might not need as many job
>> + * slots for keeping track of their profiling information. What we
>> + * need is the maximum number of slots we should allocate to this end,
>> + * which matches the maximum number of profiled jobs we can place
>> + * simultaneously in the queue's ring buffer.
>> + * That has to be calculated separately for every single job profiling
>> + * flag, but not in the case job profiling is disabled, since unprofiled
>> + * jobs don't need to keep track of this at all.
>> + */
>> + for (u32 i = 0; i < last_flag; i++) {
>> + if (BIT(i) & PANTHOR_DEVICE_PROFILING_ALL)
>
> I'll get rid of this check when applying, as suggested by Steve. Steve,
> with this modification do you want me to add your R-b?
Yes, please do.
Thanks,
Steve
> BTW, I've also fixed a bunch of checkpatch errors/warnings, so you
> might want to run checkpatch --strict next time.
>
>> + min_profiled_job_instrs =
>> + min(min_profiled_job_instrs, calc_job_credits(BIT(i)));
>> + }
>> +
>> + return DIV_ROUND_UP(cs_ringbuf_size, min_profiled_job_instrs * sizeof(u64));
>> +}