Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbdFNJau (ORCPT ); Wed, 14 Jun 2017 05:30:50 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2091 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbdFNJan (ORCPT ); Wed, 14 Jun 2017 05:30:43 -0400 Subject: Re: [PATCH v2 1/2] libsas: Don't process sas events in static works To: Johannes Thumshirn , , References: <1497425597-18799-1-git-send-email-wangyijing@huawei.com> <1497425597-18799-2-git-send-email-wangyijing@huawei.com> <692abe7a-149f-c1bf-5f28-3e36cad81b5a@suse.de> <5940FC1C.5050000@huawei.com> <3c713ab7-c958-ab1a-0a12-cdd5e876e845@suse.de> CC: , , , , , , , , , , , , , , , , , , Yousong He From: wangyijing Message-ID: <594101C2.702@huawei.com> Date: Wed, 14 Jun 2017 17:28:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <3c713ab7-c958-ab1a-0a12-cdd5e876e845@suse.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.23.4] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5941022F.00B8,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 44e9d02d2b32190fd9afdce34db3f83a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2831 Lines: 77 在 2017/6/14 17:18, Johannes Thumshirn 写道: > On 06/14/2017 11:04 AM, wangyijing wrote: >>>> static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event) >>>> { >>>> + struct sas_ha_event *ev; >>>> + >>>> BUG_ON(event >= HA_NUM_EVENTS); >>>> >>>> - sas_queue_event(event, &sas_ha->pending, >>>> - &sas_ha->ha_events[event].work, sas_ha); >>>> + ev = kzalloc(sizeof(*ev), GFP_ATOMIC); >>>> + if (!ev) >>>> + return; >>> GFP_ATOMIC allocations can fail and then no events will be queued *and* we >>> don't report the error back to the caller. >>> >> >> Yes, it's really a problem, but I don't find a better solution, do you have some suggestion ? > > Something like this? > > diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c > b/drivers/scsi/hisi_sas/hisi_sas_main.c > index d622db502ec9..27cd7307d308 100644 > --- a/drivers/scsi/hisi_sas/hisi_sas_main.c > +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c > @@ -894,7 +894,11 @@ static int hisi_sas_controller_reset(struct > hisi_hba *hisi_hba) > hisi_sas_release_tasks(hisi_hba); > spin_unlock_irqrestore(&hisi_hba->lock, flags); > > - sas_ha->notify_ha_event(sas_ha, HAE_RESET); > + rc = sas_ha->notify_ha_event(sas_ha, HAE_RESET); > + if (rc) { > + dev_warn(dev, "failed to queue HA event (%d)\n", > rc); > + goto out; > + } > dev_dbg(dev, "controller reset successful!\n"); > } else > return -1; > diff --git a/drivers/scsi/libsas/sas_event.c > b/drivers/scsi/libsas/sas_event.c > index aadbd5314c5c..6c91fb31f891 100644 > --- a/drivers/scsi/libsas/sas_event.c > +++ b/drivers/scsi/libsas/sas_event.c > @@ -116,7 +116,7 @@ void sas_enable_revalidation(struct sas_ha_struct *ha) > mutex_unlock(&ha->disco_mutex); > } > > -static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event > event) > +static int notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event > event) > { > BUG_ON(event >= HA_NUM_EVENTS); > > diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h > index dd0f72c95abe..5d9cd6d20855 100644 > --- a/include/scsi/libsas.h > +++ b/include/scsi/libsas.h > @@ -415,7 +415,7 @@ struct sas_ha_struct { > * their siblings when forming wide ports */ > > /* LLDD calls these to notify the class of an event. */ > - void (*notify_ha_event)(struct sas_ha_struct *, enum ha_event); > + int (*notify_ha_event)(struct sas_ha_struct *, enum ha_event); > void (*notify_port_event)(struct asd_sas_phy *, enum port_event); > void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); This make sense, return a fail status and report it to the callers. > >