mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gary R Hook <gary.hook@amd.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/5] iommu/amd - Add debugfs support
Date: Tue, 13 Mar 2018 13:54:00 -0500	[thread overview]
Message-ID: <30bd9559-0e44-bd18-6b9a-ec35bc8276f3@amd.com> (raw)
In-Reply-To: <CAHp75VdK6qFopBE4rD4yNO5GHccxyte=GhYU7YGcWOEYSCyX8Q@mail.gmail.com>

On 03/13/2018 12:16 PM, Andy Shevchenko wrote:
> On Fri, Mar 9, 2018 at 2:50 AM, Gary R Hook <gary.hook@amd.com> wrote:
> 
>> +       default n
> 
> Redundant

Roger that.

>> +#include <linux/pci.h>
>> +#include <linux/iommu.h>
>> +#include <linux/debugfs.h>
> 
> Keep in order?

What order would that be? These few needed files are listed in the same
order as which they appear in amd_iommu.c. I'm gonna need a preference
spelled out, please (and a rationale, so I may better understand).

>> +#include "amd_iommu_proto.h"
>> +#include "amd_iommu_types.h"
> 
>> +/* DebugFS helpers */
>> +#define        OBUFP           (obuf + oboff)
>> +#define        OBUFLEN         obuflen
>> +#define        OBUFSPC         (OBUFLEN - oboff)
>> +#define        OSCNPRINTF(fmt, ...) \
>> +               scnprintf(OBUFP, OBUFSPC, fmt, ## __VA_ARGS__)
> 
> I don't see any advantages of this. Other way around, they will simple
> makes things hard to read an understand in place.

I used this technique in the CCP driver code (where it was accepted), in 
an effort to do the opposite of what you claim: make the code more 
readable. Given the 80 column limit, a large number of arguments, and 
very long statements, IMO something needs to give. I don't find the use 
of #defines to be obfuscating.

I'm not trying to argue, but rather simply state the perspective / 
reasoning I used to create a source file I feel is manageable. I have 17 
more iommu patches built upon this strategy, and this seems to be 
advantageous for all of them.

> 
> 
>> +       for (i = start ; i <= end ; i++)
> 
> Missed {}

Wasn't sure about the M.O. given that the body of this loop is a single 
if statement. And I don't see anywhere in
https://www.kernel.org/doc/html/latest/process/coding-style.html
in section 3.1 where curly braces are called for in this situation. May 
I ask for clarification on the style rule, please?

> 
>> +               if ((amd_iommu_dev_table[i].data[0] ^ 0x3)
>> +                   || amd_iommu_dev_table[i].data[1])
>> +                       n++;
>> +       return n;
>> +}
> 
>> +
>> +static ssize_t amd_iommu_debugfs_dtecount_read(struct file *filp,
>> +                                         char __user *ubuf,
>> +                                         size_t count, loff_t *offp)
>> +{
>> +       struct amd_iommu *iommu = filp->private_data;
> 
>> +       unsigned int obuflen = 512;
> 
> Sounds like way too much.

I can tune these up.

> 
>> +       if (!iommu)
>> +               return 0;
> 
> When this possible?

It was intended as a sanity check, but if this happens, much worse has 
already gone wrong. I'll remove.

> 
>> +       obuf = kmalloc(OBUFLEN, GFP_KERNEL);
>> +       if (!obuf)
>> +               return -ENOMEM;
>> +
>> +       n = amd_iommu_count_valid_dtes(0, 0xFFFF);
>> +       oboff += OSCNPRINTF("%d\n", n);
> 
>> +       return ret;
>> +}
> 
> 
>> @@ -89,6 +89,7 @@
>>   #define ACPI_DEVFLAG_ATSDIS             0x10000000
>>
>>   #define LOOP_TIMEOUT   100000
>> +
>>   /*
>>    * ACPI table definitions
>>    *
> 
> Doesn't belong to the patch.

I'm sorry, I don't understand. The added blank line doesn't belong to 
the patch?

> 
>> +#endif
>> +
>> +
> 
> Extra unneeded line.
> 
Thanks,

  reply	other threads:[~2018-03-13 18:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09  0:50 [PATCH v2 0/5] Add debugfs info for the AMD IOMMU Gary R Hook
2018-03-09  0:50 ` [PATCH v2 1/5] iommu/amd - Add debugfs support Gary R Hook
2018-03-13 17:16   ` Andy Shevchenko
2018-03-13 18:54     ` Gary R Hook [this message]
2018-03-13 20:23       ` Andy Shevchenko
2018-03-14 15:24         ` Gary R Hook
2018-03-14 15:29           ` Andy Shevchenko
2018-03-14 22:23             ` Gary R Hook
2018-03-09  0:50 ` [PATCH v2 2/5] iommu/amd - Add a 'verbose' switch for IOMMU debugfs Gary R Hook
2018-03-09  0:51 ` [PATCH v2 3/5] iommu/amd - Add a README variable for the " Gary R Hook
2018-03-09  0:51 ` [PATCH v2 4/5] iommu/amd - Expose the active IOMMU device table entries Gary R Hook
2018-03-09  0:51 ` [PATCH v2 5/5] iommu/amd - Add a debugfs entry to specify a IOMMU device table entry Gary R Hook
2018-03-13 17:20   ` Andy Shevchenko
2018-03-13 18:54     ` Gary R Hook
2018-03-13 20:56       ` Andy Shevchenko
2018-03-14 15:24         ` Gary R Hook

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=30bd9559-0e44-bd18-6b9a-ec35bc8276f3@amd.com \
    --to=gary.hook@amd.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®