Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5768653pxu; Thu, 22 Oct 2020 10:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoO/w/FtePhnE86Mj3ycA+ikVyi/lqPA9O43jXPAVkPaOl8FQi8mvkaHbF47GPIr+W85CM X-Received: by 2002:a17:906:5402:: with SMTP id q2mr3313438ejo.316.1603387877015; Thu, 22 Oct 2020 10:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603387877; cv=none; d=google.com; s=arc-20160816; b=l1XSScUZ/zlcEC5bYOB1bIcCRTM1U1qQGaoYk7sIQi+N/gKt2bX540ro+upC38qHip l7hOJSb4Lq2rNRrxzwy5WLb5zFA6C2j+l2/rlai+Y1/RyUlzJs5xuZ3V9g1xsSfwZzM+ HlufmvZtnxIrLpUsRS4ZAZvansW2mmFP26QwuUQZd3ATq7TdHdUv4wPBqpFdPuOBGupN l1iqP7MkWZWqZRK4rVQAUGhJHyVC6KFbenuT7zj48itrueilWDcNF9F084klEabgXGpi OuLhCPqD1s6esA4vS/OmHGqTTgu5PI/HRz2Je9eQM8/kAgsOP/ZtA+nCKe5NXY8Grqnb xFyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2yAG9S+Ulrc8Y0OtRznvqZuJoXdcYomoP5AW0EBtHVg=; b=Q/PeLRqc6ZqDnazv3lWsDVKeQJ9J3NIPRo31gVbcycnU0BOcsfb8uRmexiB8rhWKAW DatiS/FsSSU8nShslRgL0AxG5wz0uCToOGPwzqLE3smWppNj6luLLnhl9eEDg5E/ASy6 crMZ8Uw83MoK13W9ovfsk/uIG3tq73AhcccBvv35kjKD6APeGxEpTksPNIV05mNrJvZw r7CtuQAm//mpwy3wj4WmSMHnVE7mLG6qaxW0qBM1amBVWLttSFZVSkmsnpT+h+bzY5VW przekPrLSXgEqXW04fBjKn+kfwbGLHGa+CBUm8qCgXDopDCpMTALBGCApQBHJEeCgCD+ yNbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ARFKFl11; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si1370795eds.559.2020.10.22.10.30.54; Thu, 22 Oct 2020 10:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ARFKFl11; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368045AbgJVNvI (ORCPT + 99 others); Thu, 22 Oct 2020 09:51:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2507012AbgJVNvG (ORCPT ); Thu, 22 Oct 2020 09:51:06 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 124A921D43; Thu, 22 Oct 2020 13:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603374665; bh=FMBUOMBhj2bHvXWwbhpY2/I5JZIS5H8lhCJdsmME7m4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ARFKFl11lu3S/EB1h+81jludIC0YHswdCCkdjvg48PkanhyvwBzw8DochJBLiUs1C zZOd1/cY1Khh3DplqjRMSz+li+sASq9CDLbu1eDCKrUn2JgjGR2N0gENxratM5sbKA sKrUd+VtpGeE6AgJsQNGr3josASCMelFCvw4mBQk= Date: Thu, 22 Oct 2020 14:50:53 +0100 From: Mark Brown To: Maxime Ripard Cc: Jaroslav Kysela , Takashi Iwai , Liam Girdwood , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Dom Cobley , Dave Stevenson , Nicolas Saenz Julienne Subject: Re: Context expectations in ALSA Message-ID: <20201022135053.GB4826@sirena.org.uk> References: <20201022095041.44jytaelnlako54w@gilmour.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cvVnyQ+4j833TQvp" Content-Disposition: inline In-Reply-To: <20201022095041.44jytaelnlako54w@gilmour.lan> X-Cookie: Some settling may occur. User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --cvVnyQ+4j833TQvp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 22, 2020 at 11:50:41AM +0200, Maxime Ripard wrote: > This is caused by the HDMI driver polling some status bit that reports > that the infoframes have been properly sent, and calling usleep_range > between each iteration[1], and that is done in our trigger callback that > seems to be run with a spinlock taken and the interrupt disabled > (snd_pcm_action_lock_irq) as part of snd_pcm_start_lock_irq. This is the > entire stack trace: That doesn't sound like something I would expect you do be doing in the trigger callback TBH - it feels like if this is something that could block then the setup should have been done during parameter configuration or something rather than in trigger. > It looks like the snd_soc_dai_link structure has a nonatomic flag that > seems to be made to address more or less that issue, taking a mutex > instead of a spinlock. However setting that flag results in another > lockdep issue, since the dmaengine controller doing the DMA transfer > would call snd_pcm_period_elapsed on completion, in a tasklet, this time > taking a mutex in an atomic context which is just as bad as the initial > issue. This is the stacktrace this time: Like Jaroslav says you could punt to a workqueue here. I'd be more inclined to move the sleeping stuff out of the trigger operations but that'd avoid the issue too. There are some drivers doing this already IIRC. > So, I'm not really sure what I'm supposed to do here. The drivers > involved don't appear to be doing anything extraordinary, but the issues > lockdep report are definitely valid too. What are the expectations in > terms of context from ALSA when running the callbacks, and how can we > fix it? To me having something in the trigger that needs waiting for is the bit that feels the most awkward fit here, trigger is supposed to run very quickly. --cvVnyQ+4j833TQvp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl+Rjj0ACgkQJNaLcl1U h9BMKgf+OmxlYVeRiaWoVuqLzW0RkFEqg3gdo4tCH7AWBWr1/fM/ZgSWGi3t3/wQ e3ZmLa/iG8v+/m44FRY4eYzrDjIQrp6JGViQKjYqIAw/rvS9IXwbBmChRUkP99WI NGNLcugo+5YNkFNAfPxRpy1sD27KSG0yaZzlt4RfGhwWuEF6bT0QnzZ+O4ClVMzE cBs8QHmqkQj5wRtkvwCk6imE4nDTvwBMAESADkA0a8guJJjvsFzEiPikEAKJaS5a 2ZfkLPhxoyCJWvJ9CxP37WK3uJcjmZXKkXX8Im7KSvvxrqx0H4aOXyYUUYlOEAuy 7vfZkmC7DsUGs8w9lTqKn6cOcq4oFg== =hlNw -----END PGP SIGNATURE----- --cvVnyQ+4j833TQvp--