summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f39f3af)
The DbC context is different from the xhci device context.
It's a lot smaller as it only contains three 64 bytes sub-contexts;
the info, endpoint-out, and endpoint-in contexts. In total 192 bytes.
The context size (CSZ) field in HCCPARAMS1 xhci register does not alter
DbC context size like it does for xhci device contexts.
So don't use the geneic xhci context memory allocation, or the
dma pool that is intended for xhci device contexts.
In addition to saving memory this also helps decoupleing xhci and dbc code.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200723144530.9992-19-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
#include "xhci-trace.h"
#include "xhci-dbgcap.h"
#include "xhci-trace.h"
#include "xhci-dbgcap.h"
+static void dbc_free_ctx(struct device *dev, struct xhci_container_ctx *ctx)
+{
+ if (!ctx)
+ return;
+ dma_free_coherent(dev, ctx->size, ctx->bytes, ctx->dma);
+ kfree(ctx);
+}
+
static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings)
{
struct usb_string_descriptor *s_desc;
static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings)
{
struct usb_string_descriptor *s_desc;
+static struct xhci_container_ctx *
+dbc_alloc_ctx(struct device *dev, gfp_t flags)
+{
+ struct xhci_container_ctx *ctx;
+
+ ctx = kzalloc(sizeof(*ctx), flags);
+ if (!ctx)
+ return NULL;
+
+ /* xhci 7.6.9, all three contexts; info, ep-out and ep-in. Each 64 bytes*/
+ ctx->size = 3 * DBC_CONTEXT_SIZE;
+ ctx->bytes = dma_alloc_coherent(dev, ctx->size, &ctx->dma, flags);
+ if (!ctx->bytes) {
+ kfree(ctx);
+ return NULL;
+ }
+ return ctx;
+}
+
static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags)
{
int ret;
static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags)
{
int ret;
goto erst_fail;
/* Allocate context data structure: */
goto erst_fail;
/* Allocate context data structure: */
- dbc->ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags);
+ dbc->ctx = dbc_alloc_ctx(dev, flags); /* was sysdev, and is still */
if (!dbc->ctx)
goto ctx_fail;
if (!dbc->ctx)
goto ctx_fail;
- xhci_free_container_ctx(xhci, dbc->ctx);
+ dbc_free_ctx(dev, dbc->ctx);
dbc->ctx = NULL;
ctx_fail:
dbc_erst_free(dev, &dbc->erst);
dbc->ctx = NULL;
ctx_fail:
dbc_erst_free(dev, &dbc->erst);
- xhci_free_container_ctx(xhci, dbc->ctx);
+ dbc_free_ctx(dbc->dev, dbc->ctx);
dbc->ctx = NULL;
dbc_erst_free(dev, &dbc->erst);
dbc->ctx = NULL;
dbc_erst_free(dev, &dbc->erst);