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=-0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 E9E00C47E49 for ; Mon, 4 Nov 2019 09:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9819222CF for ; Mon, 4 Nov 2019 09:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727454AbfKDJDj (ORCPT ); Mon, 4 Nov 2019 04:03:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:58142 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726633AbfKDJDj (ORCPT ); Mon, 4 Nov 2019 04:03:39 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E0C8AB4CD; Mon, 4 Nov 2019 09:03:36 +0000 (UTC) Date: Mon, 04 Nov 2019 10:03:34 +0100 Message-ID: From: Takashi Iwai To: Greg Kroah-Hartman Cc: youling 257 , Takashi Iwai , linux-xtensa@linux-xtensa.org, Michal Simek , Vladimir Murzin , linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Helge Deller , x86@kernel.org, Linux Kernel Mailing List , linux-m68k@lists.linux-m68k.org, Robin Murphy , linux-arm-kernel@lists.infradead.org, hch@lst.de Subject: Re: ALSA: pcm: use dma_can_mmap() to check if a device supports dma_mmap_* In-Reply-To: <19c3f0ca-9b21-0c5e-894d-976594f38a86@google.com> References: <60ee349a-1fe7-46f0-5161-1dcfcb6fbee9@google.com> <19c3f0ca-9b21-0c5e-894d-976594f38a86@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org On Mon, 04 Nov 2019 09:49:43 +0100, Greg Kroah-Hartman wrote: > > On 11/4/19 9:32 AM, Greg Kroah-Hartman wrote: > > On 11/4/19 9:27 AM, youling 257 wrote: > > > This driver > > > https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/drivers/usb/gadget/function/f_audio_source.c > > > > > > > > > > The driver is broken and needs to be fixed. Please feel free to submit > > patches to AOSP to do so as you can trigger this easily. > > Hm, maybe the driver isn't broken... It is :) > snd_pcm_lib_preallocate_pages_for_all() is called with > SNDRV_DMA_TYPE_DEV set, so that should be fine, That's the cause. It passes NULL to the device object, which is incorrect in anyway. I guess this used to work casually just because x86 accepts the NULL device object as if an ISA device. > and the only other > buffer I can see allocate here is with a call to > snd_pcm_lib_alloc_vmalloc_buffer() which _should_ be ok, right? If the driver allocates the buffer via vmalloc (and the snd_* helper), it shouldn't do preallocate in that way. That is, the correct fix would be simply to drop snd_pcm_lib_preallocate_pages_for_all() call from the driver code. Also, a quick skimming showed that the driver needs to set snd_pcm_lib_get_vmalloc_page to the snd_pcm_ops.page ops. > I don't see any buffers coming off the stack here, unless the gadget > controller is the one creating them? That's the code before actually allocating the buffer itself. It checks the availability of mmap support on the architecture, and the helper code assumed a proper device object passed there via the preallocation helper. thanks, Takashi