aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas/sas_init.c
diff options
context:
space:
mode:
authorJason Yan <yanaijie@huawei.com>2017-12-08 04:42:04 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-01-08 21:59:28 -0500
commit1c393b970e0f4070e4376d45f89a2d19a5c895d0 (patch)
tree41706d1df454c4d020a6beaf335b30c27f5f4e20 /drivers/scsi/libsas/sas_init.c
parent6f5c592ce936b2a2f5d05d3112b550bb039050f2 (diff)
scsi: libsas: Use dynamic alloced work to avoid sas event lost
Now libsas hotplug work is static, every sas event type has its own static work, LLDD driver queues the hotplug work into shost->work_q. If LLDD driver burst posts lots hotplug events to libsas, the hotplug events may pending in the workqueue like shost->work_q new work[PORTE_BYTES_DMAED] --> |[PHYE_LOSS_OF_SIGNAL][PORTE_BYTES_DMAED] -> processing |<-------wait worker to process-------->| In this case, a new PORTE_BYTES_DMAED event coming, libsas try to queue it to shost->work_q, but this work is already pending, so it would be lost. Finally, libsas delete the related sas port and sas devices, but LLDD driver expect libsas add the sas port and devices(last sas event). This patch use dynamic allocated work to avoid this issue. Signed-off-by: Yijing Wang <wangyijing@huawei.com> CC: John Garry <john.garry@huawei.com> CC: Johannes Thumshirn <jthumshirn@suse.de> CC: Ewan Milne <emilne@redhat.com> CC: Christoph Hellwig <hch@lst.de> CC: Tomas Henzl <thenzl@redhat.com> CC: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jason Yan <yanaijie@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/libsas/sas_init.c')
-rw-r--r--drivers/scsi/libsas/sas_init.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 64fa6f53cb8b..e04f6d6f5aff 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -39,6 +39,7 @@
39#include "../scsi_sas_internal.h" 39#include "../scsi_sas_internal.h"
40 40
41static struct kmem_cache *sas_task_cache; 41static struct kmem_cache *sas_task_cache;
42static struct kmem_cache *sas_event_cache;
42 43
43struct sas_task *sas_alloc_task(gfp_t flags) 44struct sas_task *sas_alloc_task(gfp_t flags)
44{ 45{
@@ -364,8 +365,6 @@ void sas_prep_resume_ha(struct sas_ha_struct *ha)
364 struct asd_sas_phy *phy = ha->sas_phy[i]; 365 struct asd_sas_phy *phy = ha->sas_phy[i];
365 366
366 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 367 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
367 phy->port_events_pending = 0;
368 phy->phy_events_pending = 0;
369 phy->frame_rcvd_size = 0; 368 phy->frame_rcvd_size = 0;
370 } 369 }
371} 370}
@@ -555,20 +554,42 @@ sas_domain_attach_transport(struct sas_domain_function_template *dft)
555} 554}
556EXPORT_SYMBOL_GPL(sas_domain_attach_transport); 555EXPORT_SYMBOL_GPL(sas_domain_attach_transport);
557 556
557
558struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy)
559{
560 gfp_t flags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
561
562 return kmem_cache_zalloc(sas_event_cache, flags);
563}
564
565void sas_free_event(struct asd_sas_event *event)
566{
567 kmem_cache_free(sas_event_cache, event);
568}
569
558/* ---------- SAS Class register/unregister ---------- */ 570/* ---------- SAS Class register/unregister ---------- */
559 571
560static int __init sas_class_init(void) 572static int __init sas_class_init(void)
561{ 573{
562 sas_task_cache = KMEM_CACHE(sas_task, SLAB_HWCACHE_ALIGN); 574 sas_task_cache = KMEM_CACHE(sas_task, SLAB_HWCACHE_ALIGN);
563 if (!sas_task_cache) 575 if (!sas_task_cache)
564 return -ENOMEM; 576 goto out;
577
578 sas_event_cache = KMEM_CACHE(asd_sas_event, SLAB_HWCACHE_ALIGN);
579 if (!sas_event_cache)
580 goto free_task_kmem;
565 581
566 return 0; 582 return 0;
583free_task_kmem:
584 kmem_cache_destroy(sas_task_cache);
585out:
586 return -ENOMEM;
567} 587}
568 588
569static void __exit sas_class_exit(void) 589static void __exit sas_class_exit(void)
570{ 590{
571 kmem_cache_destroy(sas_task_cache); 591 kmem_cache_destroy(sas_task_cache);
592 kmem_cache_destroy(sas_event_cache);
572} 593}
573 594
574MODULE_AUTHOR("Luben Tuikov <luben_tuikov@adaptec.com>"); 595MODULE_AUTHOR("Luben Tuikov <luben_tuikov@adaptec.com>");