Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp969978pxy; Wed, 28 Apr 2021 18:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsXIYSxITivXvjm+H5ogCjlP0OvmLG/KU8AeEWIj33i7ihxZyuBXAP0mxQ3Z4YRgII8gO4 X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr15180675edt.17.1619661399708; Wed, 28 Apr 2021 18:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619661399; cv=none; d=google.com; s=arc-20160816; b=hJu8pzbfe/dhiaG8HM4Kfh/BojnU+tNRBBrYtJiqnPf3JGEShQu07uoGiOM/LkhB55 reeYSnyEpS40kOvb1E2Qa5kYDDsKadAdAI8HyIWXfToc2UQprqeOxFj8/s5c+/rqbf8u 5yQO3jpRAN6DJQ+8cwa2HpjLQm5i1lzQjC5IVBcjKdo0OTBivJj22mnDwe3ULepmwWU3 6Z05b0UqIspGXuzb74mpfM1gcSpxJ0hvPryD/B/h6deGUObCLozVGKfKtGY4wMjCoWHn 2IJ8ASD/7usDLW/Kfx44kf48ZDD6comYNnUwes/PvfBwv0Jkn96Hlmdmv4FKhSdMyrzj 8kiA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CJN5Kcexc5YmqOT6pv9lP9gGODhHyBXgg7ljmhraqDk=; b=YKuuULfeCxRTKPjYHlFoleXeDPcmrJ3CH2Ey8fbOIfCQPMFySCWoqMVF9N4YZ/wzEp HGOx3qW/mQPlwYIFhW4kumJi20p6gzwn0OMGCfd1Fm+3Olj8bq4pRM2Iw+yHzcl+5vMw 5q82vnsdX41c7rAF2gx2nVGl5fapDfWpQXPKBd6QOdkTki0H2qwbXJzda29jvzyghiUJ MaMBoeC6+yG1qSUdPHc8ZJma1qwZhZEgiDrCnvPaiOniFjgvEh1meFvklMhElmem0LBJ cuD2rVh9Y/Qh0AaWgXRkGiN4J4fiKIQfztI777dR+BVSU25AYFMFcuGE8uzIOmNjssAM b8eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MgrtTnP7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si1746927ejz.266.2021.04.28.18.56.16; Wed, 28 Apr 2021 18:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MgrtTnP7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235116AbhD2Bze (ORCPT + 99 others); Wed, 28 Apr 2021 21:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbhD2Bzd (ORCPT ); Wed, 28 Apr 2021 21:55:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD44EC06138B; Wed, 28 Apr 2021 18:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CJN5Kcexc5YmqOT6pv9lP9gGODhHyBXgg7ljmhraqDk=; b=MgrtTnP78RCXUa07uJ+CbKbio8 iUKZZ0tjhYvwjvMrQCHIPLZi8HY9EV5m9xJvSSnCDbNElxcVU9P8fARoRCTzT5c5/qxfHGwvPlZct HrxzaFsQ83Kj6zqcZamFXINPoqWlDdC3fFjYcdEXmtQzb2oz2NoiINdoxlbXVC9nGUT2sYJg/PXar /tmt/2dtPlKTp37K3ZzyDrntnMe/5N7pX9fRtdP5GLrAjzIQkfTQc8cldIP6CNyv5jryXHu8Bk2LX gpE4CNUoBrk35pNxozJVVHrARz538ghHjLrOPWE3VRqxZogzNFLaaQp/3TjmRG1P3YgyOx0akvnLX bT+7TSfA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lbvsU-0093XD-V2; Thu, 29 Apr 2021 01:54:38 +0000 Date: Thu, 29 Apr 2021 02:54:06 +0100 From: Matthew Wilcox To: "Darrick J. Wong" Cc: linux-kernel@vger.kernel.org, linux-fsdevel , pakki001@umn.edu, gregkh@linuxfoundation.org, arnd@arndb.de Subject: Re: [PATCH] ics932s401: fix broken handling of errors when word reading fails Message-ID: <20210429015406.GE1847222@casper.infradead.org> References: <20210428222534.GJ3122264@magnolia> <20210428224624.GD1847222@casper.infradead.org> <20210429010351.GI1251862@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429010351.GI1251862@magnolia> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 06:03:51PM -0700, Darrick J. Wong wrote: > On Wed, Apr 28, 2021 at 11:46:24PM +0100, Matthew Wilcox wrote: > > On Wed, Apr 28, 2021 at 03:25:34PM -0700, Darrick J. Wong wrote: > > > In commit b05ae01fdb89, someone tried to make the driver handle i2c read > > > errors by simply zeroing out the register contents, but for some reason > > > left unaltered the code that sets the cached register value the function > > > call return value. > > > > > > The original patch was authored by a member of the Underhanded > > > Mangle-happy Nerds, I'm not terribly surprised. I don't have the > > > hardware anymore so I can't test this, but it seems like a pretty > > > obvious API usage fix to me... > > > > Not sure why you cc'd linux-fsdevel, but that's how i got to see it ... > > I whacked the wrong mutt shortcut key. :) "A computer lets you make more mistakes faster than any other invention with the possible exceptions of handguns and Tequila." > > Looking at a bit more context in this function, shouldn't we rather clear > > 'sensors_valid'? or does it really make sense to pretend we read zero > > (rather than 255) from this register? > > Dunno. As I said, I don't have that piece of hardware anymore. > It probably does make more sense to fail the read or something, but > since I can't QA it properly I'll go with "return a batch of zeroes". It's from 2008 ... does anyone have that piece of hardware any more, or should we delete the driver? Seems like it's for use with the Intel Pentium 4/D 955X chipset, which is from 2005. Definitely out of support, but I guess not entirely dead yet. > Though ... if memory serves, the current behavior will probably shift > the interesting parts of the errno code off the right end, filling the > u8 buffer with all ones. Maybe? Right. I mean, my smartwatch sometimes reads my heart rate as 255 bpm when it gets cold. I don't think they did QA at -40C. But what's being read here is a bit more complex than beats-per-minute; there's divisors and control registers and stuff. I just don't feel like '0' is a good fake value to pretend to have read. I think we have four options -- complicate the driver to make it understand that it didn't read a value, pretend we read 0, 255 or the-last-value-we-read. And the last option seems like the best to me? So ... @@ -134,7 +134,7 @@ static struct ics932s401_data *ics932s401_update_device(struct device *dev) for (i = 0; i < NUM_MIRRORED_REGS; i++) { temp = i2c_smbus_read_word_data(client, regs_to_copy[i]); if (temp < 0) - data->regs[regs_to_copy[i]] = 0; + continue; data->regs[regs_to_copy[i]] = temp >> 8; } might be the best we can do?