Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp663797pxb; Tue, 5 Apr 2022 17:51:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj02D0dxmY1gYH+gVOIkUM0NcrXz8IGBrcYgzGMysMyoHq3uq3qDG0IrkM7kLlGuhessJg X-Received: by 2002:a17:907:3f86:b0:6df:ad43:583 with SMTP id hr6-20020a1709073f8600b006dfad430583mr5966891ejc.535.1649206305507; Tue, 05 Apr 2022 17:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206305; cv=none; d=google.com; s=arc-20160816; b=w677TMsaahnhlhPQalklglRTPE3xYt/8lZ328uKEk8B88iNhh9UlDrJfL90Gl+8rrH wPGXSH4727YqrniJ4aHWhzeM54e5oBd/2U+XHf+0oIV2K/SdidUm2fP2tymWux7SxHs8 Jaa0VmwlpEnxlV9UP1256FWqV6f7AYOULotDJdErVBxF84s6Ax2VekFRRbZ0CSf6vHyE NUJ1eXn2j5WLyWLsvOCNIvepNU5TVbOvb2FYgv0ju+IQYiYeFHQ9k7Ibn9gFOKkofsJC evvvzb2ON+31Doyx5yFSzqlMggoVC0aQZSeEDRSWIBgMMoGIU1dphv1NvgygIDXkFAGr oZSA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lPB5fugApnEV4oNWLXhVYd2T/t9Ygy43Bk/GJSS/6TY=; b=Tuy/YgZuqtdUnq3O5pgEjOs7BLnnmGxQVSsDCxnmf1keuJRglt+F9+Vbdh2B4pijP9 fopXMTz+jIDXYk8+2wuSl4O9HSnpMoNuOG1F1fbLl05hGjGFd0fMD6c2KMz3jVY4j+vc MD7CD79bDLvZ3ynmznxqT26hMaTRKgH16FwWL7x5TMTQ8VxoTWDGbrHFRF1ky4X15k6O 07sem37idV40PW8QN2M9OxMAAqsDB1RgK4mO57Eu8P9gygsCSwpdwRb+nnCRvT4JAAkj RKAJi7a/NrQY3Rw2MuQ8BddSu2J9Cp9yIYgZceWCR7uruJNQMgTY2ZJqBedeAHd35Gb/ uSAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w0XeXc4z; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s8-20020a1709064d8800b006e7ec2be6bbsi6479602eju.411.2022.04.05.17.51.15; Tue, 05 Apr 2022 17:51:45 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=w0XeXc4z; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231867AbiDEHmT (ORCPT + 99 others); Tue, 5 Apr 2022 03:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbiDEHle (ORCPT ); Tue, 5 Apr 2022 03:41:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D58764B871; Tue, 5 Apr 2022 00:39:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 24EFC615CD; Tue, 5 Apr 2022 07:39:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B97AC36AE9; Tue, 5 Apr 2022 07:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144375; bh=/r3TLfXL+PhfwhI9AzBrwfuWC6FGOFGRuw5OYqQAU0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w0XeXc4zxE0mcZ4BTyaHeBBwVYT7Nt06MRVjGykzxAEWsNxN283c6tc5G6AZNFXXu zohWACO6lizod0IoScToUG6ZukIIkydWBwcEwOdKz3BTnxB4NZarWtrVhC6aQptE9E WXdwd2osEKmelx7UWJ+1G/b8XjupJq7rVF8eWSiA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manivannan Sadhasivam , Hemant Kumar , Alex Elder , Paul Davey , Manivannan Sadhasivam Subject: [PATCH 5.17 0023/1126] bus: mhi: Fix pm_state conversion to string Date: Tue, 5 Apr 2022 09:12:50 +0200 Message-Id: <20220405070408.228399226@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 commit 64f93a9a27c1970fa8ee5ffc5a6ae2bda477ec5b upstream. 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") Cc: stable@vger.kernel.org [mani: changed the function argument to u32] Reviewed-by: Manivannan Sadhasivam Reviewed-by: Hemant Kumar Reviewed-by: Alex Elder Signed-off-by: Paul Davey Signed-off-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20220301160308.107452-3-manivannan.sadhasivam@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/bus/mhi/core/init.c | 10 ++++++---- drivers/bus/mhi/core/internal.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) --- 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_s [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]; --- 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_cont 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);