Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1260356lfc; Wed, 1 Jun 2022 13:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0T+axYgI/FJ6lg4LW8bfBPFYRfqe23LBcbfNVmA54RK4/6Y7mJTm2RsiTX3GXV4DlbVV3 X-Received: by 2002:aa7:88d2:0:b0:50a:cf7d:6ff1 with SMTP id k18-20020aa788d2000000b0050acf7d6ff1mr1325457pff.67.1654115014553; Wed, 01 Jun 2022 13:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115014; cv=none; d=google.com; s=arc-20160816; b=KcxchXVBMAlNN+vDemN8TAx/E1wyGpHllgeNrvONhWQVWVo0Pi5WUAccErzsnmray/ VEbcrlN6Z3dngKWxMhuN2LQ4iMGs8kzYEVmVjRdYbQN4AYmbmk/WJ8tHvGjKXXPttcwm NkNjsKjKRt+g/38rqhFFnbA+pF5yBiAa25OlWq0HM6Gdk30lp6WeucOy6DwxhkzEaJXE mIaEo54XIihR+va5Lz6Y25GlMaINqMm//IYTE59N70BGbEkHU3fX0D3HxV8VmmJL21pQ exUSIhQ59GfoVvxyu8b+8K7W2Odiyn1GwHAa1c1FEhSzzu6DVamjcmYUUsbz2SFo97W2 B6ZQ== 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=ZcAOEsLtADNubp6luZubZEu5p+tXuBG+Mmwv79C/0d4=; b=LbWbj8zB2J6nrux4vjaC58E8HwjaOY2YZHhGUFmEl5lYYiWiaHbpNJ13t0inn1FUDn HtMdQiwyZ9xn9aLTYkJFmgXq+pFqIv57on2VABfSdnU6gJBlRSwYdqPKqqw/IJYBaOf2 OhxrGKoZCfjWHsJ1Q5SoTDKb1Kb3QfdTi0sTZFvy9XkeFeupwFuw3iSe9/rF1OoMZxYA BW6YqqK9gZI4oYLSk2pE/5HjKvHWehVvFRKSkKxcUMu9G/K2HDxba4m6h1Se9cx9YlUO +bDdsHPWtemYBnzO/wfaIBg0siBWaumuJ/JKe48nzHULw1Lr0sG9skUjD9r9Td+NQyU1 r+Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bGGzdgsl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m12-20020a170902f64c00b00161a5dc2ea8si3259066plg.612.2022.06.01.13.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:23:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bGGzdgsl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5D8531D5AA9; Wed, 1 Jun 2022 12:36:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351124AbiFAJd4 (ORCPT + 99 others); Wed, 1 Jun 2022 05:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351127AbiFAJdx (ORCPT ); Wed, 1 Jun 2022 05:33:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786258B09E; Wed, 1 Jun 2022 02:33:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0E3FBB8185E; Wed, 1 Jun 2022 09:33:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F7B4C385A5; Wed, 1 Jun 2022 09:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654076029; bh=5T6DOvFw902lROs1sSAyrJ/DZ8vBhIwjqturHxstVd8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bGGzdgsl0yWRtC4tWhYShHmsSXAkbeeoS1eRaWgAuHlUB8ydG6LiQgI9ENIJpxdvi lI2Zh0dsTLjglJKNtjG3AJsMHdauUUCWmZMnJDlDaUW6FNuR9a/bnbZ2OsY9rYdlzs 1s/mzxOUsVKKevlFm5kdHfOHd2SOWfgorHG4Rtuw= Date: Wed, 1 Jun 2022 11:33:29 +0200 From: Greg Kroah-Hartman To: Quan Nguyen Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Thu Nguyen , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, OpenBMC Maillist , Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: Re: [PATCH v8 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver Message-ID: References: <20220422024653.2199489-1-quan@os.amperecomputing.com> <20220422024653.2199489-4-quan@os.amperecomputing.com> <4f5d7746-3747-4a4d-525a-4fb69e706cd0@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f5d7746-3747-4a4d-525a-4fb69e706cd0@os.amperecomputing.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 01, 2022 at 03:21:47PM +0700, Quan Nguyen wrote: > > > + if (err_type & BIT(2)) { > > > + /* Error with data type */ > > > + ret = regmap_read(errmon->regmap, err_info->err_data_low, &data_lo); > > > + if (ret) > > > + goto done; > > > + > > > + ret = regmap_read(errmon->regmap, err_info->err_data_high, &data_hi); > > > + if (ret) > > > + goto done; > > > + > > > + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", > > > + 4, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, > > > + ret_hi & 0xff, ret_lo, data_hi, data_lo); > > > + /* clear the read errors */ > > > + ret = regmap_write(errmon->regmap, err_info->err_type, BIT(2)); > > > + > > > + } else if (err_type & BIT(1)) { > > > + /* Error type */ > > > + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", > > > + 2, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, > > > + ret_hi & 0xff, ret_lo, data_hi, data_lo); > > > + /* clear the read errors */ > > > + ret = regmap_write(errmon->regmap, err_info->err_type, BIT(1)); > > > + > > > + } else if (err_type & BIT(0)) { > > > + /* Warning type */ > > > + count = sysfs_emit(buf, "%01x%02x%01x%02x%04x%04x%04x\n", > > > + 1, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, > > > + ret_hi & 0xff, ret_lo, data_hi, data_lo); > > Hi Greg, > > Since the internal representation of the internal error is split into high > low chunks of the info and data values which need to be communicated > atomicly, I'm treating them as "one value" here. That is a huge "one value", that's not what this really is, it needs to be parsed by userspace, right? And why does this have to be atomic? What happens if the values change right after you read them? What is userspace going to do with them? > I could dump them in a > temporary array and print that, but it seems like additional complexity for > the same result. Can we consider this concatenated encoding as "an array of > the same type" for the purposes of this driver?" That's really not a good idea as sysfs files should never need to be "parsed" like this. Again, what are you trying to do here, and why does it have to be atomic? thanks, greg k-h