Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp616149rdb; Thu, 1 Feb 2024 20:41:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWibFFTHJurjXwt2C2Eyf0A3uS8hkFjsg7OAyeSh4BYyxELripzH6QWb+MDuwJvDzRZVeu X-Received: by 2002:aa7:d410:0:b0:55f:e653:9b8c with SMTP id z16-20020aa7d410000000b0055fe6539b8cmr704664edq.19.1706848898552; Thu, 01 Feb 2024 20:41:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706848898; cv=pass; d=google.com; s=arc-20160816; b=F4NBb4vxyfn24txsKMCWGGkcxvG+r6gxPKsdFjd62HSAuCrzvaSqfsszSsjsv4j6n0 mpTmL+7fUbGVzU0P73KzSzG2sdjYi6Bs5GE2OnwNnJSTGeqet3WNpwg8Ff3VQKBumTkE w2GogkgfU/4Okc2HmZsx840wgmWF4QexgjuGy7npXBYfoVGWIm8wDKkfi3QANdwKjrbh przTU5Kk6gnVoJK3g3RbgZnuN7/fpuV9Mg+tXDZfieKzuD4vrZqwsF0MUSWQguxVhicw QuEyeXJLfYH20PyRJjubdahIrvz5LAJ90ys6o/ziY2z4TOMYRyO/435qsfytQdyGKCcb 7e5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=MR2/y2vEPhv8eBcksIZP96OOa1fhQ1JeijHES+W35BI=; fh=JV4fdEejuLTnFaP1Oq2DsXNy8DchTqbeNiLow8iGk1E=; b=t1gr+XUVaMP5M1NHHw7mfIwe01OzybCbkYrOKbulWwBZMaPWgAygObj+TeNEXLc18e FVWu144RDlQpKHiAE0IRHuzczzuDoNbghDKhAhQeYf1SaxehOgIi3H2PDKvk3YyybGjL S6W0dxSR4Mkzi7bXNXYp7jS+us8PP4n8p1zlYbiyqx+NBQXyH0J1Dm86FD5U0ToEFGUr L6NC8yxinKya2Ia6lejB+tFtvtrpJLxqiLkGz2fd6mrhjE1XBviNSL1aMSBDGMJnclCU /oYQCUlBEFf41zwR9Pl+A/7YakEUioMFFFBdeBZ3nG2458XaMad/exE3VtwGvdHRzdj2 yMDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gk7H7qJm; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVe3B9r/QBOwXsjnnsyUbtTGIM+BHtWQg5/KtBmHVL73uX2pIXl6OovBivQ2dDnVCqjwWpFsZ0kndNqPS5d9/MR/ejq0N7cOx+zj1uMfQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i26-20020a50fc1a000000b0055fbd85ab50si476834edr.315.2024.02.01.20.41.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 20:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gk7H7qJm; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49193-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 096261F2547A for ; Fri, 2 Feb 2024 04:41:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0468EF9CA; Fri, 2 Feb 2024 04:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gk7H7qJm" Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 7B413F4F6 for ; Fri, 2 Feb 2024 04:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706848875; cv=none; b=pFLtp11AwTeBhEsiUcar7yc4iB1fv4Of4W7jwVR0u9LyTD5ThUp4926nk783uMNKqa1j9UmtxVZirI2ptyrP1zJJFXVe3y7JvkHTvVaHJ5P7HqZbtpdgyQ4KXA3P4XX+Laaodlf7G8ULjLwWaNFEYIOggrNdiHu/AmMrBAWxSek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706848875; c=relaxed/simple; bh=tcEH8y9ILQRfJEiztnFPBtbL/SdrVqxuQ6BXuMiY/J8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MtM3HmWEk3FUYd2Xqo/VDSlbd5eafUrnm9opNpcGiO1B0UNCSs1VZKPa2AoLa9C4kVllVWM0tCQeYHTt8aAl3uNUvCaBz28RwKFtWZo4uHCXPxs6r1bgOExT+wuhvlJcPCHPJ1F2OWJYSTRcXVeZUkGXnADQqPiOVCXJp81EL84= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gk7H7qJm; arc=none smtp.client-ip=209.85.219.179 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=google.com Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-dc236729a2bso1645576276.0 for ; Thu, 01 Feb 2024 20:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706848871; x=1707453671; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MR2/y2vEPhv8eBcksIZP96OOa1fhQ1JeijHES+W35BI=; b=gk7H7qJmWRxTONWlFZAJzlQt8r34Dwj0rA5axTYjyfswVxrTXK3t/vTla0eSJNE7oe kmxW+A30ZJWLmH4bNZr3rRg4gAfmbChbyPVUPWrQr/SSnXA1f0/oBq/sxBQlvq4iWPGo KkdTsHvsNuJlyi3ZDGMXNU/Nw9J6dfkk+364IRxdlY5B2Voko9WNCDKug4lACjHca+ph rU3U3rs80yaiFzCVRB90djYY6gZetIyqLGkOSb8GVKlU/XaP4U9PfpYVSvUwWW1dtrzB 2uH+1PrG0VnJqW54G5BAJtJ2SfHDT1fyTqIR9qLeMsuWdkGFB7DFL4rLFlRkoeVJvFjH uajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706848871; x=1707453671; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MR2/y2vEPhv8eBcksIZP96OOa1fhQ1JeijHES+W35BI=; b=I9xVAC8rt6LvsN4j3BMPrL6KHgZtekJ+g4BtrDZaA60ax169fxL72CNUsKFYn7gBEE rTnExYKweEnAhKl55+fCEqrxVuMvReL7iizotzeg2vPQ0OxBRGoj0OqDNlAZZgNagFPN NJ1l/eYgywslXST/nDK968CEYNGURqyigoAjdZG9Uzwk8SmBCDv6DDz/f1kLddz1R3N9 MhH2Q1Lw/vbNBxp+U4XQXeZi9uwlli2JZVcLrT5337jL9yISWCNofUM3boGngWD2IHut sAGsLel5jGJPbDMKPZaiZldbuXXjCBgzKkqw4T4fxtM1dOkjULSQ3fgHi9ZxvI7Fj7a9 92Mw== X-Gm-Message-State: AOJu0YyUyJdAF5wwXWK8hAJpvKR50FjJswqrJgs+inwUD6dj0kGIZtrK FE/A+kAP+4nCz2XLRJaD7yuiD18TBKeYjDlDWB+aLxfbg0heyU1VIyP8AI4ZChriXeGtReJM5lt gzFPBB5RGWOmndydwaLbML4n5883rzseK7jYU X-Received: by 2002:a25:9701:0:b0:dc6:bb86:ea11 with SMTP id d1-20020a259701000000b00dc6bb86ea11mr4583776ybo.19.1706848871267; Thu, 01 Feb 2024 20:41:11 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240201093515.849873-1-howardyen@google.com> <2024020156-reshuffle-salvaging-8161@gregkh> In-Reply-To: <2024020156-reshuffle-salvaging-8161@gregkh> From: Howard Yen Date: Fri, 2 Feb 2024 12:40:59 +0800 Message-ID: Subject: Re: [PATCH] dma-coherent: add support for multi coherent rmems per dev To: Greg KH Cc: Robin Murphy , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 11:41=E2=80=AFPM Greg KH wrote: > > 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 =3D <&reserved_mem0>, <&reserved_mem1>; > > > ... > > > }; > > > > > > When driver tries to allocate memory from the rmems, looks for the fi= rst > > > 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 sens= ibly. > > 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 I'm considering to modify the change to 1. Move it into the dma_coherent_mem structure, like HEAD mem0->node This case, if I check list_empty(mem0->node), it would give me the list is empty, but actually there is one rmem. 2. Replace the pointer to a list_head. HEAD dma_mems ---> mem0->node This case, if I check list_empty(dma_mems), it would give me the list is non-empty, it matches the actual status. So, the 2nd looks reasonable, I'm going to upload a v2 patch with the 2nd approach, does that make sense? --=20 Regards, Howard