From patchwork Mon Jan 15 12:12:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 10163645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2207C602C2 for ; Mon, 15 Jan 2018 12:12:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15DDC28723 for ; Mon, 15 Jan 2018 12:12:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A6DB28918; Mon, 15 Jan 2018 12:12:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E0D828723 for ; Mon, 15 Jan 2018 12:12:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932811AbeAOMMi (ORCPT ); Mon, 15 Jan 2018 07:12:38 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:45985 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932793AbeAOMMh (ORCPT ); Mon, 15 Jan 2018 07:12:37 -0500 Received: by mail-io0-f195.google.com with SMTP id p188so98695ioe.12 for ; Mon, 15 Jan 2018 04:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:mime-version:thread-index:date:message-id:subject:to; bh=QASfD33jEM8hGRy+PRA/Kr51isy4QrUgQMdIV+6IECs=; b=U2GB72RWe57y0jKImTUpIIu/MyuWyC4tdEExUEG9ajNFaaD7n3BXh1OPa7Fz4KGjNR hmCIsSFmR7W41yBd9tl8XeIlPGWnr/XMWAIgTW8AlateTjdKQQIh+MI2+AIDxaTNlnZk p/y+tMxpAiI88SIxsZlkA0bh2bRzOlHBrW21I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:thread-index:date:message-id :subject:to; bh=QASfD33jEM8hGRy+PRA/Kr51isy4QrUgQMdIV+6IECs=; b=nMO39w7FdRF3L1QMBn82yM9/5faL5HDevIoMtuWtfxwdmsTxX4zfwclfQn6mpG2HY1 kpQbx9X5X2N+Z1oZK2IGXhc5PfVvA64yXMMLNyLzW/UBIIFHdEzEVlTdbScuSb9E+taS Trbgy7b2ZSF/8AS4o0wXc5kK32NBfk0X0H1tBxKkKLdn/HoJr4EpYpV9qxkwH106S0sK Fcnx09SDx9UkbrtPSuJ2FoZ2FNwoIiGoZqcwaI9tyvnzD6MM+4+NwAl71VAvr6QSzztz JFakU0YKeLq6TDcjAKagcbDtgoVcMoU11UFLR0eGgwE+YPJczN4AYMe5uYtylJnZfVc0 uF2Q== X-Gm-Message-State: AKwxytdDh2nWovHQ+1E0JAi2G8e2ng7wtHV0JhkIf+1powaaH1F0fHyg uygiNFcJ1Rheb7vfVru6xNe8ESawL4m4CMmAHR8dmw== X-Google-Smtp-Source: ACJfBou5l8i1CIeV6a02ZzO4ht1SdL+B5YwWGUy0SFnSfocISUdr3TpYVzVlKWjFMc7O6WGB5igXsGCj1DDfR98JmCQ= X-Received: by 10.107.131.2 with SMTP id f2mr17254321iod.102.1516018356665; Mon, 15 Jan 2018 04:12:36 -0800 (PST) From: Kashyap Desai MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdON+hm+E6KBmK0hRVuFwOissmF/PQ== Date: Mon, 15 Jan 2018 17:42:35 +0530 Message-ID: Subject: [RFC 1/2] mpt3sas/megaraid_sas : irq poll to avoid CPU hard and soft lockups To: linux-scsi@vger.kernel.org, Peter Rivera Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch for Fix-1 explained in PATCH 0. Signed-off-by: Kashyap Desai < kashyap.desai@broadcom.com> --- mpt3sas/mpt3sas_base.c | 67 ++++++++++++++++++++++++++++++++++++++------------ mpt3sas/mpt3sas_base.h | 4 +++ 2 files changed, 55 insertions(+), 17 deletions(-) u16 device_remove_in_progress_sz; u8 is_gen35_ioc; u8 atomic_desc_capable; + u32 irqpoll_weight; PUT_SMID_IO_FP_HIP put_smid_scsi_io; PUT_SMID_IO_FP_HIP put_smid_fast_path; PUT_SMID_IO_FP_HIP put_smid_hi_priority; -- 2.5.5 diff --git a/mpt3sas/mpt3sas_base.c b/mpt3sas/mpt3sas_base.c index 08237b8..0b351d4 100644 --- a/mpt3sas/mpt3sas_base.c +++ b/mpt3sas/mpt3sas_base.c @@ -963,17 +963,15 @@ union reply_descriptor { }; /** - * _base_interrupt - MPT adapter (IOC) specific interrupt handler. - * @irq: irq number (not used) - * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure - * @r: pt_regs pointer (not used) + * mpt3sas_process_reply_queue - Process the RDs from reply descriptor + queue + * @ reply_q- reply queue + * @ bugget- command completion budget * - * Return IRQ_HANDLE if processed, else IRQ_NONE. + * Returns number of RDs processed. */ -static irqreturn_t -_base_interrupt(int irq, void *bus_id) +int +mpt3sas_process_reply_queue(struct adapter_reply_queue *reply_q, u32 +budget) { - struct adapter_reply_queue *reply_q = bus_id; union reply_descriptor rd; u32 completed_cmds; u8 request_desript_type; @@ -985,18 +983,15 @@ _base_interrupt(int irq, void *bus_id) Mpi2ReplyDescriptorsUnion_t *rpf; u8 rc; - if (ioc->mask_interrupts) - return IRQ_NONE; - if (!atomic_add_unless(&reply_q->busy, 1, 1)) - return IRQ_NONE; + return 0; rpf = &reply_q->reply_post_free[reply_q->reply_post_host_index]; request_desript_type = rpf->Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) { atomic_dec(&reply_q->busy); - return IRQ_NONE; + return 0; } completed_cmds = 0; @@ -1072,7 +1067,7 @@ _base_interrupt(int irq, void *bus_id) * So that FW can find enough entries to post the Reply * Descriptors in the reply descriptor post queue. */ - if (completed_cmds > ioc->hba_queue_depth/3) { + if (completed_cmds == budget) { if (ioc->combined_reply_queue) { writel(reply_q->reply_post_host_index | ((msix_index & 7) << @@ -1084,6 +1079,8 @@ _base_interrupt(int irq, void *bus_id) MPI2_RPHI_MSIX_INDEX_SHIFT), &ioc->chip->ReplyPostHostIndex); } + if (ioc->irqpoll_weight) + break; completed_cmds = 1; } if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) @@ -1098,14 +1095,14 @@ _base_interrupt(int irq, void *bus_id) if (!completed_cmds) { atomic_dec(&reply_q->busy); - return IRQ_NONE; + return 0; } if (ioc->is_warpdrive) { writel(reply_q->reply_post_host_index, ioc->reply_post_host_index[msix_index]); atomic_dec(&reply_q->busy); - return IRQ_HANDLED; + return completed_cmds; } /* Update Reply Post Host Index. @@ -1132,6 +1129,27 @@ _base_interrupt(int irq, void *bus_id) MPI2_RPHI_MSIX_INDEX_SHIFT), &ioc->chip->ReplyPostHostIndex); atomic_dec(&reply_q->busy); + return completed_cmds; +} + +/** + * _base_interrupt - MPT adapter (IOC) specific interrupt handler. + * @irq: irq number (not used) + * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure + * @r: pt_regs pointer (not used) + * + * Return IRQ_HANDLE if processed, else IRQ_NONE. + */ +static irqreturn_t +_base_interrupt(int irq, void *bus_id) +{ + struct adapter_reply_queue *reply_q = bus_id; + struct MPT3SAS_ADAPTER *ioc = reply_q->ioc; + + if (ioc->mask_interrupts) + return IRQ_NONE; + + irq_poll_sched(&reply_q->irqpoll); return IRQ_HANDLED; } @@ -2285,6 +2303,20 @@ _base_check_enable_msix(struct MPT3SAS_ADAPTER *ioc) return 0; } +int mpt3sas_irqpoll(struct irq_poll *irqpoll, int budget) { + struct adapter_reply_queue *reply_q; + int num_entries = 0; + + reply_q = container_of(irqpoll, struct adapter_reply_queue, irqpoll); + + num_entries = mpt3sas_process_reply_queue(reply_q, budget); + if (num_entries < budget) + irq_poll_complete(irqpoll); + + return num_entries; +} + /** * _base_free_irq - free irq * @ioc: per adapter object @@ -2301,6 +2333,7 @@ _base_free_irq(struct MPT3SAS_ADAPTER *ioc) list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) { list_del(&reply_q->list); + irq_poll_disable(&reply_q->irqpoll); free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index), reply_q); kfree(reply_q); @@ -2348,6 +2381,7 @@ _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index) INIT_LIST_HEAD(&reply_q->list); list_add_tail(&reply_q->list, &ioc->reply_queue_list); + irq_poll_init(&reply_q->irqpoll, ioc->irqpoll_weight, +mpt3sas_irqpoll); return 0; } @@ -2482,6 +2516,7 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc) } ioc->msix_enable = 1; + ioc->irqpoll_weight = 50; ioc->reply_queue_count = r; for (i = 0; i < ioc->reply_queue_count; i++) { r = _base_request_irq(ioc, i); diff --git a/mpt3sas/mpt3sas_base.h b/mpt3sas/mpt3sas_base.h index 60f42ca..456d928 100644 --- a/mpt3sas/mpt3sas_base.h +++ b/mpt3sas/mpt3sas_base.h @@ -66,6 +66,7 @@ #include #include #include +#include #include "mpt3sas_debug.h" #include "mpt3sas_trigger_diag.h" @@ -846,6 +847,8 @@ struct _event_ack_list { struct adapter_reply_queue { struct MPT3SAS_ADAPTER *ioc; u8 msix_index; + u32 max_budget; + struct irq_poll irqpoll; u32 reply_post_host_index; Mpi2ReplyDescriptorsUnion_t *reply_post_free; char name[MPT_NAME_LENGTH]; @@ -1353,6 +1356,7 @@ struct MPT3SAS_ADAPTER {