Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5190105rwr; Sun, 23 Apr 2023 23:38:16 -0700 (PDT) X-Google-Smtp-Source: AKy350avVODoFor1YGXBiku6RcCF6idoVaG8dlY8rt/cWBnRklS1c8QU81uDCKgL5X2z7zXe4jqJ X-Received: by 2002:a05:6a00:9a1:b0:63b:3e:cbee with SMTP id u33-20020a056a0009a100b0063b003ecbeemr18533967pfg.32.1682318295977; Sun, 23 Apr 2023 23:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682318295; cv=none; d=google.com; s=arc-20160816; b=aDQiKDlqhTXTTEgcMar9ZMWGV7E+xF2gA7h9heJQy2lWBs3KOS4SVImR7Xd6vEMovn AIiPKDe3bafYsE4nuKBzw3EdXL7cdO0+hDFtLSsEcKMSzL7BYBLITBm++AU0AFCgFwlT L0zckLgNYi8LkzDBfCGwFKk7F030Xi2yBYtNXB0o19V2g2g23Zv8VdHEG15zyaaImGx1 u9Jt4GTL8WEQcQfZHUe66tinASxWiSppSaMayBGOD0EztkV6xHn2huT/EjY1ukO3+0Lo Dc/JTBJ+wUhbhTJcFdc2qwBI+sMOV+Py+TtRsOe4W1Qra9AZQaDlioAxy1oOsUKGrXEx 2V3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MSCc4rDebecwF/Wpp/nkOzfWnity9qd9MQMn04crFwA=; b=VA4RD78vbE9kpYDLjhZjdFBETPKubmq212Wq9g4dvTyC6Z302BtRD9CxrQS+J65Mgr JPn1OJBTRcFzBhK8wQeY2pUc6V3mj/rfDSmjbRBdn3skChI3oPUkO9rJyXQ6j0DzcRvW C8yexA51rD4vWf7SxtWEKSv8QUmH71wBxnsWYO38uhbdf3LlczQMaBOCZxtyWD3q9roG 4IL7F4SmtRI7tVBmd8XWB5O6lGAjE0a/nv1zhkVSyKw1YsJ6VCyspf5FZHXP6R0yVkhx 2cxkMvc4XNErCxxZpFEtI6SFuaYxkiWzPXby82n6Scq0RJG2F+gJ/5k93np57XTBLSQR AWmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XOQ6HHxc; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a63020f000000b0051423ad5cdfsi10639172pgc.621.2023.04.23.23.38.03; Sun, 23 Apr 2023 23:38:15 -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=@linuxfoundation.org header.s=korg header.b=XOQ6HHxc; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbjDXGdY (ORCPT + 99 others); Mon, 24 Apr 2023 02:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjDXGdX (ORCPT ); Mon, 24 Apr 2023 02:33:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A2FC211F; Sun, 23 Apr 2023 23:33:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B83316143F; Mon, 24 Apr 2023 06:33:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9905C433D2; Mon, 24 Apr 2023 06:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1682318001; bh=lvovhZ5kc9XSHl+BHptc+M50M4+SNtk3zMTG/Axt4MM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XOQ6HHxc8iEBwhLWnEeV1SthX11vSU6DHzXYSKsIqis6uSfSEM55VXVnLa/l7fs7X peRCBSJcqr2aVH/T1Z6jR6fp43AD3YwpF/FenPYMtsoWrtUBOJBFFQiZk7CQsKLWAe Nt1EqpUO9iIH0QZJSbFBNjNQUbGz9eF1/3NECKBc= Date: Mon, 24 Apr 2023 08:33:18 +0200 From: Greg Kroah-Hartman To: William Breathitt Gray Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , stable@vger.kernel.org Subject: Re: [PATCH 5.10 v4 4/5] counter: 104-quad-8: Fix race condition between FLAG and CNTR reads Message-ID: <2023042454-cahoots-rotten-f3f7@gregkh> References: <20230423232047.12589-1-william.gray@linaro.org> <20230423232047.12589-4-william.gray@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230423232047.12589-4-william.gray@linaro.org> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Sun, Apr 23, 2023 at 07:20:46PM -0400, William Breathitt Gray wrote: > commit 4aa3b75c74603c3374877d5fd18ad9cc3a9a62ed upstream. > > The Counter (CNTR) register is 24 bits wide, but we can have an > effective 25-bit count value by setting bit 24 to the XOR of the Borrow > flag and Carry flag. The flags can be read from the FLAG register, but a > race condition exists: the Borrow flag and Carry flag are instantaneous > and could change by the time the count value is read from the CNTR > register. > > Since the race condition could result in an incorrect 25-bit count > value, remove support for 25-bit count values from this driver. > > Fixes: 28e5d3bb0325 ("iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8") > Cc: # 5.10.x > Signed-off-by: William Breathitt Gray > --- > drivers/counter/104-quad-8.c | 18 +++--------------- > 1 file changed, 3 insertions(+), 15 deletions(-) This patch breaks the build: CC [M] drivers/counter/104-quad-8.o drivers/counter/104-quad-8.c: In function ‘quad8_read_raw’: drivers/counter/104-quad-8.c:117:34: error: ‘QUAD8_FLAG_BT’ undeclared (first use in this function); did you mean ‘QUAD8_FLAG_E’? 117 | borrow = flags & QUAD8_FLAG_BT; | ^~~~~~~~~~~~~ | QUAD8_FLAG_E drivers/counter/104-quad-8.c:117:34: note: each undeclared identifier is reported only once for each function it appears in drivers/counter/104-quad-8.c:118:36: error: ‘QUAD8_FLAG_CT’ undeclared (first use in this function); did you mean ‘QUAD8_FLAG_E’? 118 | carry = !!(flags & QUAD8_FLAG_CT); | ^~~~~~~~~~~~~ | QUAD8_FLAG_E