From patchwork Fri May 28 13:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandrakanth Patil X-Patchwork-Id: 449807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF2F2C2B9F7 for ; Fri, 28 May 2021 13:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2FF2613E9 for ; Fri, 28 May 2021 13:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235853AbhE1NPc (ORCPT ); Fri, 28 May 2021 09:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234233AbhE1NPb (ORCPT ); Fri, 28 May 2021 09:15:31 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 046E4C061574 for ; Fri, 28 May 2021 06:13:57 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id v13so1600563ple.9 for ; Fri, 28 May 2021 06:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DiDIMiqc9B3JV75I5Hplx59o53D4BXmArTicNREC1zA=; b=DXNUvw0AdOQEOi5Nwy6EXDQMSsBljA8Tkgc1xWBFQXY+KdwncGS+Ij3arzZjGl6DSm lDLwNUlqde8j+p18VW8nRugOyB5BBHvshXuB4tSkH8ljahoit2I4CnH7K8DUiHFbzLsg KBOkB1mLR5Uzx854mCrdJsqbeB9SdQUG7zHpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DiDIMiqc9B3JV75I5Hplx59o53D4BXmArTicNREC1zA=; b=dD0bsbmWYkgBBKVimVfeeopWk8qo2BHrtzwK0yPjolN/YRwelk2WdkAX2PNHSAhGMO GfNjjhUm3E+8nvXUnWr8JZpV/qrGiW4mW93f9DNiy1gC9LF2GGgTMZFInFPc3AK8m7S4 Jwj01+qKbdeIdS41WAXPh1tq5tKxQLuvT5UxOYhEj5s3abTrNjrtS0gJs5HXVxj6oDGK WHxaSjFt3HlPhZe+4jkgXBvNZwF55adr/v/1ndcdvnn/fL9sbUwWjXZg8CrpvJH/N7bH eUKM7ab1rrGIr87RxUBKXNXQuCx40nD29ufPfzO71JL+gMQDODaFQQyBksgIsjwZSGUS ZUIw== X-Gm-Message-State: AOAM532fIcRou1wyw3QWojvYoOTXQYwpdnRUa7DVwM5s/N1nITBwCd/2 eVSrmVtx9WQ+BUPfqYZdXje556EQbExj2qxh87YJhXXebQRKX9VRGN2ZFUdmhkD01bTMdq22fSA hXqDdb3mQ04DH7oRzF6QGSpbIRFQB4gcVQkE+O6CHdCTmCneIeIzMuBh6EB7isGasfHePfGu0GF HMYCGrq6rG7FHQ5zo= X-Google-Smtp-Source: ABdhPJza7RqIj5H6rqDWWJ4iM9YhOVSQdm1iv6s2IZyJBp+LCNwB45innoD2LseObA7aumJwrMA9FQ== X-Received: by 2002:a17:902:aa02:b029:f0:cc19:faae with SMTP id be2-20020a170902aa02b02900f0cc19faaemr7918000plb.57.1622207635953; Fri, 28 May 2021 06:13:55 -0700 (PDT) Received: from dhcp-10-123-20-83.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id o2sm4238434pfu.80.2021.05.28.06.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 06:13:55 -0700 (PDT) From: Chandrakanth Patil To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Chandrakanth Patil Subject: [PATCH v3 2/5] megaraid_sas: Fix the resource leak in case of probe failure Date: Fri, 28 May 2021 18:43:04 +0530 Message-Id: <20210528131307.25683-3-chandrakanth.patil@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> References: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Driver doesn't cleanup all the allocated resources properly when scsi_add_host(),megasas_start_aen() function fails during the PCI device probe. This patch will cleanup all those resources. Signed-off-by: Chandrakanth Patil Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas_base.c | 13 +++++++++++++ drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 8ed347eebf07..35b2137e0d1a 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -7545,11 +7545,16 @@ static int megasas_probe_one(struct pci_dev *pdev, return 0; fail_start_aen: + instance->unload = 1; + scsi_remove_host(instance->host); fail_io_attach: megasas_mgmt_info.count--; megasas_mgmt_info.max_index--; megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL; + if (instance->requestorId && !instance->skip_heartbeat_timer_del) + del_timer_sync(&instance->sriov_heartbeat_timer); + instance->instancet->disable_intr(instance); megasas_destroy_irqs(instance); @@ -7557,8 +7562,16 @@ static int megasas_probe_one(struct pci_dev *pdev, megasas_release_fusion(instance); else megasas_release_mfi(instance); + if (instance->msix_vectors) pci_free_irq_vectors(instance->pdev); + instance->msix_vectors = 0; + + if (instance->fw_crash_state != UNAVAILABLE) + megasas_free_host_crash_buffer(instance); + + if (instance->adapter_type != MFI_SERIES) + megasas_fusion_stop_watchdog(instance); fail_init_mfi: scsi_host_put(host); fail_alloc_instance: diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index cd94a0c81f83..f79c19010c92 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -5272,6 +5272,7 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) if (!fusion->log_to_span) { dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__); + kfree(instance->ctrl_context); return -ENOMEM; } } From patchwork Fri May 28 13:13:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandrakanth Patil X-Patchwork-Id: 449806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 160D4C2B9F7 for ; Fri, 28 May 2021 13:14:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2075613EC for ; Fri, 28 May 2021 13:14:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235974AbhE1NPq (ORCPT ); Fri, 28 May 2021 09:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233711AbhE1NPp (ORCPT ); Fri, 28 May 2021 09:15:45 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D06AC061574 for ; Fri, 28 May 2021 06:14:10 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id u7so1619552plq.4 for ; Fri, 28 May 2021 06:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lJ+vhSTifZ67Y6OBEU2Ubh4NEYSQlr6F10hridOhSQg=; b=efPJnp3OAUh5Yv5Vzj1Hq3ADL8UnmYegwU3NpTpwoWMo2RHGNZpxO2XhI6NOuqdYhQ nd8oKA04wNOqst61ML+ow2gvjzwioLv1OH63eRuxabQ5pbiqCvVynFpu7/O1pavJrkHP NwfrLcrfJbDpaPCLi6uRVfG+8ibWCNniux6Tw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lJ+vhSTifZ67Y6OBEU2Ubh4NEYSQlr6F10hridOhSQg=; b=bb1R+RySroAcqLPAr5N9/FqyJk5YIaAjFgQJDFjZ6j8YfNdE/r3hBlds+xIvIiXK/P wEeq67DFEnbfcP0S/T+/+v8txvNxVnOd3yKkMRVZ70TyLNrsQPzD+F0lE8wDBWFfl9OA f4C/fs15Rt34822zAUw8Iv9Om4cTRPjnS/PWW3DjHWsHo7acIVRS8HO1bjT9cUF6wHG/ 6sXOhBQXikXGY3zNJBN1U1BRASCmMs0YM/4G4ccbY6uRbMACsQxLkSWvbn9m5ltYFgsd 8BZfWYrImZCE9RAiTjeTCSIMR+c32CO84uLaUUI2+9tubh+ISgCXuIcEGXZUmZ43Y+yW VN2w== X-Gm-Message-State: AOAM530MPkccPu8w2a2acZmeNhZax1Hmj+74O5kBoYGghsYo7pBwqJQ1 IcQp+IPN2pJi2up3gBuKElUSNCS3DKnlj7Mk+s/MxtGs0OhGpgwAJIkxR3QAecgJH06G4KfxZ1j XPjcPWt50JJZt3F+BjvPIHqHWBxvWJ6r2DN8qAVlC3sf5MO/3uRok5qHij7wnJK7/s+oXB6gLAa PZY5uABrx7eTIa744= X-Google-Smtp-Source: ABdhPJzh6/7iYzd2PdROWd8y9qRxt0y27bucLQXIuJRWQgz/OWBX3fF0qYpTkzPY0UbyLuRmaiRUUA== X-Received: by 2002:a17:902:d643:b029:ef:62cd:eeed with SMTP id y3-20020a170902d643b02900ef62cdeeedmr8130184plh.42.1622207649462; Fri, 28 May 2021 06:14:09 -0700 (PDT) Received: from dhcp-10-123-20-83.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id o2sm4238434pfu.80.2021.05.28.06.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 06:14:08 -0700 (PDT) From: Chandrakanth Patil To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Chandrakanth Patil , Tomas Henzl Subject: [PATCH v3 4/5] megaraid_sas: Handle missing interrupts while re-enabling IRQs Date: Fri, 28 May 2021 18:43:06 +0530 Message-Id: <20210528131307.25683-5-chandrakanth.patil@broadcom.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> References: <20210528131307.25683-1-chandrakanth.patil@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org While reenabling the IRQ after irq poll there may be a small window for the firmware to post the replies with interrupts raised. In that case, driver will not see the interrupts which lead to IOs timeout. This issue hits only when there is a high IOs completion on a single reply queue, which forces the driver to switch between the interrupt and IRQ context. To fix this, driver will process the reply queue one more time after enabling the IRQ. Link: https://lore.kernel.org/linux-scsi/20201102072746.27410-1-sreekanth.reddy@broadcom.com/ Cc: Tomas Henzl Reported-by: kernel test robot Signed-off-by: Chandrakanth Patil Signed-off-by: Sumit Saxena --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index f79c19010c92..142e60741094 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -3745,6 +3745,7 @@ static void megasas_sync_irqs(unsigned long instance_addr) if (irq_ctx->irq_poll_scheduled) { irq_ctx->irq_poll_scheduled = false; enable_irq(irq_ctx->os_irq); + complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); } } } @@ -3776,6 +3777,7 @@ int megasas_irqpoll(struct irq_poll *irqpoll, int budget) irq_poll_complete(irqpoll); irq_ctx->irq_poll_scheduled = false; enable_irq(irq_ctx->os_irq); + complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx); } return num_entries; @@ -3792,6 +3794,7 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) { struct megasas_instance *instance = (struct megasas_instance *)instance_addr; + struct megasas_irq_context *irq_ctx = NULL; u32 count, MSIxIndex; count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; @@ -3800,8 +3803,10 @@ megasas_complete_cmd_dpc_fusion(unsigned long instance_addr) if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) return; - for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++) - complete_cmd_fusion(instance, MSIxIndex, NULL); + for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++) { + irq_ctx = &instance->irq_context[MSIxIndex]; + complete_cmd_fusion(instance, MSIxIndex, irq_ctx); + } } /**