lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <53807524.70409@kernel.org>
Date:	Sat, 24 May 2014 11:32:04 +0100
From:	Jonathan Cameron <jic23@...nel.org>
To:	Reyad Attiyat <reyad.attiyat@...il.com>,
	linux-kernel@...r.kernel.org,
	linux-input <linux-input@...r.kernel.org>,
	linux-iio@...r.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
	Jiri Kosina <jkosina@...e.cz>
Subject: Re: [PATCH] HID: hid-sensor-hub: Fix lockdep warning for dynamic
 callback locks.

On 14/05/14 02:49, Reyad Attiyat wrote:
> Here is a sample of the kernel lockdep warning I got after turingon
> dynamic debugging:
> https://bugzilla.kernel.org/show_bug.cgi?id=73321#c3
>
>
>
> On Tue, May 13, 2014 at 8:03 PM, Reyad Attiyat <reyad.attiyat@...il.com> wrote:
>> Changes all dyn_callback_lock spinlocks to spinlocks that disable
>> interrupts. The dynamic callback lock (dyn_callback_lock) must not be
>> interrupted when locked as it is used in an interrupt handler
>> function, sensor_hub_raw_event.
Looks sane to me, but no sign off and Jiri not cc'd.
Would like an ack from Srinivas as well ideally.

Acked-by: Jonathan Cameron <jic23@...nel.org>
>> ---
>>   drivers/hid/hid-sensor-hub.c | 31 ++++++++++++++++++-------------
>>   1 file changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
>> index af8244b..1e1644c 100644
>> --- a/drivers/hid/hid-sensor-hub.c
>> +++ b/drivers/hid/hid-sensor-hub.c
>> @@ -133,10 +133,11 @@ static struct hid_sensor_hub_callbacks
>> *sensor_hub_get_callback(
>>    struct hid_sensor_hub_device **hsdev,
>>    void **priv)
>>   {
>> + unsigned long flags;
>>    struct hid_sensor_hub_callbacks_list *callback;
>>    struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
>>
>> - spin_lock(&pdata->dyn_callback_lock);
>> + spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
>>    list_for_each_entry(callback, &pdata->dyn_callback_list, list)
>>    if (callback->usage_id == usage_id &&
>>    (collection_index >=
>> @@ -145,10 +146,10 @@ static struct hid_sensor_hub_callbacks
>> *sensor_hub_get_callback(
>>    callback->hsdev->end_collection_index)) {
>>    *priv = callback->priv;
>>    *hsdev = callback->hsdev;
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>    return callback->usage_callback;
>>    }
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>
>>    return NULL;
>>   }
>> @@ -157,19 +158,20 @@ int sensor_hub_register_callback(struct
>> hid_sensor_hub_device *hsdev,
>>    u32 usage_id,
>>    struct hid_sensor_hub_callbacks *usage_callback)
>>   {
>> + unsigned long flags;
>>    struct hid_sensor_hub_callbacks_list *callback;
>>    struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
>>
>> - spin_lock(&pdata->dyn_callback_lock);
>> + spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
>>    list_for_each_entry(callback, &pdata->dyn_callback_list, list)
>>    if (callback->usage_id == usage_id &&
>>    callback->hsdev == hsdev) {
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>    return -EINVAL;
>>    }
>>    callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
>>    if (!callback) {
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>    return -ENOMEM;
>>    }
>>    callback->hsdev = hsdev;
>> @@ -177,7 +179,7 @@ int sensor_hub_register_callback(struct
>> hid_sensor_hub_device *hsdev,
>>    callback->usage_id = usage_id;
>>    callback->priv = NULL;
>>    list_add_tail(&callback->list, &pdata->dyn_callback_list);
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>
>>    return 0;
>>   }
>> @@ -186,10 +188,11 @@ EXPORT_SYMBOL_GPL(sensor_hub_register_callback);
>>   int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
>>    u32 usage_id)
>>   {
>> + unsigned long flags;
>>    struct hid_sensor_hub_callbacks_list *callback;
>>    struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
>>
>> - spin_lock(&pdata->dyn_callback_lock);
>> + spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
>>    list_for_each_entry(callback, &pdata->dyn_callback_list, list)
>>    if (callback->usage_id == usage_id &&
>>    callback->hsdev == hsdev) {
>> @@ -197,7 +200,7 @@ int sensor_hub_remove_callback(struct
>> hid_sensor_hub_device *hsdev,
>>    kfree(callback);
>>    break;
>>    }
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>
>>    return 0;
>>   }
>> @@ -376,34 +379,36 @@ EXPORT_SYMBOL_GPL(sensor_hub_input_get_attribute_info);
>>   #ifdef CONFIG_PM
>>   static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message)
>>   {
>> + unsigned long flags;
>>    struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
>>    struct hid_sensor_hub_callbacks_list *callback;
>>
>>    hid_dbg(hdev, " sensor_hub_suspend\n");
>> - spin_lock(&pdata->dyn_callback_lock);
>> + spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
>>    list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
>>    if (callback->usage_callback->suspend)
>>    callback->usage_callback->suspend(
>>    callback->hsdev, callback->priv);
>>    }
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>
>>    return 0;
>>   }
>>
>>   static int sensor_hub_resume(struct hid_device *hdev)
>>   {
>> + unsigned long flags;
>>    struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
>>    struct hid_sensor_hub_callbacks_list *callback;
>>
>>    hid_dbg(hdev, " sensor_hub_resume\n");
>> - spin_lock(&pdata->dyn_callback_lock);
>> + spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
>>    list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
>>    if (callback->usage_callback->resume)
>>    callback->usage_callback->resume(
>>    callback->hsdev, callback->priv);
>>    }
>> - spin_unlock(&pdata->dyn_callback_lock);
>> + spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
>>
>>    return 0;
>>   }
>> --
>> 1.9.0
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