From: Robin Murphy <robin.murphy@arm.com>
To: Howard Yen <howardyen@google.com>,
gregkh@linuxfoundation.org, rafael@kernel.org,
mathias.nyman@intel.com, hch@lst.de, m.szyprowski@samsung.com,
andriy.shevchenko@linux.intel.com, petr.tesarik.ext@huawei.com,
broonie@kernel.org, james@equiv.tech, james.clark@arm.com,
masahiroy@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
iommu@lists.linux.dev
Subject: Re: [PATCH v5 2/2] usb: host: xhci-plat: add support for multi memory regions
Date: Mon, 11 Mar 2024 12:21:27 +0000 [thread overview]
Message-ID: <2195bcc4-e5e5-44de-93c7-667da1409de3@arm.com> (raw)
In-Reply-To: <20240311094947.3738200-3-howardyen@google.com>
On 2024-03-11 9:49 am, Howard Yen wrote:
> The reason why it needs multiple regions is that in my system there is
> an always-on subsystem which includes a small size memory, and several
> functions need to run and occupy the memory from the small memory if
> they need to run on the always-on subsystem. These functions must
> allocate the memory from the small memory region, so that they can get
> benefit from the always-on subsystem. So the small memory is split for
> multiple functions which are satisfied with their generic use cases.
> But in specific use cases, like USB3 devices which support the stream
> trasnsfer or multiple devices connect to the host, they required more
> memory than their pre-allocated memory region, so I tried to propose
> this patch to give it the ability to get the memory from the other
> larger memory to solve the issue.
Once again this still fails to make sense - The USB controller has a
special always-on pool from which it "must allocate", yet it's fine if
it also allocates from elsewhere? How on Earth is that supposed to work?
As I said before, if it's actually the case that only certain specific
allocations (based on driver-level knowledge) must come from the special
pool, then this is not something which can realistically be abstracted
by the generic dma-coherent API as it stands (and if so, do the
non-special allocations even need a dedicated second reserved region, or
is that in fact just a massive hack around the dma_coherent_mem design
intentionally not falling back to the regular allocator?)
Thanks,
Robin.
> Signed-off-by: Howard Yen <howardyen@google.com>
> ---
> drivers/usb/host/xhci-plat.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 3d071b875308..7892d3eb26d2 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -14,6 +14,7 @@
> #include <linux/pci.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> +#include <linux/of_reserved_mem.h>
> #include <linux/platform_device.h>
> #include <linux/usb/phy.h>
> #include <linux/slab.h>
> @@ -149,7 +150,7 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
> struct xhci_hcd *xhci;
> struct resource *res;
> struct usb_hcd *hcd, *usb3_hcd;
> - int ret;
> + int i, count, ret;
> int irq;
> struct xhci_plat_priv *priv = NULL;
> bool of_match;
> @@ -194,6 +195,19 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
>
> xhci->allow_single_roothub = 1;
>
> + count = of_property_count_u32_elems(sysdev->of_node, "memory-region");
> +
> + for (i = 0; i < count; i++) {
> + ret = of_reserved_mem_device_init_by_idx(sysdev, sysdev->of_node, i);
> + if (ret) {
> + dev_err(sysdev, "Could not get reserved memory\n");
> + if (i > 0)
> + of_reserved_mem_device_release(sysdev);
> +
> + return ret;
> + }
> + }
> +
> /*
> * Not all platforms have clks so it is not an error if the
> * clock do not exist.
> @@ -431,6 +445,9 @@ void xhci_plat_remove(struct platform_device *dev)
> clk_disable_unprepare(clk);
> clk_disable_unprepare(reg_clk);
> reset_control_assert(xhci->reset);
> +
> + of_reserved_mem_device_release(hcd->self.sysdev);
> +
> usb_put_hcd(hcd);
>
> pm_runtime_disable(&dev->dev);
next prev parent reply other threads:[~2024-03-11 12:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 9:49 [PATCH v5 0/2] Add support for multiple coherent memory regions Howard Yen
2024-03-11 9:49 ` [PATCH v5 1/2] dma-coherent: add support for multi coherent rmems per dev Howard Yen
2024-03-11 9:49 ` [PATCH v5 2/2] usb: host: xhci-plat: add support for multi memory regions Howard Yen
2024-03-11 12:21 ` Robin Murphy [this message]
2024-03-13 7:12 ` Dan Carpenter
2024-03-11 10:03 ` [PATCH v5 0/2] Add support for multiple coherent " Andy Shevchenko
2024-03-11 10:10 ` Howard Yen
2024-03-11 10:32 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2024-03-13 6:21 [PATCH v5 2/2] usb: host: xhci-plat: add support for multi " kernel test robot
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=2195bcc4-e5e5-44de-93c7-667da1409de3@arm.com \
--to=robin.murphy@arm.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=howardyen@google.com \
--cc=iommu@lists.linux.dev \
--cc=james.clark@arm.com \
--cc=james@equiv.tech \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=masahiroy@kernel.org \
--cc=mathias.nyman@intel.com \
--cc=petr.tesarik.ext@huawei.com \
--cc=rafael@kernel.org \
/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.