From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: chao zeng <chao.zengup@gmail.com>, mathias.nyman@intel.com
Cc: linux-usb@vger.kernel.org
Subject: Re: Some problems about xhci_ring_expansion
Date: Wed, 16 Nov 2022 12:06:44 +0200 [thread overview]
Message-ID: <fa7d7926-5944-e58d-7f90-5284fdaeeb55@linux.intel.com> (raw)
In-Reply-To: <CAGzEXPYzhJdw5M+F0SdcrtN8Hnew_LCjD6bC=ANBJzBxVRM_NA@mail.gmail.com>
Hi
On 16.11.2022 10.46, chao zeng wrote:
> hello!
> Thank you for taking the time to look at my question.
>
> At file xhci-ring.c
> static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring,
> unsigned int num_trbs)
> {
> int num_trbs_in_deq_seg;
>
> if (ring->num_trbs_free < num_trbs)
> return 0;
>
> if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) {
> num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs;
> if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg)
> return 0;////suppose return here
> }
>
> return 1;
> }
>
> Suppose the function room_on_ring returns in my bolded condition.
> num_trbs_needed will be a very large value because the num_trbs <
> num_trbs_free. In this way , we will just double the total ring size.
You are correct, good point.
So it turns out we almost always double the ring size when we need
more space, and we do this just because num_trbs_neeed is completely incorrect.
(trying to store negative value in unsigned int)
> Is this as expected or should add one segment size instead?
That's a good question.
Code should be fixed, but do we want to continue doubling ring size, or add
just enough segments to fit actual num_trbs_needed, or perhaps add enough
segments to fit twice the amount of needed trbs?
Would you like work on this? patches are welcome
Thanks
-Mathias
prev parent reply other threads:[~2022-11-16 10:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 8:46 Some problems about xhci_ring_expansion chao zeng
2022-11-16 10:06 ` Mathias Nyman [this message]
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=fa7d7926-5944-e58d-7f90-5284fdaeeb55@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=chao.zengup@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@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 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.