Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp347401rdd; Tue, 9 Jan 2024 06:10:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHmDCgEHqnnexpN7lxLUZ9N9oVcM8qdwseX17CJYu1mmCccjvjFR5NmdXwTmAG06vE6HG9 X-Received: by 2002:a17:903:2308:b0:1d5:5de4:a944 with SMTP id d8-20020a170903230800b001d55de4a944mr541623plh.35.1704809443225; Tue, 09 Jan 2024 06:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704809443; cv=none; d=google.com; s=arc-20160816; b=E0nmICKbQkg5aHEytBwcb1wj6iNwpkRAn1qxwNpfFayRXLc8SfrF6/JiT6xYj7jHTd q2IiiTfsya5342oFJi4je5n1tfrlrcsgn37utVkjb4z3DeF4yQcMXiN77q8VEmPMAoPe UK+ivBZdkY3ipNRFRklBgQmkT8VkoWrlm7jn52MMXEk0EAC/7AUJAOgFCVLnWZX4gmT/ CvKvvCRaCjrtHBooxT4sUWYnJZIHVEztAjAQrxArC7h+5Yu9JWs921T9EkAL9BohxAnR 6L1j4t5c8ovu1E52mBOr5KiwB5nuVSdPyYvZaXG0V9bzD9Ow+2iFHhtLlcIPgshYk7i8 oggg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:in-reply-to:date:subject:cc:to:from:user-agent :references:dkim-signature; bh=45dZfngt7soeD+ZIJlrGsZp/t2apYjYjaHZl9vFWmeE=; fh=se+WXFMfTf8x+bcDRnuDj1QoqpWX6kkXMfHrYg47VrE=; b=PeJgd/LhT8n7gW7UA1/YcGAS5lscGjXwCd3MH3I6mvtXDcub2azkjIC9awFU5TlBA7 dwy9CT5zS7u6Cj8gcVtlrxvLDoF1TVWqMUnspUdfYeQj8Ublc0q8ux8jL9vmgIVGxN61 XVBPcYvVzB59Tg5Xrd7KAmnZAeNwizUC+M3k4KfvXJIC7XpTz5BdQHIRkLcpL5pezCnr H/4yVBD0R8t5tqL82Pr6kPGCv2gVcS9yqF54Jshu/x/kBWN7bym2wW9CIEt9Wl7yvEI1 QBFXOLEI5z4AjF9hFVuDP6K8jWjcX+nngr47U/MEaNErQ02CCKjzMWdxELusJKT8/00i AILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tkos.co.il header.s=default header.b=aAyidV3w; spf=pass (google.com: domain of linux-kernel+bounces-20952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tkos.co.il Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w5-20020a170902e88500b001d3e2a6870bsi1585167plg.419.2024.01.09.06.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 06:10:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tkos.co.il header.s=default header.b=aAyidV3w; spf=pass (google.com: domain of linux-kernel+bounces-20952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tkos.co.il 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 DE49BB24A19 for ; Tue, 9 Jan 2024 14:07:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C5F3B39879; Tue, 9 Jan 2024 14:07:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tkos.co.il header.i=@tkos.co.il header.b="aAyidV3w" Received: from mail.tkos.co.il (guitar.tkos.co.il [84.110.109.230]) (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 51C4339848; Tue, 9 Jan 2024 14:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tkos.co.il Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tkos.co.il Received: from localhost (unknown [10.0.8.2]) by mail.tkos.co.il (Postfix) with ESMTP id A125F4403F1; Tue, 9 Jan 2024 16:04:42 +0200 (IST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tkos.co.il; s=default; t=1704809082; bh=nWkMWvzxZARucV9BKvxgMiKFVZFgW9ZAI35CPkgiN1w=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=aAyidV3wDfegVJgn3hj2aDw+IJDBsWlDNykw4JwSxDMX60QxAwvxku7WYwfhglKQX 2r0YYJ4vBr+Je8oNZDOdl03Cx6gpEWss69lfGvbPCQRUa+su3KRCQ2L5JP5uk8NSsT gKR3SjuvtHwmVr93lXLKe85z8EGw5nJYRq2LITFBorKEpSQoWSM5eydLbl6TM5LuMc qXaOIwyps6aHgGJmM3j3vuH3oGosFp6h+DNn1Bl79twF0pH0Ke49ZYDFe/6A7k52C/ 2zLQhUqhtvbGT9bWpW1uWcR/oxlGh2ALKR9AqV8kfKCO+UVdQa2VwrxbqNbvbyDtKL AZGd+7diylz+Q== References: <87msterf7b.fsf@tarshish> User-agent: mu4e 1.10.8; emacs 29.1 From: Baruch Siach To: Catalin Marinas Cc: Christoph Hellwig , Marek Szyprowski , Rob Herring , Frank Rowand , Will Deacon , Robin Murphy , iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Petr =?utf-8?B?VGVzYcWZw61r?= , Ramon Fried , Elad Nachman Subject: Re: [PATCH RFC 3/4] dma-direct: add offset to zone_dma_bits Date: Tue, 09 Jan 2024 15:54:13 +0200 In-reply-to: Message-ID: <871qaqr477.fsf@tarshish> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Hi Catalin, On Tue, Jan 09 2024, Catalin Marinas wrote: > On Tue, Jan 09, 2024 at 12:03:43PM +0200, Baruch Siach wrote: >> On Mon, Jan 08 2024, Catalin Marinas wrote: >> > On Wed, Dec 27, 2023 at 05:04:27PM +0200, Baruch Siach wrote: >> >> Current code using zone_dma_bits assume that all addresses range in the >> >> bits mask are suitable for DMA. For some existing platforms this >> >> assumption is not correct. DMA range might have non zero lower limit. >> >> >> >> Add 'zone_dma_off' for platform code to set base address for DMA zone. >> >> >> >> Rename the dma_direct_supported() local 'min_mask' variable to better >> >> describe its use as limit. >> >> >> >> Suggested-by: Catalin Marinas >> > >> > When I suggested taking the DMA offsets into account, that's not exactly >> > what I meant. Based on patch 4, it looks like zone_dma_off is equivalent >> > to the lower CPU address. Let's say a system has DRAM starting at 2GB >> > and all 32-bit DMA-capable devices has a DMA offset of 0. We want >> > ZONE_DMA32 to end at 4GB rather than 6GB. >> >> Patch 4 sets zone_dma_off to the lower limit from 'dma-ranges' property >> that determines zone_dma_bits. This is not necessarily equivalent to >> start of DRAM, though it happens to be that way on my platform. > > A bit better but it still assumes that all devices have the same DMA > offset which may not be the case. Current code calculates zone_dma_bits based on the lowest high limit of all 'dma-ranges' properties. The assumption appears to be that this limit fits all devices. This series does not change this assumption. It only extends the logic to the lower limit of the "winning" 'dma-ranges' to set the base address for DMA zone. Moving to dma_zone_limit would not change that logic. Unless I'm missing something. Breaking the "one DMA zone fits all devices" assumption as Petr suggested is a much larger change. baruch -- ~. .~ Tk Open Systems =}------------------------------------------------ooO--U--Ooo------------{= - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -