From patchwork Tue May 18 16:51:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 442523 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, 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 72BF7C433B4 for ; Tue, 18 May 2021 16:53:52 +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 9762D611BD for ; Tue, 18 May 2021 16:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9762D611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de 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 DADB3174C; Tue, 18 May 2021 18:52:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DADB3174C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621356829; bh=xj8SUTbV6H42hASj1pxu3Am9johOmXWpQNqO8Uv6epA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=S7SDvqeps0hfQSz6Bm3fkfdCwkRSIVFO9CD7qaqEKOpNYFolNBWp12YWCqmVSkEld zgHUlDtHK1643zhD2EcTZMEdcGeMkJoFxzumzrIUBVLvXkPGTCGWM6iYYNPj8trFBS NAaLVjuPr/7scA+fnJY+zA0HmTjumvDW5nGwnErc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7A96CF80425; Tue, 18 May 2021 18:52:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2B7A8F80430; Tue, 18 May 2021 18:52:10 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (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 D9F51F801DB for ; Tue, 18 May 2021 18:52:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D9F51F801DB X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 48552B150; Tue, 18 May 2021 16:52:03 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 1/7] ALSA: core: Use READ_ONCE() / WRITE_ONCE() for power state change Date: Tue, 18 May 2021 18:51:55 +0200 Message-Id: <20210518165201.24376-2-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210518165201.24376-1-tiwai@suse.de> References: <20210518165201.24376-1-tiwai@suse.de> MIME-Version: 1.0 Cc: Andrey Grodzovsky 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" We need proper barriers to handle the power state change of the card from different CPUs. Signed-off-by: Takashi Iwai --- include/sound/core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 1f9aef0adbc9..d69dfc6c4953 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -142,12 +142,12 @@ struct snd_card { #ifdef CONFIG_PM static inline unsigned int snd_power_get_state(struct snd_card *card) { - return card->power_state; + return READ_ONCE(card->power_state); } static inline void snd_power_change_state(struct snd_card *card, unsigned int state) { - card->power_state = state; + WRITE_ONCE(card->power_state, state); wake_up(&card->power_sleep); }