@@ -1055,6 +1055,43 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason,
1055
1055
return 0 ;
1056
1056
}
1057
1057
1058
+ static int
1059
+ service_single_message (struct vchiq_instance * instance ,
1060
+ enum vchiq_reason reason ,
1061
+ struct vchiq_service * service , void * bulk_userdata )
1062
+ {
1063
+ struct user_service * user_service ;
1064
+
1065
+ user_service = (struct user_service * )service -> base .userdata ;
1066
+
1067
+ dev_dbg (service -> state -> dev , "arm: msg queue full\n" );
1068
+ /*
1069
+ * If there is no MESSAGE_AVAILABLE in the completion
1070
+ * queue, add one
1071
+ */
1072
+ if ((user_service -> message_available_pos -
1073
+ instance -> completion_remove ) < 0 ) {
1074
+ int ret ;
1075
+
1076
+ dev_dbg (instance -> state -> dev ,
1077
+ "arm: Inserting extra MESSAGE_AVAILABLE\n" );
1078
+ ret = add_completion (instance , reason , NULL , user_service ,
1079
+ bulk_userdata );
1080
+ if (ret )
1081
+ return ret ;
1082
+ }
1083
+
1084
+ if (wait_for_completion_interruptible (& user_service -> remove_event )) {
1085
+ dev_dbg (instance -> state -> dev , "arm: interrupted\n" );
1086
+ return - EAGAIN ;
1087
+ } else if (instance -> closing ) {
1088
+ dev_dbg (instance -> state -> dev , "arm: closing\n" );
1089
+ return - EINVAL ;
1090
+ }
1091
+
1092
+ return 0 ;
1093
+ }
1094
+
1058
1095
int
1059
1096
service_callback (struct vchiq_instance * instance , enum vchiq_reason reason ,
1060
1097
struct vchiq_header * header , unsigned int handle , void * bulk_userdata )
@@ -1104,41 +1141,18 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason,
1104
1141
spin_lock (& service -> state -> msg_queue_spinlock );
1105
1142
while (user_service -> msg_insert ==
1106
1143
(user_service -> msg_remove + MSG_QUEUE_SIZE )) {
1144
+ int ret ;
1145
+
1107
1146
spin_unlock (& service -> state -> msg_queue_spinlock );
1108
1147
DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1109
1148
DEBUG_COUNT (MSG_QUEUE_FULL_COUNT );
1110
- dev_dbg (service -> state -> dev , "arm: msg queue full\n" );
1111
- /*
1112
- * If there is no MESSAGE_AVAILABLE in the completion
1113
- * queue, add one
1114
- */
1115
- if ((user_service -> message_available_pos -
1116
- instance -> completion_remove ) < 0 ) {
1117
- int ret ;
1118
-
1119
- dev_dbg (instance -> state -> dev ,
1120
- "arm: Inserting extra MESSAGE_AVAILABLE\n" );
1121
- DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1122
- ret = add_completion (instance , reason , NULL , user_service ,
1123
- bulk_userdata );
1124
- if (ret ) {
1125
- DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1126
- vchiq_service_put (service );
1127
- return ret ;
1128
- }
1129
- }
1130
1149
1131
- DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1132
- if (wait_for_completion_interruptible (& user_service -> remove_event )) {
1133
- dev_dbg (instance -> state -> dev , "arm: interrupted\n" );
1134
- DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1135
- vchiq_service_put (service );
1136
- return - EAGAIN ;
1137
- } else if (instance -> closing ) {
1138
- dev_dbg (instance -> state -> dev , "arm: closing\n" );
1150
+ ret = service_single_message (instance , reason ,
1151
+ service , bulk_userdata );
1152
+ if (ret ) {
1139
1153
DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1140
1154
vchiq_service_put (service );
1141
- return - EINVAL ;
1155
+ return ret ;
1142
1156
}
1143
1157
DEBUG_TRACE (SERVICE_CALLBACK_LINE );
1144
1158
spin_lock (& service -> state -> msg_queue_spinlock );
0 commit comments