From patchwork Mon Mar 11 09:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Howard Yen X-Patchwork-Id: 780866 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A677E2BAFC for ; Mon, 11 Mar 2024 09:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150605; cv=none; b=Dz1TLZOaf0jwclaKxTNWmAG0whBMkNsyJ+wr5KPDn+1ecEJi9T5pFda/RYp2nJ8mIL3HhYYM59jrzWmsjzbWEFbB2nArhSBwgThnMwh00xlZgAIdTJCTSn97YQaEU0Fe4I5fSqvbikXzrGw76j3sC0ibvrwRfqchu7+yeOajUBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150605; c=relaxed/simple; bh=uvJ2hakYbHneCq8YNG7tuA44/YBDsJTeR/dxao+/8HQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=R/GIgRuMaiysuKI/u7KYCJCKzccloxT6aLWCwCyRV8m5cSINnJBH8Ko/rdyybsg/Xy7/RPJmwlpKHZNsCtaMzI2yoe5PxuxSvT/dblFqP1NSYNJh0EtKCyAdAJfD4OAtdohKvr/I/cImnjrjePrTeBv3eC6y18kWWdSPDVDWKyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--howardyen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Jdwn2ad8; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--howardyen.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jdwn2ad8" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5cec8bc5c66so2940633a12.1 for ; Mon, 11 Mar 2024 02:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710150603; x=1710755403; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=U9nKgRIKf+zajKM49T+JUxDbdLW2EfnvvMithLFK/Yc=; b=Jdwn2ad8Yjvze3A/IsjvHJzhvSbO1gi9QO23jsfDhj2r9A+5kvu3/nu7UlL+mMgNRr o9aagpGNLo0caS1btUv5dxPFRAwhK3etIZPjHQZucQRvtmdJxRp7rGN8JwmttVmvJdvP iAVlxg5z1fMOEnBOsIXBau2LHW7FmpBbZeh2VDZywnr2AZVqWe7qFKybaeWy9l2RklQB BjPRHVExc3+YhznWIJyIosgOsLSa8gi583oo24vSp6xaEoJ5uNB/y27N1yAKNVSUoK/r CUbKNBrKcRLBd+oUVul8GFhk+PvCzDiY8WkwXr9kXq4SEDJbhypRgykOVMu3UU3hQQ+g IkzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710150603; x=1710755403; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U9nKgRIKf+zajKM49T+JUxDbdLW2EfnvvMithLFK/Yc=; b=fzqSWGvggLNBMOu7Bh1csRTVX2rIozPjLQygt9sK07RMQth5ENtbX+IEsY0fGL/tz5 jWKNLG34TeH9MhRCrv2e24f6cuAZlEK6JGchg9dH6TSG4+OacBMm6CG2YKeottX/Xw7I k+RmMzUCUUBPpKbXF1jXWnNn/VCu9O7mvTs/6u7y3JmA6d1IKVtSHq5KYTafjzlVc+CE s/GVWsI6LsoUddEdYXw1T0/+GiOBC1I6u3UPdHl0HE6rFUreUKt+aTR6bmu3M4hvcgAG 8jiR0MXFdoUqc/zfLtrO2ofyECbBgCIZijHhjUcEegxYMt1tvqp8gSx80bC8/Fb7hQ3U 9EEQ== X-Forwarded-Encrypted: i=1; AJvYcCXoQrifiAc941Xb+HUSZZPzCAow4LFa8AFKyA+2Ualu1cMC/q7dA3NSnwEEh7bbY0RALO3wJgdNK1lxsbyU5WJbQIOWrMBOwPnu X-Gm-Message-State: AOJu0Yw7XzE6Uu7xdjIdIJ4LEibuySoWzvrhnQbnkmT25kSx5cc3jie3 i4InWBbLmOc6Wv1G9KsJ9Qud0eKRiGo6xhFO2ZjB+WtJ42qjicZdimdZk6M03lzVbz79Opwx1UN CBSUVHAzAhagwoA== X-Google-Smtp-Source: AGHT+IE5C8YFsWfQeFn6ZmMrCYM8EsZdK0R7B2x7aijsSo9T46qxw3LGysRAMLa17HQzOWxQTbFW0fvfbLQGTOw= X-Received: from howardyen2.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:16f7]) (user=howardyen job=sendgmr) by 2002:a63:de0b:0:b0:5dc:aa2a:7790 with SMTP id f11-20020a63de0b000000b005dcaa2a7790mr17226pgg.2.1710150602720; Mon, 11 Mar 2024 02:50:02 -0700 (PDT) Date: Mon, 11 Mar 2024 09:49:47 +0000 In-Reply-To: <20240311094947.3738200-1-howardyen@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240311094947.3738200-1-howardyen@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240311094947.3738200-3-howardyen@google.com> Subject: [PATCH v5 2/2] usb: host: xhci-plat: add support for multi memory regions From: Howard Yen To: gregkh@linuxfoundation.org, rafael@kernel.org, mathias.nyman@intel.com, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.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, Howard Yen 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. Signed-off-by: Howard Yen --- 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 #include #include +#include #include #include #include @@ -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);