From patchwork Wed Jun 14 09:18:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 9785879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E74F602C9 for ; Wed, 14 Jun 2017 09:21:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0052428741 for ; Wed, 14 Jun 2017 09:21:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F25FB2873A; Wed, 14 Jun 2017 09:21:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F8A2879A for ; Wed, 14 Jun 2017 09:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbdFNJTr (ORCPT ); Wed, 14 Jun 2017 05:19:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:46466 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751884AbdFNJTB (ORCPT ); Wed, 14 Jun 2017 05:19:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0E19DACCE; Wed, 14 Jun 2017 09:18:58 +0000 (UTC) Subject: Re: [PATCH v2 1/2] libsas: Don't process sas events in static works To: wangyijing , jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: chenqilin2@huawei.com, hare@suse.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, chenxiang66@hisilicon.com, huangdaode@hisilicon.com, wangkefeng.wang@huawei.com, zhaohongjiang@huawei.com, dingtianhong@huawei.com, guohanjun@huawei.com, yanaijie@huawei.com, hch@lst.de, dan.j.williams@intel.com, emilne@redhat.com, thenzl@redhat.com, wefu@redhat.com, charles.chenxin@huawei.com, chenweilong@huawei.com, Yousong He 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> From: Johannes Thumshirn Message-ID: <3c713ab7-c958-ab1a-0a12-cdd5e876e845@suse.de> Date: Wed, 14 Jun 2017 11:18:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <5940FC1C.5050000@huawei.com> Content-Language: en-US Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);