Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp467463pxu; Thu, 7 Jan 2021 09:22:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMzsERiNSNh1mXuIX0nOWj8Lpxo3YoFwnJCT9N8rqSnobfChUIDs5EOBQun6lCAW9nCS8/ X-Received: by 2002:aa7:c253:: with SMTP id y19mr2390067edo.179.1610040121951; Thu, 07 Jan 2021 09:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610040121; cv=none; d=google.com; s=arc-20160816; b=psi5K8TJ1yxJA+iC+CiqhtMXJNxxwuLjSA3goGMMdxilkPIyCAEx3fR8QAh4LpFJjT dHLAXtkY29nPRr1zC7s4HfHRoPNUJgo1aIJDZ7XtRvZL2X18Rabla28amYwi9AamlLCm RHMHMRJuyN1z/lDMnLlPVToH+gpbkYVfqdbHVbS05igd6Ph12WCvjg7orSTzQ2h46ume GQk8az0vVpUpgHXwfD2SMBJrqviWB9Jqx9RxpBxj20ToBrvhUEAGcG0v6owqOaj2apGI 83zYgQVU2az2N7vrKqC5valDzn2CbRT3es6klQVoOg06g1e8gfR/kYxE8ypF9c11oggH Oefw== 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; bh=nDcACUb3laTcmOlCAkbPGGsnv0pHzwMnFV90v/7Z/9E=; b=GnhB49+xRRwb8f2uKyY1argQl+1YB0tVxB3ErUbQ6r2beyIGDwKYLxVFJ2y1M15ayX dhOirSZgIk080AuqdxXeQJmB34KQGZ60wwgY/w5DtsYqWk4fsvVZn+jmbBJCeivHOuFx /h3Dkc1m8O3NmGCjeRnYy9X4Jj8NSZcTiMc1XarUZHhxiE3Imb2G8DgdCX4JT1DhLxja WzXseiuQ4TtJPqePEcTEypbUmG717q+bDgcv+qaynbMbYnpnlTf8Tfyri18QyDUm6b+Y 6YAKebN4d/Kz4jhx/9zyxCv0Fxez5tUCS0WrMlxeIvvUTaQtx/Q4uVJvvuWhFIGoQ9Ef mdUg== ARC-Authentication-Results: i=1; mx.google.com; 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 w17si2526178edv.64.2021.01.07.09.21.38; Thu, 07 Jan 2021 09:22:01 -0800 (PST) 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; 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 S1728275AbhAGRUI (ORCPT + 99 others); Thu, 7 Jan 2021 12:20:08 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:55468 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727959AbhAGRUI (ORCPT ); Thu, 7 Jan 2021 12:20:08 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kxYwV-00GiTn-Iu; Thu, 07 Jan 2021 18:19:23 +0100 Date: Thu, 7 Jan 2021 18:19:23 +0100 From: Andrew Lunn To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Russell King - ARM Linux admin , "David S. Miller" , Jakub Kicinski , Thomas Schreiber , Heiner Kallweit , Marek =?iso-8859-1?Q?Beh=FAn?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] net: sfp: add workaround for Realtek RTL8672 and RTL9601C chips Message-ID: References: <20201230154755.14746-1-pali@kernel.org> <20210106153749.6748-1-pali@kernel.org> <20210106153749.6748-2-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210106153749.6748-2-pali@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + if (sfp->i2c_block_size < 2) { > + dev_info(sfp->dev, "skipping hwmon device registration " > + "due to broken EEPROM\n"); > + dev_info(sfp->dev, "diagnostic EEPROM area cannot be read " > + "atomically to guarantee data coherency\n"); Strings like this are the exception to the 80 character rule. People grep for them, and when they are split, they are harder to find. > -static int sfp_quirk_i2c_block_size(const struct sfp_eeprom_base *base) > +static bool sfp_id_needs_byte_io(struct sfp *sfp, void *buf, size_t len) > { > - if (!memcmp(base->vendor_name, "VSOL ", 16)) > - return 1; > - if (!memcmp(base->vendor_name, "OEM ", 16) && > - !memcmp(base->vendor_pn, "V2801F ", 16)) > - return 1; > + size_t i, block_size = sfp->i2c_block_size; > > - /* Some modules can't cope with long reads */ > - return 16; > -} > + /* Already using byte IO */ > + if (block_size == 1) > + return false; This seems counter intuitive. We don't need byte IO because we are doing btye IO? Can we return True here? > > -static void sfp_quirks_base(struct sfp *sfp, const struct sfp_eeprom_base *base) > -{ > - sfp->i2c_block_size = sfp_quirk_i2c_block_size(base); > + for (i = 1; i < len; i += block_size) { > + if (memchr_inv(buf + i, '\0', block_size - 1)) > + return false; > + } Is the loop needed? I also wonder if on the last iteration of the loop you go passed the end of buf? Don't you need a min(block_size -1, len - i) or similar? > - /* Some modules (CarlitoxxPro CPGOS03-0490) do not support multibyte > - * reads from the EEPROM, so start by reading the base identifying > - * information one byte at a time. > - */ > - sfp->i2c_block_size = 1; > + sfp->i2c_block_size = 16; Did we loose the comment: /* Some modules (Nokia 3FE46541AA) lock up if byte 0x51 is read as a * single read. Switch back to reading 16 byte blocks ... That explains why 16 is used. Given how broken stuff is and the number of workaround we need, we should try to document as much as we cam, so we don't break stuff when adding more workarounds. Andrew