From patchwork Wed Feb 3 00:58: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: 8196651 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C4E819FBF9 for ; Wed, 3 Feb 2016 00:48:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCD50201ED for ; Wed, 3 Feb 2016 00:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC1C820211 for ; Wed, 3 Feb 2016 00:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754991AbcBCAsJ (ORCPT ); Tue, 2 Feb 2016 19:48:09 -0500 Received: from bby1mta03.pmc-sierra.com ([216.241.235.118]:58463 "EHLO bby1mta03.pmc-sierra.bc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751832AbcBCAsG (ORCPT ); Tue, 2 Feb 2016 19:48:06 -0500 Received: from bby1mta03.pmc-sierra.bc.ca (localhost.pmc-sierra.bc.ca [127.0.0.1]) by localhost (Postfix) with SMTP id AD5891070747; Tue, 2 Feb 2016 16:48:05 -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 bby1mta03.pmc-sierra.bc.ca (Postfix) with ESMTP id 7E8D210705CD; Tue, 2 Feb 2016 16:48:05 -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; Tue, 2 Feb 2016 16:48:04 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , , , , , , Subject: [PATCH V5 08/10] aacraid: Fix AIF triggered IOP_RESET Date: Tue, 2 Feb 2016 16:58:06 -0800 Message-ID: <1454461088-32482-9-git-send-email-RaghavaAditya.Renukunta@pmcs.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454461088-32482-1-git-send-email-RaghavaAditya.Renukunta@pmcs.com> References: <1454461088-32482-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=uYyWMRmmlsBc5Nc/4AoEgCcZaH/XGontrbSXJuMdmDE=; b=Uvw7T3MYrPmr/khCg/FoXITlr4cE5+GsYKf4bchYR2W+dYcpJ6TDcVeOH1BY/EOFB+RO9t6YcWIbpllEiSenDfAffWXz+jzhSd6V8oRDFukck69JF3ASlOHJ72MzjXJdqgdHvaZ0PuFKpetSnK5V/S2yVohhfo7M7n3P5meCMzM= 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 Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Shane Seymour Reviewed-by: Johannes Thumshirn Reviewed-by: Tomas Henzl --- drivers/scsi/aacraid/commctrl.c | 3 +++ drivers/scsi/aacraid/comminit.c | 6 ++++-- drivers/scsi/aacraid/linit.c | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 4d5f4e7..f6692d1 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -857,6 +857,9 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) mutex_lock(&dev->ioctl_mutex); + if (dev->adapter_shutdown) + return -EACCES; + /* * 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 5f08bcf..2c7405a 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -703,7 +703,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) static long aac_cfg_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown) + if (!capable(CAP_SYS_RAWIO)) return -EPERM; return aac_do_ioctl(file->private_data, cmd, (void __user *)arg); } @@ -1069,6 +1069,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 */ @@ -1080,7 +1082,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 ||