From patchwork Thu Mar 18 16:06:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12148505 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 B6A70C433E6 for ; Thu, 18 Mar 2021 16:10:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E1E8B64F01 for ; Thu, 18 Mar 2021 16:10:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1E8B64F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5037C16AC; Thu, 18 Mar 2021 17:09:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5037C16AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616083838; bh=aXyEFh8tW2QuQC4xor7E/UVAXzj2ceCRRMXjo/1qObY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eDKl6B4b1+LyIfMtTqUY6CA692lzLf+rXsbRGEqvH7Rj4VkJ65kjfhS2kp3wZDUbu Nn6F9uTs46s1ltVBf9ptdH9b4/pCotdC1X+pSbB81Y0PFfIGQlgYrTpDDsHs3Lxnmv oZ1h496RCKdYBQg+V0myCb5teymzkcSsjqc0lTr4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6E5D5F8032D; Thu, 18 Mar 2021 17:08:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7F0C5F80423; Thu, 18 Mar 2021 17:08:24 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D0671F8023B for ; Thu, 18 Mar 2021 17:08:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D0671F8023B IronPort-SDR: aDDnviJYefTaBP1inKReRM+7IM/lnsMDDsjj3zTqlUsj7/hFb91vzG9qC1lES7Rqq3GgZs2Ofm g7lO9pzQayUw== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="186360115" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="186360115" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:07:57 -0700 IronPort-SDR: 61Q5lJy7PXzSVMeSYIv3fBjxynir+AK3B/cov92RXbTt/x8CLztwaiNOG4mjoSyIBknz+kMnOh HERBr+ng0Jqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="413142070" Received: from pi-desktop.igk.intel.com ([10.237.148.102]) by orsmga008.jf.intel.com with ESMTP; 18 Mar 2021 09:07:56 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Takashi Iwai Subject: [PATCH v2 1/3] ALSA: pcm: Add debug print on memory allocation failure Date: Thu, 18 Mar 2021 17:06:16 +0100 Message-Id: <20210318160618.2504068-2-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> References: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Cezary Rojewski , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add debug prints after calls of do_alloc_pages. One simplification would be to move print into do_alloc_pages, however it would cause spam in logs, as preallocate_pcm_pages loops over do_alloc_pages trying lower values in case of failures. Reviewed-by: Cezary Rojewski Signed-off-by: Amadeusz Sławiński --- sound/core/pcm_memory.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 289dd1fd8fe7..2878c4c23583 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -176,6 +176,10 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, substream->dma_buffer.dev.dev, size, &new_dmab) < 0) { buffer->error = -ENOMEM; + pr_debug("ALSA pcmC%dD%d%c,%d:%s: cannot preallocate for size %zu\n", + substream->pcm->card->number, substream->pcm->device, + substream->stream ? 'c' : 'p', substream->number, + substream->pcm->name, size); return; } substream->buffer_bytes_max = size; @@ -400,6 +404,10 @@ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) substream->dma_buffer.dev.dev, size, dmab) < 0) { kfree(dmab); + pr_debug("ALSA pcmC%dD%d%c,%d:%s: cannot preallocate for size %zu\n", + substream->pcm->card->number, substream->pcm->device, + substream->stream ? 'c' : 'p', substream->number, + substream->pcm->name, size); return -ENOMEM; } } From patchwork Thu Mar 18 16:06:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12148501 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 EE7EEC433DB for ; Thu, 18 Mar 2021 16:09:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 17BFB601FF for ; Thu, 18 Mar 2021 16:09:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17BFB601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8EFA21699; Thu, 18 Mar 2021 17:09:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8EFA21699 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616083796; bh=dVtNYflFtvFlRKTdZYLo3FbZJPOmWz/QQ4tJP1rxfnU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=avIEwj1tGJlKhfW8ZX1Tm9h2uW+UGbxEOemqbq6szzhohjHLHmMeI/RQ4vNttQ4r9 yb9xlMd2AXjnhORTo0AgDTfdmCbULMlU0LoPK+Gh8R/1cXPpGYvf71lMvHnkR0TIDv FSHPFdSLjsG3N+pL7kuRDJEFAEyBEAJAZSBSUzDY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1A6E9F80218; Thu, 18 Mar 2021 17:08:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9D331F8025E; Thu, 18 Mar 2021 17:08:18 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8FB0FF800E0 for ; Thu, 18 Mar 2021 17:08:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8FB0FF800E0 IronPort-SDR: lZv7Rug9DU898m/b7xxLH3k8g+y6G27ttd4Vo+r1hh+cNW1ielWP5aOeWaT4JM5pIM6rE/abUf B1NyjI85NcVw== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="186360138" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="186360138" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:07:59 -0700 IronPort-SDR: m3Y/LtJO2FKtNkiSGW+gWoopwZAIyKiU5dVZx4wYXHqBPrlYHUcRg0IPyudM9HGP0HlcuBA+ww p2mu500fCD3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="413142092" Received: from pi-desktop.igk.intel.com ([10.237.148.102]) by orsmga008.jf.intel.com with ESMTP; 18 Mar 2021 09:07:58 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Takashi Iwai Subject: [PATCH v2 2/3] ALSA: hda: Change AZX_MAX_BUF_SIZE from 1GB to 4MB Date: Thu, 18 Mar 2021 17:06:17 +0100 Message-Id: <20210318160618.2504068-3-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> References: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Takashi Iwai , Cezary Rojewski , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" When SND_HDA_PREALLOC_SIZE is set to 0, applications can request as much memory as there is allowed. With value of AZX_MAX_BUF_SIZE it is 1GB per stream, which is not realistic use case. Change it 4MB. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=201251#c322 Suggested-by: Takashi Iwai Reviewed-by: Cezary Rojewski Signed-off-by: Amadeusz Sławiński --- Changes: v2: explain in comment that it is an artificial limit, as HW allows for bigger allocations --- include/sound/hda_register.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/sound/hda_register.h b/include/sound/hda_register.h index 4f987b1f32f7..ad8b71b1dbb6 100644 --- a/include/sound/hda_register.h +++ b/include/sound/hda_register.h @@ -140,8 +140,12 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; #define BDL_SIZE 4096 #define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16) #define AZX_MAX_FRAG 32 -/* max buffer size - no h/w limit, you can increase as you like */ -#define AZX_MAX_BUF_SIZE (1024*1024*1024) +/* + * max buffer size - artificial 4MB limit per stream to avoid big allocations + * In theory it can be really big, but as it is per stream on systems with many streams memory could + * be quickly saturated if userspace requests maximum buffer size for each of them. + */ +#define AZX_MAX_BUF_SIZE (4*1024*1024) /* RIRB int mask: overrun[2], response[0] */ #define RIRB_INT_RESPONSE 0x01 From patchwork Thu Mar 18 16:06:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12148503 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 74AB3C433DB for ; Thu, 18 Mar 2021 16:10:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 552B4601FF for ; Thu, 18 Mar 2021 16:10:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 552B4601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E33CE850; Thu, 18 Mar 2021 17:09:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E33CE850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616083801; bh=K15/u2IZEo5ny/u4YD+Vx8Fh3TIIDcMZpEhXaoU6Fk0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=N6c7Ht/m+lUUC5wQ3Nz2HQXjmfHIw5z5XuDJBQtQ38/uH+nZ9MFJWwt6rgsdVYUNZ LPcUF3kS+kJBdeycajWIFnBf2SZfHJ2fOdiR4j09sDZ1Kp5pVw+SYPDibmqxjR/JhT A6yQVx/pD4KW7VXZatlqygYdYifyRaCri8egVPdg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 90E05F802E3; Thu, 18 Mar 2021 17:08:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B7D3F802E3; Thu, 18 Mar 2021 17:08:20 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 49A87F80163 for ; Thu, 18 Mar 2021 17:08:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 49A87F80163 IronPort-SDR: +cFJc66K+5frK22PeCZGks4j0hDx78HAG7PaS31L+6T65Fbw5RDbX2furgMc8oWhc5bytsCY9z ysDPmANHwpJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="186360163" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="186360163" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:08:01 -0700 IronPort-SDR: 0cq4J7ABMrjPNIo7YeuB3udWfkENPgXQL35Qa0W9Qly0vasZWdXYWnHIrD4VhKje9xv4WjGJMw 2GRkr/cNwqpA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="413142119" Received: from pi-desktop.igk.intel.com ([10.237.148.102]) by orsmga008.jf.intel.com with ESMTP; 18 Mar 2021 09:07:59 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Takashi Iwai Subject: [PATCH v2 3/3] ALSA: hda: Revert "ALSA: hda: Allow setting preallocation again for x86" Date: Thu, 18 Mar 2021 17:06:18 +0100 Message-Id: <20210318160618.2504068-4-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> References: <20210318160618.2504068-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Takashi Iwai , Cezary Rojewski , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This reverts commit f8e4ae10de43 ("ALSA: hda: Allow setting preallocation again for x86"). The reverted commit itself is a revert of c31427d0d21e ("ALSA: hda: No preallocation on x86 platforms"). It was needed because HDA allowed very big allocations, up to 1GB per stream. However as previous commit in this series changes maximum allowed allocation per stream to 4MB, we can safely revert it back. On systems where there are a lot of FrontEnds, when CONFIG_SND_HDA_PREALLOC_SIZE != 0 ALSA core allocates memory for each FE, which may cause out of memory problems due to per card limit. Force config to 0 on X86, so memory will be allocated on as needed basis. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=201251#c322 Suggested-by: Takashi Iwai Reviewed-by: Cezary Rojewski Signed-off-by: Amadeusz Sławiński --- Changes: v2: improve commit message as requested to explain, why it is safe to revert --- sound/hda/Kconfig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/hda/Kconfig b/sound/hda/Kconfig index 57595f1552c9..741179ccbd4e 100644 --- a/sound/hda/Kconfig +++ b/sound/hda/Kconfig @@ -21,17 +21,16 @@ config SND_HDA_EXT_CORE select SND_HDA_CORE config SND_HDA_PREALLOC_SIZE - int "Pre-allocated buffer size for HD-audio driver" + int "Pre-allocated buffer size for HD-audio driver" if !SND_DMA_SGBUF range 0 32768 - default 2048 if SND_DMA_SGBUF + default 0 if SND_DMA_SGBUF default 64 if !SND_DMA_SGBUF help Specifies the default pre-allocated buffer-size in kB for the HD-audio driver. A larger buffer (e.g. 2048) is preferred for systems using PulseAudio. The default 64 is chosen just for compatibility reasons. - On x86 systems, the default is 2048 as a reasonable value for - most of modern systems. + On x86 systems, the default is zero as we need no preallocation. Note that the pre-allocation size can be changed dynamically via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too.