Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp441999lqc; Fri, 8 Mar 2024 01:54:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIF4YVddqeofRvuL7Tm1G9XsnLoKSllscMxvK3+lDhNZ4xoBkQM/7bQkSbxKtizmYJJizLbUrHo3ZpPIyfL6tJHQGqcZd1VmkhXY3xwQ== X-Google-Smtp-Source: AGHT+IFqdgvzTLI4pJTFPndaWzHYtAjIBqtK1ZbCT4x4dSA/DavhT+VADpaCbU07WFI6Wp75YZBh X-Received: by 2002:a17:90b:811:b0:29b:9e1:2fb0 with SMTP id bk17-20020a17090b081100b0029b09e12fb0mr5736523pjb.0.1709891672297; Fri, 08 Mar 2024 01:54:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709891672; cv=pass; d=google.com; s=arc-20160816; b=y9uUr5n62vxUtzA16cdL8MWsgD+kV0dgkqhLYzO8k5ACp34XNjME4djRypfgo0AspA guO0CV0kSwqjGHlmc0qsOijkfDmS0YXCGJXFNnt1YJRaDIvU7URN5irkLHa0WIzO6nFJ AorVfqbjwIGfC6Pb9S2p3GOSwciie66EuJrEJAyjeBfvi93H1dciCfE0yAWEALxWTSy6 rvmim9m9ed1NgfBQ7bf9pgDYNxSv85/dMGqftUL+2Xg8+KCFvHcFqparcH9D/YdiJgan 09OnzHYwm3JRIFBqKkUQSiKaQAK3BrilMbNqh0cU6WJ5WMcWn3EI31RLom/hC3VYGI2X nOlw== 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=kd9b+xnVrsV0VnvP5BBobh+7armz3SPZmewGeAELg2w=; fh=NbyUzACeGykFDohATR7iP2JKQqi6ry0gd+NCRkYmpt4=; b=z9lIKzjHyZ8bt1lfCf7emY9bkCzAXHyb76vgWXsIxU/YdQwLmeiOWvQ3a45ecBmxCy Ne/GexeboeIrVgVRIHIlxdIA5usuHJhJmdPd/M+Gbrkyf58KVr1ZmlSmXc+OHm9i7x4J 2/iLRAJRxW0z/JjTCGbuwX0LdGoFdxg4ft4kMQ/r712wdti5k76fePfOururuI5flIg/ cU5ahoy3Qkbfh12Q8r//tWD6TfQ3DWcDPqdEhhq0HER1rD87RhoooR2c9EyxhRvP187u HfH6LiOdj5dztTf7R1EVzt6t6eeog5HZ2OhLRYijuJrPHEmJyPZ07g9rKNVVVW9IDFB2 6ANw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ytV3gF8E; 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-96779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96779-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. [147.75.48.161]) by mx.google.com with ESMTPS id p9-20020a17090a0e4900b00290b1bfb082si3412545pja.130.2024.03.08.01.54.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 01:54:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ytV3gF8E; 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-96779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96779-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 AF782B20CDA for ; Fri, 8 Mar 2024 09:54:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47999535BA; Fri, 8 Mar 2024 09:54:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ytV3gF8E" Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 0021C535D3 for ; Fri, 8 Mar 2024 09:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709891656; cv=none; b=VK96tYv+92+G37qmC4wZeCkGA/03mcbGyzt8PjT3OKnzqdl7N/3Ym1T2B0H6QibWY5WebnzzkcC2I0zEPnSmkRGh+nnAb0XCT6EeTCPiIqLw1uKWeAtf9szv+cvFhek8+khHBoZSbt6YPUGiwc8H8AeQhckLnhsNb1YbTSH+aQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709891656; c=relaxed/simple; bh=PSSmdFEKXbQoDoLCkYh9gWPYZ30jQDOHJ1WglWyUdcI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Gz7FyUZJ+Ek+r/kno5tqMwJLWfm5uh52/B7LyqC3qdc7EfxWXoGjL6GZg28t0sbifXN07sm+TZDhTeQSMwpBcuJRYO8JBXunXvyRv15pe4bAQ1YUkVQILtLW0Yv3wuhbRqUp8R3/Qku0MmuBa4k/bi6rd0kSiq3vX6AUQ+jMV00= 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=ytV3gF8E; arc=none smtp.client-ip=209.85.214.202 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-pl1-f202.google.com with SMTP id d9443c01a7336-1dd129acd2aso18372115ad.2 for ; Fri, 08 Mar 2024 01:54:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709891654; x=1710496454; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=kd9b+xnVrsV0VnvP5BBobh+7armz3SPZmewGeAELg2w=; b=ytV3gF8EP34hyIMMZ2QJseL3LPVTrc2NDBdolJoM4xGO7CB8WcamB2r4NoVeAzmEYx Qz5UfThOrbqpQitYDhQ5VtwVcaDZFcIhShDnTgrBFxvvqzyf+LGvd8XsA3dEut77EOi4 ZX3iVd0yYLeHSk1kigdvZfQYJ3ImxU1bH6aK1yqaU/17kosDWPtgIQd4filUi4zIzVrr ixVjafFgRONl5mrgwtIg47RlX9g3waUeFMZGMQ76NFY2tUuCIImG6JHCYrk5JGrn57qD SR8mm9LB7PqRfjWmBbS4trJ9PMNhmcrQOnOA4QtTU8sHQW0JPR+XA+fuuZvHwSC5Wtwj EFww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709891654; x=1710496454; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kd9b+xnVrsV0VnvP5BBobh+7armz3SPZmewGeAELg2w=; b=GwzOQscCJS2aQNSnee4tT2EcI21D3UfCCnuisuw+ADuKCPvbNwhSWmvVfxFW46fuBg bWMELkQyMUlUaBIUgoLT4+Yhw52vGgPcFQSfy4D24kvWFcX6mBjHhgRfOnxyyMIhdSkF 0FrmqKEpGxdiYnEg8oa0agfRbn7wKvpO8eQXIDDdFsSH6y+ezi6Zs152qhJn3ghgKt2+ anl1eSwwFR3g40f3FcINTVHDCN6/kk5w+EQlHn1cIYItD2J8A73f4wfgjSBDKNaQZxAJ jgul9C+mLFJffHralFmId4Zr2X7Vl9HuWk21L+C3LSoxlwDvNvZGXDc/df72pTmcXGDX 7iNg== X-Gm-Message-State: AOJu0YyXtusk1/0a8SeKOF0v67xa8mquIgLpQ1Q87sIp3gfiY3DUAQh8 ZMHhfmQvoOPOFFp0+Wim5xMTlun+Qq/mfDhY0Qn12L3iovQPK5jo2VR149A6IU9H4A3BgCOu+4F bTusPwm4pfooPBw== X-Received: from howardyen2.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:16f7]) (user=howardyen job=sendgmr) by 2002:a17:903:22ce:b0:1db:f7e5:afd2 with SMTP id y14-20020a17090322ce00b001dbf7e5afd2mr717431plg.12.1709891654099; Fri, 08 Mar 2024 01:54:14 -0800 (PST) Date: Fri, 8 Mar 2024 09:53:18 +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: <20240308095320.1961469-1-howardyen@google.com> Subject: [PATCH v4 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 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