From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C75E5C7EE24 for ; Sat, 6 May 2023 05:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjEFF62 (ORCPT ); Sat, 6 May 2023 01:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbjEFF61 (ORCPT ); Sat, 6 May 2023 01:58:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D7597EFF for ; Fri, 5 May 2023 22:58:26 -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 D0F6261650 for ; Sat, 6 May 2023 05:58:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A3B9C433EF; Sat, 6 May 2023 05:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683352705; bh=lYy6PDjgFNNwGomdrnzOmSWpMNyoaiD/p9/KLTHD1js=; h=Subject:To:Cc:From:Date:From; b=NoR9x2Q1S6nYCvC8C0rMsELiMlUPCJBs0K8l8l1/t8CRdihWq3gbfjI6p/pQ+IdiK jg7sYpR/lI6LO/lO08vstIgQ7KJbf73JovJn1GRMicOKevmKpDOQRtg556CKhoaYD4 Hrr0e2Rrwsql4/JIyxRDzpEESMebA5tTCcU33DOc= Subject: FAILED: patch "[PATCH] iio: addac: stx104: Fix race condition when converting" failed to apply to 5.10-stable tree To: william.gray@linaro.org, Jonathan.Cameron@huawei.com, Stable@vger.kernel.org Cc: From: Date: Sat, 06 May 2023 11:14:48 +0900 Message-ID: <2023050648-vocalize-catcher-3f58@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 4f9b80aefb9e2f542a49d9ec087cf5919730e1dd # git commit -s git send-email --to '' --in-reply-to '2023050648-vocalize-catcher-3f58@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4f9b80aefb9e2f542a49d9ec087cf5919730e1dd Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Thu, 6 Apr 2023 10:40:11 -0400 Subject: [PATCH] iio: addac: stx104: Fix race condition when converting analog-to-digital The ADC conversion procedure requires several device I/O operations performed in a particular sequence. If stx104_read_raw() is called concurrently, the ADC conversion procedure could be clobbered. Prevent such a race condition by utilizing a mutex. Fixes: 4075a283ae83 ("iio: stx104: Add IIO support for the ADC channels") Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/2ae5e40eed5006ca735e4c12181a9ff5ced65547.1680790580.git.william.gray@linaro.org Cc: Signed-off-by: Jonathan Cameron diff --git a/drivers/iio/addac/stx104.c b/drivers/iio/addac/stx104.c index 4239aafe42fc..8730b79e921c 100644 --- a/drivers/iio/addac/stx104.c +++ b/drivers/iio/addac/stx104.c @@ -117,6 +117,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; } + mutex_lock(&priv->lock); + /* select ADC channel */ iowrite8(chan->channel | (chan->channel << 4), ®->achan); @@ -127,6 +129,8 @@ static int stx104_read_raw(struct iio_dev *indio_dev, while (ioread8(®->cir_asr) & BIT(7)); *val = ioread16(®->ssr_ad); + + mutex_unlock(&priv->lock); return IIO_VAL_INT; case IIO_CHAN_INFO_OFFSET: /* get ADC bipolar/unipolar configuration */