From patchwork Mon May 30 23:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12864999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996E1C433EF for ; Mon, 30 May 2022 23:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242826AbiE3XPk (ORCPT ); Mon, 30 May 2022 19:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233798AbiE3XPj (ORCPT ); Mon, 30 May 2022 19:15:39 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB94712FA for ; Mon, 30 May 2022 16:15:37 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6C739811AD; Mon, 30 May 2022 23:15:36 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 036D380F3B; Mon, 30 May 2022 23:15:36 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952536; a=rsa-sha256; cv=none; b=It8KsC59iNnDYcaDCFv10wEeH76+nt7+cURuYKffLQi83H7HxC21B8CO77WgellhHECNmR oZWD9AAJ/L2m7jCqa+eV2ZvpiZaVP9iy4XguKNo9nAgVE0rX1ofaWSfXz3FijHiE1JZWxn pUMhphUrlCrmmfBIAyfSFd7jrjRmfgnz+KOH4PHmZ/TuoSGhLh5gUSRd+/1YXrx18YR2Zk oOfkc795rauvSREg+oDaTj7VNKRxFSfkuTm8mJ6SsYQjW8X/HSNAFR2XpOjywOCio8xZ1W G7HEKOdD8u868v5KggHLzxTPGPXqZ87H1VfRosdFp/AGGyhlm+LHE/Tv81qC0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952536; 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:dkim-signature; bh=Md0UglnLrm55xoVRMWppSTa3P+8k6XDCY738goMHV5Y=; b=sMVE0bdUumyBTqHEqIOWLsnFbK8izFNwsrfd8WCsPxROb8jgI2e3NDhsX3XcUmO9LIDXQZ 5xiXNZ4eXe9Bhv9EVGE+IqcZp9XuQiIiealrSpzKGbMbnBXQ0lPe/M5we9qsck3l4hXeHx qdBRxSHevtMbNbtV5R5WmtEpvyz56kmgi54FFY4yensfQkVfYf7Dkv+SZKxfwXmGHi8qSA KReC5/fWY9DFDT3XRJZgPmCTwlQ338gfGfudM63jTFQzYQFMgQ0TWaSW5x7hx3UD9NnOm0 lbFTEAja8LR4UEu9+ASWy5dT/JjvLn7jE6Tfx+8IElGfokHluAmZg0KpwM7rTw== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-n6vbx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Chief-Celery: 3fef4f62615d56c2_1653952536289_3632414120 X-MC-Loop-Signature: 1653952536289:2402954016 X-MC-Ingress-Time: 1653952536289 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.242.203 (trex/6.7.1); Mon, 30 May 2022 23:15:36 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqW2md9z2g; Mon, 30 May 2022 16:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952535; bh=Md0UglnLrm55xoVRMWppSTa3P+8k6XDCY738goMHV5Y=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=S7ptYqF471xXf0BTVRrDs4tBPOmLlel5kWhtNEQ88mDPXXO4OXAdJBHdyly+usN6p a+2jiNpot8770CGXWJyDz/S+MMixx6dxZG9tpgm/xGAGQYaIsxcvyPUxKGnpKZHni2 YmnavqgIn2NVxYhwRk1VdBvRXKX5qSJUhgjhKneEQ8e+Brpcyi7o8ZiyNGmFmiXc0I 3uzTyUc//tLu464VMrwr+m71YKLSFgVb7W94hZ6W1OmE7M9+bo3N4MeqnpXqGqRbfq hE8JjXaIt/7wLvMaTXqBFTF1en1qwE0wECRWW4gzAY5HTZLbgYFRgd6ewjVsfCqDNU vlkhC8YOZFZuA== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net Subject: [PATCH 01/10] scsi/mvsas: Kill CONFIG_SCSI_MVSAS_TASKLET Date: Mon, 30 May 2022 16:15:03 -0700 Message-Id: <20220530231512.9729-2-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead. As such remove CONFIG_SCSI_MVSAS_TASKLET (which is horrible to begin with) and continue to do the async work, unconditionally now, just in task context. Just as with the tasklet version, device interrupts (MVS_IRQ_SAS_A/B) continues to be disabled from when the work was putted until it is actually complete. Because there are no guarantees vs ksoftirqd, if this is broken for threaded irqs, then they are also broken for tasklets. Signed-off-by: Davidlohr Bueso Reviewed-by: John Garry --- drivers/scsi/mvsas/Kconfig | 7 ------ drivers/scsi/mvsas/mv_init.c | 44 ++++++------------------------------ drivers/scsi/mvsas/mv_sas.h | 1 - 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/drivers/scsi/mvsas/Kconfig b/drivers/scsi/mvsas/Kconfig index 79812b80743b..e9dd8dc84b1c 100644 --- a/drivers/scsi/mvsas/Kconfig +++ b/drivers/scsi/mvsas/Kconfig @@ -23,10 +23,3 @@ config SCSI_MVSAS_DEBUG help Compiles the 88SE64XX/88SE94XX driver in debug mode. In debug mode, the driver prints some messages to the console. -config SCSI_MVSAS_TASKLET - bool "Support for interrupt tasklet" - default n - depends on SCSI_MVSAS - help - Compiles the 88SE64xx/88SE94xx driver in interrupt tasklet mode.In this mode, - the interrupt will schedule a tasklet. diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 2fde496fff5f..f36b270ba502 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -146,12 +146,10 @@ static void mvs_free(struct mvs_info *mvi) kfree(mvi); } -#ifdef CONFIG_SCSI_MVSAS_TASKLET -static void mvs_tasklet(unsigned long opaque) +static irqreturn_t mvs_async(int irq, void *opaque) { u32 stat; u16 core_nr, i = 0; - struct mvs_info *mvi; struct sas_ha_struct *sha = (struct sas_ha_struct *)opaque; @@ -172,46 +170,29 @@ static void mvs_tasklet(unsigned long opaque) out: MVS_CHIP_DISP->interrupt_enable(mvi); + return IRQ_HANDLED; } -#endif static irqreturn_t mvs_interrupt(int irq, void *opaque) { u32 stat; struct mvs_info *mvi; struct sas_ha_struct *sha = opaque; -#ifndef CONFIG_SCSI_MVSAS_TASKLET - u32 i; - u32 core_nr; - - core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; -#endif mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; if (unlikely(!mvi)) return IRQ_NONE; -#ifdef CONFIG_SCSI_MVSAS_TASKLET + MVS_CHIP_DISP->interrupt_disable(mvi); -#endif stat = MVS_CHIP_DISP->isr_status(mvi, irq); if (!stat) { - #ifdef CONFIG_SCSI_MVSAS_TASKLET MVS_CHIP_DISP->interrupt_enable(mvi); - #endif return IRQ_NONE; } -#ifdef CONFIG_SCSI_MVSAS_TASKLET - tasklet_schedule(&((struct mvs_prv_info *)sha->lldd_ha)->mv_tasklet); -#else - for (i = 0; i < core_nr; i++) { - mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[i]; - MVS_CHIP_DISP->isr(mvi, irq, stat); - } -#endif - return IRQ_HANDLED; + return IRQ_WAKE_THREAD; } static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) @@ -557,14 +538,6 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent) } nhost++; } while (nhost < chip->n_host); -#ifdef CONFIG_SCSI_MVSAS_TASKLET - { - struct mvs_prv_info *mpi = SHOST_TO_SAS_HA(shost)->lldd_ha; - - tasklet_init(&(mpi->mv_tasklet), mvs_tasklet, - (unsigned long)SHOST_TO_SAS_HA(shost)); - } -#endif mvs_post_sas_ha_init(shost, chip); @@ -575,8 +548,9 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent) rc = sas_register_ha(SHOST_TO_SAS_HA(shost)); if (rc) goto err_out_shost; - rc = request_irq(pdev->irq, irq_handler, IRQF_SHARED, - DRV_NAME, SHOST_TO_SAS_HA(shost)); + rc = request_threaded_irq(pdev->irq, irq_handler, mvs_async, + IRQF_SHARED, DRV_NAME, + SHOST_TO_SAS_HA(shost)); if (rc) goto err_not_sas; @@ -607,10 +581,6 @@ static void mvs_pci_remove(struct pci_dev *pdev) core_nr = ((struct mvs_prv_info *)sha->lldd_ha)->n_host; mvi = ((struct mvs_prv_info *)sha->lldd_ha)->mvi[0]; -#ifdef CONFIG_SCSI_MVSAS_TASKLET - tasklet_kill(&((struct mvs_prv_info *)sha->lldd_ha)->mv_tasklet); -#endif - sas_unregister_ha(sha); sas_remove_host(mvi->shost); diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h index 509d8f32a04f..a0e87fdab98a 100644 --- a/drivers/scsi/mvsas/mv_sas.h +++ b/drivers/scsi/mvsas/mv_sas.h @@ -403,7 +403,6 @@ struct mvs_prv_info{ u8 scan_finished; u8 reserve; struct mvs_info *mvi[2]; - struct tasklet_struct mv_tasklet; }; struct mvs_wq { From patchwork Mon May 30 23:15:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB6FDC433EF for ; Mon, 30 May 2022 23:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242889AbiE3XPm (ORCPT ); Mon, 30 May 2022 19:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242787AbiE3XPk (ORCPT ); Mon, 30 May 2022 19:15:40 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC70719C4 for ; Mon, 30 May 2022 16:15:38 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 678BBC0ADB; Mon, 30 May 2022 23:15:37 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D6CABC0249; Mon, 30 May 2022 23:15:36 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952537; a=rsa-sha256; cv=none; b=H//RckYQq5UvXkhrkV7LTsKfLc1HzdOuB9WkbQBpWd7o2gu2D3mpvkVMFoEImwq+CYPM0R DEL0jbpWwW1rwFW3TneQsl6IlXrMeiN8/gMPAXa8bYAxzOcCYHS+gEVtYCwtKr0SRgxplr m3hwzC946osLsv4E48l8IbyZGusZJKE2U3jHdTTG9dymrvRVvKo7aeXAd7OKPZpXmyFzPA DjMYmysnrz+6NBScYiXtsNb90FAy9L89uK0X2aKRMyR7APfBrOyZIS2xr45W4VaWYwuYZF 0VmbIC9b7sAcnjUkGA6ekdsqf/mgJ9zXrsBELzIq1XXi+goZ8BPsKX1koDT7uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952537; 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:dkim-signature; bh=gjWDDeJAYGuSQUYvY7rPie1Lt934CZzCvlxupbtLAfA=; b=qqr3yfYZuX95TNt+2ENFYdFCtVhjH5NrRcQCw0qYeJeEFqIUIiGXE4QawWDpXJ17MG8uW8 1Xup9ZMPkzbXjYE00ggQ2Eky0SIR2EB2jq2Twps3IObhSECptVULLJkEd+yJUffC0XVH/4 hq5X53ECKw7+y9t5A6Whhn3+EEMbK9oxXGqN+1N0JYX/b9SzXSDkCRpAANEGB3yD00Newz se6m06kMgkOHGHm8EUm2mF498A4hSgTj3YzsEOWKheQkohC/i4j628kcddtlpfxBU/NI6l EekO4U915razx7kuBOVzPwrTg8unxjNwyUb8Lz8h+yoFooY6G3n4/5MBjCFU1w== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-n6vbx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Madly-Absorbed: 1fec91ef01aa13f4_1653952537221_3194783024 X-MC-Loop-Signature: 1653952537221:1767497567 X-MC-Ingress-Time: 1653952537221 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.255.183 (trex/6.7.1); Mon, 30 May 2022 23:15:37 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqW705qz4C; Mon, 30 May 2022 16:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952536; bh=gjWDDeJAYGuSQUYvY7rPie1Lt934CZzCvlxupbtLAfA=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=W7QbRHPQS4mzzdzqlvLqNAEmNu781pDRkfjRI0Qytg1lXRl06WeMopPV/51+Beai3 cEcUJ19s/Gj+b4REGeB0WS8y1DXDpNov7MY12yEYe4nr27WonFPO/GNdeCFdrQ8qG3 YN1rW2pMcy4clHQ9MVl8XUOiimUmm1loCP6mivBEJP+aQXfrQqni6w6WBHsFm018KC 6xoEti13disQYV5cbRlIHq1X7s843cz3jtU5sqLHP/kAyG39Tf3EFWLtWrOcD5U1sP T+Oi9WjuDKlGiODWPw3bKIW5PrfyiCMcWNyTRnD4sWEWt9Ibubp04iEJYGn3sC/WPd 7e6LNmS9YQcyg== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Kashyap Desai , Sumit Saxena , Shivasharan S , megaraidlinux.pdl@broadcom.com Subject: [PATCH 02/10] scsi/megaraid: Replace adapter->dpc_h tasklet with threaded irq Date: Mon, 30 May 2022 16:15:04 -0700 Message-Id: <20220530231512.9729-3-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and do the ack sequence in task context. Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: megaraidlinux.pdl@broadcom.com Signed-off-by: Davidlohr Bueso --- drivers/scsi/megaraid/mega_common.h | 2 -- drivers/scsi/megaraid/megaraid_mbox.c | 52 ++++++++++----------------- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h index 2ad0aa2f837d..3e56f74061b4 100644 --- a/drivers/scsi/megaraid/mega_common.h +++ b/drivers/scsi/megaraid/mega_common.h @@ -95,7 +95,6 @@ typedef struct { /** * struct adapter_t - driver's initialization structure - * @aram dpc_h : tasklet handle * @pdev : pci configuration pointer for kernel * @host : pointer to host structure of mid-layer * @lock : synchronization lock for mid-layer and driver @@ -149,7 +148,6 @@ typedef struct { #define VERSION_SIZE 16 typedef struct { - struct tasklet_struct dpc_h; struct pci_dev *pdev; struct Scsi_Host *host; spinlock_t lock; diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 2a339d4a7e9d..b76f67887592 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -118,8 +118,7 @@ static void megaraid_mbox_prepare_epthru(adapter_t *, scb_t *, struct scsi_cmnd *); static irqreturn_t megaraid_isr(int, void *); - -static void megaraid_mbox_dpc(unsigned long); +static irqreturn_t megaraid_mbox_dpc(int, void *); static ssize_t megaraid_mbox_app_hndl_show(struct device *, struct device_attribute *attr, char *); static ssize_t megaraid_mbox_ld_show(struct device *, struct device_attribute *attr, char *); @@ -764,9 +763,8 @@ megaraid_init_mbox(adapter_t *adapter) */ /* request IRQ and register the interrupt service routine */ - if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid", - adapter)) { - + if (request_threaded_irq(adapter->irq, megaraid_isr, megaraid_mbox_dpc, + IRQF_SHARED, "megaraid", adapter)) { con_log(CL_ANN, (KERN_WARNING "megaraid: Couldn't register IRQ %d!\n", adapter->irq)); goto out_alloc_cmds; @@ -879,10 +877,6 @@ megaraid_init_mbox(adapter_t *adapter) } } - // setup tasklet for DPC - tasklet_init(&adapter->dpc_h, megaraid_mbox_dpc, - (unsigned long)adapter); - con_log(CL_DLEVEL1, (KERN_INFO "megaraid mbox hba successfully initialized\n")); @@ -917,8 +911,6 @@ megaraid_fini_mbox(adapter_t *adapter) // flush all caches megaraid_mbox_flush_cache(adapter); - tasklet_kill(&adapter->dpc_h); - megaraid_sysfs_free_resources(adapter); megaraid_free_cmd_packets(adapter); @@ -2027,7 +2019,7 @@ megaraid_mbox_prepare_epthru(adapter_t *adapter, scb_t *scb, * * Returns: 1 if the interrupt is valid, 0 otherwise */ -static int +static irqreturn_t megaraid_ack_sequence(adapter_t *adapter) { mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter); @@ -2036,7 +2028,7 @@ megaraid_ack_sequence(adapter_t *adapter) uint8_t nstatus; uint8_t completed[MBOX_MAX_FIRMWARE_STATUS]; struct list_head clist; - int handled; + int ret = IRQ_NONE; uint32_t dword; unsigned long flags; int i, j; @@ -2048,7 +2040,6 @@ megaraid_ack_sequence(adapter_t *adapter) INIT_LIST_HEAD(&clist); // loop till F/W has more commands for us to complete - handled = 0; spin_lock_irqsave(MAILBOX_LOCK(raid_dev), flags); do { /* @@ -2056,9 +2047,10 @@ megaraid_ack_sequence(adapter_t *adapter) * interrupt line low. */ dword = RDOUTDOOR(raid_dev); - if (dword != 0x10001234) break; + if (dword != 0x10001234) + break; - handled = 1; + ret = IRQ_WAKE_THREAD; WROUTDOOR(raid_dev, 0x10001234); @@ -2124,12 +2116,7 @@ megaraid_ack_sequence(adapter_t *adapter) spin_unlock_irqrestore(COMPLETED_LIST_LOCK(adapter), flags); - - // schedule the DPC if there is some work for it - if (handled) - tasklet_schedule(&adapter->dpc_h); - - return handled; + return ret; } @@ -2144,29 +2131,27 @@ static irqreturn_t megaraid_isr(int irq, void *devp) { adapter_t *adapter = devp; - int handled; + int ret; - handled = megaraid_ack_sequence(adapter); + ret = megaraid_ack_sequence(adapter); /* Loop through any pending requests */ if (!adapter->quiescent) { megaraid_mbox_runpendq(adapter, NULL); } - return IRQ_RETVAL(handled); + return ret; } /** - * megaraid_mbox_dpc - the tasklet to complete the commands from completed list - * @devp : pointer to HBA soft state + * megaraid_mbox_dpc - complete the commands from completed list * * Pick up the commands from the completed list and send back to the owners. * This is a reentrant function and does not assume any locks are held while - * it is being called. + * it is being called. Runs in process context. */ -static void -megaraid_mbox_dpc(unsigned long devp) +static irqreturn_t megaraid_mbox_dpc(int irq, void *devp) { adapter_t *adapter = (adapter_t *)devp; mraid_device_t *raid_dev; @@ -2188,7 +2173,8 @@ megaraid_mbox_dpc(unsigned long devp) uioc_t *kioc; - if (!adapter) return; + if (!adapter) + goto done; raid_dev = ADAP2RAIDDEV(adapter); @@ -2361,8 +2347,8 @@ megaraid_mbox_dpc(unsigned long devp) // send the scsi packet back to kernel scsi_done(scp); } - - return; +done: + return IRQ_HANDLED; } From patchwork Mon May 30 23:15:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC341C4332F for ; Mon, 30 May 2022 23:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242985AbiE3XPo (ORCPT ); Mon, 30 May 2022 19:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241288AbiE3XPk (ORCPT ); Mon, 30 May 2022 19:15:40 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C123719D6 for ; Mon, 30 May 2022 16:15:39 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B42815A1518; Mon, 30 May 2022 23:15:38 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E5F315A0DAC; Mon, 30 May 2022 23:15:37 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952538; a=rsa-sha256; cv=none; b=9QudtMIFBZ1WPKlRhCQcIC0vLXRroBpNRoh/JmRzUWOoNwfE7b+jHfipz8K7Ik9n3neDxa +ntzSCuHRUr7+u/OUvhqoIYBx2y5XlnYEdmhXOZub4DYrb7vkjc0my1W3OmRMKQBZrYEU1 fsGbG9+eODwVNAk2/2m1pwjeIuO3aFCXS2bnXVzT7jLZ/3w+K0V+LQ0p4IpoY4A73thb+G gWLEJnXK2bh2ImU2W75XhV+LUSSJmygog70mUtasfGkldtE8+hcqhrlJk93lNXPhidHGdh QZ0ZszzCjlNI9FYyM59JZiiNmUhHj+6Dr/oIB19AK7p7OWrgx+iNwQUvFq8Xug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952538; 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:dkim-signature; bh=p8DH74stFBo7CpSD7rNUh3UUX+QVa3hFJlyJeiZ5J+M=; b=WhAZ2CgafQVvQ2ABfWQ3su8GxBhCdD8IvIoMZMqRAYsG0t56odCgRjWVmVQiZLoNTQ784I Q71blF2M3TDklaaL56IeHqLJcLUD+hjszsKASk5SbDl34ucG7lW95+eEDga1r7bNqvWye5 RZFMHj3ikqrfjH3A9uNL5z1mjUtg5ASfX9zPNDcJa75qYXXRJvE3pbNL06mu7TV2DV4TvD bUQrEEARuLRo5R8LEmTfCHbjGfkcwElZQYbAfS3iJKUKc+T3x1ppwSk+bwICSgmWoy0R0n +x8j7m88+RQN1ySYn0nrF6SOE5H93/TVoKLGISZKodHJ2/PsJBF96rKYKZJ/Gg== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-qckb2; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Thoughtful-Dime: 510ca72b0838ae5f_1653952538283_514468687 X-MC-Loop-Signature: 1653952538283:266591513 X-MC-Ingress-Time: 1653952538283 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.115.45.17 (trex/6.7.1); Mon, 30 May 2022 23:15:38 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqX67RCz15; Mon, 30 May 2022 16:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952537; bh=p8DH74stFBo7CpSD7rNUh3UUX+QVa3hFJlyJeiZ5J+M=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=m1p1vDS+YOFOPpOXqw02UxWjPpBQNn3350FDvz1/pVlFDIh540ZYq//kcICj1j914 nCKIiiHRg3Z6+XsOyNF8y4PcnA9dSNoGrO6jEV8G2saBZ+dtiuWzqP3QSWzAPl8vsj IDzIem+h1ubH9/7eu3TFEQFwMKDpJxk8W+WsSxI/NZl8BDmDGMFRVBdoe44iwi5fdG 4IB4aEQtMIyKSLKfGjJ9l55pY5SfuV2tsoAgoUR/SwjTT+mTPEXSZzIt0/ywzftCNL iu/RJkFFMn5c6ZXzYZb0aydx2NHPq+gnRoEBanqrI54Rlom6z2pX9ntdjrk6akeNg9 79F87Lwc1aNdQ== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Kashyap Desai , Sumit Saxena , Shivasharan S , megaraidlinux.pdl@broadcom.com Subject: [PATCH 03/10] scsi/megaraid_sas: Replace instance->tasklet with threaded irq Date: Mon, 30 May 2022 16:15:05 -0700 Message-Id: <20220530231512.9729-4-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and deal with the command completion in task context. While tasklets do not run concurrently amongst themselves, the callback can compete vs megasas_wait_for_outstanding() so any races with threads will also be present with the async thread completing the command. Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S Cc: megaraidlinux.pdl@broadcom.com Signed-off-by: Davidlohr Bueso --- drivers/scsi/megaraid/megaraid_sas.h | 3 +- drivers/scsi/megaraid/megaraid_sas_base.c | 51 ++++++++++----------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 18 +++++--- 3 files changed, 37 insertions(+), 35 deletions(-) 2.36.1 diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 4919ea54b827..d119c02f0a9c 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -2387,7 +2387,6 @@ struct megasas_instance { atomic64_t high_iops_outstanding; struct megasas_instance_template *instancet; - struct tasklet_struct isr_tasklet; struct work_struct work_init; struct delayed_work fw_fault_work; struct workqueue_struct *fw_fault_work_q; @@ -2549,7 +2548,7 @@ struct megasas_instance_template { int (*check_reset)(struct megasas_instance *, \ struct megasas_register_set __iomem *); irqreturn_t (*service_isr)(int irq, void *devp); - void (*tasklet)(unsigned long); + irqreturn_t (*service_thr)(int irq, void *devp); u32 (*init_adapter)(struct megasas_instance *); u32 (*build_and_issue_cmd) (struct megasas_instance *, struct scsi_cmnd *); diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index c95360a3c186..24f31ebad877 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -229,12 +229,12 @@ static int megasas_adp_reset_gen2(struct megasas_instance *instance, struct megasas_register_set __iomem *reg_set); static irqreturn_t megasas_isr(int irq, void *devp); +static irqreturn_t megasas_complete_cmd_dpc_irq(int irq, void *devp); static u32 megasas_init_adapter_mfi(struct megasas_instance *instance); u32 megasas_build_and_issue_cmd(struct megasas_instance *instance, struct scsi_cmnd *scmd); -static void megasas_complete_cmd_dpc(unsigned long instance_addr); int wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, int seconds); @@ -615,7 +615,7 @@ static struct megasas_instance_template megasas_instance_template_xscale = { .adp_reset = megasas_adp_reset_xscale, .check_reset = megasas_check_reset_xscale, .service_isr = megasas_isr, - .tasklet = megasas_complete_cmd_dpc, + .service_thr = megasas_complete_cmd_dpc_irq, .init_adapter = megasas_init_adapter_mfi, .build_and_issue_cmd = megasas_build_and_issue_cmd, .issue_dcmd = megasas_issue_dcmd, @@ -754,7 +754,7 @@ static struct megasas_instance_template megasas_instance_template_ppc = { .adp_reset = megasas_adp_reset_xscale, .check_reset = megasas_check_reset_ppc, .service_isr = megasas_isr, - .tasklet = megasas_complete_cmd_dpc, + .service_thr = megasas_complete_cmd_dpc_irq, .init_adapter = megasas_init_adapter_mfi, .build_and_issue_cmd = megasas_build_and_issue_cmd, .issue_dcmd = megasas_issue_dcmd, @@ -895,7 +895,7 @@ static struct megasas_instance_template megasas_instance_template_skinny = { .adp_reset = megasas_adp_reset_gen2, .check_reset = megasas_check_reset_skinny, .service_isr = megasas_isr, - .tasklet = megasas_complete_cmd_dpc, + .service_thr = megasas_complete_cmd_dpc_irq, .init_adapter = megasas_init_adapter_mfi, .build_and_issue_cmd = megasas_build_and_issue_cmd, .issue_dcmd = megasas_issue_dcmd, @@ -1095,7 +1095,7 @@ static struct megasas_instance_template megasas_instance_template_gen2 = { .adp_reset = megasas_adp_reset_gen2, .check_reset = megasas_check_reset_gen2, .service_isr = megasas_isr, - .tasklet = megasas_complete_cmd_dpc, + .service_thr = megasas_complete_cmd_dpc_irq, .init_adapter = megasas_init_adapter_mfi, .build_and_issue_cmd = megasas_build_and_issue_cmd, .issue_dcmd = megasas_issue_dcmd, @@ -2268,19 +2268,16 @@ megasas_check_and_restore_queue_depth(struct megasas_instance *instance) } /** - * megasas_complete_cmd_dpc - Returns FW's controller structure - * @instance_addr: Address of adapter soft state + * megasas_complete_cmd_dpc - Completes command + * @instance: Adapter soft state instance * - * Tasklet to complete cmds */ -static void megasas_complete_cmd_dpc(unsigned long instance_addr) +static void megasas_complete_cmd_dpc(struct megasas_instance *instance) { u32 producer; u32 consumer; u32 context; struct megasas_cmd *cmd; - struct megasas_instance *instance = - (struct megasas_instance *)instance_addr; unsigned long flags; /* If we have already declared adapter dead, donot complete cmds */ @@ -2320,6 +2317,15 @@ static void megasas_complete_cmd_dpc(unsigned long instance_addr) megasas_check_and_restore_queue_depth(instance); } +/* Called from threaded IRQ, runs in task context. */ +static irqreturn_t megasas_complete_cmd_dpc_irq(int irq, void *devp) +{ + struct megasas_instance *instance = (struct megasas_instance *)devp; + + megasas_complete_cmd_dpc(instance); + return IRQ_HANDLED; +} + static void megasas_sriov_heartbeat_handler(struct timer_list *t); /** @@ -2825,7 +2831,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance) * Call cmd completion routine. Cmd to be * be completed directly without depending on isr. */ - megasas_complete_cmd_dpc((unsigned long)instance); + megasas_complete_cmd_dpc(instance); } msleep(1000); @@ -4078,8 +4084,7 @@ megasas_deplete_reply_queue(struct megasas_instance *instance, } } - tasklet_schedule(&instance->isr_tasklet); - return IRQ_HANDLED; + return IRQ_WAKE_THREAD; } /** @@ -5682,9 +5687,11 @@ megasas_setup_irqs_ioapic(struct megasas_instance *instance) instance->irq_context[0].MSIxIndex = 0; snprintf(instance->irq_context->name, MEGASAS_MSIX_NAME_LEN, "%s%u", "megasas", instance->host->host_no); - if (request_irq(pci_irq_vector(pdev, 0), - instance->instancet->service_isr, IRQF_SHARED, - instance->irq_context->name, &instance->irq_context[0])) { + if (request_threaded_irq(pci_irq_vector(pdev, 0), + instance->instancet->service_isr, + instance->instancet->service_thr, IRQF_SHARED, + instance->irq_context->name, + &instance->irq_context[0])) { dev_err(&instance->pdev->dev, "Failed to register IRQ from %s %d\n", __func__, __LINE__); @@ -6322,9 +6329,6 @@ static int megasas_init_fw(struct megasas_instance *instance) dev_info(&instance->pdev->dev, "RDPQ mode\t: (%s)\n", instance->is_rdpq ? "enabled" : "disabled"); - tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, - (unsigned long)instance); - /* * Below are default value for legacy Firmware. * non-fusion based controllers @@ -7771,8 +7775,6 @@ megasas_suspend(struct device *dev) instance->ev = NULL; } - tasklet_kill(&instance->isr_tasklet); - pci_set_drvdata(instance->pdev, instance); instance->instancet->disable_intr(instance); @@ -7879,9 +7881,6 @@ megasas_resume(struct device *dev) if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS) goto fail_init_mfi; - tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, - (unsigned long)instance); - if (instance->msix_vectors ? megasas_setup_irqs_msix(instance, 0) : megasas_setup_irqs_ioapic(instance)) @@ -8011,8 +8010,6 @@ static void megasas_detach_one(struct pci_dev *pdev) /* cancel all wait events */ wake_up_all(&instance->int_cmd_wait_q); - tasklet_kill(&instance->isr_tasklet); - /* * Take the instance off the instance array. Note that we will not * decrement the max_index. We let this array be sparse array diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 5b5885d9732b..5887e3cb725e 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -3819,15 +3819,12 @@ int megasas_irqpoll(struct irq_poll *irqpoll, int budget) /** * megasas_complete_cmd_dpc_fusion - Completes command - * @instance_addr: Adapter soft state address + * @instance: Adapter soft state instance * - * Tasklet to complete cmds */ static void -megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) +megasas_complete_cmd_dpc_fusion(struct megasas_instance *instance) { - struct megasas_instance *instance = - (struct megasas_instance *)instance_addr; struct megasas_irq_context *irq_ctx = NULL; u32 count, MSIxIndex; @@ -3843,6 +3840,15 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) } } +/* Called from threaded IRQ, runs in task context. */ +static irqreturn_t megasas_complete_cmd_dpc_fusion_irq(int irq, void *devp) +{ + struct megasas_instance *instance = (struct megasas_instance *)devp; + + megasas_complete_cmd_dpc_fusion(instance); + return IRQ_HANDLED; +} + /** * megasas_isr_fusion - isr entry point * @irq: IRQ number @@ -5367,8 +5373,7 @@ struct megasas_instance_template megasas_instance_template_fusion = { .adp_reset = megasas_adp_reset_fusion, .check_reset = megasas_check_reset_fusion, .service_isr = megasas_isr_fusion, - .tasklet = megasas_complete_cmd_dpc_fusion, + .service_thr = megasas_complete_cmd_dpc_fusion_irq, .init_adapter = megasas_init_adapter_fusion, .build_and_issue_cmd = megasas_build_and_issue_cmd_fusion, .issue_dcmd = megasas_issue_dcmd_fusion, -- From patchwork Mon May 30 23:15:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4844CC433EF for ; Mon, 30 May 2022 23:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242989AbiE3XPr (ORCPT ); Mon, 30 May 2022 19:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242837AbiE3XPl (ORCPT ); Mon, 30 May 2022 19:15:41 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 738C871A39 for ; Mon, 30 May 2022 16:15:39 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D2C0DC0AFB; Mon, 30 May 2022 23:15:38 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 575C4C09D0; Mon, 30 May 2022 23:15:38 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952538; a=rsa-sha256; cv=none; b=haO0+MFGNyrJZ3kTkW7KTWHnDbImGSf3xt7M3BHibejWEo+5/XyJG7M3vVHpvKzC8GHkw1 9obefNgcySDMZByTbHS9AwB5/1JKaQUHkqlEKjeMLdPtgZoguKmrocO5cI6D3fFj7Afzdn 1/NTV/uUeZEHFRlamVMI9pMApmPfX4ILiCZQumHRxxzEXksjFPAYqnHo7Svit4k0vfBn3e 0AianFzJh4+9gFT8jTxL1ll83TjL/pNyTTZcdRG7/nhgR4v0D3nERSA625JM74sEy/5PUS Na+gLjJBazdenJ1FruDq8YKZHBYsk8SZGTloJ0Fygzw5B+Mvug3k74zVvv2h+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952538; 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:dkim-signature; bh=uf6qf2HWvTld+HMpa8eqZZvyIZvxw3UdM3XxI24qYfg=; b=gHbjbF6Ry9VK03V0qaWT3+0N3i94SHxfUqf5lmTs7MkahhgaVuygPuUIty0/RfXA4hgQXy QR3zW/EPP+02s30CXHIcPQEF0w6M9+Le2fnmug0EG2uR7mIWZCC7SSzyVCWvWGleSV+lGp 5adYt0jazPqFkg8masn4Y7nqv4he8KGonxUf3ovwPVMzHJaJ3uo5RhdqRufAqN7S4ywXUM E/bOe0Vvqtv2ZsuMexvgrZTaGYNLfYw5Mx1wWshe9SMPTIW3ZvBwDoqqP2exHutIBQPvLa SwRLH/D46lpzF058SsoQsKH1zU5tKrIn98MgbPeiAfDNhkTEWKHbdKhZcD0/KQ== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-n6vbx; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Imminent-Spot: 412687264a5ed69d_1653952538662_69224791 X-MC-Loop-Signature: 1653952538662:2015312500 X-MC-Ingress-Time: 1653952538661 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.116.106.119 (trex/6.7.1); Mon, 30 May 2022 23:15:38 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqY4zGsz4C; Mon, 30 May 2022 16:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952538; bh=uf6qf2HWvTld+HMpa8eqZZvyIZvxw3UdM3XxI24qYfg=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=gxOZAMwXm7bEfgwFx7ymqkBVNU2BNylFrN/m9CUZ+CA5rBr8kIF+P40ab9g7XF/Ia g+IzI7PBXWGqPLG6y8Fjz1EUXwXNC8vkYMxvYjsvdsXvgBCWk6mZq5v0pXmiET+XFf 5/um80SaSN6jNTKgRUWegFqwi4X1o4iQOznhVd8yzzJ7Bt1Hw+YJtQEUB9ACS/i+ED V82pPJyF0WPU64QvSNDmL3ygqeeD0BAMn5gXNxoum6OAStx+4OjZOcE/gTOOJ6A6ur TXUqeAT9TnoQSgG8fb4dIOJaykVB9Nv2hdDnoMcZsiDjWXT997rdC2qGdqM8OC15RN AnFnqFkjnBB2A== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net Subject: [PATCH 04/10] scsi/aic94xx: Replace the donelist tasklet with threaded irq Date: Mon, 30 May 2022 16:15:06 -0700 Message-Id: <20220530231512.9729-5-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and deal with the processing of donelist entries task context. Also rename a lot of calls removing the 'tasklet' part, which of course no longer applies. Signed-off-by: Davidlohr Bueso --- drivers/scsi/aic94xx/aic94xx_hwi.c | 23 ++------ drivers/scsi/aic94xx/aic94xx_hwi.h | 5 +- drivers/scsi/aic94xx/aic94xx_init.c | 5 +- drivers/scsi/aic94xx/aic94xx_scb.c | 88 ++++++++--------------------- drivers/scsi/aic94xx/aic94xx_task.c | 16 +++--- drivers/scsi/aic94xx/aic94xx_tmf.c | 40 ++++++------- 6 files changed, 63 insertions(+), 114 deletions(-) diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c index 3dd110143471..562a59b03aa1 100644 --- a/drivers/scsi/aic94xx/aic94xx_hwi.c +++ b/drivers/scsi/aic94xx/aic94xx_hwi.c @@ -248,8 +248,6 @@ static void asd_get_max_scb_ddb(struct asd_ha_struct *asd_ha) /* ---------- Done List initialization ---------- */ -static void asd_dl_tasklet_handler(unsigned long); - static int asd_init_dl(struct asd_ha_struct *asd_ha) { asd_ha->seq.actual_dl @@ -261,8 +259,6 @@ static int asd_init_dl(struct asd_ha_struct *asd_ha) asd_ha->seq.dl = asd_ha->seq.actual_dl->vaddr; asd_ha->seq.dl_toggle = ASD_DEF_DL_TOGGLE; asd_ha->seq.dl_next = 0; - tasklet_init(&asd_ha->seq.dl_tasklet, asd_dl_tasklet_handler, - (unsigned long) asd_ha); return 0; } @@ -711,7 +707,7 @@ static void asd_chip_reset(struct asd_ha_struct *asd_ha) /* ---------- Done List Routines ---------- */ -static void asd_dl_tasklet_handler(unsigned long data) +irqreturn_t asd_dl_handler(int irq, void *data) { struct asd_ha_struct *asd_ha = (struct asd_ha_struct *) data; struct asd_seq_data *seq = &asd_ha->seq; @@ -741,26 +737,19 @@ static void asd_dl_tasklet_handler(unsigned long data) seq->pending--; spin_unlock_irqrestore(&seq->pend_q_lock, flags); out: - ascb->tasklet_complete(ascb, dl); + ascb->complete(ascb, dl); next_1: seq->dl_next = (seq->dl_next + 1) & (ASD_DL_SIZE-1); if (!seq->dl_next) seq->dl_toggle ^= DL_TOGGLE_MASK; } + + return IRQ_HANDLED; } /* ---------- Interrupt Service Routines ---------- */ -/** - * asd_process_donelist_isr -- schedule processing of done list entries - * @asd_ha: pointer to host adapter structure - */ -static void asd_process_donelist_isr(struct asd_ha_struct *asd_ha) -{ - tasklet_schedule(&asd_ha->seq.dl_tasklet); -} - /** * asd_com_sas_isr -- process device communication interrupt (COMINT) * @asd_ha: pointer to host adapter structure @@ -1011,8 +1000,6 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id) asd_write_reg_dword(asd_ha, CHIMINT, chimint); (void) asd_read_reg_dword(asd_ha, CHIMINT); - if (chimint & DLAVAIL) - asd_process_donelist_isr(asd_ha); if (chimint & COMINT) asd_com_sas_isr(asd_ha); if (chimint & DEVINT) @@ -1021,6 +1008,8 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id) asd_rbi_exsi_isr(asd_ha); if (chimint & HOSTERR) asd_hst_pcix_isr(asd_ha); + if (chimint & DLAVAIL) + return IRQ_WAKE_THREAD; return IRQ_HANDLED; } diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h index 930e192b1cd4..e3a97b5cfab5 100644 --- a/drivers/scsi/aic94xx/aic94xx_hwi.h +++ b/drivers/scsi/aic94xx/aic94xx_hwi.h @@ -117,7 +117,7 @@ struct asd_ascb { struct asd_dma_tok dma_scb; struct asd_dma_tok *sg_arr; - void (*tasklet_complete)(struct asd_ascb *, struct done_list_struct *); + void (*complete)(struct asd_ascb *, struct done_list_struct *); u8 uldd_timer:1; /* internally generated command */ @@ -152,7 +152,6 @@ struct asd_seq_data { void *tc_index_bitmap; int tc_index_bitmap_bits; - struct tasklet_struct dl_tasklet; struct done_list_struct *dl; /* array of done list entries, equals */ struct asd_dma_tok *actual_dl; /* actual_dl->vaddr */ int dl_toggle; @@ -356,7 +355,7 @@ static inline void asd_ascb_free_list(struct asd_ascb *ascb_list) int asd_init_hw(struct asd_ha_struct *asd_ha); irqreturn_t asd_hw_isr(int irq, void *dev_id); - +irqreturn_t asd_dl_handler(int irq, void *data); struct asd_ascb *asd_ascb_alloc_list(struct asd_ha_struct *asd_ha, int *num, diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 954d0c5ae2e2..b0c4af0e6479 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -790,8 +790,9 @@ static int asd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) if (use_msi) pci_enable_msi(asd_ha->pcidev); - err = request_irq(asd_ha->pcidev->irq, asd_hw_isr, IRQF_SHARED, - ASD_DRIVER_NAME, asd_ha); + err = request_threaded_irq(asd_ha->pcidev->irq, asd_hw_isr, + asd_dl_handler, IRQF_SHARED, + ASD_DRIVER_NAME, asd_ha); if (err) { asd_printk("couldn't get irq %d for %s\n", asd_ha->pcidev->irq, pci_name(asd_ha->pcidev)); diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c index 68214a58b160..abe28d80892b 100644 --- a/drivers/scsi/aic94xx/aic94xx_scb.c +++ b/drivers/scsi/aic94xx/aic94xx_scb.c @@ -64,8 +64,8 @@ static void get_lrate_mode(struct asd_phy *phy, u8 oob_mode) phy->sas_phy.oob_mode = SATA_OOB_MODE; } -static void asd_phy_event_tasklet(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void asd_phy_event(struct asd_ascb *ascb, + struct done_list_struct *dl) { struct asd_ha_struct *asd_ha = ascb->ha; int phy_id = dl->status_block[0] & DL_PHY_MASK; @@ -215,9 +215,9 @@ static void asd_deform_port(struct asd_ha_struct *asd_ha, struct asd_phy *phy) spin_unlock_irqrestore(&asd_ha->asd_ports_lock, flags); } -static void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, - struct done_list_struct *dl, - int edb_id, int phy_id) +static void asd_bytes_dmaed(struct asd_ascb *ascb, + struct done_list_struct *dl, + int edb_id, int phy_id) { unsigned long flags; int edb_el = edb_id + ascb->edb_index; @@ -237,9 +237,9 @@ static void asd_bytes_dmaed_tasklet(struct asd_ascb *ascb, sas_notify_port_event(&phy->sas_phy, PORTE_BYTES_DMAED, GFP_ATOMIC); } -static void asd_link_reset_err_tasklet(struct asd_ascb *ascb, - struct done_list_struct *dl, - int phy_id) +static void asd_link_reset_err(struct asd_ascb *ascb, + struct done_list_struct *dl, + int phy_id) { struct asd_ha_struct *asd_ha = ascb->ha; struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; @@ -290,9 +290,9 @@ static void asd_link_reset_err_tasklet(struct asd_ascb *ascb, ; } -static void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb, - struct done_list_struct *dl, - int phy_id) +static void asd_primitive_rcvd(struct asd_ascb *ascb, + struct done_list_struct *dl, + int phy_id) { unsigned long flags; struct sas_ha_struct *sas_ha = &ascb->ha->sas_ha; @@ -361,7 +361,6 @@ static void asd_primitive_rcvd_tasklet(struct asd_ascb *ascb, * * After an EDB has been invalidated, if all EDBs in this ESCB have been * invalidated, the ESCB is posted back to the sequencer. - * Context is tasklet/IRQ. */ void asd_invalidate_edb(struct asd_ascb *ascb, int edb_id) { @@ -396,8 +395,8 @@ void asd_invalidate_edb(struct asd_ascb *ascb, int edb_id) } } -static void escb_tasklet_complete(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void escb_complete(struct asd_ascb *ascb, + struct done_list_struct *dl) { struct asd_ha_struct *asd_ha = ascb->ha; struct sas_ha_struct *sas_ha = &asd_ha->sas_ha; @@ -546,21 +545,21 @@ static void escb_tasklet_complete(struct asd_ascb *ascb, switch (sb_opcode) { case BYTES_DMAED: ASD_DPRINTK("%s: phy%d: BYTES_DMAED\n", __func__, phy_id); - asd_bytes_dmaed_tasklet(ascb, dl, edb, phy_id); + asd_bytes_dmaed(ascb, dl, edb, phy_id); break; case PRIMITIVE_RECVD: ASD_DPRINTK("%s: phy%d: PRIMITIVE_RECVD\n", __func__, phy_id); - asd_primitive_rcvd_tasklet(ascb, dl, phy_id); + asd_primitive_rcvd(ascb, dl, phy_id); break; case PHY_EVENT: ASD_DPRINTK("%s: phy%d: PHY_EVENT\n", __func__, phy_id); - asd_phy_event_tasklet(ascb, dl); + asd_phy_event(ascb, dl); break; case LINK_RESET_ERROR: ASD_DPRINTK("%s: phy%d: LINK_RESET_ERROR\n", __func__, phy_id); - asd_link_reset_err_tasklet(ascb, dl, phy_id); + asd_link_reset_err(ascb, dl, phy_id); break; case TIMER_EVENT: ASD_DPRINTK("%s: phy%d: TIMER_EVENT, lost dw sync\n", @@ -600,7 +599,7 @@ int asd_init_post_escbs(struct asd_ha_struct *asd_ha) int i; for (i = 0; i < seq->num_escbs; i++) - seq->escb_arr[i]->tasklet_complete = escb_tasklet_complete; + seq->escb_arr[i]->complete = escb_complete; ASD_DPRINTK("posting %d escbs\n", i); return asd_post_escb_list(asd_ha, seq->escb_arr[0], seq->num_escbs); @@ -613,7 +612,7 @@ int asd_init_post_escbs(struct asd_ha_struct *asd_ha) | CURRENT_OOB_ERROR) /** - * control_phy_tasklet_complete -- tasklet complete for CONTROL PHY ascb + * control_phy_complete -- complete for CONTROL PHY ascb * @ascb: pointer to an ascb * @dl: pointer to the done list entry * @@ -623,8 +622,8 @@ int asd_init_post_escbs(struct asd_ha_struct *asd_ha) * - if a device is connected to the LED, it is lit, * - if no device is connected to the LED, is is dimmed (off). */ -static void control_phy_tasklet_complete(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void control_phy_complete(struct asd_ascb *ascb, + struct done_list_struct *dl) { struct asd_ha_struct *asd_ha = ascb->ha; struct scb *scb = ascb->scb; @@ -758,10 +757,9 @@ static void set_speed_mask(u8 *speed_mask, struct asd_phy_desc *pd) * * This function builds a CONTROL PHY scb. No allocation of any kind * is performed. @ascb is allocated with the list function. - * The caller can override the ascb->tasklet_complete to point + * The caller can override the ascb->complete to point * to its own callback function. It must call asd_ascb_free() - * at its tasklet complete function. - * See the default implementation. + * at its complete function. See the default implementation. */ void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc) { @@ -806,47 +804,9 @@ void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc) control_phy->conn_handle = cpu_to_le16(0xFFFF); - ascb->tasklet_complete = control_phy_tasklet_complete; + ascb->complete = control_phy_complete; } -/* ---------- INITIATE LINK ADM TASK ---------- */ - -#if 0 - -static void link_adm_tasklet_complete(struct asd_ascb *ascb, - struct done_list_struct *dl) -{ - u8 opcode = dl->opcode; - struct initiate_link_adm *link_adm = &ascb->scb->link_adm; - u8 phy_id = link_adm->phy_id; - - if (opcode != TC_NO_ERROR) { - asd_printk("phy%d: link adm task 0x%x completed with error " - "0x%x\n", phy_id, link_adm->sub_func, opcode); - } - ASD_DPRINTK("phy%d: link adm task 0x%x: 0x%x\n", - phy_id, link_adm->sub_func, opcode); - - asd_ascb_free(ascb); -} - -void asd_build_initiate_link_adm_task(struct asd_ascb *ascb, int phy_id, - u8 subfunc) -{ - struct scb *scb = ascb->scb; - struct initiate_link_adm *link_adm = &scb->link_adm; - - scb->header.opcode = INITIATE_LINK_ADM_TASK; - - link_adm->phy_id = phy_id; - link_adm->sub_func = subfunc; - link_adm->conn_handle = cpu_to_le16(0xFFFF); - - ascb->tasklet_complete = link_adm_tasklet_complete; -} - -#endif /* 0 */ - /* ---------- SCB timer ---------- */ /** diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c index ed119a3f6f2e..63e0a6db6683 100644 --- a/drivers/scsi/aic94xx/aic94xx_task.c +++ b/drivers/scsi/aic94xx/aic94xx_task.c @@ -135,10 +135,10 @@ static void asd_unmap_scatterlist(struct asd_ascb *ascb) task->num_scatter, task->data_dir); } -/* ---------- Task complete tasklet ---------- */ +/* ---------- Task complete ---------- */ -static void asd_get_response_tasklet(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void asd_get_response(struct asd_ascb *ascb, + struct done_list_struct *dl) { struct asd_ha_struct *asd_ha = ascb->ha; struct sas_task *task = ascb->uldd_task; @@ -191,7 +191,7 @@ static void asd_get_response_tasklet(struct asd_ascb *ascb, asd_invalidate_edb(escb, edb_id); } -static void asd_task_tasklet_complete(struct asd_ascb *ascb, +static void asd_task_complete(struct asd_ascb *ascb, struct done_list_struct *dl) { struct sas_task *task = ascb->uldd_task; @@ -221,7 +221,7 @@ static void asd_task_tasklet_complete(struct asd_ascb *ascb, case TC_ATA_RESP: ts->resp = SAS_TASK_COMPLETE; ts->stat = SAS_PROTO_RESPONSE; - asd_get_response_tasklet(ascb, dl); + asd_get_response(ascb, dl); break; case TF_OPEN_REJECT: ts->resp = SAS_TASK_UNDELIVERED; @@ -394,7 +394,7 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task, flags |= STP_AFFIL_POLICY; scb->ata_task.flags = flags; } - ascb->tasklet_complete = asd_task_tasklet_complete; + ascb->complete = asd_task_complete; if (likely(!task->ata_task.device_control_reg_update)) res = asd_map_scatterlist(task, scb->ata_task.sg_element, @@ -442,7 +442,7 @@ static int asd_build_smp_ascb(struct asd_ascb *ascb, struct sas_task *task, scb->smp_task.conn_handle = cpu_to_le16((u16) (unsigned long)dev->lldd_dev); - ascb->tasklet_complete = asd_task_tasklet_complete; + ascb->complete = asd_task_complete; return 0; } @@ -495,7 +495,7 @@ static int asd_build_ssp_ascb(struct asd_ascb *ascb, struct sas_task *task, scb->ssp_task.data_dir = data_dir_flags[task->data_dir]; scb->ssp_task.retry_count = scb->ssp_task.retry_count; - ascb->tasklet_complete = asd_task_tasklet_complete; + ascb->complete = asd_task_complete; res = asd_map_scatterlist(task, scb->ssp_task.sg_element, gfp_flags); diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c index 27d32b8c2987..00a148f73250 100644 --- a/drivers/scsi/aic94xx/aic94xx_tmf.c +++ b/drivers/scsi/aic94xx/aic94xx_tmf.c @@ -15,13 +15,13 @@ /* ---------- Internal enqueue ---------- */ static int asd_enqueue_internal(struct asd_ascb *ascb, - void (*tasklet_complete)(struct asd_ascb *, - struct done_list_struct *), + void (*complete)(struct asd_ascb *, + struct done_list_struct *), void (*timed_out)(struct timer_list *t)) { int res; - ascb->tasklet_complete = tasklet_complete; + ascb->complete = complete; ascb->uldd_timer = 1; ascb->timer.function = timed_out; @@ -37,7 +37,7 @@ static int asd_enqueue_internal(struct asd_ascb *ascb, /* ---------- CLEAR NEXUS ---------- */ -struct tasklet_completion_status { +struct completion_status { int dl_opcode; int tmf_state; u8 tag_valid:1; @@ -45,7 +45,7 @@ struct tasklet_completion_status { }; #define DECLARE_TCS(tcs) \ - struct tasklet_completion_status tcs = { \ + struct completion_status tcs = { \ .dl_opcode = 0, \ .tmf_state = 0, \ .tag_valid = 0, \ @@ -53,10 +53,10 @@ struct tasklet_completion_status { } -static void asd_clear_nexus_tasklet_complete(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void asd_clear_nexus_complete(struct asd_ascb *ascb, + struct done_list_struct *dl) { - struct tasklet_completion_status *tcs = ascb->uldd_task; + struct completion_status *tcs = ascb->uldd_task; ASD_DPRINTK("%s: here\n", __func__); if (!del_timer(&ascb->timer)) { ASD_DPRINTK("%s: couldn't delete timer\n", __func__); @@ -71,7 +71,7 @@ static void asd_clear_nexus_tasklet_complete(struct asd_ascb *ascb, static void asd_clear_nexus_timedout(struct timer_list *t) { struct asd_ascb *ascb = from_timer(ascb, t, timer); - struct tasklet_completion_status *tcs = ascb->uldd_task; + struct completion_status *tcs = ascb->uldd_task; ASD_DPRINTK("%s: here\n", __func__); tcs->dl_opcode = TMF_RESP_FUNC_FAILED; @@ -98,7 +98,7 @@ static void asd_clear_nexus_timedout(struct timer_list *t) #define CLEAR_NEXUS_POST \ ASD_DPRINTK("%s: POST\n", __func__); \ - res = asd_enqueue_internal(ascb, asd_clear_nexus_tasklet_complete, \ + res = asd_enqueue_internal(ascb, asd_clear_nexus_complete, \ asd_clear_nexus_timedout); \ if (res) \ goto out_err; \ @@ -245,14 +245,14 @@ static int asd_clear_nexus_index(struct sas_task *task) static void asd_tmf_timedout(struct timer_list *t) { struct asd_ascb *ascb = from_timer(ascb, t, timer); - struct tasklet_completion_status *tcs = ascb->uldd_task; + struct completion_status *tcs = ascb->uldd_task; ASD_DPRINTK("tmf timed out\n"); tcs->tmf_state = TMF_RESP_FUNC_FAILED; complete(ascb->completion); } -static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, +static int asd_get_tmf_resp(struct asd_ascb *ascb, struct done_list_struct *dl) { struct asd_ha_struct *asd_ha = ascb->ha; @@ -270,7 +270,7 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, struct ssp_response_iu *ru; int res = TMF_RESP_FUNC_FAILED; - ASD_DPRINTK("tmf resp tasklet\n"); + ASD_DPRINTK("tmf resp\n"); spin_lock_irqsave(&asd_ha->seq.tc_index_lock, flags); escb = asd_tc_index_find(&asd_ha->seq, @@ -298,21 +298,21 @@ static int asd_get_tmf_resp_tasklet(struct asd_ascb *ascb, return res; } -static void asd_tmf_tasklet_complete(struct asd_ascb *ascb, - struct done_list_struct *dl) +static void asd_tmf_complete(struct asd_ascb *ascb, + struct done_list_struct *dl) { - struct tasklet_completion_status *tcs; + struct completion_status *tcs; if (!del_timer(&ascb->timer)) return; tcs = ascb->uldd_task; - ASD_DPRINTK("tmf tasklet complete\n"); + ASD_DPRINTK("tmf complete\n"); tcs->dl_opcode = dl->opcode; if (dl->opcode == TC_SSP_RESP) { - tcs->tmf_state = asd_get_tmf_resp_tasklet(ascb, dl); + tcs->tmf_state = asd_get_tmf_resp(ascb, dl); tcs->tag_valid = ascb->tag_valid; tcs->tag = ascb->tag; } @@ -452,7 +452,7 @@ int asd_abort_task(struct sas_task *task) scb->abort_task.index = cpu_to_le16((u16)tascb->tc_index); scb->abort_task.itnl_to = cpu_to_le16(ITNL_TIMEOUT_CONST); - res = asd_enqueue_internal(ascb, asd_tmf_tasklet_complete, + res = asd_enqueue_internal(ascb, asd_tmf_complete, asd_tmf_timedout); if (res) goto out_free; @@ -600,7 +600,7 @@ static int asd_initiate_ssp_tmf(struct domain_device *dev, u8 *lun, if (tmf == TMF_QUERY_TASK) scb->ssp_tmf.index = cpu_to_le16(index); - res = asd_enqueue_internal(ascb, asd_tmf_tasklet_complete, + res = asd_enqueue_internal(ascb, asd_tmf_complete, asd_tmf_timedout); if (res) goto out_err; From patchwork Mon May 30 23:15:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD265C433F5 for ; Mon, 30 May 2022 23:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242895AbiE3XPr (ORCPT ); Mon, 30 May 2022 19:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233798AbiE3XPl (ORCPT ); Mon, 30 May 2022 19:15:41 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4027D712D4 for ; Mon, 30 May 2022 16:15:40 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 7EF6E80E74; Mon, 30 May 2022 23:15:39 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 09E9080A06; Mon, 30 May 2022 23:15:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952539; a=rsa-sha256; cv=none; b=aeaKGl0p8sDV/pu5RnXSQY/XDg6OBP8YIrVOZblRmTaGU1eZXDCFM0rZTxA8KsEyqcmhT1 ZuSeDdLNMj4x2bJrNgBRPi2FxCSdzZChl0c7HvkgqMdBvIbWJwcrhIE5K5YyYwmyzRSsgY YqhZ3ZcTbuMnkPnJdSd3lr7xFpQG9lhQywzeSdi9v9PKpJ78IXfqVfY0RA7iFiGEQ9Fog8 Mj5DuQoEFTEpi+u3X4cD6LgTUZHFg0X9fZ5t09II128aRTJo9t89Z4Icj4X+C29A/SbHN6 yv5l78f/884uA5FHQMu84oPbAAL6XO5/Hix7eKSj7Yy5OiC+8jS17fMxZCGsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952539; 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:dkim-signature; bh=bQ6k9kiUELBB1Kp/cDFLF7qdjydfeS7cxzEv4FKKf8I=; b=11gmE+WO/CCQH61K7GYe9F+rMSptRboGX8k2NRE2iKvcoimSCiwZASesyNuLNDHZdOMuj4 zdAD+8mI0niNHzVI3SnTGZWLqwfLYgPbB++7+FzZkGi6NXmOOjd+SWehxT+lHa6wzOXcp+ geV19Z2Jkc266n6QWVjqPEBiPkANQUeNyva4uWPx+gNHz0ojb5PIrJwmR9Sxb/gV3UqC5W V8dHvqJlgwF80H24z73zpMFp/Q1Q0ZucDeUX1mMOutiKulVf4biGuRwlTYF5YjcG0+jeUo cXPIqW7WfAwyoda2drFVDSjT8G+12h/KrFy/yZwpWafkbUJm61gc995cVHXt0Q== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-ghvh7; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Name-Troubled: 2bccc9d417a11ae9_1653952539330_4039614720 X-MC-Loop-Signature: 1653952539330:802792812 X-MC-Ingress-Time: 1653952539330 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.242.203 (trex/6.7.1); Mon, 30 May 2022 23:15:39 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqZ2PK8z2g; Mon, 30 May 2022 16:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952538; bh=bQ6k9kiUELBB1Kp/cDFLF7qdjydfeS7cxzEv4FKKf8I=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=B5IOebZKm5neGc5dXQ7R5YF9L32ezs5+rfRPgSfpGdHqselzgvbD3MQZ+RpchKE4Q 75T1mEBaQODZRF5Ga53x5CqTdqDcDgMRhNdKbCDC40BpA+xPu/tlkH5faPxLexI9wR dCeKvYgjnP+06R2cWqouWXutNWzwCcI8M7qqXuuQIUSRBRzZHXs+XgpDIAXGgcofZh 8U27aLiPvQX2KuFEvl8pbNaW8SfbG99LlTvBYhWz+FN5SM8Y1y2y15nk/VYjdUWTxW 6SMsE9XhwyRXLMBWDjZMC5gl2yuPHIwBLw13fd91BkoOlUs0AeGwfMZCcHATgo+RvE XnWIzmYUQf7Xg== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Artur Paszkiewicz Subject: [PATCH 05/10] scsi/isci: Replace completion_tasklet with threaded irq Date: Mon, 30 May 2022 16:15:07 -0700 Message-Id: <20220530231512.9729-6-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and run in regular task context. Cc: Artur Paszkiewicz Signed-off-by: Davidlohr Bueso Acked-by: Artur Paszkiewicz --- drivers/scsi/isci/host.c | 12 ++++++------ drivers/scsi/isci/host.h | 3 +-- drivers/scsi/isci/init.c | 17 ++++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 35589b6af90d..b2445782979d 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c @@ -220,7 +220,7 @@ irqreturn_t isci_msix_isr(int vec, void *data) struct isci_host *ihost = data; if (sci_controller_isr(ihost)) - tasklet_schedule(&ihost->completion_tasklet); + return IRQ_WAKE_THREAD; return IRQ_HANDLED; } @@ -610,8 +610,7 @@ irqreturn_t isci_intx_isr(int vec, void *data) if (sci_controller_isr(ihost)) { writel(SMU_ISR_COMPLETION, &ihost->smu_registers->interrupt_status); - tasklet_schedule(&ihost->completion_tasklet); - ret = IRQ_HANDLED; + ret = IRQ_WAKE_THREAD; } else if (sci_controller_error_isr(ihost)) { spin_lock(&ihost->scic_lock); sci_controller_error_handler(ihost); @@ -1106,12 +1105,11 @@ void ireq_done(struct isci_host *ihost, struct isci_request *ireq, struct sas_ta /** * isci_host_completion_routine() - This function is the delayed service * routine that calls the sci core library's completion handler. It's - * scheduled as a tasklet from the interrupt service routine when interrupts + * scheduled as a task from the interrupt service routine when interrupts * in use, or set as the timeout function in polled mode. * @data: This parameter specifies the ISCI host object - * */ -void isci_host_completion_routine(unsigned long data) +irqreturn_t isci_host_completion_routine(int vector, void *data) { struct isci_host *ihost = (struct isci_host *)data; u16 active; @@ -1133,6 +1131,8 @@ void isci_host_completion_routine(unsigned long data) writel(SMU_ICC_GEN_VAL(NUMBER, active) | SMU_ICC_GEN_VAL(TIMER, ISCI_COALESCE_BASE + ilog2(active)), &ihost->smu_registers->interrupt_coalesce_control); + + return IRQ_HANDLED; } /** diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h index 6bc3f022630a..f3c9ddc0ce5c 100644 --- a/drivers/scsi/isci/host.h +++ b/drivers/scsi/isci/host.h @@ -203,7 +203,6 @@ struct isci_host { #define IHOST_IRQ_ENABLED 2 unsigned long flags; wait_queue_head_t eventq; - struct tasklet_struct completion_tasklet; spinlock_t scic_lock; struct isci_request *reqs[SCI_MAX_IO_REQUESTS]; struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES]; @@ -478,7 +477,7 @@ void isci_tci_free(struct isci_host *ihost, u16 tci); void ireq_done(struct isci_host *ihost, struct isci_request *ireq, struct sas_task *task); int isci_host_init(struct isci_host *); -void isci_host_completion_routine(unsigned long data); +irqreturn_t isci_host_completion_routine(int vec, void *data); void isci_host_deinit(struct isci_host *); void sci_controller_disable_interrupts(struct isci_host *ihost); bool sci_controller_has_remote_devices_stopping(struct isci_host *ihost); diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index e294d5d961eb..d3ec9423d2b1 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -358,8 +358,10 @@ static int isci_setup_interrupts(struct pci_dev *pdev) else isr = isci_msix_isr; - err = devm_request_irq(&pdev->dev, pci_irq_vector(pdev, i), - isr, 0, DRV_NAME"-msix", ihost); + err = devm_request_threaded_irq(&pdev->dev, + pci_irq_vector(pdev, i), isr, + isci_host_completion_routine, + 0, DRV_NAME"-msix", ihost); if (!err) continue; @@ -377,9 +379,12 @@ static int isci_setup_interrupts(struct pci_dev *pdev) intx: for_each_isci_host(i, ihost, pdev) { - err = devm_request_irq(&pdev->dev, pci_irq_vector(pdev, 0), - isci_intx_isr, IRQF_SHARED, DRV_NAME"-intx", - ihost); + err = devm_request_threaded_irq(&pdev->dev, + pci_irq_vector(pdev, 0), + isci_intx_isr, + isci_host_completion_routine, + IRQF_SHARED, DRV_NAME"-intx", + ihost); if (err) break; } @@ -513,8 +518,6 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) init_waitqueue_head(&ihost->eventq); ihost->sas_ha.dev = &ihost->pdev->dev; ihost->sas_ha.lldd_ha = ihost; - tasklet_init(&ihost->completion_tasklet, - isci_host_completion_routine, (unsigned long)ihost); /* validate module parameters */ /* TODO: kill struct sci_user_parameters and reference directly */ From patchwork Mon May 30 23:15:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D4BDC433FE for ; Mon, 30 May 2022 23:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242998AbiE3XPs (ORCPT ); Mon, 30 May 2022 19:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242904AbiE3XPn (ORCPT ); Mon, 30 May 2022 19:15:43 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB65712FA for ; Mon, 30 May 2022 16:15:41 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5D6E76C16BA; Mon, 30 May 2022 23:15:40 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B84A16C1608; Mon, 30 May 2022 23:15:39 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952539; a=rsa-sha256; cv=none; b=7u5PxFAULAzGfwlnquoQvAg/UEr8Lakcz5XG65ihCNJV8rjZoFM4xuNRGjfDHJPOSTB3MJ +rLAAnMri16ye6ZUQ7LpvmVSe4JTw/Wsxebrrdr3YyQw8JyvwwndC9rTihCHlEAL4qnWYz 4tZQwddO40+eJBzVUy4ByNmdy30qvJKAaYJpntdO7HUpFj5524KWYfPsZyiSzC6l6z/foj HjbBG5obvhfGGvbyUbLodUUSy8oJ2hr8FObUb+tfnaFhVgs8LPk1lQXg/YyE4Xx6SzZaQp G+vBvzkgJMS+5o5pjHwHW1X2+bbLLWdzGe6pdkn/rpgukXkIStQbrzPIw0XP6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952539; 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:dkim-signature; bh=CTIylgDlf3e+RiEnLIJjWrizgO0Y+1XwvuDvHKKokNo=; b=RE2aoUCcjqvZ064MRtcadDLi5OrLtbMLXRP6tvQsutuGw8rWI0qKVCQi+DfQDuhvBi20Oa Ow7vgmM9MUjcF1RBgQNl9Ar4N07NWxKJ0ddxaA5lCBE/5bRqWGPg5C0z44yoNJlvYUG1Q8 K3xTeT0btyGFh7l0hJ7c+JM55In/DoTzEe5Cim4FGT5ksw+mEW4wK2/kvjPPNBFn63isPo juqgke13Cj+eMAon86Vv6X9SUjs6J9lBvH/0Q2KXbb0gaAdov57OtY4GEqEKWZ9zlTdW7Q bGBZh3MTkHPx9udFjiTZUwjh87xXlT9YLt5oh748uzrY/HUrKzE/qa4wJg37Ew== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-jfs9l; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Average-Tangy: 39a916fa00139767_1653952540243_1245808343 X-MC-Loop-Signature: 1653952540243:63556705 X-MC-Ingress-Time: 1653952540243 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.242.203 (trex/6.7.1); Mon, 30 May 2022 23:15:40 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqb0DDJz4C; Mon, 30 May 2022 16:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952539; bh=CTIylgDlf3e+RiEnLIJjWrizgO0Y+1XwvuDvHKKokNo=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=SWOO5qaZQ0TteFE/jV/muVadvdOggd+kJ3R38M+wWDSAMTwkiIu5bnSuGixZDSS6U LLD9ZCCfGOzLrASvidgx/FrQ+zpSeBVDNGqbbGODpp9kngfSjpsfvQkcjrsb87cupH Pij4XH1FOi9DLexobSQNjS/dkzJoc3+WyPHoSsC4tV/ZQZAL8nxEO090/hCvFuhsDY qpEQGvFsEHcjuQWhv+6nlVVpNy+r29Bb4wsJDQdHmlUu7oV/uz7ff4wTkpqyzX4/as qPRDusxZukp//J2higDuoF3x4mzYMYagHJo8ceF6/o6hHOvoV14Mepvy+1T1uT3CGE uUR6YqX5zi+/A== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Michael Cyr , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 06/10] scsi/ibmvscsi_tgt: Replace work tasklet with threaded irq Date: Mon, 30 May 2022 16:15:08 -0700 Message-Id: <20220530231512.9729-7-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. A more suitable equivalent is to converted to threaded irq instead and deal with the async work in task context. Cc: Michael Cyr Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Davidlohr Bueso --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 17 +++++++---------- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index eee1a24f7e15..fafadb7158a3 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -2948,9 +2948,8 @@ static irqreturn_t ibmvscsis_interrupt(int dummy, void *data) struct scsi_info *vscsi = data; vio_disable_interrupts(vscsi->dma_dev); - tasklet_schedule(&vscsi->work_task); - return IRQ_HANDLED; + return IRQ_WAKE_THREAD; } /** @@ -3317,7 +3316,7 @@ static int ibmvscsis_rdma(struct ibmvscsis_cmd *cmd, struct scatterlist *sg, * * Note: this is an edge triggered interrupt. It can not be shared. */ -static void ibmvscsis_handle_crq(unsigned long data) +static irqreturn_t ibmvscsis_handle_crq(int irq, void *data) { struct scsi_info *vscsi = (struct scsi_info *)data; struct viosrp_crq *crq; @@ -3340,7 +3339,7 @@ static void ibmvscsis_handle_crq(unsigned long data) dev_dbg(&vscsi->dev, "handle_crq, don't process: flags 0x%x, state 0x%hx\n", vscsi->flags, vscsi->state); spin_unlock_bh(&vscsi->intr_lock); - return; + goto done; } rc = vscsi->flags & SCHEDULE_DISCONNECT; @@ -3417,6 +3416,8 @@ static void ibmvscsis_handle_crq(unsigned long data) vscsi->state); spin_unlock_bh(&vscsi->intr_lock); +done: + return IRQ_HANDLED; } static int ibmvscsis_probe(struct vio_dev *vdev, @@ -3530,9 +3531,6 @@ static int ibmvscsis_probe(struct vio_dev *vdev, dev_dbg(&vscsi->dev, "probe hrc %ld, client partition num %d\n", hrc, vscsi->client_data.partition_number); - tasklet_init(&vscsi->work_task, ibmvscsis_handle_crq, - (unsigned long)vscsi); - init_completion(&vscsi->wait_idle); init_completion(&vscsi->unconfig); @@ -3544,7 +3542,8 @@ static int ibmvscsis_probe(struct vio_dev *vdev, goto unmap_buf; } - rc = request_irq(vdev->irq, ibmvscsis_interrupt, 0, "ibmvscsis", vscsi); + rc = request_threaded_irq(vdev->irq, ibmvscsis_interrupt, + ibmvscsis_handle_crq, 0, "ibmvscsis", vscsi); if (rc) { rc = -EPERM; dev_err(&vscsi->dev, "probe: request_irq failed, rc %d\n", rc); @@ -3565,7 +3564,6 @@ static int ibmvscsis_probe(struct vio_dev *vdev, free_buf: kfree(vscsi->map_buf); destroy_queue: - tasklet_kill(&vscsi->work_task); ibmvscsis_unregister_command_q(vscsi); ibmvscsis_destroy_command_q(vscsi); free_timer: @@ -3602,7 +3600,6 @@ static void ibmvscsis_remove(struct vio_dev *vdev) dma_unmap_single(&vdev->dev, vscsi->map_ioba, PAGE_SIZE, DMA_BIDIRECTIONAL); kfree(vscsi->map_buf); - tasklet_kill(&vscsi->work_task); ibmvscsis_destroy_command_q(vscsi); ibmvscsis_freetimer(vscsi); ibmvscsis_free_cmds(vscsi); diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h index 7ae074e5d7a1..b66c982b8b00 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.h @@ -295,7 +295,6 @@ struct scsi_info { struct vio_dev *dma_dev; struct srp_target target; struct ibmvscsis_tport tport; - struct tasklet_struct work_task; struct work_struct proc_work; }; From patchwork Mon May 30 23:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 387DBC433F5 for ; Mon, 30 May 2022 23:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243021AbiE3XPv (ORCPT ); Mon, 30 May 2022 19:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242938AbiE3XPn (ORCPT ); Mon, 30 May 2022 19:15:43 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A3071D8B for ; Mon, 30 May 2022 16:15:41 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 51C42C0A85; Mon, 30 May 2022 23:15:41 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 67673C0DEE; Mon, 30 May 2022 23:15:40 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952540; a=rsa-sha256; cv=none; b=2aImFOt9QS2ASMgmt/Y4BmTVuDboLOWrOlMmaN0bkwqcNl9O2zjrv6JvFKVtv0NG+Mzz++ 1iGCG9m0x3OyVNCpyGdsyW49nIQHen/fVMIo6kp8qxMK4FVo6pg5ZEmapGdLT6YRgLbVyG kl6+YS/jES/q37cqtwWTFfBiah2pkD7H14B/4sqj/FXYfMLiQh7cHPLew7CFvt3WL7MEvt bS9seFpXq0veCfiXw31LemRpbpQtmGpQkSkHiSgzcUiQWHAOdD7cDzh+/t+qOWxpwXwkWn pfpq8qVOSeerbNha7ogEY5FNYOf0S012GJ1wlBNZgRoes8V8dYBReRrGlVmqWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952540; 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:dkim-signature; bh=V1IMWtLw/kNCt3Stor1ZVTDAU6CkIBW33piu4s3bM94=; b=tbZ4f3wx+OmAiUZ/TnXPleGBhbC2/vARLvsE8v02aAwJip0TXU0ylbrrqfVimd7VvHuFMl kYynzEffxki+qLLPlVXRRPmdaI+m8+dyyz0t/j5wsuZgLAykByhxVsS/PCrjXMlLHYSCxH Y2eXYAzfYWQuFnezQnsntBWk+T3nvXu5Q70m2C0fTaLerFWCSev6g1Xc/fNlwNko9OJRzW F8nxO3u3Kv+6akJXjR2eqyeMYERnP6xcLxRChVFpOQo+Th8un46or9UJJTbqSRyY415qpO n4PcYqHoCTdbsSt7X68zv6ThXW1XVcr9P5AbftBVwPhU/3FzTWADpEmSE1M+Ig== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-fpjqt; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Spicy-Soft: 47447e21153db0c7_1653952540791_4041795566 X-MC-Loop-Signature: 1653952540791:1109267282 X-MC-Ingress-Time: 1653952540791 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.255.183 (trex/6.7.1); Mon, 30 May 2022 23:15:40 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqb5Fzyz2g; Mon, 30 May 2022 16:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952540; bh=V1IMWtLw/kNCt3Stor1ZVTDAU6CkIBW33piu4s3bM94=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=axFBcZa8Q81oQHBvqLO3+tu33uB/tO1uKEbqQnK2WW0rxLFzgNNUYh5OIwIGS2jNk f1Cw7xB74flDQsYpsd8J5L7hJMWVUXvSu9JEvjm3zCQUSmcpUlQhbUiK9PVl9GJRkr 7A5CED+HD+bkNP+wtAeJHun1dncaZ66MrZnxnBKjuebmdzBBperkClmO/b72ELWd7L aS5Bcg7ye/UhSPraSYzY25jgekim0V8ZIDwnLoMuPery0kRpPFKnYi7oJ6lCrYvfxO dF/YsnpIOQ6Pi7dqwo7d0AAHo56Y4smeYYeuVWZJV86czPDWocEOlH5cPsd+oxrlJF YeQN4nc7+KuuQ== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Bradley Grove Subject: [PATCH 07/10] scsi/esas2r: Replace tasklet with workqueue Date: Mon, 30 May 2022 16:15:09 -0700 Message-Id: <20220530231512.9729-8-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. Use an dedicated (single threaded) high-priority workqueue instead such that async work can be done in task context instead. The AF_WORK_SCHEDULED semantics remain the same for the tasklet scope. Cc: Bradley Grove Signed-off-by: Davidlohr Bueso --- drivers/scsi/esas2r/esas2r.h | 19 +++++++++-------- drivers/scsi/esas2r/esas2r_init.c | 20 ++++++++---------- drivers/scsi/esas2r/esas2r_int.c | 20 +++++++++--------- drivers/scsi/esas2r/esas2r_io.c | 2 +- drivers/scsi/esas2r/esas2r_main.c | 34 ++++++++++++++++++++----------- 5 files changed, 52 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h index ed63f7a9ea54..732309425956 100644 --- a/drivers/scsi/esas2r/esas2r.h +++ b/drivers/scsi/esas2r/esas2r.h @@ -64,6 +64,7 @@ #define ESAS2R_H /* Global Variables */ +extern struct workqueue_struct *esas2r_wq; extern struct esas2r_adapter *esas2r_adapters[]; extern u8 *esas2r_buffered_ioctl; extern dma_addr_t esas2r_buffered_ioctl_addr; @@ -815,7 +816,7 @@ struct esas2r_adapter { #define AF_NVR_VALID 12 #define AF_DEGRADED_MODE 13 #define AF_DISC_PENDING 14 - #define AF_TASKLET_SCHEDULED 15 + #define AF_WORK_SCHEDULED 15 #define AF_HEARTBEAT 16 #define AF_HEARTBEAT_ENB 17 #define AF_NOT_PRESENT 18 @@ -900,7 +901,7 @@ struct esas2r_adapter { struct esas2r_flash_context flash_context; u32 num_targets_backend; u32 ioctl_tunnel; - struct tasklet_struct tasklet; + struct work_struct work; struct pci_dev *pcid; struct Scsi_Host *host; unsigned int index; @@ -992,7 +993,7 @@ int esas2r_write_vda(struct esas2r_adapter *a, const char *buf, long off, int esas2r_read_fs(struct esas2r_adapter *a, char *buf, long off, int count); int esas2r_write_fs(struct esas2r_adapter *a, const char *buf, long off, int count); -void esas2r_adapter_tasklet(unsigned long context); +void esas2r_adapter_work(struct work_struct *work); irqreturn_t esas2r_interrupt(int irq, void *dev_id); irqreturn_t esas2r_msi_interrupt(int irq, void *dev_id); void esas2r_kickoff_timer(struct esas2r_adapter *a); @@ -1022,7 +1023,7 @@ bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll); void esas2r_start_request(struct esas2r_adapter *a, struct esas2r_request *rq); bool esas2r_send_task_mgmt(struct esas2r_adapter *a, struct esas2r_request *rqaux, u8 task_mgt_func); -void esas2r_do_tasklet_tasks(struct esas2r_adapter *a); +void esas2r_do_work_tasks(struct esas2r_adapter *a); void esas2r_adapter_interrupt(struct esas2r_adapter *a); void esas2r_do_deferred_processes(struct esas2r_adapter *a); void esas2r_reset_bus(struct esas2r_adapter *a); @@ -1283,7 +1284,7 @@ static inline void esas2r_rq_destroy_request(struct esas2r_request *rq, rq->data_buf = NULL; } -static inline bool esas2r_is_tasklet_pending(struct esas2r_adapter *a) +static inline bool esas2r_is_work_pending(struct esas2r_adapter *a) { return test_bit(AF_BUSRST_NEEDED, &a->flags) || @@ -1324,14 +1325,14 @@ static inline void esas2r_enable_chip_interrupts(struct esas2r_adapter *a) ESAS2R_INT_ENB_MASK); } -/* Schedule a TASKLET to perform non-interrupt tasks that may require delays +/* Schedule work to perform non-interrupt tasks that may require delays * or long completion times. */ -static inline void esas2r_schedule_tasklet(struct esas2r_adapter *a) +static inline void esas2r_schedule_work(struct esas2r_adapter *a) { /* make sure we don't schedule twice */ - if (!test_and_set_bit(AF_TASKLET_SCHEDULED, &a->flags)) - tasklet_hi_schedule(&a->tasklet); + if (!test_and_set_bit(AF_WORK_SCHEDULED, &a->flags)) + queue_work(esas2r_wq, &a->work); } static inline void esas2r_enable_heartbeat(struct esas2r_adapter *a) diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index c1a5ab662dc8..c7ca9435d395 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -401,9 +401,7 @@ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid, return 0; } - tasklet_init(&a->tasklet, - esas2r_adapter_tasklet, - (unsigned long)a); + INIT_WORK(&a->work, esas2r_adapter_work); /* * Disable chip interrupts to prevent spurious interrupts @@ -441,7 +439,7 @@ static void esas2r_adapter_power_down(struct esas2r_adapter *a, && (!test_bit(AF_DEGRADED_MODE, &a->flags))) { if (!power_management) { del_timer_sync(&a->timer); - tasklet_kill(&a->tasklet); + cancel_work_sync(&a->work); } esas2r_power_down(a); @@ -1338,7 +1336,7 @@ bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll) * usually requested during initial driver load and possibly when * resuming from a low power state. deferred device waiting will use * interrupts. chip reset recovery always defers device waiting to - * avoid being in a TASKLET too long. + * avoid being in a work too long. */ if (init_poll) { u32 currtime = a->disc_start_time; @@ -1346,10 +1344,10 @@ bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll) u32 deltatime; /* - * Block Tasklets from getting scheduled and indicate this is + * Block async work from getting scheduled and indicate this is * polled discovery. */ - set_bit(AF_TASKLET_SCHEDULED, &a->flags); + set_bit(AF_WORK_SCHEDULED, &a->flags); set_bit(AF_DISC_POLLED, &a->flags); /* @@ -1394,8 +1392,8 @@ bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll) nexttick -= deltatime; /* Do any deferred processing */ - if (esas2r_is_tasklet_pending(a)) - esas2r_do_tasklet_tasks(a); + if (esas2r_is_work_pending(a)) + esas2r_do_work_tasks(a); } @@ -1403,7 +1401,7 @@ bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll) atomic_inc(&a->disable_cnt); clear_bit(AF_DISC_POLLED, &a->flags); - clear_bit(AF_TASKLET_SCHEDULED, &a->flags); + clear_bit(AF_WORK_SCHEDULED, &a->flags); } @@ -1463,7 +1461,7 @@ void esas2r_reset_adapter(struct esas2r_adapter *a) { set_bit(AF_OS_RESET, &a->flags); esas2r_local_reset_adapter(a); - esas2r_schedule_tasklet(a); + esas2r_schedule_work(a); } void esas2r_reset_chip(struct esas2r_adapter *a) diff --git a/drivers/scsi/esas2r/esas2r_int.c b/drivers/scsi/esas2r/esas2r_int.c index 5281d9356327..1b1b8b65539d 100644 --- a/drivers/scsi/esas2r/esas2r_int.c +++ b/drivers/scsi/esas2r/esas2r_int.c @@ -86,7 +86,7 @@ void esas2r_polled_interrupt(struct esas2r_adapter *a) /* * Legacy and MSI interrupt handlers. Note that the legacy interrupt handler - * schedules a TASKLET to process events, whereas the MSI handler just + * schedules work to process events, whereas the MSI handler just * processes interrupt events directly. */ irqreturn_t esas2r_interrupt(int irq, void *dev_id) @@ -97,7 +97,7 @@ irqreturn_t esas2r_interrupt(int irq, void *dev_id) return IRQ_NONE; set_bit(AF2_INT_PENDING, &a->flags2); - esas2r_schedule_tasklet(a); + esas2r_schedule_work(a); return IRQ_HANDLED; } @@ -162,7 +162,7 @@ irqreturn_t esas2r_msi_interrupt(int irq, void *dev_id) if (likely(atomic_read(&a->disable_cnt) == 0)) esas2r_do_deferred_processes(a); - esas2r_do_tasklet_tasks(a); + esas2r_do_work_tasks(a); return 1; } @@ -327,8 +327,8 @@ void esas2r_do_deferred_processes(struct esas2r_adapter *a) /* Clear off the completed list to be processed later. */ - if (esas2r_is_tasklet_pending(a)) { - esas2r_schedule_tasklet(a); + if (esas2r_is_work_pending(a)) { + esas2r_schedule_work(a); startreqs = 0; } @@ -476,7 +476,7 @@ static void esas2r_process_bus_reset(struct esas2r_adapter *a) esas2r_trace_exit(); } -static void esas2r_chip_rst_needed_during_tasklet(struct esas2r_adapter *a) +static void esas2r_chip_rst_needed_during_work(struct esas2r_adapter *a) { clear_bit(AF_CHPRST_NEEDED, &a->flags); @@ -558,7 +558,7 @@ static void esas2r_chip_rst_needed_during_tasklet(struct esas2r_adapter *a) } } -static void esas2r_handle_chip_rst_during_tasklet(struct esas2r_adapter *a) +static void esas2r_handle_chip_rst_during_work(struct esas2r_adapter *a) { while (test_bit(AF_CHPRST_DETECTED, &a->flags)) { /* @@ -614,15 +614,15 @@ static void esas2r_handle_chip_rst_during_tasklet(struct esas2r_adapter *a) /* Perform deferred tasks when chip interrupts are disabled */ -void esas2r_do_tasklet_tasks(struct esas2r_adapter *a) +void esas2r_do_work_tasks(struct esas2r_adapter *a) { if (test_bit(AF_CHPRST_NEEDED, &a->flags) || test_bit(AF_CHPRST_DETECTED, &a->flags)) { if (test_bit(AF_CHPRST_NEEDED, &a->flags)) - esas2r_chip_rst_needed_during_tasklet(a); + esas2r_chip_rst_needed_during_work(a); - esas2r_handle_chip_rst_during_tasklet(a); + esas2r_handle_chip_rst_during_work(a); } if (test_bit(AF_BUSRST_NEEDED, &a->flags)) { diff --git a/drivers/scsi/esas2r/esas2r_io.c b/drivers/scsi/esas2r/esas2r_io.c index a8df916cd57a..d45e6e16a858 100644 --- a/drivers/scsi/esas2r/esas2r_io.c +++ b/drivers/scsi/esas2r/esas2r_io.c @@ -851,7 +851,7 @@ void esas2r_reset_bus(struct esas2r_adapter *a) set_bit(AF_BUSRST_PENDING, &a->flags); set_bit(AF_OS_RESET, &a->flags); - esas2r_schedule_tasklet(a); + esas2r_schedule_work(a); } } diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c index 7a4eadad23d7..abe45a934cce 100644 --- a/drivers/scsi/esas2r/esas2r_main.c +++ b/drivers/scsi/esas2r/esas2r_main.c @@ -530,7 +530,7 @@ static void esas2r_remove(struct pci_dev *pdev) static int __init esas2r_init(void) { - int i; + int i, ret; esas2r_log(ESAS2R_LOG_INFO, "%s called", __func__); @@ -606,7 +606,15 @@ static int __init esas2r_init(void) for (i = 0; i < MAX_ADAPTERS; i++) esas2r_adapters[i] = NULL; - return pci_register_driver(&esas2r_pci_driver); + esas2r_wq = alloc_ordered_workqueue("esas2r_wq", WQ_HIGHPRI); + if (!esas2r_wq) + return -ENOMEM; + + ret = pci_register_driver(&esas2r_pci_driver); + if (ret) + destroy_workqueue(esas2r_wq); + + return ret; } /* Handle ioctl calls to "/proc/scsi/esas2r/ATTOnode" */ @@ -649,6 +657,8 @@ static void __exit esas2r_exit(void) esas2r_log(ESAS2R_LOG_INFO, "pci_unregister_driver() called"); pci_unregister_driver(&esas2r_pci_driver); + + destroy_workqueue(esas2r_wq); } int esas2r_show_info(struct seq_file *m, struct Scsi_Host *sh) @@ -1540,10 +1550,10 @@ void esas2r_complete_request_cb(struct esas2r_adapter *a, esas2r_free_request(a, rq); } -/* Run tasklet to handle stuff outside of interrupt context. */ -void esas2r_adapter_tasklet(unsigned long context) +/* Handle stuff outside of interrupt context. */ +void esas2r_adapter_work(struct work_struct *work) { - struct esas2r_adapter *a = (struct esas2r_adapter *)context; + struct esas2r_adapter *a = (struct esas2r_adapter *)work; if (unlikely(test_bit(AF2_TIMER_TICK, &a->flags2))) { clear_bit(AF2_TIMER_TICK, &a->flags2); @@ -1555,16 +1565,16 @@ void esas2r_adapter_tasklet(unsigned long context) esas2r_adapter_interrupt(a); } - if (esas2r_is_tasklet_pending(a)) - esas2r_do_tasklet_tasks(a); + if (esas2r_is_work_pending(a)) + esas2r_do_work_tasks(a); - if (esas2r_is_tasklet_pending(a) + if (esas2r_is_work_pending(a) || (test_bit(AF2_INT_PENDING, &a->flags2)) || (test_bit(AF2_TIMER_TICK, &a->flags2))) { - clear_bit(AF_TASKLET_SCHEDULED, &a->flags); - esas2r_schedule_tasklet(a); + clear_bit(AF_WORK_SCHEDULED, &a->flags); + esas2r_schedule_work(a); } else { - clear_bit(AF_TASKLET_SCHEDULED, &a->flags); + clear_bit(AF_WORK_SCHEDULED, &a->flags); } } @@ -1586,7 +1596,7 @@ static void esas2r_timer_callback(struct timer_list *t) set_bit(AF2_TIMER_TICK, &a->flags2); - esas2r_schedule_tasklet(a); + esas2r_schedule_work(a); esas2r_kickoff_timer(a); } From patchwork Mon May 30 23:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B47C433EF for ; Mon, 30 May 2022 23:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243052AbiE3XPw (ORCPT ); Mon, 30 May 2022 19:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242983AbiE3XPn (ORCPT ); Mon, 30 May 2022 19:15:43 -0400 Received: from beige.elm.relay.mailchannels.net (beige.elm.relay.mailchannels.net [23.83.212.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB73A71D8D for ; Mon, 30 May 2022 16:15:42 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5F9F75A0D30; Mon, 30 May 2022 23:15:42 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3F6415A177D; Mon, 30 May 2022 23:15:41 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952541; a=rsa-sha256; cv=none; b=2fRJw4uCiUXvAr9guNkoLKXsXYHQLyuXeQ0h3YRAKKBnyMNh0jeIu++o4oVQB/Wj4FK31S Ygf3eeoVtm47apbUIsZ8xkmYFPMUsByNK3bZVA+SW88A5NGt2ehHKMpw1a6ubPimk/efY2 G1AlOzrkxuzBMvw8Uco6ocKLL2G4xEMplqIXU02PxwH8QrTNn12thBN85UuZ7RsgvlxPfH Thg4bIXMYgm1WSILJPJE5oQXBnIJQtp8eTDsGGiPj5CVq2o2Iuh0QLuCxl+SZZTgJ3f8BU ouwX+//TII3dwPjszt9EsfLG6ahE6JzTJ5d2vr7nJFoHFc8IxvDJLgZIC5tO8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952541; 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:dkim-signature; bh=JgAdW87Fv5v39ixkCy0W/N22qyz98Z0Qv2cJzG+soWg=; b=YTNklxn8ZfxWnr+i1ULqGHkrUDoJx5TJf9LbOPWmPDlyd/Ib3a3WG0mITtTOS+zBOh99rm 9YBDyh58B1lOb86TbwxY/XYz4o0PfmcqPLTkPJKtBz/VC5IpNmFgE0URvz8h8CpA0RXN/q Ntds5aURkGh0wMUlQko8ZALWweWlTbO2L3poHCkNdlWgVwVffG07/Y4o4KHMXI7tQeuLpm BJLzoevh8PKs1RF7timYdXmbDU3Cr4+y5eCkyinFFh80NunHmbZ3QCRIcuc7JSPLTCNtDQ 8E39kMMuHGta3CDmhVgZuNPB6ESOykmexXlrxsd/IFopFi8mZ9/wbUEFIwQM6g== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-jfs9l; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Chemical-Grain: 3fae3fd83ba3d4b7_1653952541715_1488611591 X-MC-Loop-Signature: 1653952541715:1766411694 X-MC-Ingress-Time: 1653952541715 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.242.203 (trex/6.7.1); Mon, 30 May 2022 23:15:41 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqc2csnz15; Mon, 30 May 2022 16:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952540; bh=JgAdW87Fv5v39ixkCy0W/N22qyz98Z0Qv2cJzG+soWg=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=IUN/2cDWsQFrrKBUggexCWfUwhVrj1AxxjhrEsxUZIL9305oWm14L0DQ39X7fdel3 /mb1Rb+htn9uGV8hHXOGajhPaddxDQ53XkTlOi/cX4WE5jpfvXVJ1Q5EjZTnwW7xBp OQf8fMj0pcziQAHr8kLTwIJVnnV4pzK7vt1fuKiHx5+CU96RKEJdoZ91XNYT95S0WF UxgU/DLX0AGqJNRnvZrMmEC01thefraS2lcO9eaRg9x4OppEtmK5/Yk+r857QyECm4 d7EID9JwY3EtX3vOd/c3qwvcFYGAHH+vCeSAfuuZteZjMrEabreHIL2T2zZnBPg3+l 82dz7sH7wZ98w== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Tyrel Datwyler , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 08/10] scsi/ibmvfc: Replace tasklet with work Date: Mon, 30 May 2022 16:15:10 -0700 Message-Id: <20220530231512.9729-9-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. Use a workqueue instead and run in task context - albeit the increased concurrency (tasklets safe against themselves), but the handler is done under both the vhost's host_lock + crq.q_lock so should be safe. Cc: Tyrel Datwyler Cc: Michael Ellerman --- drivers/scsi/ibmvscsi/ibmvfc.c | 21 ++++++++++++--------- drivers/scsi/ibmvscsi/ibmvfc.h | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index d0eab5700dc5..31b1900489e7 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -891,7 +891,7 @@ static void ibmvfc_release_crq_queue(struct ibmvfc_host *vhost) ibmvfc_dbg(vhost, "Releasing CRQ\n"); free_irq(vdev->irq, vhost); - tasklet_kill(&vhost->tasklet); + cancel_work_sync(&vhost->work); do { if (rc) msleep(100); @@ -3689,22 +3689,22 @@ static irqreturn_t ibmvfc_interrupt(int irq, void *dev_instance) spin_lock_irqsave(vhost->host->host_lock, flags); vio_disable_interrupts(to_vio_dev(vhost->dev)); - tasklet_schedule(&vhost->tasklet); + schedule_work(&vhost->work); spin_unlock_irqrestore(vhost->host->host_lock, flags); return IRQ_HANDLED; } /** - * ibmvfc_tasklet - Interrupt handler tasklet + * ibmvfc_work - work handler * @data: ibmvfc host struct * * Returns: * Nothing **/ -static void ibmvfc_tasklet(void *data) +static void ibmvfc_workfn(struct work_struct *work) { - struct ibmvfc_host *vhost = data; - struct vio_dev *vdev = to_vio_dev(vhost->dev); + struct ibmvfc_host *vhost; + struct vio_dev *vdev; struct ibmvfc_crq *crq; struct ibmvfc_async_crq *async; struct ibmvfc_event *evt, *temp; @@ -3712,6 +3712,9 @@ static void ibmvfc_tasklet(void *data) int done = 0; LIST_HEAD(evt_doneq); + vhost = container_of(work, struct ibmvfc_host, work); + vdev = to_vio_dev(vhost->dev); + spin_lock_irqsave(vhost->host->host_lock, flags); spin_lock(vhost->crq.q_lock); while (!done) { @@ -5722,7 +5725,7 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost) retrc = 0; - tasklet_init(&vhost->tasklet, (void *)ibmvfc_tasklet, (unsigned long)vhost); + INIT_WORK(&vhost->work, ibmvfc_workfn); if ((rc = request_irq(vdev->irq, ibmvfc_interrupt, 0, IBMVFC_NAME, vhost))) { dev_err(dev, "Couldn't register irq 0x%x. rc=%d\n", vdev->irq, rc); @@ -5738,7 +5741,7 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost) return retrc; req_irq_failed: - tasklet_kill(&vhost->tasklet); + cancel_work_sync(&vhost->work); do { rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address); } while (rc == H_BUSY || H_IS_LONG_BUSY(rc)); @@ -6213,7 +6216,7 @@ static int ibmvfc_resume(struct device *dev) spin_lock_irqsave(vhost->host->host_lock, flags); vio_disable_interrupts(vdev); - tasklet_schedule(&vhost->tasklet); + schedule_work(&vhost->work); spin_unlock_irqrestore(vhost->host->host_lock, flags); return 0; } diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index 3718406e0988..7eca3622a2fa 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -12,6 +12,7 @@ #include #include +#include #include #define IBMVFC_NAME "ibmvfc" @@ -892,7 +893,7 @@ struct ibmvfc_host { char partition_name[97]; void (*job_step) (struct ibmvfc_host *); struct task_struct *work_thread; - struct tasklet_struct tasklet; + struct work_struct work; struct work_struct rport_add_work_q; wait_queue_head_t init_wait_q; wait_queue_head_t work_wait_q; From patchwork Mon May 30 23:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BC83C433FE for ; Mon, 30 May 2022 23:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243076AbiE3XPz (ORCPT ); Mon, 30 May 2022 19:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233639AbiE3XPo (ORCPT ); Mon, 30 May 2022 19:15:44 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFC1C71DAB for ; Mon, 30 May 2022 16:15:43 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 073A65A0F1F; Mon, 30 May 2022 23:15:43 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4556C5A14FA; Mon, 30 May 2022 23:15:42 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952542; a=rsa-sha256; cv=none; b=rIBi/rLonGF3LF6tk6bYXJfq69HMNGVOsxLFHHrQ7Dg0RkD5iQw8MC5NPdRcKZUq499VTn F6BGD7xGiidV5Rwd9t1jjeKe9WauSjI43Zzv99IuPWvUbkG7pwS8h3IqSuPB1WMLEDI/oH KYVqQ1IQZmU57EZu1XhiA9ksxanb0KV1wlyUG4uyvVCr0HtTiawbUOq117SA1UMbms+Mfe sl4m0A6yKhe1zQDyjL7F+kQclJ1sz2f2AS44kjbDBoFnz3xPgnBN+Eh6Iz+C2B7xxhBQaz YMCqNro6TKFUbFe374e6BJFXpAK/vYvclMFm1Zk44uRYR9irbvg+1ZBt6eO/dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952542; 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:dkim-signature; bh=pKBd6u6q/2SN1T1w2HcEAEHPpfdIA0VzXHcUYKhBS7Q=; b=GuyHmQEuEdb5nZhl+mT6ThQ5RkY4ao+6U0mnw7sZETTpjzJDtCnI2QydaRbJOYaujLRbQn 3/uCr0My3DJS795ZGC//yrQO6xzbqXJ7n6K/DXEe1DzYomMrOtHmZ6r6F5hMod15QsMTEd anD+SWPe7mnB9+XTS/5didjVMzJeuTK8sIQcWqpXboBU3aoKsbiuxVKOYd3b84YnH66jAN LfhCBJeoijz4VLh6ZIcK3a63brTyhcyes0fa8mrS4gDve4j/MqQOndoBjvrdhqb0Fyp03v 40Qq0xXDGUwgFszXz8n3nF0jpoaoKjMNSSpfYUTpAPE3Wlxc97tsWTHNkeNwCA== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-2ttcb; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Tank-Name: 7f79b8d90939a8af_1653952542763_3847775782 X-MC-Loop-Signature: 1653952542762:1227645974 X-MC-Ingress-Time: 1653952542762 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.255.183 (trex/6.7.1); Mon, 30 May 2022 23:15:42 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqd0hJlzlP; Mon, 30 May 2022 16:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952541; bh=pKBd6u6q/2SN1T1w2HcEAEHPpfdIA0VzXHcUYKhBS7Q=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=grqSe0IDLVJTv3Z0LQINO4IL5pPnKs77Bg1TeogCEQG0YVcNqJWgIaxftgo9GU2xp YRCJ0DvJzlr4pRWtN4gkzpD/9vGkCO0r2fvnqQ/GIEgi+fqPmru3g+Vp9cC2nU5Gyx 0gUzRipHYyY4/TOZFbwNCyqlOUlegiK+4kSloxisybTLS69zp9gSTekCg/+lB1lIqd ANHW+uh4skBlL2ZZ24IKo17BqsJR2k87LYMWNU+feBKQBP4m8FCWer2Twj87rds4qK teKd0zJNz9YSV5BEnZP9CiOa9G2XtgzCy5SZudm6nPy1HdFyF/9oH9gs2HmGcXBMlJ 3W2lLBH51RaoA== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, Tyrel Datwyler , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 09/10] scsi/ibmvscsi: Replace srp tasklet with work Date: Mon, 30 May 2022 16:15:11 -0700 Message-Id: <20220530231512.9729-10-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Tasklets have long been deprecated as being too heavy on the system by running in irq context - and this is not a performance critical path. If a higher priority process wants to run, it must wait for the tasklet to finish before doing so. Process srps asynchronously in process context in a dedicated single threaded workqueue. Cc: Tyrel Datwyler Cc: Michael Ellerman --- drivers/scsi/ibmvscsi/ibmvscsi.c | 38 ++++++++++++++++++++++---------- drivers/scsi/ibmvscsi/ibmvscsi.h | 3 ++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 63f32f843e75..37cbea8bb0af 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -86,6 +86,8 @@ static DEFINE_SPINLOCK(ibmvscsi_driver_lock); static struct scsi_transport_template *ibmvscsi_transport_template; +static struct workqueue_struct *ibmvscsi_wq; + #define IBMVSCSI_VERSION "1.5.9" MODULE_DESCRIPTION("IBM Virtual SCSI"); @@ -117,7 +119,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, * @irq: number of irq to handle, not used * @dev_instance: ibmvscsi_host_data of host that received interrupt * - * Disables interrupts and schedules srp_task + * Disables interrupts and schedules srp_work * Always returns IRQ_HANDLED */ static irqreturn_t ibmvscsi_handle_event(int irq, void *dev_instance) @@ -125,7 +127,7 @@ static irqreturn_t ibmvscsi_handle_event(int irq, void *dev_instance) struct ibmvscsi_host_data *hostdata = (struct ibmvscsi_host_data *)dev_instance; vio_disable_interrupts(to_vio_dev(hostdata->dev)); - tasklet_schedule(&hostdata->srp_task); + queue_work(ibmvscsi_wq, &hostdata->srp_work); return IRQ_HANDLED; } @@ -145,7 +147,7 @@ static void ibmvscsi_release_crq_queue(struct crq_queue *queue, long rc = 0; struct vio_dev *vdev = to_vio_dev(hostdata->dev); free_irq(vdev->irq, (void *)hostdata); - tasklet_kill(&hostdata->srp_task); + cancel_work_sync(&hostdata->srp_work); do { if (rc) msleep(100); @@ -206,16 +208,19 @@ static int ibmvscsi_send_crq(struct ibmvscsi_host_data *hostdata, } /** - * ibmvscsi_task: - Process srps asynchronously + * ibmvscsi_workfn: - Process srps asynchronously * @data: ibmvscsi_host_data of host */ -static void ibmvscsi_task(void *data) +static void ibmvscsi_workfn(struct work_struct *work) { - struct ibmvscsi_host_data *hostdata = (struct ibmvscsi_host_data *)data; - struct vio_dev *vdev = to_vio_dev(hostdata->dev); + struct ibmvscsi_host_data *hostdata; + struct vio_dev *vdev; struct viosrp_crq *crq; int done = 0; + hostdata = container_of(work, struct ibmvscsi_host_data, srp_work); + vdev = to_vio_dev(hostdata->dev); + while (!done) { /* Pull all the valid messages off the CRQ */ while ((crq = crq_queue_next_crq(&hostdata->queue)) != NULL) { @@ -367,8 +372,7 @@ static int ibmvscsi_init_crq_queue(struct crq_queue *queue, queue->cur = 0; spin_lock_init(&queue->lock); - tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task, - (unsigned long)hostdata); + INIT_WORK(&hostdata->srp_work, ibmvscsi_workfn); if (request_irq(vdev->irq, ibmvscsi_handle_event, @@ -387,7 +391,7 @@ static int ibmvscsi_init_crq_queue(struct crq_queue *queue, return retrc; req_irq_failed: - tasklet_kill(&hostdata->srp_task); + cancel_work_sync(&hostdata->srp_work); rc = 0; do { if (rc) @@ -2371,7 +2375,7 @@ static int ibmvscsi_resume(struct device *dev) { struct ibmvscsi_host_data *hostdata = dev_get_drvdata(dev); vio_disable_interrupts(to_vio_dev(hostdata->dev)); - tasklet_schedule(&hostdata->srp_task); + queue_work(ibmvscsi_wq, &hostdata->srp_work); return 0; } @@ -2418,15 +2422,25 @@ static int __init ibmvscsi_module_init(void) if (!ibmvscsi_transport_template) return -ENOMEM; + ibmvscsi_wq = alloc_ordered_workqueue("ibmvscsi_wq", 0); + if (!ibmvscsi_wq) { + srp_release_transport(ibmvscsi_transport_template); + return -ENOMEM; + } + ret = vio_register_driver(&ibmvscsi_driver); - if (ret) + if (ret) { + destroy_workqueue(ibmvscsi_wq); srp_release_transport(ibmvscsi_transport_template); + } + return ret; } static void __exit ibmvscsi_module_exit(void) { vio_unregister_driver(&ibmvscsi_driver); + destroy_workqueue(ibmvscsi_wq); srp_release_transport(ibmvscsi_transport_template); } diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.h b/drivers/scsi/ibmvscsi/ibmvscsi.h index e60916ef7a49..f7c52744a206 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.h +++ b/drivers/scsi/ibmvscsi/ibmvscsi.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -90,7 +91,7 @@ struct ibmvscsi_host_data { struct device *dev; struct event_pool pool; struct crq_queue queue; - struct tasklet_struct srp_task; + struct work_struct srp_work; struct list_head sent; struct Scsi_Host *host; struct task_struct *work_thread; From patchwork Mon May 30 23:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12865009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9E9EC433EF for ; Mon, 30 May 2022 23:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233798AbiE3XP5 (ORCPT ); Mon, 30 May 2022 19:15:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241288AbiE3XPo (ORCPT ); Mon, 30 May 2022 19:15:44 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E5D71DB9 for ; Mon, 30 May 2022 16:15:43 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 101D3761D04; Mon, 30 May 2022 23:15:43 +0000 (UTC) Received: from pdx1-sub0-mail-a312.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 856A9761C0A; Mon, 30 May 2022 23:15:42 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653952542; a=rsa-sha256; cv=none; b=04vckKGduvQIZmCpOrEAOJVREFQyMCkwEK+sJ166BQfWWSpUpkxJ7KmRB1r5QvOnEbCEkR uBlF++AHXT/Dzircz08sHzLgrqm74Igqn8iVh3cq97QnRx6wPN+Mb9gqaGN5Z1JxWcZ5xw sbuH3gEHoxW7YOIuPL1IuAQCSp+oQ8+S2M0GV/DJ8C6Kg6J3/fTkTmzKGBQCh6gDscaByT ysNgQ9BNOVjm3ijF6fAJgDs6TJpuTxr0JyXDW00hPMHxu2lkJNX7gREQ8+siSvIkPeZ9Rw rLdSqIPJyNNFUvEGOWR3jSHhlBxys/Km8WouGGhL+bnI3apIAlNrVeMqpYenXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653952542; 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:dkim-signature; bh=BfMMaISwkYzSVqBGFVh9TD0h12Q2tQqtKfbcv93VqnQ=; b=+NSZIYXDHRtxBkggdMZTRwy17Tpvl3Y0SCl8clpYfkrk+0zGnrT3bKC1WzfXNPZ0LVRHKN shTr5/A3iAqFoR2n/BfpO1H6CddMwxIfjit6gbWLLRHjg/Q3tUa0r4k7CpTcr9L6gXSZ9t XDmx/k4kI1mXlrwqsnObXNdYVY+CFKJIstd96R3Sd8/oodH+qv/0EMvXQTV5XCnp6/MH9U Ba2uBEAqnnILAcufBNLEo6q7XspryHENK2kLnEmKZJmSjcRPFJWaCno8U/XHYvCvaqo9w6 wNTJzFTQpLg0ZDWfodg1cVPpaS4XcrUdpxCK5nbWf/toiiWyywPdzWTEvsllKQ== ARC-Authentication-Results: i=1; rspamd-54ff499d4f-fpjqt; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Ruddy-Broad: 6d1dfe923a560f99_1653952542872_107488069 X-MC-Loop-Signature: 1653952542872:926491730 X-MC-Ingress-Time: 1653952542872 Received: from pdx1-sub0-mail-a312.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.158.163 (trex/6.7.1); Mon, 30 May 2022 23:15:42 +0000 Received: from localhost.localdomain (unknown [104.36.31.105]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a312.dreamhost.com (Postfix) with ESMTPSA id 4LBrqd5c5sz2g; Mon, 30 May 2022 16:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1653952542; bh=BfMMaISwkYzSVqBGFVh9TD0h12Q2tQqtKfbcv93VqnQ=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=pN2vWdMrav6gFnlvXfOp51xO/gClC7puAmCyzUiieY9f4Wi8v/9Ii79JtdVpu1XuV w5QBYzzku7CViPA+MpcC5so5s20tRHNrt+NUrFQ/ktdWs1e+4Dryw/3j6QFIeN8PQC hBqPhnMTnC86qVzS20RPjMPxOV2+eMzDKa2lf4L+M9Bw/m9AgvuANTiiePYSIf9cem RdVcwZCa8esx5xYefmUJH6mFwOlsKww+Jm5n34oUV0fKMesmXdPli59Qi1zPgrWsQS L9e3679IJ1b/N/ODAx7jMKCos76OOulBCKDKaJrplLY8+dX5rJSL14Bi+y3m82hm/D aDs3LnT1+ovrg== From: Davidlohr Bueso To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, ejb@linux.ibm.com, bigeasy@linutronix.de, tglx@linutronix.de, dave@stgolabs.net, James Smart , Dick Kennedy Subject: [PATCH 10/10] scsi/lpfc: Remove bogus references to discovery tasklet Date: Mon, 30 May 2022 16:15:12 -0700 Message-Id: <20220530231512.9729-11-dave@stgolabs.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220530231512.9729-1-dave@stgolabs.net> References: <20220530231512.9729-1-dave@stgolabs.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is done as thread. Also remove an unused member of the lpfc_vport structure. Cc: James Smart Cc: Dick Kennedy Signed-off-by: Davidlohr Bueso Reviewed-by: Sebastian Andrzej Siewior --- drivers/scsi/lpfc/lpfc.h | 2 -- drivers/scsi/lpfc/lpfc_disc.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index da9070cdad91..05da8ccb0933 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -645,8 +645,6 @@ struct lpfc_vport { struct lpfc_name fc_nodename; /* fc nodename */ struct lpfc_name fc_portname; /* fc portname */ - struct lpfc_work_evt disc_timeout_evt; - struct timer_list fc_disctmo; /* Discovery rescue timer */ uint8_t fc_ns_retry; /* retries for fabric nameserver */ uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */ diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index 37a4b79010bf..40f458ee1aec 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h @@ -44,7 +44,7 @@ enum lpfc_work_type { LPFC_EVT_RECOVER_PORT }; -/* structure used to queue event to the discovery tasklet */ +/* structure used to queue event to the discovery thread */ struct lpfc_work_evt { struct list_head evt_listp; void *evt_arg1;