All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 10/12] xhci: translate virtual addresses into the bus's address space
Date: Fri, 18 Dec 2020 19:28:50 -0700	[thread overview]
Message-ID: <CAPnjgZ0YnDD_ierHFTZ4sq60apKzMFpVE_copdCGXsoECkxDHg@mail.gmail.com> (raw)
In-Reply-To: <20201215172323.13309-11-nsaenzjulienne@suse.de>

Hi Nicolas,

On Tue, 15 Dec 2020 at 10:23, Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> So far we've been content with passing physical addresses when
> configuring memory addresses into XHCI controllers, but not all
> platforms have buses with transparent mappings. Specifically the
> Raspberry Pi 4 might introduce an offset to memory accesses incoming
> from its PCIe port.
>
> Introduce xhci_virt_to_bus() and xhci_bus_to_virt() to cater with these
> limitations, and make sure we don't break non DM users.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/usb/host/xhci-mem.c  | 45 +++++++++++++++++++-----------------
>  drivers/usb/host/xhci-ring.c | 11 +++++----
>  drivers/usb/host/xhci.c      |  4 ++--
>  include/usb/xhci.h           | 22 +++++++++++++++++-
>  4 files changed, 54 insertions(+), 28 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

nits below

[..]

> diff --git a/include/usb/xhci.h b/include/usb/xhci.h
> index e1d382369a..b87210b9ba 100644
> --- a/include/usb/xhci.h
> +++ b/include/usb/xhci.h
> @@ -16,6 +16,7 @@
>  #ifndef HOST_XHCI_H_
>  #define HOST_XHCI_H_
>
> +#include <phys2bus.h>
>  #include <reset.h>
>  #include <asm/types.h>
>  #include <asm/cache.h>
> @@ -1250,7 +1251,8 @@ int xhci_check_maxpacket(struct usb_device *udev);
>  void xhci_flush_cache(uintptr_t addr, u32 type_len);
>  void xhci_inval_cache(uintptr_t addr, u32 type_len);
>  void xhci_cleanup(struct xhci_ctrl *ctrl);
> -struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, bool link_trbs);
> +struct xhci_ring *xhci_ring_alloc(struct xhci_ctrl *ctrl, unsigned int num_segs,
> +                                 bool link_trbs);

Can you please add a comment while you are here?

>  int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id);
>  int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr,
>                   struct xhci_hcor *hcor);
> @@ -1278,4 +1280,22 @@ extern struct dm_usb_ops xhci_usb_ops;
>
>  struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev);
>
> +static inline dma_addr_t xhci_virt_to_bus(struct xhci_ctrl *ctrl, void *addr)
> +{
> +#if CONFIG_IS_ENABLED(DM_DMA)

Can this use if() ?

> +       return dev_phys_to_bus(ctrl->dev, virt_to_phys(addr));
> +#else
> +       return phys_to_bus(virt_to_phys(addr));
> +#endif
> +}
> +
> +static inline void *xhci_bus_to_virt(struct xhci_ctrl *ctrl, dma_addr_t addr)
> +{
> +#if CONFIG_IS_ENABLED(DM_DMA)
> +       return phys_to_virt(dev_bus_to_phys(ctrl->dev, addr));
> +#else
> +       return phys_to_virt(bus_to_phys(addr));
> +#endif
> +}
> +
>  #endif /* HOST_XHCI_H_ */
> --
> 2.29.2
>

Regards,
Simon

  reply	other threads:[~2020-12-19  2:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 17:23 [PATCH v3 00/12] Raspberry Pi 400/Compute Module 4 support Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 01/12] rpi: Add identifier for the new RPi400 Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 02/12] rpi: Add identifier for the new CM4 Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 03/12] pci: pcie-brcmstb: Fix inbound window configurations Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 04/12] dm: Introduce xxx_get_dma_range() Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-21 13:03     ` Nicolas Saenz Julienne
2020-12-21 16:47       ` Simon Glass
2020-12-15 17:23 ` [PATCH v3 05/12] dm: test: Add test case for dev_get_dma_ranges() Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-15 17:23 ` [PATCH v3 06/12] dm: Introduce DMA constraints into the core device model Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-15 17:23 ` [PATCH v3 07/12] dm: test: Add test case for dev->dma_offset Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-21 13:36     ` Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 08/12] dm: Introduce dev_phys_to_bus()/dev_bus_to_phys() Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 09/12] dm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys() Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-21 13:47     ` Nicolas Saenz Julienne
2020-12-21 16:47       ` Simon Glass
2020-12-15 17:23 ` [PATCH v3 10/12] xhci: translate virtual addresses into the bus's address space Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass [this message]
2020-12-21 13:51     ` Nicolas Saenz Julienne
2020-12-15 17:23 ` [PATCH v3 11/12] mmc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys() Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass
2020-12-21 14:23     ` Nicolas Saenz Julienne
2020-12-21 16:47       ` Simon Glass
2020-12-21 19:52         ` Nicolas Saenz Julienne
2020-12-21 20:23           ` Simon Glass
2020-12-15 17:23 ` [PATCH v3 12/12] configs: rpi4: Enable DM_DMA across all RPi4 configurations Nicolas Saenz Julienne
2020-12-19  2:28   ` Simon Glass

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=CAPnjgZ0YnDD_ierHFTZ4sq60apKzMFpVE_copdCGXsoECkxDHg@mail.gmail.com \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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.