From patchwork Thu Jul 13 07:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13311484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 236FDEB64DD for ; Thu, 13 Jul 2023 08:08:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CAD263E7; Thu, 13 Jul 2023 10:07:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CAD263E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689235689; bh=u8/1Ke69uTiV1kx6vnwfL57G/ak/cvE+6M63Jr4+byY=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=E6o7dTu8T8qpYR2+edf5mqAbua8RHtgpGJ/UUeCFxzIm++1DyOylTTqSfW9Ju/io1 cSBo6teIkCaFsoJQbc5egCW7yWxQ1Oyk98atLGQANdV4i1LZRoS89/DUSQjfhg9yoz j8a9Z34ENGu26vZRtQk1jIwGtwZBFxK5oNgTqp1M= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6AE5CF80553; Thu, 13 Jul 2023 10:06:29 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E7745F80552; Thu, 13 Jul 2023 10:06:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6757F8024E; Thu, 13 Jul 2023 10:00:11 +0200 (CEST) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 143E3F80153 for ; Thu, 13 Jul 2023 10:00:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 143E3F80153 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=ZPCjuNgz Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fb7bbbfa95so133173e87.0 for ; Thu, 13 Jul 2023 01:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689235205; x=1689840005; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=f23IFSdAOOx9PAA+0aLReuK2qCBP8wxWyzhLV70mA1Y=; b=ZPCjuNgzjHKy2ukXiMpF5+1SaokuO4SFHcj6+qof6IjynhPZbDizhhjdWOE0RpuNPR NhghNqr7XvvXoxL9KbOnd9NKm+a3waju4+jxeXmyICV7qkn5Hay6z5+3dHFDtwmG5flN wLa4R3ocItGUmtWTw7j2PCiF9lzuxFIuJFRVCA54nmFogl5IGt51PPsNZWIxWOT/2Ggo 4jHKcLNDQxYzqViUb52biOOzzXZZyI5fkkUX2K9xc9xB166kLY/tJzbtDQzdWRStlF1m t8qapuor1wm5GWV5FFM/bjDXG4tLmpmQoxzihdCdls6rnKiy0zyjSCvlxUp6FPnzpwIt pouw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689235205; x=1689840005; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f23IFSdAOOx9PAA+0aLReuK2qCBP8wxWyzhLV70mA1Y=; b=g1Dgi9wSw+Fk4p9/ZLwtG1V2i/DZA/z/WhdM+rmJg3Dgua5TwSVTKVfcr3gBHjKhmb qIx+xw81B19wjH2iRfYPmAGohrO8IhRefMBUr3smuvqlgcZmcUR+0EV79CFINhj4QXfH dHqG1nEaue6JGxH8JSxpsvYLr0Q+L7SefVXC9+IKkPcP5m7ru7tEIKB9Rllqp5X9QB/f MUSlyAkNvwCHr/yU51gYjjfXR4e6Fr2mVT9Eci5gAWu0QARWN9/F4cy/DRkvG4XUNVm7 3fPzwQhheg4hFDnRwH8P9+Nv9BLnt5kkXjfYa4IhYKwa80w/Az0rAZOnGflC4XUJoQiT QZpQ== X-Gm-Message-State: ABy/qLYnfNZCdqZ8OdDZKCmp+nUouk2/Ndk0A13Wea1W2EvpFieIr63m lip7yXrP+oEMpiL0Nzuaq7I= X-Google-Smtp-Source: APBJJlGtg3kc9cR2gS2y8xggbKx8I5ncgNvVW0HhONStlpTat/Dts17uh0AzUS7JnmEXKghRuez/yw== X-Received: by 2002:ac2:53ad:0:b0:4fa:73ea:aa2d with SMTP id j13-20020ac253ad000000b004fa73eaaa2dmr487312lfh.4.1689235204577; Thu, 13 Jul 2023 01:00:04 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([178.160.196.94]) by smtp.gmail.com with ESMTPSA id q8-20020ac25288000000b004fb8c0f247fsm1011385lfm.129.2023.07.13.01.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:00:04 -0700 (PDT) From: Ivan Orlov To: perex@perex.cz, tiwai@suse.com Cc: Ivan Orlov , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] ALSA: pcmtest: Add 'open' PCM callback error injection Date: Thu, 13 Jul 2023 11:59:52 +0400 Message-Id: <20230713075953.13692-1-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-MailFrom: ivan.orlov0322@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: SUI3LVY447PK6K3QFBMHK5WRCGMDPHLN X-Message-ID-Hash: SUI3LVY447PK6K3QFBMHK5WRCGMDPHLN X-Mailman-Approved-At: Thu, 13 Jul 2023 08:06:23 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Extend 'pcmtest' virtual driver with 'open' callback error injection functionality, as it already can inject errors into other PCM callbacks. Add module parameter which enables EBUSY error injection in the 'open' PCM callback. Signed-off-by: Ivan Orlov --- V1 -> V2: - Split changes in the patch into two different patches sound/drivers/pcmtest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index 291e7fe47893..e74c523e49eb 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -65,6 +65,7 @@ static int inject_delay; static bool inject_hwpars_err; static bool inject_prepare_err; static bool inject_trigger_err; +static bool inject_open_err; static short fill_mode = FILL_MODE_PAT; @@ -88,6 +89,9 @@ module_param(inject_prepare_err, bool, 0600); MODULE_PARM_DESC(inject_prepare_err, "Inject EINVAL error in the 'prepare' callback"); module_param(inject_trigger_err, bool, 0600); MODULE_PARM_DESC(inject_trigger_err, "Inject EINVAL error in the 'trigger' callback"); +module_param(inject_open_err, bool, 0600); +MODULE_PARM_DESC(inject_open_err, "Inject EBUSY error in the 'open' callback"); + struct pcmtst { struct snd_pcm *pcm; @@ -364,6 +368,9 @@ static int snd_pcmtst_pcm_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct pcmtst_buf_iter *v_iter; + if (inject_open_err) + return -EBUSY; + v_iter = kzalloc(sizeof(*v_iter), GFP_KERNEL); if (!v_iter) return -ENOMEM; From patchwork Thu Jul 13 07:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Orlov X-Patchwork-Id: 13311485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DD065EB64DD for ; Thu, 13 Jul 2023 08:08:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BD4544E; Thu, 13 Jul 2023 10:07:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BD4544E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689235695; bh=k1t7EGxyj2v6chAtKe0HuXuEvZijx6eZ9AqnjfNyULA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fzM9oZCTSNu6BwN4+Kk98IKQ7ESgl2koJ6rUaIW2MnsVu5oBmhPmPJByxyTk2SHkj ojSr7k+X+qz0U49f///n45VgELPJVBSzY1bf7tMUB5nJX1LDSDQZIsUaRWmUhXPTxH 35WuJ6tTFVGxQRp1ZqkpvmwTFnIX2xbFL2BNwrmk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F332CF80563; Thu, 13 Jul 2023 10:06:31 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6A802F80563; Thu, 13 Jul 2023 10:06:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2132F80249; Thu, 13 Jul 2023 10:00:13 +0200 (CEST) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9D959F80236 for ; Thu, 13 Jul 2023 10:00:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D959F80236 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=AbdHpSx4 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4fccade2141so38722e87.0 for ; Thu, 13 Jul 2023 01:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689235208; x=1691827208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zQWUSEoOR5t3MEXAfVU6qpzWsgyy+Mooxn06h3Z1zKo=; b=AbdHpSx4W0NU1QBnqdMfK5CRrsrCnCDXoNeNtfRok8O6iX1amyWXGG5Mk/QKRKTAwC 9KW+bTz5eZFBTyuq4Y0wxP7KBdIO836HbQ73gkAb493zR4IwTrjk0tsXs3/IELE/H7wm VxkVNCGVeEIaAUwf0aZpMLOCq7J2zB+Pp84scSphSsXA1XTWl2vYk+4Oy++5BFR1ilkD wYDeskynXwOoE17nfa7gMUCT46k8f3zhiWQHJFTEOW9elUY+8yzuowcG3/TY8SJAaaje 3Irjw2wlQ7B04AwJXPzb7gUGC1jcJbNNAMu+TbJt+VGfwjl1cseVeke5MlxYgx6EqwLv FTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689235208; x=1691827208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zQWUSEoOR5t3MEXAfVU6qpzWsgyy+Mooxn06h3Z1zKo=; b=WaglONjFbt7sSE79amBzh7ca7eGRzxg0xdJ5u0ML+6swjfum2PvYy3zkyAamcRMHG/ clU9MIlDs1jHNGmOkGivpY8vkEVQ15yHm8ViiMjZyTezX1TWEYEClr18nztTIrbUR2dm QqUO7CZSbl9eLp1oZioXuh4Be18LDCfq0/eJxToF8IDZC2yQdF8/9TxGcYRShpk+o3Pz weLN+sjSymR4dvpBaCtf5SsKZQ28+blMB/In2nfUdqcf/av5w9B5qrmWBPvsglIGN+H+ ewizYSIWsHG/rPzYlMKbx66iS4+MdRNF5oeW/3qbGdwThbkegG3fEjeKHkuuahQc4P9Z f2NQ== X-Gm-Message-State: ABy/qLZNYEeIpSvf8ez+raeJfOtVPiQ+8dwjlVhptxwxXjTzOhE2n6we yWWZgjr0Ehks/g7QlIPIzdo= X-Google-Smtp-Source: APBJJlHt2Zs4KS1Le0F4m4coeU4CvQdR1DZX2Yu483HL8m6d0Nk0AYwmmEWZ6I3sZYF5Hpm0aqVZoA== X-Received: by 2002:ac2:4833:0:b0:4fb:8eac:8571 with SMTP id 19-20020ac24833000000b004fb8eac8571mr491482lft.0.1689235208117; Thu, 13 Jul 2023 01:00:08 -0700 (PDT) Received: from ivan-HLYL-WXX9.. ([178.160.196.94]) by smtp.gmail.com with ESMTPSA id q8-20020ac25288000000b004fb8c0f247fsm1011385lfm.129.2023.07.13.01.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 01:00:07 -0700 (PDT) From: Ivan Orlov To: perex@perex.cz, tiwai@suse.com Cc: Ivan Orlov , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] ALSA: pcmtest: minor optimizations Date: Thu, 13 Jul 2023 11:59:53 +0400 Message-Id: <20230713075953.13692-2-ivan.orlov0322@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713075953.13692-1-ivan.orlov0322@gmail.com> References: <20230713075953.13692-1-ivan.orlov0322@gmail.com> MIME-Version: 1.0 X-MailFrom: ivan.orlov0322@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: VGLDUMMEHMNKMAQ7IH6WHNQAXK6RX7KS X-Message-ID-Hash: VGLDUMMEHMNKMAQ7IH6WHNQAXK6RX7KS X-Mailman-Approved-At: Thu, 13 Jul 2023 08:06:23 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Decrease the buffer filling overhead with conditional remainder calculation in the 'inc_buf_pos' inline function. Fix the driver to use already defined variables where it is possible in 'check_buf_block_ni' and 'fill_block_pattern_n' functions. Signed-off-by: Ivan Orlov --- V1 -> V2: - Split changes in the patch into two different patches sound/drivers/pcmtest.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index e74c523e49eb..08e14b5eb772 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -144,7 +144,8 @@ static inline void inc_buf_pos(struct pcmtst_buf_iter *v_iter, size_t by, size_t { v_iter->total_bytes += by; v_iter->buf_pos += by; - v_iter->buf_pos %= bytes; + if (v_iter->buf_pos >= bytes) + v_iter->buf_pos %= bytes; } /* @@ -200,10 +201,10 @@ static void check_buf_block_ni(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ru u8 current_byte; for (i = 0; i < v_iter->b_rw; i++) { - current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)]; + ch_num = i % channels; + current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)]; if (!current_byte) break; - ch_num = i % channels; if (current_byte != patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]) { v_iter->is_buf_corrupted = true; @@ -243,7 +244,7 @@ static void fill_block_pattern_n(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ for (i = 0; i < v_iter->b_rw; i++) { ch_num = i % channels; - runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)] = + runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)] = patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]; inc_buf_pos(v_iter, 1, runtime->dma_bytes);