From patchwork Thu May 16 16:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 164339 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1065112ili; Thu, 16 May 2019 09:33:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzj4rtFkC+yYJX5FkFDWCDmRbAMtRaxY98OB7d3eRNJyDvGYbbXtRJOJPzQPgRRhMys1Lbu X-Received: by 2002:a63:c750:: with SMTP id v16mr50519730pgg.409.1558024405478; Thu, 16 May 2019 09:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558024405; cv=none; d=google.com; s=arc-20160816; b=xbwkBTRK1G8SypOwJmweB0NoumVMKVtIUK1hzWRyYxd2RIUz+dxKgq5eHcGqIdSqGK MmOm51fqthwgTsMCWe/IK6QK/B/AOBVgTfylDBK9VNmBek6aNGoknOTyUjrj7I3Fj2/P l0mXsXzL6625nshNoE36Cp4kckj6HRJVjqoCtd7FvlbbwEPFZf3NIjAdhX2++6tWE+2n 2Qj3exhGI1sRRFTC6L6wwTS5xcLu6nIw0QZgPVJy6BliByjreMlOHbhYOgUTJGPrt8DW t8kD21vb//ihcXg2712CmQLiKk1fkFmgMaTfCYiu9TQ+tS5O1AKwiD84u0MqEkEZ1W6U ACGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=EeB/dE641Vnt/zM11swGBy7BNDqgFAA1I/7YxY2qPkY=; b=ywa1JX2F5kjSEgko861KswT04eD/SCbFPiRbg7O0B0mwLwK7QXWUE8VbRnpsyPPuYn SA8DFlYvNb3pPiksRl1XQXxaeyrDHjojSJmCIpx6rfU1cWAkkoGr0SW+54PrWhkG6B+j SQYO301K8/yhn/p8RiGUGfjA+XGiGxaT8gBNDU7JNerJjl7MWce9cq6lJWFpGywt6E0c JLk+Q7zVrlAjzQjdCs+OCvzz/P0TSpxRcoBnqg1e8DlXTjH2bxZo5EovdtZFV/m/wa8f uvhi0mA+FYI/XypV+yy4JKQ2wF8xYGAcYl0gQQn2bQr2RpXCoEVi/51Gpk9SD1CjVXjq 6XtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si5507698pgf.582.2019.05.16.09.33.25; Thu, 16 May 2019 09:33:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbfEPQdY (ORCPT + 30 others); Thu, 16 May 2019 12:33:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51518 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbfEPQdX (ORCPT ); Thu, 16 May 2019 12:33:23 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4DD521715; Thu, 16 May 2019 09:33:23 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 60D6E3F5AF; Thu, 16 May 2019 09:33:22 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Florian Fainelli Subject: [PATCH] firmware: arm_scmi: fix bitfield definitions for SENSOR_DESC attributes Date: Thu, 16 May 2019 17:33:15 +0100 Message-Id: <20190516163315.18505-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As per the SCMI specification the bitfields for SENSOR_DESC attributes are as follows: attributes_low [7:0] Number of trip points supported attributes_high [15:11] The power-of-10 multiplier in 2's-complement format that is applied to the sensor units Looks like the code developed during the draft versions of the specification slipped through and are wrong with respect to final released version. Fix them by adjusting the bitfields appropriately. Cc: Florian Fainelli Fixes: 5179c523c1ea ("firmware: arm_scmi: add initial support for sensor protocol") Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/sensors.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Hi Florian, While testing your patches, I found this horrible/silly bug with bitfields which initial made me think firmware is buggy but later found out driver was buggy instead. I updated your patch accordingly[1] Regards, Sudeep [1] https://git.kernel.org/sudeep.holla/linux/h/for-next/scmi-updates -- 2.17.1 Reviewed-by: Florian Fainelli diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index b53d5cc9c9f6..c00287b5f2c2 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -30,10 +30,10 @@ struct scmi_msg_resp_sensor_description { __le32 id; __le32 attributes_low; #define SUPPORTS_ASYNC_READ(x) ((x) & BIT(31)) -#define NUM_TRIP_POINTS(x) (((x) >> 4) & 0xff) +#define NUM_TRIP_POINTS(x) ((x) & 0xff) __le32 attributes_high; #define SENSOR_TYPE(x) ((x) & 0xff) -#define SENSOR_SCALE(x) (((x) >> 11) & 0x3f) +#define SENSOR_SCALE(x) (((x) >> 11) & 0x1f) #define SENSOR_UPDATE_SCALE(x) (((x) >> 22) & 0x1f) #define SENSOR_UPDATE_BASE(x) (((x) >> 27) & 0x1f) u8 name[SCMI_MAX_STR_SIZE];