linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "chenxiang (M)" <chenxiang66@hisilicon.com>
To: John Garry <john.garry@huawei.com>, <jejb@linux.ibm.com>,
	<martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <linuxarm@huawei.com>
Subject: Re: [PATCH 11/15] scsi: libsas: Refactor out sas_queue_deferred_work()
Date: Wed, 15 Dec 2021 15:59:21 +0800	[thread overview]
Message-ID: <148b57c3-6c24-aae7-e5c9-b4aee7509cdf@hisilicon.com> (raw)
In-Reply-To: <29a7ccb2-9b25-5da7-2a3e-609718593ecd@huawei.com>



在 2021/12/13 19:20, John Garry 写道:
> Please consider these:
>
> On 17/11/2021 02:45, chenxiang wrote:
>
> I'd have "scsi: libsas: Refactor sas_queue_deferred_work()"

Ok, i will change it.

>
>> From: Xiang Chen <chenxiang66@hisilicon.com>
>>
>> In the 2rd part of function __sas_drain_work, it queues defer work. 
>> And it
>> will be used in other places, so refactor out sas_queue_deferred_work().
>
> The second part of the function __sas_drain_work() queues the deferred 
> work. This functionality would be duplicated in other places, so 
> factor out into sas_queue_deferred_work().

I will rewrite them in next verison.

