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=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 DE048C433DF for ; Mon, 12 Oct 2020 10:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 831C12173E for ; Mon, 12 Oct 2020 10:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602499398; bh=AJ0Fhu60Tr804rRCM1+P680y3M3FPp/EV8RIsUNxmZg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=1NRTZtwul3ad1Wf206EzniBxFSdAQebNGBHErTxB/KQ6eOQ8RpiJ+E3e8EEK3DY8v 2skdwwGjI/jaY2+hwBso+wiStHzY4twWqCYXBR11zcI7SuenscBC6w3t54p0+7Nqa5 KrBwIzlwRZfMRn+fGbOp4YbUbvOyIb6igcaRoHgo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387616AbgJLKnS (ORCPT ); Mon, 12 Oct 2020 06:43:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:41128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387596AbgJLKnR (ORCPT ); Mon, 12 Oct 2020 06:43:17 -0400 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 AA8152078E for ; Mon, 12 Oct 2020 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602499396; bh=AJ0Fhu60Tr804rRCM1+P680y3M3FPp/EV8RIsUNxmZg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QUrMCuOUSGgm6NhT34utLHj+2M3cYSn2ZzDRFXsfAalA6phMTCwNzIZSy6STpPxU1 NsZkH8QXngPNzTzDCNVFgVAkkcPU8pukrcNasOXajnsQIUXOIdh+Zh7n7Ih9Hmhqr6 +fee0mjuWDL2YCkN24H45r84U/o1PwbUrllnKWV8= Received: by mail-oi1-f173.google.com with SMTP id s81so5878527oie.13 for ; Mon, 12 Oct 2020 03:43:16 -0700 (PDT) X-Gm-Message-State: AOAM533tJWmwN+aZVqihpKYX/DnjEnZGBKUMfqceuE4+AD/L6+5cMadL ZR8cRN13/Vvg03mSEHvHnQ1Hyv0Ip+qdI59oxW8= X-Google-Smtp-Source: ABdhPJy+fq4uKCteCCnTri1DaNthEYUGEsliRxVnw0Pxl+Uia5bYwZ4wO/aZBWBU9kpgLTCrrg3y3cDwUSVk7q9xc/Q= X-Received: by 2002:aca:d845:: with SMTP id p66mr9727095oig.47.1602499395977; Mon, 12 Oct 2020 03:43:15 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> In-Reply-To: From: Ard Biesheuvel Date: Mon, 12 Oct 2020 12:43:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: set ZONE_DMA size based on early IORT scan To: Catalin Marinas Cc: Linux ARM , ACPI Devel Maling List , Will Deacon , Jeremy Linton , Lorenzo Pieralisi , Nicolas Saenz Julienne , Rob Herring , Christoph Hellwig , Robin Murphy , Hanjun Guo , Sudeep Holla , Anshuman Khandual Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Mon, 12 Oct 2020 at 11:30, Ard Biesheuvel wrote: > > On Mon, 12 Oct 2020 at 11:28, Catalin Marinas wrote: > > > > On Sat, Oct 10, 2020 at 11:31:53AM +0200, Ard Biesheuvel wrote: > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > index f0599ae73b8d..829fa63c3d72 100644 > > > --- a/arch/arm64/mm/init.c > > > +++ b/arch/arm64/mm/init.c > > > @@ -191,6 +191,14 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > > unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; > > > > > > #ifdef CONFIG_ZONE_DMA > > > + if (IS_ENABLED(CONFIG_ACPI)) { > > > + extern unsigned int acpi_iort_get_zone_dma_size(void); > > > > Nitpick: can we add this prototype to include/linux/acpi_iort.h? > > > > > + > > > + zone_dma_bits = min(zone_dma_bits, > > > + acpi_iort_get_zone_dma_size()); > > > + arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); > > > + } > > > + > > > max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); > > > > I think we should initialise zone_dma_bits slightly earlier via > > arm64_memblock_init(). We'll eventually have reserve_crashkernel() > > called before this and it will make use of arm64_dma_phys_limit for > > "low" reservations: > > > > https://lore.kernel.org/linux-arm-kernel/20200907134745.25732-7-chenzhou10@huawei.com/ > > > > We don't have access to the ACPI tables yet at that point. Also, could someone give an executive summary of why it matters where the crashkernel is loaded? As far as I can tell, reserve_crashkernel() only allocates memory for the kernel's executable image itself, which can usually be loaded anywhere in memory. I could see how a crashkernel might need some DMA'able memory if it needs to use the hardware, but I don't think that is what is going on here. 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=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,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 6D36AC433E7 for ; Mon, 12 Oct 2020 10:44:39 +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 E7FA32078E for ; Mon, 12 Oct 2020 10:44:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xbq9wxuX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="QUrMCuOU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7FA32078E 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=e1frUmsZrxdFOUQ7RZp8KZx1e5xQxscTfDGRp3fTBQo=; b=xbq9wxuXALSczrOv7ZXGKtlJX rSGqqGU23eSqUOwYXcbeCY7UJsq8ahpokQ4fWVkd3Cj/BLO6MutL3Ce7xXhMkNN9HfEKr/SDZ8oO/ HxXLnKslVvKS6jZHjPn0C8NdJD1vMWqG61PXo2Ac2lrDzz97CShKCwvACN7BQE0Zm5K5tOQ6NwgQl MxlezB6BLVY60Gb3RdhriIOb55Q/i6MS99dBUZHhPqScrLTs/ncs6rQOooez8NQfOvY/tbNl4q1vj rYHrgbotPnWqFIHoOFMfpPVJdwGbAduN9bt/kHWu6LukzRUg8EJYlM91AQZ2s5UtKr4AIhJhx/XsQ yIg5keozA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kRvIX-0002ak-IZ; Mon, 12 Oct 2020 10:43:21 +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 1kRvIT-0002Zg-PY for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2020 10:43:19 +0000 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 B3E3D214D8 for ; Mon, 12 Oct 2020 10:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602499396; bh=AJ0Fhu60Tr804rRCM1+P680y3M3FPp/EV8RIsUNxmZg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QUrMCuOUSGgm6NhT34utLHj+2M3cYSn2ZzDRFXsfAalA6phMTCwNzIZSy6STpPxU1 NsZkH8QXngPNzTzDCNVFgVAkkcPU8pukrcNasOXajnsQIUXOIdh+Zh7n7Ih9Hmhqr6 +fee0mjuWDL2YCkN24H45r84U/o1PwbUrllnKWV8= Received: by mail-oi1-f175.google.com with SMTP id c13so18264617oiy.6 for ; Mon, 12 Oct 2020 03:43:16 -0700 (PDT) X-Gm-Message-State: AOAM5335IsJImJrpaGLZXm/BkLvjkTwkeSYAtlYu7HQMslY11aYCfuBk zYsLqoE9BNH9ROmSBWfgVJP3ZN+7qjt3ZZsuzPY= X-Google-Smtp-Source: ABdhPJy+fq4uKCteCCnTri1DaNthEYUGEsliRxVnw0Pxl+Uia5bYwZ4wO/aZBWBU9kpgLTCrrg3y3cDwUSVk7q9xc/Q= X-Received: by 2002:aca:d845:: with SMTP id p66mr9727095oig.47.1602499395977; Mon, 12 Oct 2020 03:43:15 -0700 (PDT) MIME-Version: 1.0 References: <20201010093153.30177-1-ardb@kernel.org> <20201012092821.GB9844@gaia> In-Reply-To: From: Ard Biesheuvel Date: Mon, 12 Oct 2020 12:43:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: set ZONE_DMA size based on early IORT scan To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201012_064318_490731_643E1BCD X-CRM114-Status: GOOD ( 25.89 ) 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: Lorenzo Pieralisi , Anshuman Khandual , Robin Murphy , Sudeep Holla , Jeremy Linton , ACPI Devel Maling List , Rob Herring , Linux ARM , Hanjun Guo , Will Deacon , Christoph Hellwig , Nicolas Saenz Julienne 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 Mon, 12 Oct 2020 at 11:30, Ard Biesheuvel wrote: > > On Mon, 12 Oct 2020 at 11:28, Catalin Marinas wrote: > > > > On Sat, Oct 10, 2020 at 11:31:53AM +0200, Ard Biesheuvel wrote: > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > > index f0599ae73b8d..829fa63c3d72 100644 > > > --- a/arch/arm64/mm/init.c > > > +++ b/arch/arm64/mm/init.c > > > @@ -191,6 +191,14 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > > unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; > > > > > > #ifdef CONFIG_ZONE_DMA > > > + if (IS_ENABLED(CONFIG_ACPI)) { > > > + extern unsigned int acpi_iort_get_zone_dma_size(void); > > > > Nitpick: can we add this prototype to include/linux/acpi_iort.h? > > > > > + > > > + zone_dma_bits = min(zone_dma_bits, > > > + acpi_iort_get_zone_dma_size()); > > > + arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); > > > + } > > > + > > > max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); > > > > I think we should initialise zone_dma_bits slightly earlier via > > arm64_memblock_init(). We'll eventually have reserve_crashkernel() > > called before this and it will make use of arm64_dma_phys_limit for > > "low" reservations: > > > > https://lore.kernel.org/linux-arm-kernel/20200907134745.25732-7-chenzhou10@huawei.com/ > > > > We don't have access to the ACPI tables yet at that point. Also, could someone give an executive summary of why it matters where the crashkernel is loaded? As far as I can tell, reserve_crashkernel() only allocates memory for the kernel's executable image itself, which can usually be loaded anywhere in memory. I could see how a crashkernel might need some DMA'able memory if it needs to use the hardware, but I don't think that is what is going on here. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel