Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp256191rdb; Thu, 1 Feb 2024 07:43:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGozhvpVrX2FDsmOyrslmsDpnDjlzn0WtCnvjFjKuefWjxYXUfVTWYlR0CAaX/oCWgi4zFd X-Received: by 2002:a05:6830:13cb:b0:6dd:e6f7:8e3e with SMTP id e11-20020a05683013cb00b006dde6f78e3emr5481535otq.15.1706802218538; Thu, 01 Feb 2024 07:43:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706802218; cv=pass; d=google.com; s=arc-20160816; b=RRkovJv5uwLE45/FRlh8GWOTAbH6G/HDYlBoRzklfFZ3MfWgJyWSiJ0ceoQQOV82GL lRSBYBpe+8+hHOP7QT+RhrsHNrI0zAb0JzZsbyvWPNtSGu6ur84SJk7PBfQnjBL9rpZH AKrP9He7i5AVM9DNKwWWE3yOJ96Tvsj3AWbRoyEDpKP8u9ZrjqRJEyLxWlDvpS4cMJyn PF9MuLnRSU+8WuYlpMwtVdemviCNg+pWalHJ3hBFpZw0LoXnPUEpzaFBE+aNMIYG5BJD SXZ2WlyCOelQax2uOJjXs23TjF+1EN8OD/pV4XnC9m+yfCtRmHPzHsUK8SQRhDHTg7CA xyjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FTpGQNY/g/skVD5oD71JcIU9zT3a99G0PcgsMENglkw=; fh=zZT9RqXdJAt2Nrm0CChCCV6ykM5JZazb8hquCqc51yw=; b=OqzV7jVdxpnb66iHMaWQQenoRXZPs9lIsKfcdNyi6gmh3U7/fxvxb+GWtNdB6aSWHu 31CleyW3Y16IuSP7+yl8ScyPSdxJjYX4v5PMbIiEgkeH63QfKfEwbjpdtLkgQuRvqye7 hb+r8iAJgm7Fy3vOqULTXuHCBs+iWUbYWBCciNAOGbn3H42q4pg70JgmS8DCHf1eovBr aVcZ11nxhF8zUu+v0G51a8CUNNN7KEq0iGZ48E6C7egd29Or1oSavvrUWUTf1FgUHeU2 AmMjsso/6FT4ouQbilbkaGMKxUkX1uvMLe7XEtlddAVFLv9n2mYaZXvuqtsHajhKUqzh u1Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jgce6kue; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-48423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org X-Forwarded-Encrypted: i=1; AJvYcCX66BbM8CaI9IGr76TIqsepobSq5lDjRczBC1IxAK1+/RLvGHyAlHTGRCiolV7ho9iQJB8d5OSOMXZQPXlMLtwf2wOCOGvqExabs+V66w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h6-20020a656386000000b005d8bb714e79si10180862pgv.586.2024.02.01.07.43.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 07:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jgce6kue; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-48423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 28997295620 for ; Thu, 1 Feb 2024 15:41:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92DC06217F; Thu, 1 Feb 2024 15:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Jgce6kue" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B05614D9E8; Thu, 1 Feb 2024 15:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802092; cv=none; b=KIotKduXjAhpTTXkOID7X5+QorV7DDLxz1CpjGWzhRux6hGmqeJ7jrRUFGj7eYNzjFR0wOUenF9S0MyNzoqh+AtJjyXnifaSYml8qU23lB1QcGnAfUWIwtbkMB6cicXKm9+M8BOHYbQ9JRJm//ZoBYk4Q7llkr3XelF123AVd/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706802092; c=relaxed/simple; bh=uOhLn9KGWSsPb/i3wVsc6qllskkS7kDtVG0rkTIgNCY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KhDFlPY3YSGhDeQWqCltiqacaIHzjE7Amn0k48/ULmonpOWtn6Ks2cpY4/+LiYzA1hQXoBDR/ZtJCRoJ7MvsmBJHTkBZ8nyzjbfSrMsv9EdCCu37Yml5jvAZiuf2ONydvIQWUEiFtYPhKWN4nwA/ZEVZY5MGLqtmjPCjZ2tFJWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Jgce6kue; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18876C433F1; Thu, 1 Feb 2024 15:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706802092; bh=uOhLn9KGWSsPb/i3wVsc6qllskkS7kDtVG0rkTIgNCY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jgce6kueTjW7XRyvtrePo8xS39zvtMxeRTwK65el9+Gf7MQpEnLDdMRu33TKtnK56 /RT+fTtHgBQTEWOZNf65lIb4CdqlsWYP5pGhcXNlhm2FZ6AFPUbv9MW26eGi8qFFEi 6Gg2gedX2zr19gPZk9R2twYUJXLjb1aK67wKUPDY= Date: Thu, 1 Feb 2024 07:41:31 -0800 From: Greg KH To: Robin Murphy Cc: Howard Yen , hch@lst.de, m.szyprowski@samsung.com, andriy.shevchenko@linux.intel.com, petr.tesarik.ext@huawei.com, rafael@kernel.org, broonie@kernel.org, james@equiv.tech, james.clark@arm.com, masahiroy@kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev Subject: Re: [PATCH] dma-coherent: add support for multi coherent rmems per dev Message-ID: <2024020156-reshuffle-salvaging-8161@gregkh> References: <20240201093515.849873-1-howardyen@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Feb 01, 2024 at 10:45:30AM +0000, Robin Murphy wrote: > On 2024-02-01 9:35 am, Howard Yen wrote: > > Add support for multiple coherent rmems per device. This patch addes > > dma_mem_list to device structure to store multiple rmems. > > > > These multiple rmems can be assigned to the device one by one by > > of_reserved_mem_device_init_by_idx() with the memory-region > > declaration in device tree as below and store the rmem to the dma_mem_list. > > > > device1@0 { > > ... > > memory-region = <&reserved_mem0>, <&reserved_mem1>; > > ... > > }; > > > > When driver tries to allocate memory from the rmems, looks for the first > > available rmem and allocates the memory from this rmem. > > > > Then if driver removed, of_reserved_mem_device_release() needs to be > > invoked to release all the rmems assigned to the device. > > > > Signed-off-by: Howard Yen > > --- > > include/linux/device.h | 1 + > > kernel/dma/coherent.c | 66 +++++++++++++++++++++++++++++++++++------- > > 2 files changed, 56 insertions(+), 11 deletions(-) > > > > diff --git a/include/linux/device.h b/include/linux/device.h > > index 97c4b046c09d..c8682ee507cf 100644 > > --- a/include/linux/device.h > > +++ b/include/linux/device.h > > @@ -751,6 +751,7 @@ struct device { > > #ifdef CONFIG_DMA_DECLARE_COHERENT > > struct dma_coherent_mem *dma_mem; /* internal for coherent mem > > override */ > > + struct list_head dma_mem_list; > > I'm not necessarily against the idea, but only if it's implemented sensibly. > If we're going to have a list of these it should *replace* the existing > pointer, not do this weird thing with both. Agreed, it should be one pointer max for this structure for this type of thing. Why not move it into the dma_coherent_mem structure? thanks, greg k-h