>
> Thanks,
> John
>
>>
>> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
>> Reviewed-by: John Garry <john.garry@huawei.com>
>> ---
>>   drivers/scsi/libsas/sas_event.c    | 25 ++++++++++++++-----------
>>   drivers/scsi/libsas/sas_internal.h |  1 +
>>   2 files changed, 15 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/scsi/libsas/sas_event.c 
>> b/drivers/scsi/libsas/sas_event.c
>> index af605620ea13..01e544ca518a 100644
>> --- a/drivers/scsi/libsas/sas_event.c
>> +++ b/drivers/scsi/libsas/sas_event.c
>> @@ -41,12 +41,23 @@ static int sas_queue_event(int event, struct 
>> sas_work *work,
>>       return rc;
>>   }
>>   -
>> -void __sas_drain_work(struct sas_ha_struct *ha)
>> +void sas_queue_deferred_work(struct sas_ha_struct *ha)
>>   {
>>       struct sas_work *sw, *_sw;
>>       int ret;
>>   +    spin_lock_irq(&ha->lock);
>> +    list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
>> +        list_del_init(&sw->drain_node);
>> +        ret = sas_queue_work(ha, sw);
>> +        if (ret != 1)
>> +            sas_free_event(to_asd_sas_event(&sw->work));
>> +    }
>> +    spin_unlock_irq(&ha->lock);
>> +}
>> +
>> +void __sas_drain_work(struct sas_ha_struct *ha)
>> +{
>>       set_bit(SAS_HA_DRAINING, &ha->state);
>>       /* flush submitters */
>>       spin_lock_irq(&ha->lock);
>> @@ -55,16 +66,8 @@ void __sas_drain_work(struct sas_ha_struct *ha)
>>       drain_workqueue(ha->event_q);
>>       drain_workqueue(ha->disco_q);
>>   -    spin_lock_irq(&ha->lock);
>>       clear_bit(SAS_HA_DRAINING, &ha->state);
>> -    list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
>> -        list_del_init(&sw->drain_node);
>> -        ret = sas_queue_work(ha, sw);
>> -        if (ret != 1)
>> -            sas_free_event(to_asd_sas_event(&sw->work));
>> -
>> -    }
>> -    spin_unlock_irq(&ha->lock);
>> +    sas_queue_deferred_work(ha);
>>   }
>>     int sas_drain_work(struct sas_ha_struct *ha)
>> diff --git a/drivers/scsi/libsas/sas_internal.h 
>> b/drivers/scsi/libsas/sas_internal.h
>> index ad9764a976c3..acd515c01861 100644
>> --- a/drivers/scsi/libsas/sas_internal.h
>> +++ b/drivers/scsi/libsas/sas_internal.h
>> @@ -57,6 +57,7 @@ void sas_unregister_ports(struct sas_ha_struct 
>> *sas_ha);
>>     void sas_disable_revalidation(struct sas_ha_struct *ha);
>>   void sas_enable_revalidation(struct sas_ha_struct *ha);
>> +void sas_queue_deferred_work(struct sas_ha_struct *ha);
>>   void __sas_drain_work(struct sas_ha_struct *ha);
>>     void sas_deform_port(struct asd_sas_phy *phy, int gone);
>>
>
>
> .
>



  reply	other threads:[~2021-12-15  7:59 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  2:44 [PATCH 00/15] Add runtime PM support for libsas chenxiang
2021-11-17  2:44 ` [PATCH 01/15] libsas: Don't always drain event workqueue for HA resume chenxiang
2021-11-17  4:14   ` Bart Van Assche
2021-11-17  5:06     ` Bart Van Assche
2021-11-17  2:44 ` [PATCH 02/15] Revert "scsi: hisi_sas: Filter out new PHY up events during suspend" chenxiang
2021-12-13 10:31   ` John Garry
2021-12-15  7:20     ` chenxiang (M)
2021-11-17  2:44 ` [PATCH 03/15] scsi/block PM: Always set request queue runtime active in blk_post_runtime_resume() chenxiang
2021-11-17  4:58   ` Bart Van Assche
2021-11-17  2:44 ` [PATCH 04/15] scsi: libsas: Add spin_lock/unlock() to protect asd_sas_port->phy_list chenxiang
2021-11-17  2:44 ` [PATCH 05/15] scsi: hisi_sas: Fix some issues related to asd_sas_port->phy_list chenxiang
2021-11-17  2:44 ` [PATCH 06/15] scsi: mvsas: Add spin_lock/unlock() to protect asd_sas_port->phy_list chenxiang
2021-11-17  2:45 ` [PATCH 07/15] scsi: libsas: Send event PORTE_BROADCAST_RCVD for valid ports chenxiang
2021-12-13 11:02   ` John Garry
2021-12-15  7:25     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 08/15] scsi: hisi_sas: Add more prink for runtime suspend/resume chenxiang
2021-12-13 10:34   ` John Garry
2021-12-15  7:26     ` chenxiang (M)
2021-12-13 10:35   ` John Garry
2021-12-15  7:26     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 09/15] scsi: libsas: Resume sas host before sending SMP IOs chenxiang
2021-12-13 11:12   ` John Garry
2021-12-15  8:00     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 10/15] scsi: libsas: Add a flag SAS_HA_RESUMING of sas_ha chenxiang
2021-12-13 11:17   ` John Garry
2021-12-15  7:34     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 11/15] scsi: libsas: Refactor out sas_queue_deferred_work() chenxiang
2021-12-13 11:20   ` John Garry
2021-12-15  7:59     ` chenxiang (M) [this message]
2021-11-17  2:45 ` [PATCH 12/15] scsi: libsas: Defer works of new phys during suspend chenxiang
2021-11-17  2:45 ` [PATCH 13/15] scsi: hisi_sas: Keep controller active between ISR of phyup and the event being processed chenxiang
2021-12-13 10:44   ` John Garry
2021-12-15  7:57     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 14/15] scsi: libsas: Keep sas host active until finished some work chenxiang
2021-12-14 12:34   ` John Garry
2021-12-15  7:46     ` chenxiang (M)
2021-11-17  2:45 ` [PATCH 15/15] scsi: hisi_sas: Use autosuspend for SAS controller chenxiang
2021-12-13 10:50   ` John Garry
2021-12-15  7:52     ` chenxiang (M)
2021-11-19  4:04 ` [PATCH 00/15] Add runtime PM support for libsas Martin K. Petersen
2021-11-23  6:01   ` chenxiang (M)
2021-12-14 11:52 ` John Garry
2021-12-15  7:56   ` chenxiang (M)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=148b57c3-6c24-aae7-e5c9-b4aee7509cdf@hisilicon.com \
    --to=chenxiang66@hisilicon.com \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).