From patchwork Wed Feb 3 23:06:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 8210881 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 64CADBEEE5 for ; Wed, 3 Feb 2016 22:56:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69A9D2022A for ; Wed, 3 Feb 2016 22:56:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16235202F8 for ; Wed, 3 Feb 2016 22:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757159AbcBCW4I (ORCPT ); Wed, 3 Feb 2016 17:56:08 -0500 Received: from bby1mta02.pmc-sierra.com ([216.241.235.117]:38075 "EHLO bby1mta02.pmc-sierra.bc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756695AbcBCW4C (ORCPT ); Wed, 3 Feb 2016 17:56:02 -0500 Received: from bby1mta02.pmc-sierra.bc.ca (localhost.pmc-sierra.bc.ca [127.0.0.1]) by localhost (Postfix) with SMTP id 531CC8E04CA; Wed, 3 Feb 2016 14:56:02 -0800 (PST) Received: from smtp.pmcs.com (bby1cas02.pmc-sierra.internal [216.241.227.143]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by bby1mta02.pmc-sierra.bc.ca (Postfix) with ESMTP id 346608E04C1; Wed, 3 Feb 2016 14:56:02 -0800 (PST) Received: from localhost (216.241.227.4) by bby1cas02.pmc-sierra.internal (216.241.227.143) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 3 Feb 2016 14:56:02 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , , , , , , Subject: [PATCH V6 08/10] aacraid: Fix AIF triggered IOP_RESET Date: Wed, 3 Feb 2016 15:06:06 -0800 Message-ID: <1454540768-12271-9-git-send-email-RaghavaAditya.Renukunta@pmcs.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454540768-12271-1-git-send-email-RaghavaAditya.Renukunta@pmcs.com> References: <1454540768-12271-1-git-send-email-RaghavaAditya.Renukunta@pmcs.com> MIME-Version: 1.0 X-Originating-IP: [216.241.227.4] DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmcs.com; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-type; s=default; bh=nPeNPFYxy1w5P2W2SzYjYW/fB8Pw6tftSl4MuhWwl9I=; b=R3d4CsOqFq+Mead1HYHO6kNLhsiSbd52G9nY46PsHfoGK2T2BL82EB93hEJZmWKWGTJHMdsE4itd/2+KDApd+HXVsOSnfgLcSb0kDZ6XoHplMk85mnUgvTScbApaVgmd+FfEy/bhx+irG/bsTn3rd9IyBAuIf41cu5kPidEu3IM= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Raghava Aditya Renukunta while driver removal is in progress or PCI shutdown is invoked, driver kills AIF aacraid thread, but IOCTL requests from the management tools re-start AIF thread leading to IOP_RESET. Fixed by setting adapter_shutdown flag when PCI shutdown is invoked. Changes in V2: Set adapter_shutdown flag before shutdown command is sent to \ controller Changes in V3: Call aac_send_shut_shutdown first thing in __aac_shutdown Convert adapter_shutdown to atomic_t variable to prevent \ SMP coherency issues(race conditions) Changes in V4: Used mutex to protect ioctl path and adapter_shutdown to prevent \ race conditions. Changes in V5: Moved replacement of aac_mutex with ioctl_mutex to previous patch Changes in V6: Unlock ioctl_mutex if adpater_shutdown is set Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Shane Seymour Reviewed-by: Johannes Thumshirn Reviewed-by: Tomas Henzl --- drivers/scsi/aacraid/commctrl.c | 5 +++++ drivers/scsi/aacraid/comminit.c | 6 ++++-- drivers/scsi/aacraid/linit.c | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index ebf214b..4b3bb52 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -857,6 +857,11 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) mutex_lock(&dev->ioctl_mutex); + if (dev->adapter_shutdown) { + status = -EACCES; + goto cleanup; + } + /* * HBA gets first crack */ diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 0e954e3..2b4e753 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -212,8 +212,11 @@ int aac_send_shutdown(struct aac_dev * dev) return -ENOMEM; aac_fib_init(fibctx); - cmd = (struct aac_close *) fib_data(fibctx); + mutex_lock(&dev->ioctl_mutex); + dev->adapter_shutdown = 1; + mutex_unlock(&dev->ioctl_mutex); + cmd = (struct aac_close *) fib_data(fibctx); cmd->command = cpu_to_le32(VM_CloseAll); cmd->cid = cpu_to_le32(0xfffffffe); @@ -229,7 +232,6 @@ int aac_send_shutdown(struct aac_dev * dev) /* FIB should be freed only after getting the response from the F/W */ if (status != -ERESTARTSYS) aac_fib_free(fibctx); - dev->adapter_shutdown = 1; if ((dev->pdev->device == PMC_DEVICE_S7 || dev->pdev->device == PMC_DEVICE_S8 || dev->pdev->device == PMC_DEVICE_S9) && diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 3f9c741..334f2a6 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -705,7 +705,7 @@ static long aac_cfg_ioctl(struct file *file, { struct aac_dev *aac = (struct aac_dev *)file->private_data; - if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown) + if (!capable(CAP_SYS_RAWIO)) return -EPERM; return aac_do_ioctl(aac, cmd, (void __user *)arg); @@ -1072,6 +1072,8 @@ static void __aac_shutdown(struct aac_dev * aac) int i; int cpu; + aac_send_shutdown(aac); + if (aac->aif_thread) { int i; /* Clear out events first */ @@ -1083,7 +1085,6 @@ static void __aac_shutdown(struct aac_dev * aac) } kthread_stop(aac->thread); } - aac_send_shutdown(aac); aac_adapter_disable_int(aac); cpu = cpumask_first(cpu_online_mask); if (aac->pdev->device == PMC_DEVICE_S6 ||