Alexis Bruemmer <alexisb@xxxxxxxxxx> wrote: > > Which shows that the current scsi_flush_work() is in the wrong place. > > If you move it out of sas_init.c and into aic94xx_init.c at this place, > > I think you'll find everything now works for you. > > I tried your suggestion and moved the scsi_flush_work() from sas_init.c > to aic94xx_init.c and, unfortunately the discovery race condition still > existed with this change (see dump below). This makes sense because > where we are flushing the work queue we cannot guarantee that any work > actually exits there yet. I assume one explanation is that without waiting for the event thread to make it passed the event_sema there is no work to flush. I have added some notes I had below of the different call chains. -andmike -- Michael Anderson andmike@xxxxxxxxxx Moving the scsi_flush_work from sas_register_ha to asd_pci_probe() prior to return of asd_pci_probe may still miss an event. The difference between this move not working and the patch that Alexis posted working could be that Alexis's patch was waiting until sas_discover_work_fn had called sas_process_events prior to indicating discovery was done. 1.) pci probe context asd_pci_probe(...) asd_register_sas_ha(...) sas_register_ha(...) sas_start_event_thread(...) wait_for_completion(&event_th_comp); <-- asd_enable_phys(...) scsi_flush_work(sas_ha->core.shost); 2.) hw interrupt leading to event context. asd_hw_isr(...) asd_process_donelist_isr(...) asd_dl_tasklet_handler(...) asd_task_tasklet_complete(...) or control_phy_tasklet_complete(...) or escb_tasklet_complete(...) asd_bytes_dmaed_tasklet(...) notify_port_event(...) up(&ha->event_sema); 3.) event thread context sas_event_thread(...) complete(&event_th_comp); down_interruptible(&sas_ha->event_sema); sas_process_events(...) sas_process_port_event(...) sas_porte_bytes_dmaed(...) sas_form_port(...) sas_discover_event(...) INIT_WORK(&port->work, sas_discover_work_fn, port); scsi_queue_work(port->ha->core.shost, &port->work); 4.) work fn context sas_discover_work_fn(...) sas_discover_domain(...) sas_discover_end_dev(...) sas_rphy_add(...) scsi_scan_target(...) - : send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html