From patchwork Wed Jul 13 15:19:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 12918206 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 0BC03C43334 for ; Thu, 14 Jul 2022 16:38:55 +0000 (UTC) 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 40043180D; Thu, 14 Jul 2022 18:38:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 40043180D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1657816733; bh=0lMnN8TYh2PQWfbGnXTKoT+meILKEXksSUZFL3FLEF4=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=b1kirxexkzU3Uw6vv/FSKbsSt9YEEcxGR0m5wDzVNw82R36xnEHrnQIbvVotKvP5C b+bscgZb+YeTWFNUqrIQ/IGdpaOnE1r1TzNBCZdoPrdmfgyscygIwgAk+PvKC+Q58H mCUsqJballJgjpiK7Epw/YHGyZO2lpTZa9BLl0Jo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A4988F805AE; Thu, 14 Jul 2022 18:34:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 213B2F80249; Wed, 13 Jul 2022 17:20:08 +0200 (CEST) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 C2D21F80134 for ; Wed, 13 Jul 2022 17:19:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C2D21F80134 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UbfTqu9U" Received: by mail-wm1-x32b.google.com with SMTP id l42so6645676wms.5 for ; Wed, 13 Jul 2022 08:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x6cQzIVXOIBGsoXiuif7G7saQrxwRpZyrgHwFA3owXw=; b=UbfTqu9UK6HYMNNZQE81zT8rSE22hs7tx/XmkR6naxIYHSRGj6AEx6AltM1hsmzR4F 4bXiETy55+RlwNvk1IjEOCCbrBKWjYwh8FJes5Nj5Gtm0KJ0htpOIJcD7Hqwk2zDs7Iq TdthzJ+MRMfxWgMott1HwM2DG2cj/Ltjf6j/wAqI5snSDTfKrvkC9XrwI0qTjTRcvv+c 5LWJTTUyjFR99MZfzZv0TGCrJP0PiIujZlTZZ4o1r1cfo8P2cE8WuqC3pSDEs4JlOAeL YWJ0AJHbxRcc0zRWjx++Lf/SLw0q11YGW/x+ml0SCKTD9TzAh2NljacWhysNuOeW9n9o irzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x6cQzIVXOIBGsoXiuif7G7saQrxwRpZyrgHwFA3owXw=; b=tcUKdguuWbMTU8OS8ozOPin0qTre29PQ004xCpPWmDY6hBFm599a7Q7T7K642Zal6Y 1Tce6RltPNTc05ck+GZkeVmKI4qweFcKfDk8FeSRu4i4sRwekXlOC2qFwDabtL3xnfqA JI0FnBTCCJ604R8wpnbdHcZmPLBCpRkGxQXZdKMqfV+UUm8o5uTcNTbQoIoDDtkcOTU5 OXQ+fgBy17Yss4H1rwkYEW64Yqf9n1x2GDiA3UM5KC313vJ6ZaljJ937eAxjclYpglO9 N+UqraHKHtPQr6ZCYNAY1VFsEC0jcaqwXiWxJdmF9w2tSC0RV+CYX67Jk1bA2WY5KTmj es4A== X-Gm-Message-State: AJIora/GyIbYny5EcnRyS6IxTguaurQqpwy8tpT3dvAQ8mHvn5mdngjL BgsIMeMCQRFeXIk30BS2NykH8TI9vrM= X-Google-Smtp-Source: AGRyM1vdjvXKJQAC8aIpaLRCPxjr+/igY107IqJbiR9fjfmShIfWeDr52ubwhRVrPyxEKfoziD1OXw== X-Received: by 2002:a05:600c:1e20:b0:3a2:e540:17ad with SMTP id ay32-20020a05600c1e2000b003a2e54017admr4151536wmb.205.1657725598094; Wed, 13 Jul 2022 08:19:58 -0700 (PDT) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id i16-20020a05600c355000b003a2f88b2559sm2329150wmq.44.2022.07.13.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 08:19:57 -0700 (PDT) From: Uros Bizjak To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: usb-audio: Use atomic_try_cmpxchg in ep_state_update Date: Wed, 13 Jul 2022 17:19:46 +0200 Message-Id: <20220713151946.4743-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 14 Jul 2022 18:34:36 +0200 Cc: Takashi Iwai , Uros Bizjak 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" Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old in ep_state_update. x86 CMPXCHG instruction returns success in ZF flag, so this change saves a compare after cmpxchg (and related move instruction in front of cmpxchg). No functional change intended. Signed-off-by: Uros Bizjak Cc: Takashi Iwai --- sound/usb/endpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index f9c921683948..0d7b73bf7945 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -133,7 +133,7 @@ static inline bool ep_state_running(struct snd_usb_endpoint *ep) static inline bool ep_state_update(struct snd_usb_endpoint *ep, int old, int new) { - return atomic_cmpxchg(&ep->state, old, new) == old; + return atomic_try_cmpxchg(&ep->state, &old, new); } /**