From: bbhatt@codeaurora.org
To: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: mani@kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, hemantk@codeaurora.org,
linux-kernel-owner@vger.kernel.org
Subject: Re: [PATCH v3 9/9] bus: mhi: core: Ensure non-zero session or sequence ID values
Date: Fri, 01 May 2020 19:33:03 -0700 [thread overview]
Message-ID: <612b805e217eebbafeaa080655af2fba@codeaurora.org> (raw)
In-Reply-To: <e609031b-33a1-2db6-21b9-8ebadafba509@codeaurora.org>
On 2020-04-30 08:12, Jeffrey Hugo wrote:
> On 4/29/2020 2:52 PM, Bhaumik Bhatt wrote:
>> While writing any sequence or session identifiers, it is possible that
>> the host could write a zero value, whereas only non-zero values are
>> supported writes to those registers. Ensure that host does not write a
>> non-zero value for those cases.
>>
>> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>> ---
>> drivers/bus/mhi/core/boot.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
>> index 0bc9c50..c9971d4 100644
>> --- a/drivers/bus/mhi/core/boot.c
>> +++ b/drivers/bus/mhi/core/boot.c
>> @@ -199,6 +199,9 @@ static int mhi_fw_load_amss(struct mhi_controller
>> *mhi_cntrl,
>> mhi_write_reg(mhi_cntrl, base, BHIE_TXVECSIZE_OFFS, mhi_buf->len);
>> sequence_id = prandom_u32() & BHIE_TXVECSTATUS_SEQNUM_BMSK;
>> + if (unlikely(!sequence_id))
>> + sequence_id = 1;
>
> Seems like you could use prandom_u32_max(), and add 1 to the result to
> eliminate the conditional. What do you think?
>
Agreed. Done using an internal macro in those places.
>> +
>> mhi_write_reg_field(mhi_cntrl, base, BHIE_TXVECDB_OFFS,
>> BHIE_TXVECDB_SEQNUM_BMSK, BHIE_TXVECDB_SEQNUM_SHFT,
>> sequence_id);
>> @@ -254,6 +257,9 @@ static int mhi_fw_load_sbl(struct mhi_controller
>> *mhi_cntrl,
>> lower_32_bits(dma_addr));
>> mhi_write_reg(mhi_cntrl, base, BHI_IMGSIZE, size);
>> session_id = prandom_u32() & BHI_TXDB_SEQNUM_BMSK;
>> + if (unlikely(!session_id))
>> + session_id = 1;
>> +
>> mhi_write_reg(mhi_cntrl, base, BHI_IMGTXDB, session_id);
>> read_unlock_bh(pm_lock);
>>
prev parent reply other threads:[~2020-05-02 2:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 20:52 [PATCH v3 0/9] Bug fixes and improved logging in MHI Bhaumik Bhatt
2020-04-29 20:52 ` [PATCH v3 1/9] bus: mhi: core: Refactor mhi queue APIs Bhaumik Bhatt
2020-04-30 14:22 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 2/9] bus: mhi: core: Cache intmod from mhi event to mhi channel Bhaumik Bhatt
2020-04-30 14:23 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 3/9] bus: mhi: core: Add range check for channel id received in event ring Bhaumik Bhatt
2020-04-30 14:26 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 4/9] bus: mhi: core: Read transfer length from an event properly Bhaumik Bhatt
2020-04-30 14:28 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 5/9] bus: mhi: core: Handle firmware load using state worker Bhaumik Bhatt
2020-04-30 14:50 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 6/9] bus: mhi: core: WARN_ON for malformed vector table Bhaumik Bhatt
2020-04-30 15:02 ` Jeffrey Hugo
2020-05-02 2:38 ` bbhatt
2020-04-29 20:52 ` [PATCH v3 7/9] bus: mhi: core: Return appropriate error codes for AMSS load failure Bhaumik Bhatt
2020-04-30 15:03 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 8/9] bus: mhi: core: Improve debug logs for loading firmware Bhaumik Bhatt
2020-04-30 15:06 ` Jeffrey Hugo
2020-04-29 20:52 ` [PATCH v3 9/9] bus: mhi: core: Ensure non-zero session or sequence ID values Bhaumik Bhatt
2020-04-30 15:12 ` Jeffrey Hugo
2020-05-02 2:33 ` bbhatt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=612b805e217eebbafeaa080655af2fba@codeaurora.org \
--to=bbhatt@codeaurora.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel-owner@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.