Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2013199pxj; Sat, 19 Jun 2021 00:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa0N7Vdk/ujqhkABHtp79vfV1bQv1bX63iSTfikB3f3XtXtczRa6qLqRrC7mlIPHQnjAts X-Received: by 2002:a05:6638:3393:: with SMTP id h19mr6916974jav.11.1624086234079; Sat, 19 Jun 2021 00:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624086234; cv=none; d=google.com; s=arc-20160816; b=k2gGblkJqU5qEtd9BZMwinHkg/DmTPpJpGwAR2+XDtrE9Hmhdb3olGJ4N8l0nQcqpH 6Zikp91OWhsxdUfxBupLk6D9zjgQBl9FvXHFaKdE+dP3utzCEFfRyRWZZZUP+cCVbldI eXquU3oY4CfJTOp7eMKs622r0jJ4LkKHtRAE1eoYwgkuRr5i52MEPEYHKfb9wJi3sJrB PjUmqvXXTb/EA3OYq5tfDxcFFoEg/CAPOXVvsQkn5aulCmzuTGbMwCJls1D026Zt2dOx pgqdPL79QJan/5R5xz2A74XZRj5jDmcGqymSwqUm8ftYBaHxUnvgg5R0JaJehp4JF/dE HQEg== 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:date:cc:to:from:subject:message-id :dmarc-filter:sender:dkim-signature; bh=yXhmmp3HnP6JSHafnSyJemeEbnB6pdcDfRv16as6wsU=; b=GxHhyyMDzSKaF31GSDRZhcNZqSwz2tJohiXmmjxsSjcLDhv6wXqZINBO9mytI9T7Er ZKPZjaaaoHEL/vl1lKhGjgsvqaLE/m6fv2+nOA+/ygMVj4EV+XyHv7nsgU4RODd4vfdS wSVgYyub3akMdd+yHXrLz10ukEqmWdwgLf71MZjVDHHBb2pGkBXOg0qIg9eT7I/8hD5Y qjERxUpp7UxsBk9z5B6l/O6/nIC0t/O8SDlfCQO3DGJJqZk93lQE4hXK1qAIpV+KwD+v Xr1oaOdGg5ca1A0WJFdAMKrxRlpga9ITfR+DW7nGgUukBmpye6KeHMk8ulp5Faph66L4 Ariw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=xAZ1uITD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si11978197iod.34.2021.06.19.00.03.41; Sat, 19 Jun 2021 00:03:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=xAZ1uITD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234607AbhFRVnt (ORCPT + 99 others); Fri, 18 Jun 2021 17:43:49 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:18367 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbhFRVns (ORCPT ); Fri, 18 Jun 2021 17:43:48 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1624052498; h=Content-Transfer-Encoding: Mime-Version: Content-Type: References: In-Reply-To: Date: Cc: To: From: Subject: Message-ID: Sender; bh=yXhmmp3HnP6JSHafnSyJemeEbnB6pdcDfRv16as6wsU=; b=xAZ1uITDjN8/dHp+Sq1etlZm5raCOiGG3yomjcjfNxT5pKxjP0j+2I6qF2XNrIkFSaMgtwNH 6kM5E1lVAb40FAFmAZdAnxddiz7Y5+P3NbxJFDmffsLt3YrCZdx6YUXiGr5Ucp3JI6vsTwLC T0k3TsP0VYpXRHRKqqf+1RA3Ilw= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 60cd1312e27c0cc77f90a8dd (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 18 Jun 2021 21:41:38 GMT Sender: hemantk=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1E07AC4338A; Fri, 18 Jun 2021 21:41:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from hemantk-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: hemantk) by smtp.codeaurora.org (Postfix) with ESMTPSA id 09D88C433D3; Fri, 18 Jun 2021 21:41:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 09D88C433D3 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=hemantk@codeaurora.org Message-ID: <1624052489.10055.12.camel@codeaurora.org> Subject: Re: [PATCH 1/2] bus: mhi: Fix pm_state conversion to string From: Hemant Kumar To: Paul Davey , Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 18 Jun 2021 14:41:29 -0700 In-Reply-To: <20210618033132.24839-2-paul.davey@alliedtelesis.co.nz> References: <20210618033132.24839-1-paul.davey@alliedtelesis.co.nz> <20210618033132.24839-2-paul.davey@alliedtelesis.co.nz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Fri, 2021-06-18 at 15:31 +1200, Paul Davey wrote: > On big endian architectures the mhi debugfs files which report pm > state > give "Invalid State" for all states. > > Fix to_mhi_pm_state_str by using a local unsigned long as an > intemediate > to pass the state to find_last_bit to avoid endianness issues with > cast > from enum mhi_pm_state * to unsigned long *. > > Signed-off-by: Paul Davey > --- >  drivers/bus/mhi/core/init.c | 3 ++- >  1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/bus/mhi/core/init.c > b/drivers/bus/mhi/core/init.c > index c81b377fca8f..87cc0c449078 100644 > --- a/drivers/bus/mhi/core/init.c > +++ b/drivers/bus/mhi/core/init.c > @@ -79,7 +79,8 @@ static const char * const mhi_pm_state_str[] = { >   >  const char *to_mhi_pm_state_str(enum mhi_pm_state state) >  { > - int index = find_last_bit((unsigned long *)&state, 32); > + unsigned long tmp = state; > + int index = find_last_bit((unsigned long *)&tmp, 32); >   >   if (index >= ARRAY_SIZE(mhi_pm_state_str)) >   return "Invalid State"; Considering KASAN bugs reported in the past related to find_next_bit https://www.spinics.net/lists/alsa-devel/msg110946.html Since you are addressing the BE arch issue, would you please use this solution instead :- diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c index 8f4cd4d..744b617 100644 --- a/drivers/bus/mhi/core/init.c +++ b/drivers/bus/mhi/core/init.c @@ -77,9 +77,12 @@ static const char * const mhi_pm_state_str[] = {    const char *to_mhi_pm_state_str(enum mhi_pm_state state)  { + 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]; Thanks, Hemant -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project