Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966241AbcCPKGB (ORCPT ); Wed, 16 Mar 2016 06:06:01 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60629 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964968AbcCPKF6 (ORCPT ); Wed, 16 Mar 2016 06:05:58 -0400 From: Arnd Bergmann To: Adrian Hunter Cc: Alexandre Courbot , Ulf Hansson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, gnurou@gmail.com Subject: Re: [PATCH v4 1/3] mmc: sdhci: Set DMA mask when adding host Date: Wed, 16 Mar 2016 11:05:34 +0100 Message-ID: <2646031.AqmqXYeZyr@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <56E926D8.7020908@intel.com> References: <1457316477-8153-1-git-send-email-acourbot@nvidia.com> <4404643.KcAFCUffYS@wuerfel> <56E926D8.7020908@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Q79zIA4lHxQ9iJdibQfKN5adedENBBHUbT76ZKhTEr1XVDK0yvX UrFQFICnNEz0scmFhFLKlnwVP4Q00amLHChdBQQe7eGSAunLFSimSfX3sXiEuqM2aWCAkd3 OqUBGxlqSANRyhOygp9tNSpF8oIYzrZESBnyNr8EKD/A4nJdIqRFP2LOpOnDPP/tSHuonyN aj4+SIiDtvOCN1Q/RAYmQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:1iYalC9igyQ=:2rQm8F6DKh9V59s9Gj4Uwl lcTr9TGK5L3SK726DhAYSDM+teo+bwCJJQAoo4PUP01w5UBmblcnKSwIl/1MWFTjgMh6RTdZK BMHYN3ELaYphBB2VI4/VbV2MjzEWMwjpYRGgQz72y6YMUx3WFtsulfkNeL2MO6+AfESjQL8zU YMmeZxmodBu1b7fZIV73u0qH6ZxsjqfjJ3fi+vvyt2Ji06oeRUTOSnbh1xOh7Ous7XW1eoUUG wptJzVbSiG3BSRw5qpiST6tG2oogA0oVDK8kk2EUSl5L3Dk2z0C5WtamYNaGCvwMgUC6m9FMs fb/lLQERwajbdxthSmLrtACJTNyJ0s7kvHIj5OLGaOgpcvtGClH4e0Zzer2IPg8qzycd0b6tA Py53t45XaHo4lmG9yhGLS34GOt2Ur8vpFGy+HE6EOAa4oFUV92XxgdocA2/jxijZRSzDa2bQR jUyfR7s5q6EIPdmnlEgF+pH5pMFJsckuySI0J1WEhQtbdziE4EPQE8PAX0/xgM9cfCLq96DrY vXXg/RYqWo0u3/UCPBQncQasRMqpgeant1ulV3mHwsl1mDyanL8iSROWuorlL7h/TDlcZcFPo gZYQUxQtB8RxbPMqbol6QLCybck5fN6bBfJQH8ry75YEKTC5lDdhVsqX+4w1gDDxdaURIadXZ tPLCOOgZ7kZyGavZI5+JsHMCX24lUtLpxsaS9aMK81vSmtUkfGhqu4z7lI5Z1oyhfM/9RxrAU iENn/HLqwxYrhBKG Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1712 Lines: 43 On Wednesday 16 March 2016 11:26:48 Adrian Hunter wrote: > On 16/03/16 11:07, Arnd Bergmann wrote: > > On Wednesday 16 March 2016 10:43:33 Adrian Hunter wrote: > >>> + > >>> + /* 32-bit mask as default & fallback */ > >>> + if (ret) { > >>> + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); > >> > >> What happens if device enumeration (e.g. of_dma_configure) has already set a > >> more restrictive DMA mask? > >> > >> > > > > In this case, dma_set_mask_and_coherent() is supposed to check the > > bus properties settings again and fail dma_set_mask_and_coherent(). > > So the logic this patch introduces will disable DMA in that case. Would it > be better just to leave the DMA mask alone (as it does now for most sdhci > drivers) in the 32-bit case? It depends to some degree on the specific capabilities of the system. Basically when the driver asks for a 32-bit mask, we have to check if that is actually possible, and there are a couple of possible outcomes: - If the bus is less than 32-bit wide but the RAM is small enough to to fit within the addressable range of the bus, the dma_set_mask_and_coherent() should succeed - If the RAM is larger than what the bus can address, but swiotlb is configured and the swiotlb bounce buffer is addressable by the bus, dma_set_mask_and_coherent() should also succeed - If there is no swiotlb and there is RAM that fits into the 32-bit mask but that is not addressable by the bus, the dma_set_mask_and_coherent() should fail, and the driver should not use DMA. - Similarly, if swiotlb is enabled, but its bounce buffer is not reachable by the bus, the call needs to fail and the driver must not use DMA. Arnd