Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1858933rwb; Wed, 5 Oct 2022 06:01:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jXXAevwxgJuqvPRfIBDVK9Gt6UPXxNwh7nFIl+AEqEWn1eDLDTM/gHawOcZrQwe+RuUVZ X-Received: by 2002:a05:6402:557:b0:458:7488:8958 with SMTP id i23-20020a056402055700b0045874888958mr23848260edx.242.1664974863110; Wed, 05 Oct 2022 06:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664974863; cv=none; d=google.com; s=arc-20160816; b=RuSBLOZfWCEj++keiEo98N75THCgYFv/IrzkCPVUhkBfoQGlcareBomN3Xq9fbWIqZ uCIxdZc7GORzxH+4O42ZnDKCtLaN6/Lis7kJZMXme9954elkPRjzwvbSQfEViu+qKQ8f xywCzAnayC8baprRAxuIcmQDUeOgzkwmHx/uFJiz/Abo9Ac6izxBGS3yutW/CxWQk+ju H2ljfC4K1wJSHtzAv99PwRv4ffUrU1L8dhqwOMylvjpa4ZP2lw52CAt7m8fVz5PNgaru EzetTSy1TlCZCw5ozLSfnKMxK2zTnBmwEYYRqHyQazGpo3CQ9I4RTwzG38GNKKcSdtKZ Sz2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature:dkim-signature; bh=u/8GR/Kq2197POrlb3Z0XSA69VpAh7DDJ2yh6w32HEE=; b=mAc+n8blsCso1vyy1nMiAqqLSSj8YKtK/uqemuYYI6nLpZxePUlmHKN3KNCNPhO5Fh oxdYjbbpKSB2zHAnz39PqQOeLeNS4r6bdNgFGPoYV11kORER2e8IK9iPRcbDrGYBJ1Sj QOI4l6O6wtKp+HP6kmJ2ttV+/JX3NDubFPn7YlixLbSDATp1/P8GwYN9ZtuErU6exRaB ndVhsilnoD6X06++TB9Z03Mdke14to24gVwGPunehvYbj26QuNQe/pQ8sQbdGMezCAAl 7NZrVdCL9BcTp8M5tvBv4FnL3jjn4WjvsAucVBVLCMtFnMdzOuVbLtY6mwqBHs0F1goy 4Utg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=o80yfHY0; dkim=neutral (no key) header.i=@suse.de header.b=2LljzEJO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw23-20020a1709066a1700b00779a3220c5asi13403902ejc.343.2022.10.05.05.59.35; Wed, 05 Oct 2022 06:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=o80yfHY0; dkim=neutral (no key) header.i=@suse.de header.b=2LljzEJO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229598AbiJEM3i (ORCPT + 99 others); Wed, 5 Oct 2022 08:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiJEM3g (ORCPT ); Wed, 5 Oct 2022 08:29:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04984DB; Wed, 5 Oct 2022 05:29:34 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BA13B2189F; Wed, 5 Oct 2022 12:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1664972972; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u/8GR/Kq2197POrlb3Z0XSA69VpAh7DDJ2yh6w32HEE=; b=o80yfHY0Zi28fKsec7y4wlldToSYEmO8b8DULSvWNGUVVUsRM/vNS9LWGb2/L422ovBWzT CV0P7ewIUddqY4xOee3PZWl+oaU1Rs5FXXttyeu78ub/b5p5rVs+hfLRmOSa/32tG0RDCr ntvPpjVE481nCWN7mBfzuLlGhmLqEmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1664972972; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u/8GR/Kq2197POrlb3Z0XSA69VpAh7DDJ2yh6w32HEE=; b=2LljzEJORJ6XeXKXnZt3J3XtG+rgiTh6Y3tFNuwS/VeLWsKvLqE/eL8bgk047QLztaIVHl 5bW7DyxSIOREhpDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7AD6E13ABD; Wed, 5 Oct 2022 12:29:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yellHax4PWOCawAAMHmgww (envelope-from ); Wed, 05 Oct 2022 12:29:32 +0000 Date: Wed, 05 Oct 2022 14:29:31 +0200 Message-ID: <87a66av4gk.wl-tiwai@suse.de> From: Takashi Iwai To: Jon Hunter Cc: Amadeusz =?ISO-8859-2?Q?S=B3awi=F1ski?= , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Cezary Rojewski , Pierre-Louis Bossart , Jaroslav Kysela , "linux-tegra@vger.kernel.org" , Mohan Kumar D Subject: Re: [PATCH v2 2/4] ALSA: hda: Rework snd_hdac_stream_reset() to use macros In-Reply-To: <657d2418-0c3e-296f-8f4a-dc10ced2dffe@nvidia.com> References: <20220818141517.109280-1-amadeuszx.slawinski@linux.intel.com> <20220818141517.109280-3-amadeuszx.slawinski@linux.intel.com> <657d2418-0c3e-296f-8f4a-dc10ced2dffe@nvidia.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 05 Oct 2022 14:10:04 +0200, Jon Hunter wrote: > > > On 18/08/2022 15:15, Amadeusz S?awi?ski wrote: > > We can use existing macros to poll and update register values instead of > > open coding the functionality. > > > > Reviewed-by: Cezary Rojewski > > Signed-off-by: Amadeusz S?awi?ski > > --- > > sound/hda/hdac_stream.c | 26 ++++++-------------------- > > 1 file changed, 6 insertions(+), 20 deletions(-) > > > > diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c > > index f3582012d22f..bdf6d4db6769 100644 > > --- a/sound/hda/hdac_stream.c > > +++ b/sound/hda/hdac_stream.c > > @@ -165,7 +165,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_stop_streams_and_chip); > > void snd_hdac_stream_reset(struct hdac_stream *azx_dev) > > { > > unsigned char val; > > - int timeout; > > int dma_run_state; > > snd_hdac_stream_clear(azx_dev); > > @@ -173,30 +172,17 @@ void snd_hdac_stream_reset(struct hdac_stream *azx_dev) > > dma_run_state = snd_hdac_stream_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START; > > snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, > > SD_CTL_STREAM_RESET); > > - udelay(3); > > - timeout = 300; > > - do { > > - val = snd_hdac_stream_readb(azx_dev, SD_CTL) & > > - SD_CTL_STREAM_RESET; > > - if (val) > > - break; > > - } while (--timeout); > > + > > + /* wait for hardware to report that the stream entered reset */ > > + snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, (val & SD_CTL_STREAM_RESET), 3, 300); > > if (azx_dev->bus->dma_stop_delay && dma_run_state) > > udelay(azx_dev->bus->dma_stop_delay); > > - val &= ~SD_CTL_STREAM_RESET; > > - snd_hdac_stream_writeb(azx_dev, SD_CTL, val); > > - udelay(3); > > + snd_hdac_stream_updateb(azx_dev, SD_CTL, SD_CTL_STREAM_RESET, 0); > > - timeout = 300; > > - /* waiting for hardware to report that the stream is out of reset */ > > - do { > > - val = snd_hdac_stream_readb(azx_dev, SD_CTL) & > > - SD_CTL_STREAM_RESET; > > - if (!val) > > - break; > > - } while (--timeout); > > + /* wait for hardware to report that the stream is out of reset */ > > + snd_hdac_stream_readb_poll(azx_dev, SD_CTL, val, !(val & SD_CTL_STREAM_RESET), 3, 300); > > /* reset first position - may not be synced with hw at this > > time */ > > if (azx_dev->posbuf) > > > HDA playback is failing on -next for various Tegra boards. Bisect is > point to this commit and reverting it fixes the problem. I was a bit > puzzled why this change is causing a problem, but looking closer there > is a difference between the previous code that was calling > snd_hdac_stream_readb() and the new code that is calling > snd_hdac_stream_readb_poll(). The function snd_hdac_stream_readb() > calls snd_hdac_aligned_mmio() is see if the device has an aligned MMIO > which Tegra does and then would call snd_hdac_aligned_read(). However, > now the code always call readb() and this is breaking Tegra. > > So it is either necessary to update snd_hdac_stream_readb_poll() to > handle this or revert this change. Does the patch below work? thanks, Takashi -- 8< -- --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -592,8 +592,8 @@ int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus, #define snd_hdac_stream_readb(dev, reg) \ snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) #define snd_hdac_stream_readb_poll(dev, reg, val, cond, delay_us, timeout_us) \ - readb_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ - delay_us, timeout_us) + read_poll_timeout(snd_hdac_reg_readb, val, cond, delay_us, timeout_us,\ + false, (dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) #define snd_hdac_stream_readl_poll(dev, reg, val, cond, delay_us, timeout_us) \ readl_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ delay_us, timeout_us)