Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2612727rdd; Fri, 12 Jan 2024 15:51:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGT2FT5N4pJPrqtrNECLn7qRA7WJi7nqJxSsX/dDhQ/zYb50kwplmTQpDT0PA/qQSYeg63Y X-Received: by 2002:a92:d292:0:b0:360:7828:c653 with SMTP id p18-20020a92d292000000b003607828c653mr1951218ilp.1.1705103513668; Fri, 12 Jan 2024 15:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705103513; cv=none; d=google.com; s=arc-20160816; b=ywEoTUkm8kxQcKZDA3O36udEJwST3jiBoJ9+npcDUDK4yff5ls/afZnqF1MdkbS9ct IzpAmVJaDUGtjA7tcdwZPHSQspezc+bTWNIs4FvVBzmGZPubSHV0Kf4m5OfZdStkv8zG 1sL4vNm3pgY7QCmyS4JxT6/CLPmB5nCK6g6+p8lnC/+kfPUNN/cXvMPVRqiBiGx2Tsfl l2k9ROJS1HPBPAjxBCMd2MufKmtBFz7VuS2QZdrF3UNGx54+lnC+Al9reUXlm/McnkBs ZUwX/o/DUt2BUTOQwXfyo+hRO9h1LjfyJzUcAlTfXvZ0EyVz29uITHAhzAvJpJi+iqwo Bi0Q== ARC-Message-Signature: i=1; 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=kp9mV4Ke/a2nl4+Mq/TPZKlXYFvSYBSYldkMY7yov80=; fh=ovknJr9urMw3MUKEB0PXUiHgyJSr1UK5XycBNk86+4s=; b=gPK4HnL0pB6DgygAm6e/8Rj03lL/BtqCHDmhVANBQB/cRIQrmMlAn+VVZvXSihqnSt ITbqlzF+FOs6ST3BLdm1p2eiJtOZ7HbgBh5tHpIZINyrlXwQLZbEjsbyFNqdb5yzh+6i 1gTRZ5sSx9pOQrt7u6geDVGPibBoqVmsRbEEqOFrL+hNsOsiAO0AjMwwUG4TqwUGKrmI Uyp8+NflvIZxMljtsWf7ZP6S0osOBLRP8Keym5x+U07OJW6G9EIENi67t92KaWiRmrP/ 2VhEZeEjBCC6oJ+6vY+ese6saKMAuwDuEtLuGRpUARRYHnyXCTTivvpPmQLERDmR2zHF BPGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=myfLgcSj; spf=pass (google.com: domain of linux-kernel+bounces-25116-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x64-20020a638643000000b005b8a295f016si4224843pgd.64.2024.01.12.15.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 15:51:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25116-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=@google.com header.s=20230601 header.b=myfLgcSj; spf=pass (google.com: domain of linux-kernel+bounces-25116-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25116-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5099D286EFB for ; Fri, 12 Jan 2024 23:51:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1B461A703; Fri, 12 Jan 2024 23:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="myfLgcSj" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 2E6581A700 for ; Fri, 12 Jan 2024 23:51:39 +0000 (UTC) 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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40d5097150fso6875e9.1 for ; Fri, 12 Jan 2024 15:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705103498; x=1705708298; 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=kp9mV4Ke/a2nl4+Mq/TPZKlXYFvSYBSYldkMY7yov80=; b=myfLgcSjytfRZ6t/8DfAQPm/n1Cu0HBmrg+nJyGtRDDzjIc0W7QZE0UMBPAL9W4JHo YZidLGqeidk+xuvmLM+Rj6JnLh56L9zWvfKEauB4PO+UOXZrYFvhVzYDzLAMH7EC9otz oFSySZFEHTtUJQuAg2SpyD/5WVapblGxUqAzVnDs+Kg80vX8sWnXB/BJhRSB4lNMY4kz mk9zy6ipFE2KZeWwh7e9m2dqdt/bNSa3ZoAGi0/JRCo6e+8Tj9UxfmgbHDiMjFWETkJl xiXdMovx3hnFFssezLTz4Lf7TWEHmCJTddz6wixJ0pvTSc0k2tZ2a/8oRfBf5luFuaEb /nYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705103498; x=1705708298; 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=kp9mV4Ke/a2nl4+Mq/TPZKlXYFvSYBSYldkMY7yov80=; b=qobh9ivRKlMt0Cm/QFy5XvZQ3JiiWIhGOdiPSp/ZfAQNy6Xm7w6PEfhHn35wzsmNJL LUSzj1xy06ZB/YT2195XJsqpiEsJg1e2Ky7mx445RQ+HrjUOHrVusma1Ly36pPMgLegR pBd9Kbom7yKUCKfBIVLh58swYqGXync5n51Xx62izxs+wAR9WoW7RzE7V591psQdwrPF lfg/oG1XpODz0c0jVAVDyIKg6CYSgT1faYqAtRnsaeUFUG+6KLawAXIQbixDj2w4hsRV qYjBOQoaADbWbUiUvzg3c+AgB2e5I3JbYb6RLACySOmCoZfh5d5o0xn2q0eeGeMtrpUp 4LgQ== X-Gm-Message-State: AOJu0YwT32m/EHTogkLDTW65uiJD1nN/s+R3pYhkcZDiV5JSkBcrk2Hw X/MFH6I+1LaJ4glJsQI4wmFNe79sm3Cm/3fPn/3kdhOG7qU= X-Received: by 2002:a05:600c:3b1d:b0:40d:87df:92ca with SMTP id m29-20020a05600c3b1d00b0040d87df92camr30276wms.3.1705103498218; Fri, 12 Jan 2024 15:51:38 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240112092014.23999-1-yong.wu@mediatek.com> <20240112092014.23999-4-yong.wu@mediatek.com> In-Reply-To: From: John Stultz Date: Fri, 12 Jan 2024 15:51:25 -0800 Message-ID: Subject: Re: [PATCH v4 3/7] dma-buf: heaps: restricted_heap: Add private heap ops To: Jeffrey Kardatzke Cc: Yong Wu , Rob Herring , Matthias Brugger , christian.koenig@amd.com, Sumit Semwal , Krzysztof Kozlowski , Conor Dooley , Benjamin Gaignard , Brian Starkey , tjmercier@google.com, AngeloGioacchino Del Regno , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Robin Murphy , Vijayanand Jitta , Joakim Bech , Pavel Machek , Simon Ser , Pekka Paalanen , jianjiao.zeng@mediatek.com, kuohong.wang@mediatek.com, youlin.pei@mediatek.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 12, 2024 at 3:27=E2=80=AFPM Jeffrey Kardatzke wrote: > On Fri, Jan 12, 2024 at 2:52=E2=80=AFPM John Stultz = wrote: > > On Fri, Jan 12, 2024 at 1:21=E2=80=AFAM Yong Wu = wrote: > > > diff --git a/drivers/dma-buf/heaps/restricted_heap.h b/drivers/dma-bu= f/heaps/restricted_heap.h > > > index 443028f6ba3b..ddeaf9805708 100644 > > > --- a/drivers/dma-buf/heaps/restricted_heap.h > > > +++ b/drivers/dma-buf/heaps/restricted_heap.h > > > @@ -15,6 +15,18 @@ struct restricted_buffer { > > > > > > struct restricted_heap { > > > const char *name; > > > + > > > + const struct restricted_heap_ops *ops; > > > +}; > > > + > > > +struct restricted_heap_ops { > > > + int (*heap_init)(struct restricted_heap *heap); > > > + > > > + int (*memory_alloc)(struct restricted_heap *heap, struct = restricted_buffer *buf); > > > + void (*memory_free)(struct restricted_heap *heap, struct r= estricted_buffer *buf); > > > + > > > + int (*memory_restrict)(struct restricted_heap *heap, stru= ct restricted_buffer *buf); > > > + void (*memory_unrestrict)(struct restricted_heap *heap, st= ruct restricted_buffer *buf); > > > }; > > > > > > int restricted_heap_add(struct restricted_heap *rstrd_heap); > > > > So, I'm a little worried here, because you're basically turning the > > restricted_heap dma-buf heap driver into a framework itself. > > Where this patch is creating a subdriver framework. > > > > Part of my hesitancy, is you're introducing this under the dma-buf > > heaps. For things like CMA, that's more of a core subsystem that has > > multiple users, and exporting cma buffers via dmabuf heaps is just an > > additional interface. What I like about that is the core kernel has > > to define the semantics for the memory type and then the dmabuf heap > > is just exporting that well understood type of buffer. > > > > But with these restricted buffers, I'm not sure there's yet a well > > understood set of semantics nor a central abstraction for that which > > other drivers use directly. > > > > I know part of this effort here is to start to centralize all these > > vendor specific restricted buffer implementations, which I think is > > great, but I just worry that in doing it in the dmabuf heap interface, > > it is a bit too user-facing. The likelihood of encoding a particular > > semantic to the singular "restricted_heap" name seems high. > > In patch #5 it has the actual driver implementation for the MTK heap > that includes the heap name of "restricted_mtk_cm", so there shouldn't > be a heap named "restricted_heap" that's actually getting exposed. The Ah, I appreciate that clarification! Indeed, you're right the name is passed through. Apologies for missing that detail. > restricted_heap code is a framework, and not a driver itself. Unless > I'm missing something in this patchset...but that's the way it's > *supposed* to be. So I guess I'm not sure I understand the benefit of the extra indirection. What then does the restricted_heap.c logic itself provide? The dmabuf heaps framework already provides a way to add heap implementatio= ns. thanks -john