From: Logan Gunthorpe <logang@deltatee.com>
To: Allen Hubbe <allenbh@gmail.com>
Cc: Jon Mason <jdmason@kudzu.us>, Dave Jiang <dave.jiang@intel.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 5/8] ntb_tool: BUG: Ensure the buffer size is large enough to return all spads
Date: Sat, 11 Jun 2016 09:29:05 -0600 [thread overview]
Message-ID: <575C2E41.6080407@deltatee.com> (raw)
In-Reply-To: <CAJ80savw=Lpzpf5VT2X=Uge0XO13nrwmw6SypvhiPgLsK6CLOw@mail.gmail.com>
Ok, I'll add a comment.
Logan
On 10/06/16 08:35 PM, Allen Hubbe wrote:
> On Fri, Jun 10, 2016 at 6:54 PM, Logan Gunthorpe <logang@deltatee.com> wrote:
>> On hardware with 32 scratchpad registers the spad field in ntb tool
>> could chop off the end. The maximum buffer size is increased from
>> 256 to 15 times the number or scratchpads.
>>
>> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
>
> It could be marginally better if there was an explanation to accompany
> the magic number 15, but it's not a big deal. One might guess it has
> something to do with the expected length of the formatted string.
>
> Acked-by: Allen Hubbe <Allen.Hubbe@emc.com>
>
>> ---
>> drivers/ntb/test/ntb_tool.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
>> index 4c01057..954e1d5 100644
>> --- a/drivers/ntb/test/ntb_tool.c
>> +++ b/drivers/ntb/test/ntb_tool.c
>> @@ -368,7 +368,9 @@ static ssize_t tool_spadfn_read(struct tool_ctx *tc, char __user *ubuf,
>> if (!spad_read_fn)
>> return -EINVAL;
>>
>> - buf_size = min_t(size_t, size, 0x100);
>> + spad_count = ntb_spad_count(tc->ntb);
>> +
>> + buf_size = min_t(size_t, size, spad_count * 15);
>>
>> buf = kmalloc(buf_size, GFP_KERNEL);
>> if (!buf)
>> @@ -376,7 +378,6 @@ static ssize_t tool_spadfn_read(struct tool_ctx *tc, char __user *ubuf,
>>
>> pos = 0;
>>
>> - spad_count = ntb_spad_count(tc->ntb);
>> for (i = 0; i < spad_count; ++i) {
>> pos += scnprintf(buf + pos, buf_size - pos, "%d\t%#x\n",
>> i, spad_read_fn(tc->ntb, i));
>> --
>> 2.1.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "linux-ntb" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com.
>> To post to this group, send email to linux-ntb@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/d9488f2c946644c2b1258a78929d3543747283ec.1465598632.git.logang%40deltatee.com.
>> For more options, visit https://groups.google.com/d/optout.
next prev parent reply other threads:[~2016-06-11 15:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 22:54 [PATCH 0/8] NTB Selftest Script Logan Gunthorpe
2016-06-10 22:54 ` [PATCH 1/8] ntb_perf: Schedule based on time not on performance Logan Gunthorpe
2016-06-13 18:05 ` Jiang, Dave
2016-06-10 22:54 ` [PATCH 2/8] ntb_perf: Improve thread handling to increase robustness Logan Gunthorpe
2016-06-13 18:16 ` Jiang, Dave
2016-06-10 22:54 ` [PATCH 3/8] ntb_perf: Return results by reading the run file Logan Gunthorpe
2016-06-13 20:09 ` Jiang, Dave
2016-06-10 22:54 ` [PATCH 4/8] ntb_perf: Wait for link before running test Logan Gunthorpe
2016-06-13 20:14 ` Jiang, Dave
2016-06-10 22:54 ` [PATCH 5/8] ntb_tool: BUG: Ensure the buffer size is large enough to return all spads Logan Gunthorpe
2016-06-11 2:35 ` Allen Hubbe
2016-06-11 15:29 ` Logan Gunthorpe [this message]
2016-06-10 22:54 ` [PATCH 6/8] ntb_tool: Add link status file to debugfs Logan Gunthorpe
2016-06-11 2:27 ` Allen Hubbe
2016-06-11 15:28 ` Logan Gunthorpe
2016-06-12 1:28 ` Allen Hubbe
2016-06-14 15:45 ` Allen Hubbe
2016-06-14 15:45 ` Allen Hubbe
2016-06-14 15:48 ` Logan Gunthorpe
2016-06-14 15:54 ` Allen Hubbe
2016-06-14 15:54 ` Allen Hubbe
2016-06-10 22:54 ` [PATCH 7/8] ntb_pingpong: Add a debugfs file to get the ping count Logan Gunthorpe
2016-06-11 2:46 ` Allen Hubbe
2016-06-11 15:30 ` Logan Gunthorpe
2016-06-10 22:54 ` [PATCH 8/8] ntb_test: Add a selftest script for the NTB subsystem Logan Gunthorpe
2016-06-14 14:06 ` Jon Mason
2016-06-14 14:16 ` Shuah Khan
2016-06-14 15:45 ` Logan Gunthorpe
2016-06-14 15:47 ` Allen Hubbe
2016-06-14 15:47 ` Allen Hubbe
2016-06-14 15:49 ` Logan Gunthorpe
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=575C2E41.6080407@deltatee.com \
--to=logang@deltatee.com \
--cc=allenbh@gmail.com \
--cc=arnd@arndb.de \
--cc=dave.jiang@intel.com \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-ntb@googlegroups.com \
--cc=shuahkh@osg.samsung.com \
--cc=sudipm.mukherjee@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.