Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp290732lql; Mon, 11 Mar 2024 02:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmjVr/s1mzRPP6l2S453Mu2vpuGtdV+V9+jMW+WTvphTW03FfYDpqTdiDbInuaZ11Glvga4viOCJ4IFMhhFuDrAmCfLMY/Cig5OT+uyQ== X-Google-Smtp-Source: AGHT+IFCsksxwgp508auYEuZRc0GynmPxqKAesh3IFugeUL63zCOhZSnYd7kTxIDLgTMW1+uVSxP X-Received: by 2002:a05:6808:3994:b0:3c1:b335:12bc with SMTP id gq20-20020a056808399400b003c1b33512bcmr10371825oib.5.1710150614821; Mon, 11 Mar 2024 02:50:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710150614; cv=pass; d=google.com; s=arc-20160816; b=Ut+jjE6wSqkKNVo3jp8/6fjc40hTC/90XlvD9NyGm3Lw8el3/VHqlIKlYG3Dt1EIhl lOaMRojgY/DP0pAceTOAUJ0no2DHPZLw0aO1o/6GQsfBpyvqXpsPCeFNhXedqES/O4Lg oIJeoLahdfBL/5+Qjlaj/piRoFny5skjbVWku/r88COxbJBDl1aEKN1WAkvyAxalSfVM TrIPMbQzHqSk2k1ekFH8J3dOZ/5Ykih3s6yuCGf+SczHK7V82RWlWqPIf2Os+zu2HWc6 w+FK0vxg6HFvC82aGHnNIjM0CbgwqSnrvSU62u6NsUSjkCJukJGizToW1yobckcRrHeI Q40A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=81noNCiMPxc7RXsxTs6R3a4olVVx7LQELUcM8AsXs8I=; fh=NbyUzACeGykFDohATR7iP2JKQqi6ry0gd+NCRkYmpt4=; b=P0xg7Sn6FRZ1rVdGU9Z93uwFSWDwCQ3bamEckPYzkIpeFQ6VKz40Po8DfMU2KTsJEe tAOFCRCETnd0O1SqJDT1kdMnrMYwFDi9gFpS3nYaDMYQpxGBj5gy1Tw+tgbI6ENee4yL jGU36k0Q10XXIWA8EPY0ANmhE0FRM6+JVfjqQhZWa6PbBdAPqw63qpYr4FyfWEbVm7Ek l6uV056B4LDI6V8ewsUyMuXj1izDTheT+TdqME3I/+uMTijmiG+Op1DLWCodCoBpv3ya XOu9UTOmGZ9KkPqJKZMsw3wBECVBV37WcqN5YkC9fYMeGmA07jNoS9fQeTQFNElbuh3u YcOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DXmn2+wZ; arc=pass (i=1 spf=pass spfdomain=flex--howardyen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-98649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v16-20020a63f850000000b005d8b5979996si4634164pgj.492.2024.03.11.02.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 02:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DXmn2+wZ; arc=pass (i=1 spf=pass spfdomain=flex--howardyen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-98649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98649-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6247AB21556 for ; Mon, 11 Mar 2024 09:50:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CB2D208C8; Mon, 11 Mar 2024 09:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DXmn2+wZ" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 8DEF118658 for ; Mon, 11 Mar 2024 09:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150597; cv=none; b=hgPxL0nxbbQ133/LEvbmm2VRRQvUMOOf/PJ82aPEKISJxS97RxsxRHaUMVw1Z80D5f0clYbUjMxApVqrP3C/L0y6YsmRyJjVpf65jpe77BI6+zArCUhov14iZD8JbDqlYNLZqEa7yb+kH4tlq//kz8T2fe+etuahoalZdqmugbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710150597; c=relaxed/simple; bh=AToYTf+vDn2ZCE/0NLRzCVPVI2xnwx7R0rBGKkMz5O8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=UVOK/XszRZDbBCFxbNtZMM0P6o2J5PVchtnDSN8cuN7LsjiXnQbN8sm89rxQmlRQ5ya4Fiz+060O++zSIrSEzdNkkV5NYqktYYRziWc/cKEIWVyonz6fhhk+ENewDXKlgVQKT2gwtDinhY8sMkZBP57EzEUV632PY2R/OxkeEGo= 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=DXmn2+wZ; arc=none smtp.client-ip=209.85.128.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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60a0a5bf550so45515197b3.3 for ; Mon, 11 Mar 2024 02:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710150594; x=1710755394; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=81noNCiMPxc7RXsxTs6R3a4olVVx7LQELUcM8AsXs8I=; b=DXmn2+wZ2J1o8Fb+f6BGl/hzkXdgp378FQ0n7dsounKQILrPkAe0HM5vHfke2JCxTe +8Iqzqi0Mw7Qv6m1WsW2oRwk4o34zcSqtZl/i8QVhe6PxZqf84cl9FUvSBrA9ZV2YjkM i7eZvzvGdxGjEZJCm4o3J789ejOHsZ37b3mHKfAMFi7yJcXQkJ/Wjd50b1pnNSEzfARw Jud+NEinq2nIJbOJXr+X9F9dum7I26CgqYyQip7H913QoivAXfFUfs2PmkqeRAuBO+UJ y6HblrAbOAxulwVoVWvusV4NHlnx+GZRT8F6FYzkAFfkjZiUDK8d1s7V5AsVZ5xcNPwc fDgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710150594; x=1710755394; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=81noNCiMPxc7RXsxTs6R3a4olVVx7LQELUcM8AsXs8I=; b=KcrYglOR76pUB/tBYXclnWbUaG7dUw9E8rgjHTWGXVErqwNUmFtN+QNMsjBn4BbX3i n+5woIFVm9/L71evjaMxdsfUf0eONMwGr5kwk3Of7vTK431duHuNnFcPGlHvr/XxSUsj qU9krSiAICjjQ0Ibt7pCKsygZ+wD+Wvbr0tzyuUbZWCsQWdEeKm/km5g+QKCb78G2SMe /aTEhDJoHtoFRpM8u+lpmEzxv/sH8Je/scpRkKGip0TEj966oEs6e3NgwBlShkllc52p LkaWUP5I0w3NBqLM0iKul87IvaTlVvsogY7WH+LNAeyDEErYOZtyG5ft+BVXy56H89eW CGxg== X-Gm-Message-State: AOJu0YzzB9w+8KU9B2nRzEG3PeSudNiBF/+JHHASYC9iE56sAyx+9f/z qJd1z8QQD2nimedG18Zc7juzdyJCHgts1zhkXO+8tKPA6YifYpcstjbbHa6O2EDeeo3BSG6nDqh iqrh+8WQBOw7W+g== X-Received: from howardyen2.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:16f7]) (user=howardyen job=sendgmr) by 2002:a0d:dd04:0:b0:60a:25ce:c165 with SMTP id g4-20020a0ddd04000000b0060a25cec165mr1150328ywe.6.1710150594639; Mon, 11 Mar 2024 02:49:54 -0700 (PDT) Date: Mon, 11 Mar 2024 09:49:45 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240311094947.3738200-1-howardyen@google.com> Subject: [PATCH v5 0/2] Add support for multiple coherent 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 Content-Type: text/plain; charset="UTF-8" In the system I'm working on, 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. I tried to implement it in a generic way and propose this patch to give it the ability to get the memory from the other larger memory to solve the issue. Changelog -------------------------------------------- Changes in v5: - Fix build break. - Use of_property_count_u32_elems() instead of of_property_count_elems_of_size(). Changes in v4: - Add the driver where uses the multiple coherent memory regions. Changes in v3: - Re-org the members of struct dma_coherent_mem to avoid additional pointer arithmetics and the holes inside the structure. - Use consistent naming of return value. - Re-write the dev checking statement to be more clear. Changes in v2: - Replace the pointer(dma_mem) to a list_head(dma_mems) in the device structure and initialize the list_head in device_initialize(). - Modify the required changes in coherent.c. Howard Yen (2): dma-coherent: add support for multi coherent rmems per dev usb: host: xhci-plat: add support for multi memory regions drivers/base/core.c | 3 ++ drivers/usb/host/xhci-plat.c | 19 +++++++- include/linux/device.h | 5 +- kernel/dma/coherent.c | 92 +++++++++++++++++++++++------------- 4 files changed, 82 insertions(+), 37 deletions(-) -- 2.44.0.278.ge034bb2e1d-goog