From patchwork Wed Jan 18 15:44:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 45347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2409104wrn; Wed, 18 Jan 2023 07:47:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3kx5N5tS6HRb4QhcsawPkhwjswX/RBdQY02KzPz9XCZApVf9Py1djPrXiM1LOwhtS4boQ X-Received: by 2002:a17:907:7f14:b0:84d:3e5b:7c02 with SMTP id qf20-20020a1709077f1400b0084d3e5b7c02mr4925837ejc.22.1674056856042; Wed, 18 Jan 2023 07:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674056856; cv=none; d=google.com; s=arc-20160816; b=TZxZVDRG+DCmUO1wCTFy+ESENZOBMReo0GlHLj+2i0e72mwCtex8qcrQ1qjjAbEham C57+BzVAi/JoR109l5TvdEZj7v2YBAMTPk02adme/6Q5pdpoU0Iuz+LpBoDoTmZPjiUB 6K7xLQSrV4wBErsjiOmqH7MnMfHWS1WxaZWu10ZDhgBuluObjtDMKf+agJ32WYWp7yGy AbxHeWJyV3WHeSKRySVkOISfMR6c1eOYGpEkonmen/Gpc6E35mFL6J4Uugu6ssOQ1tKv ntC6iVP55KW03rko7a8uowmLmUU40EhyJ12OWh63/ArY02nqaF6t/0RZRKBZed/BRhQ0 zWhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x9gcJtZ+K+8NK3iaEwGRBmGCqNTTSqj8WV09GiO8V5A=; b=Td83P0DvcmJjPkgZ88+IoCNlmRAjxGEYXkz3b3njnsDiuSoPFhpI2e6pQgrX2MU70s 40WFMnyyxdF114/h2ykd3A52b6/JvN4ZBuNDKtZBRPkhscqAY9cWw6P/fvHYerzzn9X8 XmxqBt5LJx8jjlfAhrQE/LxfCdlVrVj12aa+dKgMAWrcw97EpPVdmK/e0rJHF0+LWJVj Cq0TOiRJdnmVSnG0zvm7AniE3rPe2Z7/oeXVUv1mjO1TDMGfdF4DKLNcpDCPIBemhjB4 PHyAaC14j+2T5Z7vNSIxW0/Qk4kWDU/Z54obvaawPMEWEP4xuLs3c7Bmr2pQvdw6Ieu0 r1PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ARBxIRa8; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj1-20020a170906db0100b007c4fadff8dasi39951732ejb.933.2023.01.18.07.47.12; Wed, 18 Jan 2023 07:47:36 -0800 (PST) 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=@intel.com header.s=Intel header.b=ARBxIRa8; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbjARPqt (ORCPT + 99 others); Wed, 18 Jan 2023 10:46:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjARPqV (ORCPT ); Wed, 18 Jan 2023 10:46:21 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578FB392B4; Wed, 18 Jan 2023 07:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674056742; x=1705592742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6s3fA2jhqnAHgwbfGrKCZDIy07cNkborYz0vvTXb80k=; b=ARBxIRa8dOe2aTvANSHwhwDAZb/B9J/CYENY+VceAGs91iYP2hvhVcFL pgbPbT+ghnRyGID5IspmKMbimup3eB+zT+zhYr23FiinwIoC39VoqR9CO wXWJdp5rdit6EftFTiUxYU/k9n8fOTQLrUWxxfsc60GcTdwbP11pce3fO 3Fy9/3DHTcxWZbO0cITD88Komsj1sPIq9b+HLiKV87Z1n4yeHxbxtlAvY tgVskRL0vd22R3O1u9u2Ca14pI2UgL7YvOI2YTXrclBAqqjrsJdFeq89n qMUr2FsG8n1SY0NqBwjIZpNc+51WUhmRMOGXsaUejTZSC+jl1nyJOL90P A==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322701411" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="322701411" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 07:45:40 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="661759384" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="661759384" Received: from lab-ah.igk.intel.com ([10.102.42.211]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 07:45:35 -0800 From: Andrzej Hajda To: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Andrzej Hajda , Arnd Bergmann , Rodrigo Vivi , Andrew Morton , Andy Shevchenko , Peter Zijlstra , Boqun Feng , Mark Rutland Subject: [PATCH v5 6/7] qed: use __xchg if possible Date: Wed, 18 Jan 2023 16:44:49 +0100 Message-Id: <20230118154450.73842-6-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118154450.73842-1-andrzej.hajda@intel.com> References: <20230118153529.57695-1-andrzej.hajda@intel.com> <20230118154450.73842-1-andrzej.hajda@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755375841888073161?= X-GMAIL-MSGID: =?utf-8?q?1755375841888073161?= Recently introduced helper simplifies the code. Signed-off-by: Andrzej Hajda Reviewed-by: Andi Shyti --- include/linux/qed/qed_chain.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/include/linux/qed/qed_chain.h b/include/linux/qed/qed_chain.h index a84063492c71ae..6355d558cf01b2 100644 --- a/include/linux/qed/qed_chain.h +++ b/include/linux/qed/qed_chain.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -368,7 +369,7 @@ static inline void qed_chain_return_produced(struct qed_chain *p_chain) */ static inline void *qed_chain_produce(struct qed_chain *p_chain) { - void *p_ret = NULL, *p_prod_idx, *p_prod_page_idx; + void *p_prod_idx, *p_prod_page_idx; if (is_chain_u16(p_chain)) { if ((p_chain->u.chain16.prod_idx & @@ -390,11 +391,8 @@ static inline void *qed_chain_produce(struct qed_chain *p_chain) p_chain->u.chain32.prod_idx++; } - p_ret = p_chain->p_prod_elem; - p_chain->p_prod_elem = (void *)(((u8 *)p_chain->p_prod_elem) + - p_chain->elem_size); - - return p_ret; + return __xchg(&p_chain->p_prod_elem, + (u8 *)p_chain->p_prod_elem + p_chain->elem_size); } /** @@ -439,7 +437,7 @@ static inline void qed_chain_recycle_consumed(struct qed_chain *p_chain) */ static inline void *qed_chain_consume(struct qed_chain *p_chain) { - void *p_ret = NULL, *p_cons_idx, *p_cons_page_idx; + void *p_cons_idx, *p_cons_page_idx; if (is_chain_u16(p_chain)) { if ((p_chain->u.chain16.cons_idx & @@ -461,11 +459,8 @@ static inline void *qed_chain_consume(struct qed_chain *p_chain) p_chain->u.chain32.cons_idx++; } - p_ret = p_chain->p_cons_elem; - p_chain->p_cons_elem = (void *)(((u8 *)p_chain->p_cons_elem) + - p_chain->elem_size); - - return p_ret; + return __xchg(&p_chain->p_cons_elem, + (u8 *)p_chain->p_cons_elem + p_chain->elem_size); } /**