From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33E0F70810 for ; Sun, 29 Mar 2026 05:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774760443; cv=none; b=kThTiSLsPlEeMPMFa3KDn4K+W8lys1IMzgGbCOICFNPk1LoZQ3Q1kLIi+ANBo2xZ0HF+fYBylmNTcDaqIkbucBb+QyZ7a2yz3z0K/1c7/mv1fDLBX4dqddihgnUQ2xs4RttHiMftDvVmDP5KzMO3kmRlFzqOrmVpFtiGAMvmTLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774760443; c=relaxed/simple; bh=4DY5/9rnXYqzghJED76UNN2L9JwFq/I+6HIlK/oTu9o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Cf/G/Mv0ju3eUVU1tLU5m+YxNzMA2cobSorXBq3St/XQ1E29UBREGeUqKoIQx3Rq6bhRPqKGESMPo8jCTTsUZaDM0WfKIgPAvH3sNlPSi4CHST/yQ9chTZJIEcJIKZCRL5Zyw1PeNPsPKZz2pKLbYTVnNSfZxUju0cY9bJlqlF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F7DsDrl0; arc=none smtp.client-ip=74.125.82.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F7DsDrl0" Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-12a71ade78cso3921375c88.0 for ; Sat, 28 Mar 2026 22:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774760441; x=1775365241; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qLBf3VpXlanIYFVKTRazomaXtbgOLJXSGdrPEjAl+SY=; b=F7DsDrl0JFFzI7jKhBDD+aZ78Vx13acPpaoks4z6PDYAxZ16/GCTHRqG/tyWI3C4FV zqTqcoMSJFJcYKD3UzLe0x9jmAm2J2bkU4B2re4DVZmS/H8lSc5bm9Ws07rS+l5GWCXF tFWPgup05DW7BbJcChCMJItzxLeXnSJ5vQpZmv1AjdyRr+XFlQyi9Qtot3Buhs6zaMtm KU9ALV57dE9H/daK5p+idfDfGYsX9J4eMRYRAUuFuki0qaX7oCFUX6GQNO3y/RnI39mh Fa6rZQvhijtsg/jf9wjZ2k0zjxHZuxsga7QJUGidqFO8jCmre+bYSSFNr0vtsT5usnmf oq1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774760441; x=1775365241; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qLBf3VpXlanIYFVKTRazomaXtbgOLJXSGdrPEjAl+SY=; b=iJsqmu7+m9v3phb/6GweSLIHvtz8g5LTbii27A1gDvIBDWnMIPvcoAA4yWbWDigXtY c3Jb7dPxKPrKa2JbMMC3pYsYV7MaiAImlX61ysICCRlk/VWCpsQCpCCH4MNWlvgQEBl9 LfBQmM3Q1mkWvAywGKA20P/Z55wC3+i3Ho6u+d+0GQQsLxOfC34OYsb+ieWlGEwR97xI 0OwL9jWoIiAXITwuK2ZXszn1ZUB50OP2TmcyolekqfOj/1/JAg3QmXu09l2U3xU1YYf0 AxPiRbSFrhZyvN7NLU6dUv3NSi2mIy8pVHYeCzJwV3ENnnaRMk1vBkbrKOJ+s67gV7dp uVrg== X-Forwarded-Encrypted: i=1; AJvYcCUXO9xoEBVQLD12m1IpvWy6zZ6uWYI4BfAjdzAneTsoEtGxko3qEU6S9pPSjmJ51GB0RerBja8KkJZ9d60=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1kLKOBN0jfXcFDZqSjZoRKelPJzlIn3HMFBZ5Sfn4LQRMLmdb USseFCoQxm3qX2wozxVyWgqUGkFftNYvZ0fJ9zFa8lv0IItK1MJfC3sAZ3CRSA== X-Gm-Gg: ATEYQzxLC+e9qDmvAc/uv21O8FdgVDZMBcwiOx89szzrlKrB8whiUqO38BRvJuCpq48 /h9eRE669/kSapwkaiEtd7K7lqDQKFDdCpfZ/jwYIhDo2DYmFZ5wFFM2+FQ6X6xWUyki62odBSJ MkKYoLCUmdXyeVBmmnT582yNcfSmdPZm079z5gMat9F2pZEwZCpwmT9sdzqLIGVPiX6ENOrcVx6 /FDmbbPmbpWzBUlRh7QuobiUnIu57mRMiKtKGLbUYLQSwK7exSYCuD9JjCYwRzHlAZVV1FdJ8sa uiqOnmeMVcm1WJpmyNU9z3abaYLeiDSMOFEuVJacCwPvIpDDHXsuvCYcBsBF2pqgsRaashzoEnf nHXtvvfk0WJFUIqwqjq93lfTLe+xll1ZXVmTpvBkNWd/iraU4cuqCU1sRNmpVxQyS6XwR/qfJix P4N9LVA2/14/UafTpqTC5sNn2G/M0= X-Received: by 2002:a05:7022:458d:b0:11b:9e5e:1a40 with SMTP id a92af1059eb24-12ab287d8aamr4250785c88.15.1774760441151; Sat, 28 Mar 2026 22:00:41 -0700 (PDT) Received: from [192.168.1.30] ([115.96.68.45]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12ac4a0fa8dsm429205c88.15.2026.03.28.22.00.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Mar 2026 22:00:40 -0700 (PDT) Message-ID: <9c7b873d-8797-4fa1-ab44-2599b2b02f4e@gmail.com> Date: Sun, 29 Mar 2026 10:30:36 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] hwmon: (ads7871) Add mutex to serialize SPI transactions To: Guenter Roeck Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, shuah@kernel.org, me@brighamcampbell.com References: <20260328182015.220298-1-tabreztalks@gmail.com> <20260328182015.220298-2-tabreztalks@gmail.com> Content-Language: en-US From: Tabrez Ahmed In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/29/26 08:46, Guenter Roeck wrote: > When using the with_info API to register the hwmon device, the subsystem > already > serializes sysfs accesses. The next patch converts the driver to use the > with_info API. Pleas explain why the extra protection is necessary. Ah yes. I originally wrote the mutex patch to fix the race condition in the legacy sysfs code, but totally missed that migrating to with_info handles the serialization for us natively. > Sashiko has the same feedback: > > https://sashiko.dev/#/patchset/20260328182015.220298-1- > tabreztalks%40gmail.com Separately, Sashiko flagged a pre-existing bug where ads7871_write_reg8() passes a stack-allocated array (u8 tmp[2]) to spi_write(), breaking DMA. To fix this properly, I need to move the buffer into the device's private data structure. However, doing so requires serialization to prevent concurrent reads from corrupting the shared buffer. Since moving to with_info provides that serialization, my plan for the v2 series is: - Patch 1: Convert to hwmon_device_register_with_info (which natively serializes the driver). - Patch 2: Fix the SPI DMA bug by introducing a shared tx_buf (now safely protected by the hwmon core). I will drop the custom mutex entirely and send out v2 with this structure. Thanks, Tabrez