Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2274490imm; Thu, 7 Jun 2018 08:03:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIwEV7SWKDGE5XMKCf5ivvL+8pehwkNId9Dxl4xUIMbZbmJIGx4C4PI3fqa9wF65IA96zbk X-Received: by 2002:a17:902:6546:: with SMTP id d6-v6mr2438161pln.196.1528383812318; Thu, 07 Jun 2018 08:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383812; cv=none; d=google.com; s=arc-20160816; b=D+IXdUZKAyUDx4rka0Hu3JYba5Q4PYOxcfy1rQXZa8FK/VFadnOkD1b5Au3vEMnWAb /UYNta6TGfNCBsnBhGbyLqA7Hr1CSC+rJeRAxyTiVCUu52PfZlY0Q1z8kdJK8EsAQ1WZ usnxeV6P5U2d3vudAqVCPWIanSrH+ElhEh1k9kAW7SQRLdMz1q7VpksaPzu8ejOd2wn8 3RqYtwlh7jVfBL8ZZtiWQtXRwArs72+6PXEduiORTpa0T0z+h5SaqPmAi661ACwqYLp4 5sByy9fS9uPj8IIxRzhyNMAq5UwTcKC1Fg9hiO2VLzDo71Hhbj7c7S2YQfmJhe0v/k4D 91ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=vWNMb4PtlSUoFdOO82e3d1D6u8xo7soPs9d0bWN6HME=; b=VF1UGLXQxAD7oQ2fzzb8/dKxn20IwK8rV+wwECN6nwCyK/Bl14F5yBkb9CY6pw319C vQ9pjA2S0KMQ0CRKgK3FXkVW5VAaYdYocBt+PhM88oCwmlMehFg0KK9wZM8FGEKoJtqt KEe0kYbZ2AKvQJlKMIW3zLV8dQiZZDIbqHINgYz3JoBtKsXFJVLrCh2+MfDb1qC24e9o m+gSIoysjU1+wkpAy3p+c7ShyRlqAjRPDIuFYp1dPJFSwRwerhcOLs31gRNyiIt8+1Zh /Cmt0HqACD+G0CXE+1mqe0RnDpRTB1ffHCWncaGcNMrhQEzHgNt/hGBf98/oGfknycC+ TkMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18-v6si53489877pfd.357.2018.06.07.08.03.17; Thu, 07 Jun 2018 08:03:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935888AbeFGPCC (ORCPT + 99 others); Thu, 7 Jun 2018 11:02:02 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41423 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935339AbeFGPB4 (ORCPT ); Thu, 7 Jun 2018 11:01:56 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbU-0005dI-8N; Thu, 07 Jun 2018 15:09:28 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbB-0003B8-8A; Thu, 07 Jun 2018 15:09:09 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Tejun Heo" , "Jason Yan" , "Ding Xiang" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 318/410] ata: do not schedule hot plug if it is a sas host In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jason Yan commit 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad upstream. We've got a kernel panic when using sata disk with sas controller: [115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8 [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G W OEL 4.14.0 #1 [115946.232925] Workqueue: events ata_scsi_hotplug [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000 [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114 [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114 ...... [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000) [115946.363369] Call trace: [115946.456356] [] sas_find_dev_by_rphy+0x44/0x114 [115946.462908] [] sas_target_alloc+0x20/0x5c [115946.469408] [] scsi_alloc_target+0x250/0x308 [115946.475781] [] __scsi_add_device+0xb0/0x154 [115946.481991] [] ata_scsi_scan_host+0x180/0x218 [115946.488367] [] ata_scsi_hotplug+0xb0/0xcc [115946.494801] [] process_one_work+0x144/0x390 [115946.501115] [] worker_thread+0x144/0x418 [115946.507093] [] kthread+0x10c/0x138 [115946.512792] [] ret_from_fork+0x10/0x18 We found that Ding Xiang has reported a similar bug before: https://patchwork.kernel.org/patch/9179817/ And this bug still exists in mainline. Since libsas handles hotplug and device adding/removing itself, do not need to schedule ata hot plug task here if it is a sas host. Signed-off-by: Jason Yan Cc: Ding Xiang Signed-off-by: Tejun Heo Signed-off-by: Ben Hutchings --- drivers/ata/libata-eh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(struct if (ap->pflags & ATA_PFLAG_LOADING) ap->pflags &= ~ATA_PFLAG_LOADING; - else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) + else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && + !(ap->flags & ATA_FLAG_SAS_HOST)) schedule_delayed_work(&ap->hotplug_task, 0); if (ap->pflags & ATA_PFLAG_RECOVERED)