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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 413B0C433E7 for ; Fri, 16 Oct 2020 06:57:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF5EC206DD for ; Fri, 16 Oct 2020 06:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tsvxY6cP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="kW25M9o0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF5EC206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3M4vcHkEWx5PoIHwJTrrc+GUP/JoeQ/G7b+EVNHSb+M=; b=tsvxY6cPRDsJIduqEcEopNGjM +9sh/+8bdOmKO2jDl3krRwgSZZJTAOslyAQTCKCY8ECtRm1ldV90GSi503Bm0wQvzLnmb7BjVvr1z 672zK/vYNpUGoZ3uiMD5tP4R4+iXW4PRmOpS7ks6CmaEFIcFDt1lPMMK9Q7ZkozUVA6fz73gdpknD 8IyJIO72uj9MBfuyf0IkKH2LfvajRqKEjZQfKlIcF7tOMAn0dOnNRtbrM1IHqaQElnkkPYJRj+xK8 iTO73O7DwuIO9rSI/allSdYqqqMD2zvdwOwpPEugKZ7Wx+/LaNdy1d1tvP/C6oxkVmebMQqXyEhb8 /jbLk4UPA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTJfE-00029W-Dh; Fri, 16 Oct 2020 06:56:32 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTJfA-000287-IX; Fri, 16 Oct 2020 06:56:29 +0000 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EDE920829; Fri, 16 Oct 2020 06:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602831386; bh=Qt5cK4GbMy1zYjzp9yoahcnNoGCra0PWF0mygx/BzDY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kW25M9o0mHtPxHMea8yV80oWEA7vsMtr2BnXS+nM5/3MQhqUaPvN+MhMXTh+FopX7 uX5bRbMj4YsNF7JnVpLGJ8bkygcEu+ZEiqZ/YvRS766TMA7DF9cF/fcUls1f6GBkDC KZugE4D2A0tX8R0wG7oMBjzYLxgCNaiu0dmN+tRI= Received: by mail-oi1-f169.google.com with SMTP id u17so1336687oie.3; Thu, 15 Oct 2020 23:56:26 -0700 (PDT) X-Gm-Message-State: AOAM531KsFLAcWQHFKnFeUMIFR98hKfC/+3xRDhPu2JodfU+V18gNret famsgm/sidM/xzfaoXIw9CCnY1rkY6kgwu8lOvw= X-Google-Smtp-Source: ABdhPJz06rV6WAWm42aN14z1C+ajNWUQE5kD2qLfjxAdRc9MpB29T/PNIdoPGp5uO2oI3ZIgGfWCv7Dbtg/8qUfzXjc= X-Received: by 2002:aca:d64f:: with SMTP id n76mr1596675oig.174.1602831385656; Thu, 15 Oct 2020 23:56:25 -0700 (PDT) MIME-Version: 1.0 References: <20201014191211.27029-1-nsaenzjulienne@suse.de> <20201014191211.27029-8-nsaenzjulienne@suse.de> <20201015103106.GA24739@e121166-lin.cambridge.arm.com> In-Reply-To: <20201015103106.GA24739@e121166-lin.cambridge.arm.com> From: Ard Biesheuvel Date: Fri, 16 Oct 2020 08:56:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 7/8] arm64: mm: Set ZONE_DMA size based on early IORT scan To: Lorenzo Pieralisi X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201016_025628_765659_DE9BC75A X-CRM114-Status: GOOD ( 20.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Will Deacon , Anshuman Khandual , Catalin Marinas , Sudeep Holla , "Rafael J. Wysocki" , Linux Kernel Mailing List , Jeremy Linton , ACPI Devel Maling List , Linux IOMMU , Rob Herring , Linux ARM , Hanjun Guo , Len Brown , Robin Murphy , Christoph Hellwig , Nicolas Saenz Julienne , "moderated list:BROADCOM BCM2835 ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 15 Oct 2020 at 12:31, Lorenzo Pieralisi wrote: > > On Wed, Oct 14, 2020 at 09:12:09PM +0200, Nicolas Saenz Julienne wrote: > > [...] > > > +unsigned int __init acpi_iort_get_zone_dma_size(void) > > +{ > > + struct acpi_table_iort *iort; > > + struct acpi_iort_node *node, *end; > > + acpi_status status; > > + u8 limit = 32; > > + int i; > > + > > + if (acpi_disabled) > > + return limit; > > + > > + status = acpi_get_table(ACPI_SIG_IORT, 0, > > + (struct acpi_table_header **)&iort); > > + if (ACPI_FAILURE(status)) > > + return limit; > > + > > + node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); > > + end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); > > + > > + for (i = 0; i < iort->node_count; i++) { > > + if (node >= end) > > + break; > > + > > + switch (node->type) { > > + struct acpi_iort_named_component *ncomp; > > + struct acpi_iort_root_complex *rc; > > + > > + case ACPI_IORT_NODE_NAMED_COMPONENT: > > + ncomp = (struct acpi_iort_named_component *)node->node_data; > > + if (ncomp->memory_address_limit) > > + limit = min(limit, ncomp->memory_address_limit); > > + break; > > + > > + case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: > > + rc = (struct acpi_iort_root_complex *)node->node_data; > > + if (rc->memory_address_limit) > > You need to add a node revision check here, see rc_dma_get_range() in > drivers/acpi/arm64/iort.c, otherwise we may be reading junk data > in older IORT tables - acpica structures are always referring to the > latest specs. > Indeed - apologies for not mentioning that when handing over the patch. Also, we could use min_not_zero() here instead of the if () _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel