All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Niklas Neronin <niklas.neronin@linux.intel.com>
Cc: michal.pecio@gmail.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 2/2] usb: xhci: set page size to the xHCI-supported size
Date: Tue, 4 Feb 2025 18:06:39 +0200	[thread overview]
Message-ID: <3d52ea9a-7923-4f0f-9da8-507a554639fd@linux.intel.com> (raw)
In-Reply-To: <20250204124145.3998098-3-niklas.neronin@linux.intel.com>

On 4.2.2025 14.41, Niklas Neronin wrote:
> The current xHCI driver does not validate whether a page size of 4096
> bytes is supported. Address the issue by setting the page size to the
> value supported by the xHCI controller, as read from the Page Size
> register. In the event of an unexpected value; default to a 4K page size.
> 
> Additionally, this commit removes unnecessary debug messages and instead
> prints the supported and used page size once.
> 
> The xHCI controller supports page sizes of (2^{(n+12)}) bytes, where 'n'
> is the Page Size Bit. Only one page size is supported, with a maximum
> page size of 128 KB.
> 
> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
> ---
> V3:
>   * Rename local variable 'page_shift' to 'page_size'.
> 
>   drivers/usb/host/xhci-mem.c | 34 ++++++++++++++++++----------------
>   drivers/usb/host/xhci.h     |  8 ++++----
>   2 files changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index dc5bcd8db4c0..c2ee0d32f5cd 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1953,7 +1953,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>   	xhci->interrupters = NULL;
>   
>   	xhci->page_size = 0;
> -	xhci->page_shift = 0;
>   	xhci->usb2_rhub.bus_state.bus_suspended = 0;
>   	xhci->usb3_rhub.bus_state.bus_suspended = 0;
>   }
> @@ -2372,6 +2371,22 @@ xhci_create_secondary_interrupter(struct usb_hcd *hcd, unsigned int segs,
>   }
>   EXPORT_SYMBOL_GPL(xhci_create_secondary_interrupter);
>   
> +static void xhci_hcd_page_size(struct xhci_hcd *xhci)
> +{
> +	u32 page_size;
> +
> +	page_size = readl(&xhci->op_regs->page_size) & XHCI_PAGE_SIZE_MASK;
> +	if (!page_size || page_size & (page_size - 1)) {

is_power_of_2(page_size) does the same, and is easier to understand

-Mathias


      reply	other threads:[~2025-02-04 16:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 12:41 [PATCH v3 0/2] usb: xhci: page size improvements Niklas Neronin
2025-02-04 12:41 ` [PATCH v3 1/2] usb: xhci: correct debug message page size calculation Niklas Neronin
2025-03-05  8:32   ` Michał Pecio
2025-02-04 12:41 ` [PATCH v3 2/2] usb: xhci: set page size to the xHCI-supported size Niklas Neronin
2025-02-04 16: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=3d52ea9a-7923-4f0f-9da8-507a554639fd@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=michal.pecio@gmail.com \
    --cc=niklas.neronin@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 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.