Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1165919ybf; Thu, 27 Feb 2020 06:12:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzhuIM2QfuL/2p73Gr2h6BTijh4oTQdZdCftX2jzQKaEGurdayy0EYqqTRb3tRLzesOIbwv X-Received: by 2002:aca:49cd:: with SMTP id w196mr3313735oia.15.1582812746340; Thu, 27 Feb 2020 06:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582812746; cv=none; d=google.com; s=arc-20160816; b=ScgBYVeVX/qyKbTJQ9WYvygios9gXuSPefhYEKz9IyA5INPF6qi5aPQpZTI7Fk0QfZ A3U+GH+BftTMYQtxbAr73CCxJOR005+obxqBDLJnEXvVXFXNnHV9JkXhvf/RuBVXEpRq WbeXagYNPJF4dI+pfQWmmwDoBnWA0yUFk6JOa4tvJdI53zg2XTxAs9D9bjhp1y3OAV35 tRCxDMfWol75Tp2uOwmcnafLTVH4RemNPA8kJWrGm3+ZdwexDXyHMWaAP62PPlFs35xm 7YJiFtn3hj/Sy7t3x0eBTbgFsigbbUpdf+xaa/ixFQ7eSsZVZGGl8ApSz1SBIWVK0Ymr iRDQ== 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=oZN7r1sLeROmm4uVN+QJX1T0CO7GYcClPhfQ4B0AKFo=; b=Boucz5GGeyFsVO0gWORznHYRojEdj9RWIadG4WbcbFNDhlEqV9TOMjOVV+M/5MraQ0 SRFKNkPO7geLSjJ6rVPaadB3Nkz70M7yyigh+iuGmTp14BRKMcyXw6fVuLuH4raLVXh+ OptwgSGqkQDgA2zVZSUl7KyrOEkLcU2RKHxERv39ebMzFXqA/c7shVzuanTnj4m4e+SI wzGAYRDBIr69hfBZSh29Nu+3/V3L5reI7bGIVVaxLgjw3ZIqtgLIc6sENJMqAbcUNg83 vlSOiLlnEdS2J65vnobyaqZC6THmjea2w2pRghejT2VQfnEt7iUf7fy7Tj5I09C1YC8n XuRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="rjocaSb/"; 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 a5si1476345oti.22.2020.02.27.06.12.11; Thu, 27 Feb 2020 06:12:26 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="rjocaSb/"; 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 S2388526AbgB0OMI (ORCPT + 99 others); Thu, 27 Feb 2020 09:12:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:50768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388052AbgB0OMH (ORCPT ); Thu, 27 Feb 2020 09:12:07 -0500 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 F3C3824697; Thu, 27 Feb 2020 14:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812726; bh=63t+dcbRQP2Tl3GMNI+Ooh16wCL0rbWIF1ffSXgbeIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjocaSb/0yQirVVCHFGln3VQzdgMm2yavZIjq1k1qGkwhICVBn6QwUF4kDTACqTgf pPCVbPqckVvsbNojnIMaHAJcgGwvXGlIx6BMqpL+kLneb8Ove2+yaH1auJDWBQmxTj CI5kGkBmO9eRUsjJ+17cUUmVFFVYOcDYekjlO424= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prabhakar Kushwaha , Jens Axboe Subject: [PATCH 5.4 128/135] ata: ahci: Add shutdown to freeze hardware resources of ahci Date: Thu, 27 Feb 2020 14:37:48 +0100 Message-Id: <20200227132248.298321023@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132228.710492098@linuxfoundation.org> References: <20200227132228.710492098@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: Prabhakar Kushwaha commit 10a663a1b15134a5a714aa515e11425a44d4fdf7 upstream. device_shutdown() called from reboot or power_shutdown expect all devices to be shutdown. Same is true for even ahci pci driver. As no ahci shutdown function is implemented, the ata subsystem always remains alive with DMA & interrupt support. File system related calls should not be honored after device_shutdown(). So defining ahci pci driver shutdown to freeze hardware (mask interrupt, stop DMA engine and free DMA resources). Signed-off-by: Prabhakar Kushwaha Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/ata/ahci.c | 7 +++++++ drivers/ata/libata-core.c | 21 +++++++++++++++++++++ include/linux/libata.h | 1 + 3 files changed, 29 insertions(+) --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -80,6 +80,7 @@ enum board_ids { static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); static void ahci_remove_one(struct pci_dev *dev); +static void ahci_shutdown_one(struct pci_dev *dev); static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, unsigned long deadline); static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, @@ -593,6 +594,7 @@ static struct pci_driver ahci_pci_driver .id_table = ahci_pci_tbl, .probe = ahci_init_one, .remove = ahci_remove_one, + .shutdown = ahci_shutdown_one, .driver = { .pm = &ahci_pci_pm_ops, }, @@ -1864,6 +1866,11 @@ static int ahci_init_one(struct pci_dev return 0; } +static void ahci_shutdown_one(struct pci_dev *pdev) +{ + ata_pci_shutdown_one(pdev); +} + static void ahci_remove_one(struct pci_dev *pdev) { pm_runtime_get_noresume(&pdev->dev); --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6762,6 +6762,26 @@ void ata_pci_remove_one(struct pci_dev * ata_host_detach(host); } +void ata_pci_shutdown_one(struct pci_dev *pdev) +{ + struct ata_host *host = pci_get_drvdata(pdev); + int i; + + for (i = 0; i < host->n_ports; i++) { + struct ata_port *ap = host->ports[i]; + + ap->pflags |= ATA_PFLAG_FROZEN; + + /* Disable port interrupts */ + if (ap->ops->freeze) + ap->ops->freeze(ap); + + /* Stop the port DMA engines */ + if (ap->ops->port_stop) + ap->ops->port_stop(ap); + } +} + /* move to PCI subsystem */ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) { @@ -7382,6 +7402,7 @@ EXPORT_SYMBOL_GPL(ata_timing_cycle2mode) #ifdef CONFIG_PCI EXPORT_SYMBOL_GPL(pci_test_config_bits); +EXPORT_SYMBOL_GPL(ata_pci_shutdown_one); EXPORT_SYMBOL_GPL(ata_pci_remove_one); #ifdef CONFIG_PM EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1220,6 +1220,7 @@ struct pci_bits { }; extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); +extern void ata_pci_shutdown_one(struct pci_dev *pdev); extern void ata_pci_remove_one(struct pci_dev *pdev); #ifdef CONFIG_PM