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 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 823B5C31680 for ; Mon, 21 Jan 2019 18:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52C422085A for ; Mon, 21 Jan 2019 18:16:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="ZOpECJSe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbfAUSQK (ORCPT ); Mon, 21 Jan 2019 13:16:10 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:50759 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbfAUSQJ (ORCPT ); Mon, 21 Jan 2019 13:16:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=xr30ONJ35j0FVun5wkxLLegpT8y4R5E1fiBKrEWRHCQ=; b=ZOpECJSebfe7R2wozlDzLMZuDu7rac5QcWbRIXm8jm7TfapwtV3E0dpFHwtD30amSqCJ6pROSwEJYhMgMxRzoGSnLJ01B8mn5Olk0P+nl4OfnvsbLusO9/M1pv5693dyh2/sUxl5paphqssI73ugfPG3gcZr3r3CLHyVpxoq5GM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1gle7C-0004IC-Ld; Mon, 21 Jan 2019 19:16:06 +0100 Date: Mon, 21 Jan 2019 19:16:06 +0100 From: Andrew Lunn To: Bryan.Whitehead@microchip.com Cc: davem@davemloft.net, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: Re: [PATCH v1 net-next] lan743x: Provide Read/Write Access to on chip OTP Message-ID: <20190121181606.GA16212@lunn.ch> References: <1547848493-16985-1-git-send-email-Bryan.Whitehead@microchip.com> <20190120193234.GD19714@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Jan 21, 2019 at 06:06:20PM +0000, Bryan.Whitehead@microchip.com wrote: > > On Fri, Jan 18, 2019 at 04:54:53PM -0500, Bryan Whitehead wrote: > > > The LAN743x includes on chip One-Time-Programmable (OTP) memory. > > > > > > This patch extends the ethtool EEPROM read/write interface to access > > > OTP memory space. > > > > > > This is done by adding the private flag OTP_ACCESS, which is used to > > > switch between EEPROM, and OTP modes. > > > > > > The private flag OTP_ACCESS is configurable through the > > > ethtool --set-priv-flags command. > > > And visible through the > > > ethtool --show-priv-flags command. > > > > Hi Bryan > > > > It would be good to explain what is wrong with the current code, which > > allows you to select between the OTP and the EEPROM at write time. > > Hi Andrew, > > The current code does not allow OTP read access. > Plus the current code places unreasonable restrictions on OTP write operations. > Such as requiring offset == 0, length == 512, > and data[0] == 0xF3, which is the signature used to indicate the first OTP block is valid. > However if the user wanted to use the second block, then data[0] should be 0xF7, > And data should start at offset 513. > Also if you want to permanently invalidate the OTP then data[0] should be 0xFF. > This patch allows the user the program OTP with any offset, length and data. > And read access is necessary to confirm what is currently in the OTP. > > Would you like me to submit a new patch containing this information? Hi Bryan Yes, please indicate why the patch is needed. > > Is the EEPROM mandatory? Could there be designs without an EEPROM? > > When setting the private flag here, should you probe to see if there actually > > is an EEPROM and return -ENODEV if it is missing. > > EEPROM is not mandatory. If EEPROM is not attached or contains invalid data, > the lan743x will attempt to load configuration from on chip OTP memory. > > To be honest, I'm not sure how to do a EEPROM probe with out doing a > Write and read back test. And it is not recommended to do that due to limited > write cycles which cause EEPROM damage. > > The current code does not do an EEPROM probe, so I don't see why the new > code should. And we assume that the user can diagnose EEPROM presence > using existing read/write operations. I would also put some text in the commit message to it is possible to swap to the EEPROM using the private setting, even when the EEPROM is not present. The failure will only happen later. With the current code, the failure is going to happen immediately. Andrew