Re: [PATCH v2 11/20] rpmsg: glink: Fix idr_lock from mutex to spinlock

From: Sricharan R
Date: Mon Aug 28 2017 - 19:14:03 EST


Hi Chris,

On 8/29/2017 3:21 AM, Chris Lew wrote:
> Hi Sricharan,
>
> Minor bug in this patch.
>
> On 8/24/2017 12:21 AM, Sricharan R wrote:
> [..]
>> @@ -829,11 +839,14 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
>> ÂÂÂÂÂ struct device_node *node;
>> ÂÂÂÂÂ int lcid;
>> ÂÂÂÂÂ int ret;
>> +ÂÂÂ unsigned long flags;
>> Â +ÂÂÂ spin_lock_irqsave(&glink->idr_lock, flags);
>> ÂÂÂÂÂ idr_for_each_entry(&glink->lcids, channel, lcid) {
>> ÂÂÂÂÂÂÂÂÂ if (!strcmp(channel->name, name))
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ break;
>> ÂÂÂÂÂ }
>> +ÂÂÂ spin_unlock_irqrestore(&glink->idr_lock, flags);
>> Â ÂÂÂÂÂ if (!channel) {
>> ÂÂÂÂÂÂÂÂÂ channel = qcom_glink_alloc_channel(glink, name);
>> @@ -844,15 +857,15 @@ static int qcom_glink_rx_open(struct qcom_glink *glink, unsigned int rcid,
>> ÂÂÂÂÂÂÂÂÂ create_device = true;
>> ÂÂÂÂÂ }
>> Â -ÂÂÂ mutex_lock(&glink->idr_lock);
>> +ÂÂÂ spin_lock_irqsave(&glink->idr_lock, flags);
>> ÂÂÂÂÂ ret = idr_alloc(&glink->rcids, channel, rcid, rcid + 1, GFP_KERNEL);
>
> I think GFP_KERNEL should be changed to GFP_ATOMIC if the mutex is changed to spinlock.
>

ha, thanks for the catch.

Regards,
Sricharan

--
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus