From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2294FC71153 for ; Tue, 29 Aug 2023 15:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235375AbjH2PEw (ORCPT ); Tue, 29 Aug 2023 11:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237174AbjH2PEt (ORCPT ); Tue, 29 Aug 2023 11:04:49 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200BEC9; Tue, 29 Aug 2023 08:04:47 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id C41C46732D; Tue, 29 Aug 2023 17:04:42 +0200 (CEST) Date: Tue, 29 Aug 2023 17:04:42 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Tomasz Figa , Anle Pan , Christoph Hellwig , m.szyprowski@samsung.com, mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hui.fang@nxp.com Subject: Re: [PATCH] media: videobuf2-dma-sg: limit the sg segment size Message-ID: <20230829150442.GA3929@lst.de> References: <20230828075420.2009568-1-anle.pan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On Tue, Aug 29, 2023 at 12:14:44PM +0100, Robin Murphy wrote: > dma_get_max_seg_size() represents a capability of the device itself, namely > the largest contiguous range it can be programmed to access in a single DMA > descriptor/register/whatever. Yes. In a way it's a bit odd that it ended up in a field in struct device, as the feature might actually be different for different DMA engines or features in a device. If I was to redesign it from scratch I'd just pass it to dma_map_sg. >> Generally looking at videobuf2-dma-sg, I feel like we would benefit >> from some kind of dma_alloc_table_from_pages() that simply takes the >> struct dev pointer and does everything necessary. > > Possibly; this code already looks lifted from drm_prime_pages_to_sg(), and > if it's needed here then presumably vb2_dma_sg_get_userptr() also needs it, > at the very least. Yes, there's tons of them. But I'd feel really bad adding even more struct scatterlist based APIs given how bad of a data structure that is.