From patchwork Fri Nov 2 07:46:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 196496 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BB00A2C00F3 for ; Fri, 2 Nov 2012 18:47:19 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754248Ab2KBHq7 (ORCPT ); Fri, 2 Nov 2012 03:46:59 -0400 Received: from mail-da0-f46.google.com ([209.85.210.46]:43309 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754296Ab2KBHqz (ORCPT ); Fri, 2 Nov 2012 03:46:55 -0400 Received: by mail-da0-f46.google.com with SMTP id n41so1546133dak.19 for ; Fri, 02 Nov 2012 00:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=0C3dXIZ90uZsr4aIUQBbH5TQitof9DfzIml/muRvMTU=; b=YkVOcvJf28n7X89thJFbYEGZIgulERqfs5cLzrKfmWkKX84+kRNkylexH3veQCrJEk NQsYmNKjxw7afteIkVz0b+0cluQcTi1383tvm+Ik3Mp79DMjjR5Pf3/76XDaFIHFKeYW Bp2wbJifkDFNPBiPnKUeKcHgXiK010I0HrooRLfV7YDP0bBFjiY/hB/WDuhDxlNZ7ts/ pHtQoDDeaz4tpDIhGLQPBCSXS+QfH8OkCahnHSPi7b4NomiXENrVEi4ZRZMrFNNS70yI 1218AtnO9FI7OqJ8qzOWt7dE/XQkYQntnkvSnAEoITgs6uEZc0GxYzCVEYNic7S0ZD73 nGow== Received: by 10.68.244.135 with SMTP id xg7mr3674216pbc.87.1351842414859; Fri, 02 Nov 2012 00:46:54 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (pv141010.reshsg.uci.edu. [169.234.141.10]) by mx.google.com with ESMTPS id is6sm5365133pbc.55.2012.11.02.00.46.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Nov 2012 00:46:54 -0700 (PDT) From: Brian Norris To: Jeff Garzik Cc: , Brian Norris , Tejun Heo Subject: [PATCH 03/14] ahci_platform: perform platform exit in host_stop() hook Date: Fri, 2 Nov 2012 00:46:17 -0700 Message-Id: <1351842388-27210-4-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1351842388-27210-1-git-send-email-computersforpeace@gmail.com> References: <1351842388-27210-1-git-send-email-computersforpeace@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org AHCI platform devices may provide an exit() routine, via ahci_platform_data, that powers off the SATA core. Such a routine should be executed from the ata_port_operations host_stop() hook. That way, the ATA subsystem can perform any last-minute hardware cleanup (via devres, for example), then trigger the power-off at the appropriate time. This patch fixes bus errors triggered during module removal or device unbinding, seen on an SoC SATA core. Signed-off-by: Brian Norris --- drivers/ata/ahci_platform.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 8ae1c6f..05806e0 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -25,6 +25,8 @@ #include #include "ahci.h" +static void ahci_host_stop(struct ata_host *host); + enum ahci_type { AHCI, /* standard platform ahci */ IMX53_AHCI, /* ahci on i.mx53 */ @@ -47,6 +49,15 @@ static struct platform_device_id ahci_devtype[] = { }; MODULE_DEVICE_TABLE(platform, ahci_devtype); +struct ata_port_operations ahci_platform_ops = { + .inherits = &ahci_ops, + .host_stop = ahci_host_stop, +}; + +struct ata_port_operations ahci_platform_retry_srst_ops = { + .inherits = &ahci_pmp_retry_srst_ops, + .host_stop = ahci_host_stop, +}; static const struct ata_port_info ahci_port_info[] = { /* by features */ @@ -54,20 +65,20 @@ static const struct ata_port_info ahci_port_info[] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, [IMX53_AHCI] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_pmp_retry_srst_ops, + .port_ops = &ahci_platform_retry_srst_ops, }, [STRICT_AHCI] = { AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE), .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, }; @@ -221,12 +232,19 @@ free_clk: static int __devexit ahci_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ahci_platform_data *pdata = dev_get_platdata(dev); struct ata_host *host = dev_get_drvdata(dev); - struct ahci_host_priv *hpriv = host->private_data; ata_host_detach(host); + return 0; +} + +static void ahci_host_stop(struct ata_host *host) +{ + struct device *dev = host->dev; + struct ahci_platform_data *pdata = dev_get_platdata(dev); + struct ahci_host_priv *hpriv = host->private_data; + if (pdata && pdata->exit) pdata->exit(dev); @@ -234,8 +252,6 @@ static int __devexit ahci_remove(struct platform_device *pdev) clk_disable_unprepare(hpriv->clk); clk_put(hpriv->clk); } - - return 0; } #ifdef CONFIG_PM