Linux kernel staging patches
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Neal Patalay <nealpatalay0@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	andy@kernel.org, hansg@kernel.org, mchehab@kernel.org,
	gregkh@linuxfoundation.org, sakari.ailus@linux.intel.com,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-staging@lists.linux.dev, mugrinphoto@gmail.com,
	matt@mattwardle.net
Subject: Re: [PATCH v4] staging: media: atomisp: refactor pipe graph dump stage formatting
Date: Tue, 7 Jul 2026 10:18:06 +0300	[thread overview]
Message-ID: <akyoLqy98pt2iRkP@ashevche-desk.local> (raw)
In-Reply-To: <CAGjuiT9gu32wvx2Vf0U0g9deyAzzGtwwCNEdW_R4JVarO9x4JQ@mail.gmail.com>

On Mon, Jul 06, 2026 at 02:59:16PM -0700, Neal Patalay wrote:
> On Sun, Jul 5, 2026 at 10:37 PM Andy Shevchenko wrote:
> 
> > Please, slow down! No need to send a new version immediately after
> > replying to the previous one without settling down all aspects of the
> > change.
> >
> > This version is no go, sorry.
> 
> Understood, no problem.
> 
> > > +static void ia_css_debug_build_info(char *info, size_t info_size,
> > > +                                   int *offset,
> > > +                                   const char *flag_str, size_t flag_str_size,
> > > +                                   int *line_len,
> > > +                                   int *num_lines)
> > > +{
> > > +       int len = *line_len;
> > > +       int off = *offset;
> > > +       int lines = *num_lines;
> > > +       int len_written;
> > > +
> > > +       if (lines > 3)
> > > +               return;
> > > +
> > > +       /*
> > > +        * If new line length exceeds max line length,
> > > +        * replace the last ',' with a "\\n".
> > > +        */
> > > +       if (len > 0 && off > 0 && info_size - off >= 2 &&
> > > +           len + flag_str_size > ENABLE_LINE_MAX_LENGTH) {
> > > +               if (lines >= 3) {
> > > +                       *num_lines = lines + 1;
> > > +                       return;
> > > +               }
> > > +               info[off - 1] = '\\';
> > > +               info[off] = 'n';
> > > +               off += 1;
> > > +               len = 0;
> > > +               lines += 1;
> > > +       }
> > > +
> > > +       len_written = scnprintf(info + off, info_size - off, "%s,", flag_str);
> > > +       *offset = off + len_written;
> > > +       *line_len = len + len_written;
> > > +       *num_lines = lines;
> > > +}
> >
> > This makes helper too ugly and unreadable. Again, study the case
> > first, when this can be true. Do we really need to cut it? This whole
> > thing AFAICS depends on the dtrace facility in the driver. Is that
> > HW-related? Is it pure SW? You need to perform some homework.
> 
> I've taken a look at the driver in greater depth. The flag wrapping
> functionality being refactored here is used to construct a graph
> visualization for debugging.
> 
> > >                 dtrace_dot("node [shape = circle, fixedsize=true, width=2.5, label=\"%s\\n%s\\n\\n%s\"]; \"%s(pipe%d)\"",
> > >                            bin_type, blob_name, enable_info, blob_name, id);
> 
> Each one of these calls generates a node in that graph, and the contents
> of the node are decided by the flag string we build in enable_info. Seeing
> as we are just collecting debug info and populating a visualization with it,
> this refactor seems to be software.
> 
> Seeing as it's unlikely that every flag is enabled at once, and even if they
> are this only causes a slightly more unreadable graph, avoiding 3 line
> truncation seems to be the best option since it leads to more readable code
> and avoids omitting information.
> 
> Additionally, len > 0 && offset == 0 is an impossible condition under any
> feasible helper function use condition. This can be documented in a comment.
> 
> Given this information, to me it seems like the best course of action is to
> revert the helper function to its simpler state without line count truncation
> or the offset > 0 comparison. What do you think?

I agree, just add more comments to the code and elaborate in the commit message
the (potential) difference in the behaviour.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-07-07  7:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  0:07 [PATCH v4] staging: media: atomisp: refactor pipe graph dump stage formatting Neal Patalay
2026-07-06  5:36 ` Andy Shevchenko
2026-07-06 21:59   ` Neal Patalay
2026-07-07  7:18     ` Andy Shevchenko [this message]
2026-07-08  3:04       ` Neal Patalay

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=akyoLqy98pt2iRkP@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=matt@mattwardle.net \
    --cc=mchehab@kernel.org \
    --cc=mugrinphoto@gmail.com \
    --cc=nealpatalay0@gmail.com \
    --cc=sakari.ailus@linux.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