Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2502164pxb; Mon, 18 Jan 2021 21:23:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv1Tzq9u3ayNqRCGFQj0GJRoYM8rICJS+raxT0UD2PQRyCvvqkCpvc54j17vYAhd8s/LAs X-Received: by 2002:a17:907:3fa6:: with SMTP id hr38mr1942606ejc.24.1611033780365; Mon, 18 Jan 2021 21:23:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611033780; cv=none; d=google.com; s=arc-20160816; b=JVRgFa5XTLhzbJM8DB0l82kHvts56kumBRD+V2t/TU3lgZqHVoZ45igDFasyu/lHuJ d6PGUZ5GUOg19FA70BaRzXcTS7j+hLIjqPsbuf2Rkllqly9hFAIaT6rAgNvHz8vvYQzQ RLDfTK6fe4pYtknRvrXcfBwIE/nQUpiNS+5q9JD560+L5LaEulOP1jlMUESMBe5iKb5g UOXE6k2bCTFWQIH/YiscB/4lRQgTfvCw5xdRRwPbkQqCOPP2SAcYP67gFVyWvp0OPFei 3JBEpkxk03sSYVlBG/7Fy8oAUgZhNan9g5aE/8qi6r7NhpQ8OiYX36KEL2nuddSEPuZd oOpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=xTiNsIBa59THcsevJRE+EeFn5TKH8F5bbL95uC706VA=; b=NmJs0g2/rRdu2TZk7IfrSHNIoCSxU5wMLLitz0MB6XMsBS/Xji+kiLSGwyvXaU01uA 0jEz+aKOAvUQvOSquH3qyWFWKZJpFoqww1mNVgROVPn0cYYawGjuegxEay7XnSwSk/W7 wyFev3GKDL5+o/Mdybg4Y7SY1F/p7m+gM4eWfB9Lcf5t/hLQFkjYEnBMl+V6m5KN4FI1 CQvpRPTN3nkhns9xAuhFltmAuwdBmYpFKRKH9863+7aBMILabfkzHJ++TrmudyVGF7aV gyESNXmzaJqUFUWxNVDqDq5smXF6fJQCwIlvxltznYHTQEcfn0PICkDo93m2ATdFkDF0 NYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ka1t3IR8; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gl11si3252276ejb.382.2021.01.18.21.22.35; Mon, 18 Jan 2021 21:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ka1t3IR8; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394536AbhARVNa (ORCPT + 99 others); Mon, 18 Jan 2021 16:13:30 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55212 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389745AbhARKN3 (ORCPT ); Mon, 18 Jan 2021 05:13:29 -0500 From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1610964665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xTiNsIBa59THcsevJRE+EeFn5TKH8F5bbL95uC706VA=; b=ka1t3IR86Q+9e2uN+9+j13J1LdMnq89Zvppoq+Zl/6r7n9KT1qO4DKNd819mNFKLfYM+aE hrLesJUrQ+tA3rpgTRc82+VK5kp7DJFxuk49Ejqw31EQxfUi7Ku5lPCUaOKKzA6iOLJqpR NHKZscIxzIEVBSuUKc+ttMeKCz28MSxNcsda/Zsq3iTc9N6MNi521ivHrVeL62Skz1cnZ/ vWswQP5r6oXEoNHe4oujx2Y7Zx8wVMaInX+0IVmCoc2i7QkHJ8NOjVBwf7oeeNn3GE7CnG FdbzRlNHb97NNoPy0zFj5oOMnheSZz11gxdpqc8nlODbvaCUj4o1hQN5yUtVZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1610964665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xTiNsIBa59THcsevJRE+EeFn5TKH8F5bbL95uC706VA=; b=W6R5b8bJ9oT5kC2wqiGwDm7TsvE9HMtXqz4qlRRfBsez/E4RDQERKePEnINBhTs/5GgWJo ObTFszyjZIaK1BDA== To: "James E.J. Bottomley" , "Martin K. Petersen" , Christoph Hellwig , John Garry , Jason Yan , Daniel Wagner , Artur Paszkiewicz , Jack Wang Cc: linux-scsi@vger.kernel.org, LKML , Thomas Gleixner , "Sebastian A. Siewior" , "Ahmed S. Darwish" Subject: [PATCH v3 12/19] scsi: libsas: event notifiers API: Add gfp_t flags parameter Date: Mon, 18 Jan 2021 11:09:48 +0100 Message-Id: <20210118100955.1761652-13-a.darwish@linutronix.de> In-Reply-To: <20210118100955.1761652-1-a.darwish@linutronix.de> References: <20210118100955.1761652-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All call-sites of below libsas APIs: - sas_alloc_event() - sas_notify_port_event() - sas_notify_phy_event() have been converted to use the _gfp()-suffixed version. Modify the original APIs above to take a gfp_t flags parameter by default. For bisectability, call-sites will be modified again to use the original libsas APIs (while passing gfp_t). The temporary _gfp()-suffixed versions can then be removed. Signed-off-by: Ahmed S. Darwish Reviewed-by: John Garry Cc: Jason Yan --- Documentation/scsi/libsas.rst | 4 +- drivers/scsi/libsas/sas_event.c | 62 +++++++++--------------------- drivers/scsi/libsas/sas_init.c | 12 ++---- drivers/scsi/libsas/sas_internal.h | 5 ++- include/scsi/libsas.h | 6 ++- 5 files changed, 31 insertions(+), 58 deletions(-) diff --git a/Documentation/scsi/libsas.rst b/Documentation/scsi/libsas.rst index ea63ab3a9216..c65086470a15 100644 --- a/Documentation/scsi/libsas.rst +++ b/Documentation/scsi/libsas.rst @@ -189,8 +189,8 @@ num_phys The event interface:: /* LLDD calls these to notify the class of an event. */ - void sas_notify_port_event(struct sas_phy *, enum port_event); - void sas_notify_phy_event(struct sas_phy *, enum phy_event); + void sas_notify_port_event(struct sas_phy *, enum port_event, gfp_t); + void sas_notify_phy_event(struct sas_phy *, enum phy_event, gfp_t); void sas_notify_port_event_gfp(struct sas_phy *, enum port_event, gfp_t); void sas_notify_phy_event_gfp(struct sas_phy *, enum phy_event, gfp_t); diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c index 25f3aaea8142..3d0cc407b33f 100644 --- a/drivers/scsi/libsas/sas_event.c +++ b/drivers/scsi/libsas/sas_event.c @@ -132,15 +132,19 @@ static void sas_phy_event_worker(struct work_struct *work) sas_free_event(ev); } -static int __sas_notify_port_event(struct asd_sas_phy *phy, - enum port_event event, - struct asd_sas_event *ev) +int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, + gfp_t gfp_flags) { struct sas_ha_struct *ha = phy->ha; + struct asd_sas_event *ev; int ret; BUG_ON(event >= PORT_NUM_EVENTS); + ev = sas_alloc_event_gfp(phy, gfp_flags); + if (!ev) + return -ENOMEM; + INIT_SAS_EVENT(ev, sas_port_event_worker, phy, event); ret = sas_queue_event(event, &ev->work, ha); @@ -149,41 +153,28 @@ static int __sas_notify_port_event(struct asd_sas_phy *phy, return ret; } +EXPORT_SYMBOL_GPL(sas_notify_port_event); int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event, gfp_t gfp_flags) { - struct asd_sas_event *ev; - - ev = sas_alloc_event_gfp(phy, gfp_flags); - if (!ev) - return -ENOMEM; - - return __sas_notify_port_event(phy, event, ev); + return sas_notify_port_event(phy, event, gfp_flags); } EXPORT_SYMBOL_GPL(sas_notify_port_event_gfp); -int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event) -{ - struct asd_sas_event *ev; - - ev = sas_alloc_event(phy); - if (!ev) - return -ENOMEM; - - return __sas_notify_port_event(phy, event, ev); -} -EXPORT_SYMBOL_GPL(sas_notify_port_event); - -static inline int __sas_notify_phy_event(struct asd_sas_phy *phy, - enum phy_event event, - struct asd_sas_event *ev) +int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, + gfp_t gfp_flags) { struct sas_ha_struct *ha = phy->ha; + struct asd_sas_event *ev; int ret; BUG_ON(event >= PHY_NUM_EVENTS); + ev = sas_alloc_event_gfp(phy, gfp_flags); + if (!ev) + return -ENOMEM; + INIT_SAS_EVENT(ev, sas_phy_event_worker, phy, event); ret = sas_queue_event(event, &ev->work, ha); @@ -192,28 +183,11 @@ static inline int __sas_notify_phy_event(struct asd_sas_phy *phy, return ret; } +EXPORT_SYMBOL_GPL(sas_notify_phy_event); int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event, gfp_t gfp_flags) { - struct asd_sas_event *ev; - - ev = sas_alloc_event_gfp(phy, gfp_flags); - if (!ev) - return -ENOMEM; - - return __sas_notify_phy_event(phy, event, ev); + return sas_notify_phy_event(phy, event, gfp_flags); } EXPORT_SYMBOL_GPL(sas_notify_phy_event_gfp); - -int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event) -{ - struct asd_sas_event *ev; - - ev = sas_alloc_event(phy); - if (!ev) - return -ENOMEM; - - return __sas_notify_phy_event(phy, event, ev); -} -EXPORT_SYMBOL_GPL(sas_notify_phy_event); diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 9ce0cd214eb9..f06b83211e3b 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -585,8 +585,8 @@ sas_domain_attach_transport(struct sas_domain_function_template *dft) } EXPORT_SYMBOL_GPL(sas_domain_attach_transport); -static struct asd_sas_event *__sas_alloc_event(struct asd_sas_phy *phy, - gfp_t gfp_flags) +struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy, + gfp_t gfp_flags) { struct asd_sas_event *event; struct sas_ha_struct *sas_ha = phy->ha; @@ -619,15 +619,11 @@ static struct asd_sas_event *__sas_alloc_event(struct asd_sas_phy *phy, return event; } -struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy) -{ - return __sas_alloc_event(phy, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -} - struct asd_sas_event *sas_alloc_event_gfp(struct asd_sas_phy *phy, gfp_t gfp_flags) { - return __sas_alloc_event(phy, gfp_flags); + + return sas_alloc_event(phy, gfp_flags); } void sas_free_event(struct asd_sas_event *event) diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index 52e09c3e2b50..294cdcb4ce42 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -48,7 +48,7 @@ int sas_show_oob_mode(enum sas_oob_mode oob_mode, char *buf); int sas_register_phys(struct sas_ha_struct *sas_ha); void sas_unregister_phys(struct sas_ha_struct *sas_ha); -struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy); +struct asd_sas_event *sas_alloc_event(struct asd_sas_phy *phy, gfp_t gfp_flags); struct asd_sas_event *sas_alloc_event_gfp(struct asd_sas_phy *phy, gfp_t gfp_flags); void sas_free_event(struct asd_sas_event *event); @@ -78,7 +78,8 @@ int sas_smp_phy_control(struct domain_device *dev, int phy_id, enum phy_func phy_func, struct sas_phy_linkrates *); int sas_smp_get_phy_events(struct sas_phy *phy); -int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event); +int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, + gfp_t flags); int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event, gfp_t flags); void sas_device_set_phy(struct domain_device *dev, struct sas_port *port); diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index e6a43163ab5b..fda56e151695 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -702,8 +702,10 @@ struct sas_phy *sas_get_local_phy(struct domain_device *dev); int sas_request_addr(struct Scsi_Host *shost, u8 *addr); -int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event); -int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event); +int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, + gfp_t gfp_flags); +int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, + gfp_t gfp_flags); int sas_notify_port_event_gfp(struct asd_sas_phy *phy, enum port_event event, gfp_t gfp_flags); int sas_notify_phy_event_gfp(struct asd_sas_phy *phy, enum phy_event event, -- 2.30.0