@@ -110,7 +110,7 @@ struct ffa_drv_info {
110110 struct work_struct sched_recv_irq_work ;
111111 struct xarray partition_info ;
112112 DECLARE_HASHTABLE (notifier_hash , ilog2 (FFA_MAX_NOTIFICATIONS ));
113- struct mutex notify_lock ; /* lock to protect notifier hashtable */
113+ rwlock_t notify_lock ; /* lock to protect notifier hashtable */
114114};
115115
116116static struct ffa_drv_info * drv_info ;
@@ -1182,18 +1182,18 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id)
11821182 if (notify_id >= FFA_MAX_NOTIFICATIONS )
11831183 return - EINVAL ;
11841184
1185- mutex_lock (& drv_info -> notify_lock );
1185+ write_lock (& drv_info -> notify_lock );
11861186
11871187 rc = update_notifier_cb (notify_id , type , NULL );
11881188 if (rc ) {
11891189 pr_err ("Could not unregister notification callback\n" );
1190- mutex_unlock (& drv_info -> notify_lock );
1190+ write_unlock (& drv_info -> notify_lock );
11911191 return rc ;
11921192 }
11931193
11941194 rc = ffa_notification_unbind (dev -> vm_id , BIT (notify_id ));
11951195
1196- mutex_unlock (& drv_info -> notify_lock );
1196+ write_unlock (& drv_info -> notify_lock );
11971197
11981198 return rc ;
11991199}
@@ -1220,7 +1220,7 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
12201220 cb_info -> cb_data = cb_data ;
12211221 cb_info -> cb = cb ;
12221222
1223- mutex_lock (& drv_info -> notify_lock );
1223+ write_lock (& drv_info -> notify_lock );
12241224
12251225 if (is_per_vcpu )
12261226 flags = PER_VCPU_NOTIFICATION_FLAG ;
@@ -1237,7 +1237,7 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
12371237 }
12381238
12391239out_unlock_free :
1240- mutex_unlock (& drv_info -> notify_lock );
1240+ write_unlock (& drv_info -> notify_lock );
12411241 if (rc )
12421242 kfree (cb_info );
12431243
@@ -1269,9 +1269,9 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type)
12691269 if (!(bitmap & 1 ))
12701270 continue ;
12711271
1272- mutex_lock (& drv_info -> notify_lock );
1272+ read_lock (& drv_info -> notify_lock );
12731273 cb_info = notifier_hash_node_get (notify_id , type );
1274- mutex_unlock (& drv_info -> notify_lock );
1274+ read_unlock (& drv_info -> notify_lock );
12751275
12761276 if (cb_info && cb_info -> cb )
12771277 cb_info -> cb (notify_id , cb_info -> cb_data );
@@ -1721,7 +1721,7 @@ static void ffa_notifications_setup(void)
17211721 goto cleanup ;
17221722
17231723 hash_init (drv_info -> notifier_hash );
1724- mutex_init (& drv_info -> notify_lock );
1724+ rwlock_init (& drv_info -> notify_lock );
17251725
17261726 drv_info -> notif_enabled = true;
17271727 return ;
0 commit comments