Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2796212pxm; Mon, 28 Feb 2022 06:19:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgc+0yiEcLxHMjXV3DujHlCC/0KKe6CIxjKzI/qu0LD9vO/pW021Ahh3ddIv+tErFUdzC/ X-Received: by 2002:aa7:999a:0:b0:4cf:3290:ebb8 with SMTP id k26-20020aa7999a000000b004cf3290ebb8mr22003774pfh.19.1646057942930; Mon, 28 Feb 2022 06:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646057942; cv=none; d=google.com; s=arc-20160816; b=rdkqg5RJVJ0xKxnh527O64PxpTvkCBXFsqefxWcqr16uDdqouPmmXDt797KnPpdz9W EP66YuCkFq5O+NetAQZFS+bWSs2K7FLdUviQi4WtmVVfMvOCZqne8u9EohSQmgIk5nt7 WsAcb8OlivWmrn+8In0N3Hou5snFi0DwEJK+klf+IF1F5Xvyy1C6/D70dVUNDYgp2U7w NXqQEyu51WJMhZ78oaKb0hfovnEu9KkBnvov89ep81CoRQXSbLoOW8J3Lb1Xat3q7XHM FXY77yKpp0mIXXLqHbZOfyphl3N2W1V7UJFlmLZzivriwDohIH95ORn3o4wohlnq1yEN rYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LWisg6Oh4GHR/KswpTeQPwr12khSI6Ztj7YPF2Wfszg=; b=IzRxxzhDSoC3jyb9PTllEbQJonPNl6Gp+axBUM9/Twi7k4af+6gysuC5jUG5WHqaZk eoBs3PvgNmhOqHwAYbj8KROMxPotjeoJvniC1+nsLn71NFtyrLGaEROqgUKq1sixcq7d l34m4wkwYckGiAYNTnJD48qKwz7z+tEa0sRkn3sU4774Sg7+uXVItevf2b0wAHEihwnY 6EHFpYjMHqY3+FjVtQdy77eZ/clvlqGHXKr//IQaiJUAJD2azB0qpN8olxqP8e5uVbEp /L4egP/NzOoX4p2SsfzPmIy7UUtSv2FfSV8NsSmdEr9ydQ6UgtxBSTXXn4QjfZxSqQM4 bHyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qDj++Gwu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il15-20020a17090b164f00b001bd2f563070si5895211pjb.6.2022.02.28.06.18.42; Mon, 28 Feb 2022 06:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qDj++Gwu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236598AbiB1Moy (ORCPT + 99 others); Mon, 28 Feb 2022 07:44:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236599AbiB1Mom (ORCPT ); Mon, 28 Feb 2022 07:44:42 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04AF847548 for ; Mon, 28 Feb 2022 04:44:02 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id g1so11066455pfv.1 for ; Mon, 28 Feb 2022 04:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LWisg6Oh4GHR/KswpTeQPwr12khSI6Ztj7YPF2Wfszg=; b=qDj++Gwu/eEmp4bsP/+3bcnFlobpxn6RDmubKL2qGHAOl6r/F2Pkd/2ynCN7nKVazW UyKF2hUaVknYV8Y/e5JVOXyGgVnOa5+YwUu6qpLHuuuaHlQmo3701W9NuNMJbPoW+ojj Wu8k/aJuc0HKP0C16YHrOFE9qsdBKXiEj+Jb1ihpYbI/+r9/bJE4ENH7O7p2yt8bkqNB p38oINaJc6rqfFbqi2Ta4zAiZ7L8h6aNnqf6ra0kXVPAhsWVyJRJWj0h/1Aiv3ysi/4m PtH03h9MOqq3BYmv0hiNGTWcGj3taADffjbJ+QUklZ90ClyyRzIVNPloYhRpTSA/Njkx kSrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LWisg6Oh4GHR/KswpTeQPwr12khSI6Ztj7YPF2Wfszg=; b=cVFQiAP0BGcTz6hg4d0OTDR+VK4HSr2y2PsF8rIYS+gCNiVN/cwB/8Wpbdtami0r59 p0xps/F/W6jtN4EDwGn3STU9T7v5abyyie2oMZwVxCroIA0BYKNOjOyihpBfMv2BI1mD qN/sfDjlXfZxbo4mV2HxAlfy4fJV2EldEBTiXwjtLT3OFHiJEEICDtsI2895NXpbKM0b gv3WfkkcEqWBNeINeYvrKsqTq3OE/IDs1tmaI5vWKA3nvvlzP9UNYyDsTdtgqlTXA/9q z9o6iJ3iU3flYCXbcArF0A8OWPXYXYmq86hosvwA72aFWDABGeBTUYkyzrnONVWGini/ TgQw== X-Gm-Message-State: AOAM533Fl2LL63zomm2PztqJHEPjikme+vEEp8Ct4AY2pedXSD+/5JRM gJ6ufMVOCKlewuk1lO2xJsFr X-Received: by 2002:a62:ab09:0:b0:4e0:d967:318f with SMTP id p9-20020a62ab09000000b004e0d967318fmr21755203pff.86.1646052242367; Mon, 28 Feb 2022 04:44:02 -0800 (PST) Received: from localhost.localdomain ([117.207.25.37]) by smtp.gmail.com with ESMTPSA id y12-20020a056a00190c00b004f39e28fb87sm14256737pfi.98.2022.02.28.04.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 04:44:02 -0800 (PST) From: Manivannan Sadhasivam To: mhi@lists.linux.dev Cc: quic_hemantk@quicinc.com, quic_bbhatt@quicinc.com, quic_jhugo@quicinc.com, vinod.koul@linaro.org, bjorn.andersson@linaro.org, dmitry.baryshkov@linaro.org, quic_vbadigan@quicinc.com, quic_cang@quicinc.com, quic_skananth@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, elder@linaro.org, Paul Davey , Manivannan Sadhasivam , Hemant Kumar , stable@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v4 01/27] bus: mhi: Fix pm_state conversion to string Date: Mon, 28 Feb 2022 18:13:18 +0530 Message-Id: <20220228124344.77359-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228124344.77359-1-manivannan.sadhasivam@linaro.org> References: <20220228124344.77359-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Paul Davey On big endian architectures the mhi debugfs files which report pm state give "Invalid State" for all states. This is caused by using find_last_bit which takes an unsigned long* while the state is passed in as an enum mhi_pm_state which will be of int size. Fix by using __fls to pass the value of state instead of find_last_bit. Also the current API expects "mhi_pm_state" enumerator as the function argument but the function only works with bitmasks. So as Alex suggested, let's change the argument to u32 to avoid confusion. Fixes: a6e2e3522f29 ("bus: mhi: core: Add support for PM state transitions") Signed-off-by: Paul Davey Reviewed-by: Manivannan Sadhasivam Reviewed-by: Hemant Kumar Cc: stable@vger.kernel.org [mani: changed the function argument to u32] Signed-off-by: Manivannan Sadhasivam --- drivers/bus/mhi/core/init.c | 10 ++++++---- drivers/bus/mhi/core/internal.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 046f407dc5d6..09394a1c29ec 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -77,12 +77,14 @@ static const char * const mhi_pm_state_str[] = { [MHI_PM_STATE_LD_ERR_FATAL_DETECT] = "Linkdown or Error Fatal Detect", }; -const char *to_mhi_pm_state_str(enum mhi_pm_state state) +const char *to_mhi_pm_state_str(u32 state) { - unsigned long pm_state = state; - int index = find_last_bit(&pm_state, 32); + int index; - if (index >= ARRAY_SIZE(mhi_pm_state_str)) + if (state) + index = __fls(state); + + if (!state || index >= ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; return mhi_pm_state_str[index]; diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h index e2e10474a9d9..3508cbbf555d 100644 --- a/drivers/bus/mhi/core/internal.h +++ b/drivers/bus/mhi/core/internal.h @@ -622,7 +622,7 @@ void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, enum mhi_pm_state __must_check mhi_tryset_pm_state( struct mhi_controller *mhi_cntrl, enum mhi_pm_state state); -const char *to_mhi_pm_state_str(enum mhi_pm_state state); +const char *to_mhi_pm_state_str(u32 state); int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, enum dev_st_transition state); void mhi_pm_st_worker(struct work_struct *work); -- 2.25.1