Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3967278rdb; Mon, 11 Dec 2023 05:28:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtqRq1nweTE0MGJ4buRm39Std/ESdge2BX6cIun1iLfD052Ie5ZDWjPbaK1YX/kOGjiAOh X-Received: by 2002:a17:903:2282:b0:1d0:9979:7be5 with SMTP id b2-20020a170903228200b001d099797be5mr7309310plh.31.1702301304524; Mon, 11 Dec 2023 05:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702301304; cv=none; d=google.com; s=arc-20160816; b=Ejsh4obfdLwnkpmE45dY/pOTnuoCy+yv/+b517MqNYznwAP8EfjtC7EckuecI90yLQ S2WvdPFvoVFweJm2UXUmSL8OgWCMkWAjwm0U3i/Rt4PshfrNkhcjjphQta11nqRr3ZZz 3UYH0qbVSOSm3JOi6TNNRikM7KK8w/Q3dZw9lgY/Om4ukN/Yt7fPQuZs7yFvAR2k7Zdc dN21g/wJ9GCqVT4PGKuDnDCmbwgn70N9ztuXlyzphsqUk788dphlAl+/Vc+GAKBfUx2M J9DEBr8NHTfp89VoPJ5C7jQ1drZj7Y/DltYCB7IgnTQV+JZQobHCGwm+m4bKF1J2kyy9 2qNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=h/56clkvVTGn8qApCBUlyFBXTtkaArzPhnCS+ldQ0JU=; fh=zEh6gcAvF6cu7Bgh8fftLetNLrvvqAqYFTVkhunBPrs=; b=li1LWaE1ddbRaXGOkBXApw/ZDsxK3+HUp7qng3WoCQ1ArcsBWaXmHaNtUwoN/rYH6a Mr/tPucXMlKHSIos5gDq8hhgYi2ybJ7QvR+4NSWq6pfaZcGAfHLRtD4FDMRwAyI7bReE QFojhlEOkJr78Dv0uS5/8NWGWX1v83KA6sJhb8DUaiM9AV31TWYIm0FS0+4XZjnE/3ke oohTw7BJScXMOr9XcXBd3HzruD9jqfihfNmIYD4iIQ69kxWDFSqO1pjx+qNz7m7LFb4L JeG0UvltDQgzRA2mNa7Cmtx4K1b/j4VhDS7O4DyeOmlaKoAmlFNKSZhQzFViD2YAMQ9l /LKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAu0byBI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l12-20020a170903120c00b001d06d47c3c8si6195227plh.299.2023.12.11.05.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 05:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAu0byBI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 01A538080E21; Mon, 11 Dec 2023 05:28:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343502AbjLKN2C (ORCPT + 99 others); Mon, 11 Dec 2023 08:28:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbjLKN2B (ORCPT ); Mon, 11 Dec 2023 08:28:01 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDEEA9A for ; Mon, 11 Dec 2023 05:28:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D407C433C9; Mon, 11 Dec 2023 13:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702301287; bh=Uh28siBgKPrRx4R97NHRHFSutMUu3voxmGrI4tHwqJY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LAu0byBI6RS1NorYku2b05EMpa2te/9yWVIdkVVhc3v0B2IUobjYl5G4y/bzWa9pJ JjIUc0L5jQy3+vJf3iSPZ9w7NHWJVeveZ8Hwjs82eBFchAAU/z+AI2ET4sBi5zgaos Y0BeQpqkgtzEVa5x6sxs4Sp3r9IZJ5Rm+nk8ZGcx906z+EgRGwrnEybDL8FBes+JOD A3vFUH1fc1/B2QPP2C8HpmJtX19M50Ti3rcMizOlJoN3msljQPC6btRRBnBhEx7nid Mv90l0Dd4s6KBcpO77xaQlgW6DEuntN8+hgoFozymI86YA8qy5G89c76Za3gkok+AX LP/+5T3W8DdeA== Date: Mon, 11 Dec 2023 13:27:57 +0000 From: Will Deacon To: Robin Murphy Cc: Joerg Roedel , Christoph Hellwig , Vineet Gupta , Russell King , Catalin Marinas , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Niklas Schnelle , Matthew Rosato , Gerald Schaefer , Jean-Philippe Brucker , Rob Herring , Frank Rowand , Marek Szyprowski , Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org Subject: Re: [PATCH 3/7] ACPI/IORT: Handle memory address size limits as limits Message-ID: <20231211132757.GE25681@willie-the-truck> References: <2ae6199a9cf035c1defd42e48675b827f41cdc95.1701268753.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ae6199a9cf035c1defd42e48675b827f41cdc95.1701268753.git.robin.murphy@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 11 Dec 2023 05:28:22 -0800 (PST) On Wed, Nov 29, 2023 at 05:43:00PM +0000, Robin Murphy wrote: > Return the Root Complex/Named Component memory address size limit as an > inclusive limit value, rather than an exclusive size. This saves us > having to special-case 64-bit overflow, and simplifies our caller too. > > Signed-off-by: Robin Murphy > --- > drivers/acpi/arm64/dma.c | 9 +++------ > drivers/acpi/arm64/iort.c | 18 ++++++++---------- > include/linux/acpi_iort.h | 4 ++-- > 3 files changed, 13 insertions(+), 18 deletions(-) [...] > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index 6496ff5a6ba2..eb64d8e17dd1 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -1367,7 +1367,7 @@ int iort_iommu_configure_id(struct device *dev, const u32 *input_id) > { return -ENODEV; } > #endif > > -static int nc_dma_get_range(struct device *dev, u64 *size) > +static int nc_dma_get_range(struct device *dev, u64 *limit) > { > struct acpi_iort_node *node; > struct acpi_iort_named_component *ncomp; > @@ -1384,13 +1384,12 @@ static int nc_dma_get_range(struct device *dev, u64 *size) > return -EINVAL; > } > > - *size = ncomp->memory_address_limit >= 64 ? U64_MAX : > - 1ULL<memory_address_limit; > + *limit = (1ULL << ncomp->memory_address_limit) - 1; The old code handled 'ncomp->memory_address_limit >= 64' -- why is it safe to drop that? You mention it in the cover letter, so clearly I'm missing something! > > return 0; > } > > -static int rc_dma_get_range(struct device *dev, u64 *size) > +static int rc_dma_get_range(struct device *dev, u64 *limit) > { > struct acpi_iort_node *node; > struct acpi_iort_root_complex *rc; > @@ -1408,8 +1407,7 @@ static int rc_dma_get_range(struct device *dev, u64 *size) > return -EINVAL; > } > > - *size = rc->memory_address_limit >= 64 ? U64_MAX : > - 1ULL<memory_address_limit; > + *limit = (1ULL << rc->memory_address_limit) - 1; Same thing here. Will