Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2993986pxm; Mon, 28 Feb 2022 09:55:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/14HUN64sC53Y1UByRbZWuuBicb09dcsXAwPhCcFBdW+B8923CAg79byI81p8XnqvJnGG X-Received: by 2002:a05:6402:3549:b0:412:b31c:5509 with SMTP id f9-20020a056402354900b00412b31c5509mr20994902edd.224.1646070956988; Mon, 28 Feb 2022 09:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646070956; cv=none; d=google.com; s=arc-20160816; b=ZESPGDp3/zZ4utkQD/us050XqQ9ijMliSvM0mSjZ7qkXGYQOTUW69V8ThsnA3DmXst npvqW0NDkFpJ+DKUpKUuHHe3gSvNwXAf/LX0fhtmOfDJ/u1PQDZb4r2kV40GChZHA+fc 1VWeyazdMCbvVo09e2TarqhF+WPfrq537Umt/Mg5elOtSfiOz9UIGmAaCAspD15VMmdw ByqxUCbCMCSjNaxbHeddt+Be5vGONkmwRrGDglSW2kMh58jjW+GTYUHknEefIv1YfleT +yoCwB8kg7gkJD3G410XYHDXqYHvV7s7nTK1B2AY0evrPinVa88BvzzdkoSktssgfpsl ypkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7xuq/jHgOUriIm1O/BV7S1L7sNlV9+5iBX6aT2AWV0s=; b=BGHPDdDtnltrIZivjk2jkWSSmCYDSQs+WnKgoQMT/lunujJl5W82xnmpPPKILJcqBD bPMzt/otUN2iyEsy5oBjXm8WRA2e6zSSIJzyF/B2WW2kQQKzEHnIBTCW6pQTkd92I1QR NNzOCRhLocZC34FZ6UUEHI5j1vSA3Q+Kek4k7eGWgjfL5zjNkbLJtAGEl5C8si1/YTqJ sF1+b7eFGpNZWaiyhX3Nx1TiP88E9g7tsKsStH2Z5183IxXr+szbzPpRmRHO9ZHkDuHJ uca32jQCeJtnd/uZSfyyiCnfqfk9QGXQPJJBZ1Nk6lCUjOxLB3wrt2wr0uYuT06Rgq76 pVNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ckmgyi0L; 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 q14-20020a50da8e000000b0041062423637si7283800edj.355.2022.02.28.09.55.34; Mon, 28 Feb 2022 09:55:56 -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=Ckmgyi0L; 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 S236574AbiB1PbM (ORCPT + 99 others); Mon, 28 Feb 2022 10:31:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236106AbiB1PbJ (ORCPT ); Mon, 28 Feb 2022 10:31:09 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71587EB04 for ; Mon, 28 Feb 2022 07:30:29 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id j5so10257588ila.2 for ; Mon, 28 Feb 2022 07:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=7xuq/jHgOUriIm1O/BV7S1L7sNlV9+5iBX6aT2AWV0s=; b=Ckmgyi0L1ORPLOIs0I59pJKj3U54sFM9eXt7zVW3L8Zz3vVWcUMuDhm4H5a0vH4P0r dMwwxS0/KGseXwyf0kqph5aogznMPR27U5WJtAkF1tTLkwgui7KkoFSBuNke67NYvHBn zo4bt5FdK9LoYJx8RqwfwmVSextkRSxiTUfjgQUMI9y2NzVE8v6DcZBQfMygp4HF3c3/ K5PTTu5KC2uqpcwucSwCDYMzKUpA6YfJVXHgHqiEmkBagcqLNDZvufFiD6k4WPgOiNkq vJu3UipP5TDqjLSQGIhc0SdYb16UTannauH9vGQH08ptV/XB1MlfgAQrD7j0WeyrBVEg SBBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=7xuq/jHgOUriIm1O/BV7S1L7sNlV9+5iBX6aT2AWV0s=; b=QoCMhVD5Z7ElOenoGdXhlZRwBHVbaiLsEqacDVfd1vZJH+MGQCpjoj9QOlvxD5iONA sFL0LEqMRps6oE6fiqi9yYrd5FZajY1pJBFiFDADbENO8ZLJIY0SHAYJllHi7HHrg6OY STgbC924J8etcsA2asBxWAVObOcYAFSS9rpmlARxQgaCDk4S2hy6bz+twrQ53lodbAy7 IoV3I0VUZkc8XP1/dpGQUJ8zdY7SY6QxvpzyUZnG8pjNddFDc09ReOLw3cyKuXQmbbGe Zfo0bQe4qBzILqO5wBg4QCHFMyvuT4zD7+Et6HnL94FgMQXXV1lkohOtTJqBnToywkOb 8Iqg== X-Gm-Message-State: AOAM531DrtZEWK8IFqP7dnBKHpAiR1fmBEVLs321SWHxdaDa56DrFFky AvtzGRcmSIewMi1FWCa4KJ3fdw== X-Received: by 2002:a05:6e02:1587:b0:2c2:5c48:a695 with SMTP id m7-20020a056e02158700b002c25c48a695mr19306744ilu.169.1646062229191; Mon, 28 Feb 2022 07:30:29 -0800 (PST) Received: from [172.22.22.4] (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.googlemail.com with ESMTPSA id u17-20020a056e02111100b002c2a943034esm5952850ilk.5.2022.02.28.07.30.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Feb 2022 07:30:28 -0800 (PST) Message-ID: <6fc89860-9eea-630c-f193-272bf436ad81@linaro.org> Date: Mon, 28 Feb 2022 09:30:26 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 01/27] bus: mhi: Fix pm_state conversion to string Content-Language: en-US To: Manivannan Sadhasivam , 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, Paul Davey , Manivannan Sadhasivam , Hemant Kumar , stable@vger.kernel.org References: <20220228124344.77359-1-manivannan.sadhasivam@linaro.org> <20220228124344.77359-2-manivannan.sadhasivam@linaro.org> From: Alex Elder In-Reply-To: <20220228124344.77359-2-manivannan.sadhasivam@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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 On 2/28/22 6:43 AM, Manivannan Sadhasivam wrote: > 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. (Grumble grumble too much static data in header file.) Reviewed-by: Alex Elder > 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);