Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp8728ybt; Tue, 23 Jun 2020 13:53:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfnOSxLs7UI0HJQxSo0knydkXYNOPCfJVXFas1kfznhYSasvy6cHhPVGS7GhBeLPDx+duW X-Received: by 2002:a17:906:1149:: with SMTP id i9mr23014125eja.100.1592945598276; Tue, 23 Jun 2020 13:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945598; cv=none; d=google.com; s=arc-20160816; b=w/agYO1RcXX0/jemiUyA0oUGw75yi4lclR8sXwlej/6GGvVAisFaRB4vNJ3Q343J0a ax7AU8+a1ElWT5OJhHuBEPAJNWW5JE+LNoXkhsk52XD6ZJBwtFmm9HgROfzuje6kkkkv oNqgIpgo7WTz8AE0osJfzH+QJ+pubEclLKaAg5qBMsxRgonbesRtd5DLjsXYVfTipkS/ DzlbYtxdu4hzUz8cHKLEb6yc39ymvU/ElJiOYopfkuyQhistoORAIrZf4YUUvyuUfm40 ZYCpkvoIVq4JVo80NfqrqTqEEFWn6Fa14mbYREecIpRO+XEOcM7pnLs2Q8GEe+JdZBGO EsFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bcaqi+n/opyeU4wsR/DXWWoQmQL8dbw16rVVNXp45tM=; b=BMvYa6B1GeMZtl1DdCyTkMLPie5kjiUJ75UHFMpjGok4YfdagskPL2nRGgqTHJBTqI h9Fq392oB//9k4BveDCqNLgT4+7lUhXHfKtq4PmanXH6qJuWcEbRQT0De1yt1oUU4hki G4bdwZiiWDOoq1rNYEXlTTI2arjKDajYkB8HJXB6pJ/I+Q+r8IAa0xUSA3D+nso3Om0+ AB3gHlAekbsBK6f1BFGEoPJdR1wy0pX9YRrsizFMEhfKZ58W2RQFzwbOfqg8zP1Bpr90 UMqDwYieVfzu3p+etADcw+ZmBau/KZSQKWcPvsJLgCWi+Cj5YZly7Yh0a+ifQ9ZcCIVk bxRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AkXO041n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si12021797ejz.569.2020.06.23.13.52.54; Tue, 23 Jun 2020 13:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AkXO041n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392456AbgFWUve (ORCPT + 99 others); Tue, 23 Jun 2020 16:51:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404089AbgFWUsA (ORCPT ); Tue, 23 Jun 2020 16:48:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45CAD20781; Tue, 23 Jun 2020 20:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945280; bh=9JfGyIO+8KFIailyOcCU39lQSbxxXvYSoDyUkehv/Jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AkXO041nlBTL3ILop9qQyawz4kiAnK3B3BFOwqx34FOoofUdORDBlv69lS5NFlLVJ XKsI9Gv4+kRFPm9WevQjSidW1rpVUhYLAyvizCDECey1eJA40NmM7e/6x5D8OeLQdb x2ABOrNDbaaMD48Kr0mECQYvfkjz07xtmf4RLwVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , Kai-Heng Feng , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 110/136] libata: Use per port sync for detach Date: Tue, 23 Jun 2020 21:59:26 +0200 Message-Id: <20200623195309.208905092@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai-Heng Feng [ Upstream commit b5292111de9bb70cba3489075970889765302136 ] Commit 130f4caf145c ("libata: Ensure ata_port probe has completed before detach") may cause system freeze during suspend. Using async_synchronize_full() in PM callbacks is wrong, since async callbacks that are already scheduled may wait for not-yet-scheduled callbacks, causes a circular dependency. Instead of using big hammer like async_synchronize_full(), use async cookie to make sure port probe are synced, without affecting other scheduled PM callbacks. Fixes: 130f4caf145c ("libata: Ensure ata_port probe has completed before detach") Suggested-by: John Garry Signed-off-by: Kai-Heng Feng Tested-by: John Garry BugLink: https://bugs.launchpad.net/bugs/1867983 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/ata/libata-core.c | 11 +++++------ include/linux/libata.h | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 33eb5e342a7a9..a3a65f5490c02 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -6536,7 +6535,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) /* perform each probe asynchronously */ for (i = 0; i < host->n_ports; i++) { struct ata_port *ap = host->ports[i]; - async_schedule(async_port_probe, ap); + ap->cookie = async_schedule(async_port_probe, ap); } return 0; @@ -6676,11 +6675,11 @@ void ata_host_detach(struct ata_host *host) { int i; - /* Ensure ata_port probe has completed */ - async_synchronize_full(); - - for (i = 0; i < host->n_ports; i++) + for (i = 0; i < host->n_ports; i++) { + /* Ensure ata_port probe has completed */ + async_synchronize_cookie(host->ports[i]->cookie + 1); ata_port_detach(host->ports[i]); + } /* the host is dead now, dissociate ACPI */ ata_acpi_dissociate(host); diff --git a/include/linux/libata.h b/include/linux/libata.h index 93838d98e3f38..5c9a44e3a0278 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -38,6 +38,7 @@ #include #include #include +#include /* * Define if arch has non-standard setup. This is a _PCI_ standard @@ -884,6 +885,8 @@ struct ata_port { struct timer_list fastdrain_timer; unsigned long fastdrain_cnt; + async_cookie_t cookie; + int em_message_type; void *private_data; -- 2.25.1