| .. | .. |
|---|
| 3221 | 3221 | struct megasas_instance *instance = |
|---|
| 3222 | 3222 | (struct megasas_instance *) shost->hostdata; |
|---|
| 3223 | 3223 | int val = 0; |
|---|
| 3224 | | - unsigned long flags; |
|---|
| 3225 | 3224 | |
|---|
| 3226 | 3225 | if (kstrtoint(buf, 0, &val) != 0) |
|---|
| 3227 | 3226 | return -EINVAL; |
|---|
| 3228 | 3227 | |
|---|
| 3229 | | - spin_lock_irqsave(&instance->crashdump_lock, flags); |
|---|
| 3228 | + mutex_lock(&instance->crashdump_lock); |
|---|
| 3230 | 3229 | instance->fw_crash_buffer_offset = val; |
|---|
| 3231 | | - spin_unlock_irqrestore(&instance->crashdump_lock, flags); |
|---|
| 3230 | + mutex_unlock(&instance->crashdump_lock); |
|---|
| 3232 | 3231 | return strlen(buf); |
|---|
| 3233 | 3232 | } |
|---|
| 3234 | 3233 | |
|---|
| .. | .. |
|---|
| 3243 | 3242 | unsigned long dmachunk = CRASH_DMA_BUF_SIZE; |
|---|
| 3244 | 3243 | unsigned long chunk_left_bytes; |
|---|
| 3245 | 3244 | unsigned long src_addr; |
|---|
| 3246 | | - unsigned long flags; |
|---|
| 3247 | 3245 | u32 buff_offset; |
|---|
| 3248 | 3246 | |
|---|
| 3249 | | - spin_lock_irqsave(&instance->crashdump_lock, flags); |
|---|
| 3247 | + mutex_lock(&instance->crashdump_lock); |
|---|
| 3250 | 3248 | buff_offset = instance->fw_crash_buffer_offset; |
|---|
| 3251 | | - if (!instance->crash_dump_buf && |
|---|
| 3249 | + if (!instance->crash_dump_buf || |
|---|
| 3252 | 3250 | !((instance->fw_crash_state == AVAILABLE) || |
|---|
| 3253 | 3251 | (instance->fw_crash_state == COPYING))) { |
|---|
| 3254 | 3252 | dev_err(&instance->pdev->dev, |
|---|
| 3255 | 3253 | "Firmware crash dump is not available\n"); |
|---|
| 3256 | | - spin_unlock_irqrestore(&instance->crashdump_lock, flags); |
|---|
| 3254 | + mutex_unlock(&instance->crashdump_lock); |
|---|
| 3257 | 3255 | return -EINVAL; |
|---|
| 3258 | 3256 | } |
|---|
| 3259 | 3257 | |
|---|
| 3260 | 3258 | if (buff_offset > (instance->fw_crash_buffer_size * dmachunk)) { |
|---|
| 3261 | 3259 | dev_err(&instance->pdev->dev, |
|---|
| 3262 | 3260 | "Firmware crash dump offset is out of range\n"); |
|---|
| 3263 | | - spin_unlock_irqrestore(&instance->crashdump_lock, flags); |
|---|
| 3261 | + mutex_unlock(&instance->crashdump_lock); |
|---|
| 3264 | 3262 | return 0; |
|---|
| 3265 | 3263 | } |
|---|
| 3266 | 3264 | |
|---|
| .. | .. |
|---|
| 3272 | 3270 | src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] + |
|---|
| 3273 | 3271 | (buff_offset % dmachunk); |
|---|
| 3274 | 3272 | memcpy(buf, (void *)src_addr, size); |
|---|
| 3275 | | - spin_unlock_irqrestore(&instance->crashdump_lock, flags); |
|---|
| 3273 | + mutex_unlock(&instance->crashdump_lock); |
|---|
| 3276 | 3274 | |
|---|
| 3277 | 3275 | return size; |
|---|
| 3278 | 3276 | } |
|---|
| .. | .. |
|---|
| 3297 | 3295 | struct megasas_instance *instance = |
|---|
| 3298 | 3296 | (struct megasas_instance *) shost->hostdata; |
|---|
| 3299 | 3297 | int val = 0; |
|---|
| 3300 | | - unsigned long flags; |
|---|
| 3301 | 3298 | |
|---|
| 3302 | 3299 | if (kstrtoint(buf, 0, &val) != 0) |
|---|
| 3303 | 3300 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 3311 | 3308 | instance->fw_crash_state = val; |
|---|
| 3312 | 3309 | |
|---|
| 3313 | 3310 | if ((val == COPIED) || (val == COPY_ERROR)) { |
|---|
| 3314 | | - spin_lock_irqsave(&instance->crashdump_lock, flags); |
|---|
| 3311 | + mutex_lock(&instance->crashdump_lock); |
|---|
| 3315 | 3312 | megasas_free_host_crash_buffer(instance); |
|---|
| 3316 | | - spin_unlock_irqrestore(&instance->crashdump_lock, flags); |
|---|
| 3313 | + mutex_unlock(&instance->crashdump_lock); |
|---|
| 3317 | 3314 | if (val == COPY_ERROR) |
|---|
| 3318 | 3315 | dev_info(&instance->pdev->dev, "application failed to " |
|---|
| 3319 | 3316 | "copy Firmware crash dump\n"); |
|---|
| .. | .. |
|---|
| 7325 | 7322 | init_waitqueue_head(&instance->int_cmd_wait_q); |
|---|
| 7326 | 7323 | init_waitqueue_head(&instance->abort_cmd_wait_q); |
|---|
| 7327 | 7324 | |
|---|
| 7328 | | - spin_lock_init(&instance->crashdump_lock); |
|---|
| 7325 | + mutex_init(&instance->crashdump_lock); |
|---|
| 7329 | 7326 | spin_lock_init(&instance->mfi_pool_lock); |
|---|
| 7330 | 7327 | spin_lock_init(&instance->hba_lock); |
|---|
| 7331 | 7328 | spin_lock_init(&instance->stream_lock); |
|---|