From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbcFUUNb (ORCPT ); Tue, 21 Jun 2016 16:13:31 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59916 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750890AbcFUUNa (ORCPT ); Tue, 21 Jun 2016 16:13:30 -0400 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Jisheng Zhang , will.deacon@arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: mm: only initialize swiotlb when necessary Date: Tue, 21 Jun 2016 22:13:45 +0200 Message-ID: <4203245.3RUrvgiPFd@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20160621160625.GE14542@e104818-lin.cambridge.arm.com> References: <1465372426-4077-1-git-send-email-jszhang@marvell.com> <3518191.m1tVRlZvU1@wuerfel> <20160621160625.GE14542@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:L2Eky/rs3lhx16oH+1H7Ma8/hrGcNCR12wlnOYiRK3zbHF4+mJM Esfy9tjgMC+nRd4UodsQ3k1e2Np+noOYJDsKP2f54od2hfeMN4r8eLX97C5LI68wdQX/xlz 2j1TgTEe5NYuVL4W57/49qxCQfFUopiK3un1wE6As3mhtjPPeQ0TZ1W3neri0jzEmTXxtsz jNd4Z+N+TxD1ZVFmNClpg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Z9fqidRb0CM=:t/8eM05vAWvZq5BSfMjkaZ qfBg1P7JP3HxNbkmzbBIJfw4yCCXEPTe2/TpCcia0wBswbauI3ebU/PVUxGIp+Gc9KzS1zYLJ l/J96X80Ye9f74Inm7DF3hrcFeEJGZ9jMHccbTPhsDjE+/cwFREWIhFqYMpXXHpYCmnSeDt7S 1uU/PaD4Xg0uBvst05RsNSzpvvbhpeUpwfKk2cgVhVFfT16ZMQ+6c1T3MU/FzncoshvUXFyaD QO3PjNHY8TXlsKFJMA97BUQwc0o8bUiJCX1hRBvcWDyzwu8B++jbPXq7Sa8eWqVqrrsbKiRsj xdQq1ry4b0pacHgHET0fGmGulBseLxFaVHjr+MtXpe9i3bGnYe1+VJ8Z4H49LiMZKvJpFYJPz fdNJIi/wghfxQkKERqqZiR4IqHzC0R3ykIiyWfy/Rs9ce8kl0hhQ9f1VoyZKp3J3C4F+LZJu4 Zb7zWm6E03566JHbgPK+cwmZdfXkmC3ftY2gi8Erv7zd73GN95i1b5V1ruj5tKntCUffmnjgf TRH2aLUszUfm74wB0a0fLbpEjNS7LahSu7byPR8Vbu4XdjaDg5zoWdrPekkg6mz/m0+ZOaGbX t6d3uh8t8BwAVTcueRNeADSTSxiD0PIYxLr9asMzPQD3b5Uvh/uP0S5H/Ti7gegJ9GvUORZux Xy2/ZRaiRaxlOVZe5aunspiICzpvb4NuHKIXh0HqbjeM6wYfjJfki1eX8SZSnOVr7fpNAEgaS 5wbco9ya+YYgCjpH Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, June 21, 2016 5:06:25 PM CEST Catalin Marinas wrote: > On Wed, Jun 08, 2016 at 05:49:59PM +0200, Arnd Bergmann wrote: > > On Wednesday, June 8, 2016 1:08:29 PM CEST Catalin Marinas wrote: > > > On Wed, Jun 08, 2016 at 03:53:46PM +0800, Jisheng Zhang wrote: > > > > static int __init arm64_dma_init(void) > > > > { > > > > + if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) > > > > + swiotlb = 1; > > > > + > > > > return atomic_pool_init(); > > > > } > > > > > > So any platform with RAM larger than 4GB would still initialise swiotlb. > > > I wouldn't say it's an issue, 64MB is not a significant loss on such > > > systems. > > > > > > An alternative would be to defer the freeing until we are aware of all > > > possible dma masks for the populated devices (e.g. from DT), though I'm > > > not sure that's enough, drivers may try to change such masks when > > > probed. > > > > Right, this is a hard problem, because you can in theory have odd devices > > that require a DMA mask lower than the limit of ZONE_DMA. > > I'm not sure what we can do about such devices even with swiotlb. The > bounce buffer is allocated from ZONE_DMA and currently it assumes a > 32-bit mask from the start of RAM, so it is not guaranteed to support a > smaller mask. We may need to come up with some DT memory node attribute > to define the minimum DMA-able memory and restrict ZONE_DMA during early > boot but I would rather wait until we hit a real issue in practice. The bounce buffer is allocated at early boot time in order to get an address as low as possible, in the hope that it is small enough for those cases. Arnd