Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp365879lql; Mon, 11 Mar 2024 05:22:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZY17l4KVUFptZRG138snMpvXwaf+gzdvc4rTWuaEhtuC9h98n2vtmyKuW8Ue5haIekZPbPxAcXGzgntZGt1Es/AUs1CQ40+WSYVW3/A== X-Google-Smtp-Source: AGHT+IGpAPFVnXe/+zG620qHXpqFeA+ECcaq9sXJ41JUQKNsnQVTGKPtFfAIy0wli1Kg6f38yOOX X-Received: by 2002:a05:620a:a11:b0:787:ec39:8210 with SMTP id i17-20020a05620a0a1100b00787ec398210mr5492038qka.52.1710159726767; Mon, 11 Mar 2024 05:22:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710159726; cv=pass; d=google.com; s=arc-20160816; b=08yKo86F9da3pxsXsg0OY0Wz9lhScuSQ3laVVm/mcAnGaZSsbKIuQtK1leDwfTL+tn 9WjalVdSp6xBNDCKoAkRGw204wKbEOcF4hwJK4jt6TQpoUJSr/IuAn3em+kTXBCtnc3m FRxAme3nG7uP0F4n4K2uVOSnE0q2y/b1kCdvpmR+XrL1+2kRu2RC6DVdq1A/xXti+Rqd ps0A4aIEwGhP9SpdRs6k3rdbmD0OjmEIMhP/Rt6Bp5Ub7N+t7OHovl4YIYp649UQuduv a2y3HhdPFx0ztKhK+F19OE+JQyGPsLnoS7dpU804EbyzQssw3mKRaRIopDu/7byYblG5 fOgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=v6Bh4zrMNgwRf7ZBs2wbTAQM4cbF+DMRH9zgXKc7Z0c=; fh=xmBVGAu/tNyFRJM1+3yqixCQWsXntAPOMm2/BlHfgGQ=; b=W9BWGeHi3o4kwWG1MVmpGYJgsACAwUFXBmCnPch7ABnWI/c7XCLUC9HELqWRWCOk6K YgIfPSsp9BVlTPf9nVczh6lTRvImfx6Oc0vEzx3PxOJnuQVwMEeOVXjub+mahKuwU/Q1 j4PUvCi0CvPmInq85/K8Yzzvq4kMnEvXn1tm7gSyzqW4ujRzeXYESGHz/TqTnDtMQZJj NDy2yWnOnlkdZgJOLqLnMDr0Eq/DL6SL9a/72uhach2tAfY0JShUQGfRjkwigA5VD/Km SHkWeWvC8Amu61eawvwV41f6t00G5gb9Z75kRBRlDvlsM5OQyrwnaNaM2z+Mm9FQjXgv 6l0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-98819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u10-20020a05620a022a00b007883eead90fsi5079868qkm.473.2024.03.11.05.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 05:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-98819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7E14D1C214B8 for ; Mon, 11 Mar 2024 12:22:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82F463D0A3; Mon, 11 Mar 2024 12:21:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61CFD3D566; Mon, 11 Mar 2024 12:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710159703; cv=none; b=Smqh1yPln8Vp9ze4JKcA54UTo/sAobHZBHZbm1UgH2n2ASnXqTwOJxhTqTOE8lTEr20wSF8Np0FzPWY8dJLswBqhO54rmVSGlwnwfr3PGQNASe+7YVUeHnYRPnvOjVuvdRv56L01FLbNAnO+P/xMANs145BSNYjEN+BBusQmt3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710159703; c=relaxed/simple; bh=YWXmoG22Kj2qyiViztAEHNEe7bmLj3dtO38tSp891P8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TIgyRDviSJ99H4gCCuUX02l03fXY/OEEmj1y7QvGdUGk3BxAS6NkUV3Ugo7ZqDAdNTFiROMVsRsV//R9+TjTdRXzhUO//gJopV4lXUASu5zxNTMqbhhfz073wtxGM0dQdvUrdW+ykGpcnv00riHZJ97G4BrqrwBsYaN2Ub1XTzk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66175FEC; Mon, 11 Mar 2024 05:22:16 -0700 (PDT) Received: from [10.57.49.244] (unknown [10.57.49.244]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B4C773F64C; Mon, 11 Mar 2024 05:21:36 -0700 (PDT) Message-ID: <2195bcc4-e5e5-44de-93c7-667da1409de3@arm.com> Date: Mon, 11 Mar 2024 12:21:27 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/2] usb: host: xhci-plat: add support for multi memory regions To: Howard Yen , 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 References: <20240311094947.3738200-1-howardyen@google.com> <20240311094947.3738200-3-howardyen@google.com> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20240311094947.3738200-3-howardyen@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > --- > 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);