On 09/08/2016 10:50 AM, Gabriel Krisman Bertazi wrote:
>> @@ -3324,25 +3394,90 @@ restart:
>>              }
>>
>>              list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
>> -                    if (res->del_from_ml && res->sdev) {
>> +                    if (!res->del_from_ml)
>> +                            continue;
>> +                    if (res->sdev) {
>>                              did_work = 1;
>>                              sdev = res->sdev;
>>                              if (!scsi_device_get(sdev)) {
>> -                                    if (!res->add_to_ml)
>> -                                            list_move_tail(&res->queue, 
>> &ioa_cfg->free_res_q);
>> -                                    else
>> -                                            res->del_from_ml = 0;
>> +                                    if (!res->sata_port) {
>> +                                            if (!res->add_to_ml)
>> +                                                    
>> list_move_tail(&res->queue, &ioa_cfg->free_res_q);
>> +                                            else
>> +                                                    res->del_from_ml = 0;
>> +                                    }
>>                                      
>> spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
>>                                      scsi_remove_device(sdev);
>>                                      scsi_device_put(sdev);
>>                                      
>> spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
>>                              }
>>                              break;
>> +                    } else if (ipr_is_gata(res)) {
>> +                            did_work = 1;
>> +                            sata_port = res->sata_port;
>> +                            res->sata_port = NULL;
>> +                            ap = sata_port->ap;
>> +                            if (!res->add_to_ml)
>> +                                    list_move_tail(&res->queue, 
>> &ioa_cfg->free_res_q);
>> +                            else
>> +                                    res->del_from_ml = 0;
>> +
>> +                            
>> spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
>> +                            spin_lock_irqsave(ap->lock, lock_flags);
>> +                            ap->pflags |= ATA_PFLAG_UNLOADING;
>> +                            ata_port_schedule_eh(ap);
>> +                            spin_unlock_irqrestore(ap->lock, lock_flags);
>> +
>> +                            ata_port_wait_eh(ap);
>> +                            ata_sas_port_destroy(ap);
>> +                            kfree(sata_port);
>> +                            spin_lock_irqsave(ioa_cfg->host->host_lock, 
>> lock_flags);
>>                      }
>>              }
>>      } while (did_work);
>>
>>      list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
>> +            if (res->add_to_ml && ipr_is_gata(res) && !res->sata_port) {
>> +                    spin_unlock_irqrestore(ioa_cfg->host->host_lock, 
>> lock_flags);
>> +                    sata_port = kzalloc(sizeof(*sata_port), GFP_KERNEL);
>> +                    ap = ata_sas_port_alloc(&ioa_cfg->ata_host, 
>> &sata_port_info, ioa_cfg->host);
>> +
>> +                    if (!sata_port || !ap) {
>> +                            spin_lock_irqsave(ioa_cfg->host->host_lock, 
>> lock_flags);
>> +                            res->add_to_ml = 0;
>> +                            kfree(sata_port);
>> +                            goto restart;
>> +                    }
> 
> 
>> +
>> +                    spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
>> +                    sata_port->ioa_cfg = ioa_cfg;
>> +                    sata_port->ap = ap;
>> +                    sata_port->res = res;
>> +                    INIT_WORK(&sata_port->work, ipr_sata_eh_work);
>> +
>> +                    res->sata_port = sata_port;
>> +                    ap->private_data = sata_port;
>> +                    ap->cbl = ATA_CBL_SATA;
>> +                    ap->scsi_host = ioa_cfg->host;
>> +                    spin_unlock_irqrestore(ioa_cfg->host->host_lock,
>> lock_flags);
> 
> Do we really need to hold the host_lock in this small hunk?

Nope. Removed.

Thanks,

Brian


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


------------------------------------------------------------------------------
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to