netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Christensen <drc@linux.vnet.ibm.com>
To: "Nelson, Shannon" <shannon.nelson@amd.com>,
	brett.creeley@amd.com, drivers@pensando.io
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ionic: fix 16bit math issue when PAGE_SIZE >= 64KB
Date: Tue, 12 Sep 2023 15:31:31 -0700	[thread overview]
Message-ID: <df083cc4-e903-f122-0817-b1313397e89f@linux.vnet.ibm.com> (raw)
In-Reply-To: <a7c39c89-c277-4b5f-92c0-690e31c769b5@amd.com>



On 9/11/23 5:24 PM, Nelson, Shannon wrote:

>> @@ -452,7 +452,7 @@ void ionic_rx_fill(struct ionic_queue *q)
>>
>>                  /* fill main descriptor - buf[0] */
>>                  desc->addr = cpu_to_le64(buf_info->dma_addr + 
>> buf_info->page_offset);
>> -               frag_len = min_t(u16, len, IONIC_PAGE_SIZE - 
>> buf_info->page_offset);
>> +               frag_len = min_t(u32, len, IONIC_PAGE_SIZE - 
>> buf_info->page_offset);
>>                  desc->len = cpu_to_le16(frag_len);
> 
> Hmm... using cpu_to_le16() on a 32-bit value looks suspect - it might 
> get forced to 16-bit, but looks funky, and might not be as successful in 
> a BigEndian environment.
> 
> Since the descriptor and sg_elem length fields are limited to 16-bit, 
> there might need to have something that assures that the resulting 
> lengths are never bigger than 64k - 1.
> 

What do you think about this:

  frag_len = min_t(u16, len, min_t(u32, 0xFFFF, IONIC_PAGE_SIZE - 
buf_info->page_offset));

Can you think of a test case where buf_info->page_offset will be 
non-zero that I can test locally?

Dave

  reply	other threads:[~2023-09-12 22:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 22:22 [PATCH] ionic: fix 16bit math issue when PAGE_SIZE >= 64KB David Christensen
2023-09-12  0:14 ` Jacob Keller
2023-09-12 20:48   ` David Christensen
2023-09-12 21:13     ` Jacob Keller
2023-09-12  0:24 ` Nelson, Shannon
2023-09-12 22:31   ` David Christensen [this message]
2023-09-14 20:28     ` Nelson, Shannon
2023-09-14 20:39       ` Nelson, Shannon
2023-09-14 22:02 ` [PATCH net v2] " David Christensen
2023-09-15 16:55   ` Nelson, Shannon
2023-09-16 10:50   ` patchwork-bot+netdevbpf

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=df083cc4-e903-f122-0817-b1313397e89f@linux.vnet.ibm.com \
    --to=drc@linux.vnet.ibm.com \
    --cc=brett.creeley@amd.com \
    --cc=drivers@pensando.io \
    --cc=netdev@vger.kernel.org \
    --cc=shannon.nelson@amd.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;
as well as URLs for NNTP newsgroup(s).