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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 D0993C4338F for ; Tue, 10 Aug 2021 12:24:55 +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 7249961008 for ; Tue, 10 Aug 2021 12:24:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7249961008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=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 5D02C167A; Tue, 10 Aug 2021 14:24:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5D02C167A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1628598292; bh=H83WsfgY8KFZL1PLlxT2/WoIHmS/QLFcjVxiT40IQwE=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=IpXMMQ9JPEJs1nVQ0zqF68xOBSIxOAPcp6LmAWEfF+rwfLu9i3VDnqAihMrfbEVMt tQG2bUt/k1lXIuFuCvcUi8t+46GkOni/xt8xWz4d9z+/9o8laUniVCHj/KDqrrZJkk claDC1H/UuFmotq81NwlZOS38zXD52mf9UF23ZJ4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E3301F804F3; Tue, 10 Aug 2021 14:22:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 02A43F804D1; Tue, 10 Aug 2021 14:22:20 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 76B45F80279 for ; Tue, 10 Aug 2021 14:22:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 76B45F80279 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BCFm5vhS"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="miuuXfin" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9B0D022024 for ; Tue, 10 Aug 2021 12:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1628598123; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZTY+/atdF/ux4ZWjcZEEo0GeD9uvV3FBOiivcBYk3LY=; b=BCFm5vhSGOGcaZU9IEvBinkGwRtEdMf4xJNFaGxSceRYN8OCqX9SQHPHbdwjW0X24kkraM XQfz/fbZzqLuDXwIr5i7oFKRwhFB55f5RFpZNmJ/rhRB6IFH+xIh4/YitM06GU36Bg3KTQ 9niX2HGe0DM+R/yEAK5x/Ln+uOQWZr0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1628598123; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZTY+/atdF/ux4ZWjcZEEo0GeD9uvV3FBOiivcBYk3LY=; b=miuuXfinOljjXdODoamb2gPapADLQttkkE8SwIub6urmbKJbKb8IntHV/+UfZpiVU4jlNT zS76D3DZ98LoFdDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 87866A3B85; Tue, 10 Aug 2021 12:22:03 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH RFC 0/5] ALSA: Support for non-coherent and non-contiguous page allocation Date: Tue, 10 Aug 2021 14:21:55 +0200 Message-Id: <20210810122200.971-1-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" Hi, this is an experimental patch set to add the support for PCM buffers with non-coherent and non-contiguous pages, typically useful for non-x86 architectures. The first patch improves the SG-buffer handling, then add a new PCM info flag that disables the control and status mmap, and implements two new buffer types, SNDRV_DMA_TYPE_NONCONTIG and SNDRV_DMA_TYPE_NONCOHERENT. The former is the SG-buffer and the latter is the continuous page allocation, corresponding to SNDRV_DMA_TYPE_DEV_SG and SNDRV_DMA_TYPE_DEV on x86. Unlike other page types, those are directional (that need the DMA direction at allocation time) and require the explicit sync of buffers around the data transfer (flushing, invalidating). The sync is implemented inside ALSA PCM core and automatically applied at updating the applptr and hwsync via SYNC_PTR ioctl, which should be issued during mmap operation, so it should work transparently as long as applications are running with alsa-lib. For tinyALSA, we might need to revisit the implementation. This is currently an RFC -- more exactly, CALL FOR TESTERS, as I have no Arm machine with the sound device for now. The needed change for an existing driver is simple: * Replace the buffer type from SNDRV_DMA_TYPE_DEV to SNDRV_DMA_TYPE_NONCOHERENT (or from SNDRV_DMA_TYPE_DEV_SG to SNDRV_DMA_TYPE_NONCONTIG), which is set up typically in snd_pcm_set_managed_buffer*() call. * Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag to the PCM runtime hardware.info field It'd be greatly appreciated if anyone can test and try the changes, and help debugging. Again, the code is faily untested. The latest code is found in topic/memalloc-noncontig branch of my sound git tree: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git The patch set is based on for-next branch, i.e. changes for 5.15 are included. thanks, Takashi === Takashi Iwai (5): ALSA: memalloc: Count continuous pages in vmalloc buffer handler ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag ALSA: memalloc: Assign ops field to snd_dma_buffer ALSA: memalloc: Support for non-contiguous page allocation ALSA: memalloc: Support for non-coherent page allocation include/sound/memalloc.h | 48 +++++++- include/uapi/sound/asound.h | 1 + sound/core/memalloc.c | 223 ++++++++++++++++++++++++++++-------- sound/core/memalloc_local.h | 1 + sound/core/pcm_lib.c | 9 ++ sound/core/pcm_memory.c | 13 ++- sound/core/pcm_native.c | 22 ++++ 7 files changed, 263 insertions(+), 54 deletions(-) -- 2.26.2