Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759368AbaD3SXG (ORCPT ); Wed, 30 Apr 2014 14:23:06 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:46942 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759057AbaD3SXD (ORCPT ); Wed, 30 Apr 2014 14:23:03 -0400 X-AuditID: cbfee61a-b7f2b6d000006c4d-c2-53613f85a06f From: Bartlomiej Zolnierkiewicz To: Levente Kurusa Cc: Tejun Heo , LKML , Linux ATA/IDE , Joe Thomas Subject: Re: [PATCH] ahci: unregister acpi notify handler when a ZPODD is unbound Date: Wed, 30 Apr 2014 20:22:31 +0200 Message-id: <1414277.0ei2d0Yjc1@amdc1032> User-Agent: KMail/4.8.4 (Linux/3.2.0-54-generic-pae; KDE/4.8.5; i686; ; ) In-reply-to: <1398873887-23920-1-git-send-email-levex@linux.com> References: <1398873887-23920-1-git-send-email-levex@linux.com> MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=ISO-8859-1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsVy+t9jAd1W+8Rgg78z1C0ObHnGaLG04y27 xbEdj5gsLu+aw2bxa/lRRgdWj9aLcR6bVnWyeTy5Mp3J4/MmuQCWKC6blNSczLLUIn27BK6M 6cduMBbslqrYOHs9UwPjLNEuRg4OCQETiSsn5boYOYFMMYkL99azdTFycQgJLGKU2PPoKRNI QkighUliUVs2iM0mYCUxsX0VI0iviICKxIWt6iD1zAJTGCXOLXrMDFIjLBAscXXXVzCbRUBV 4teP9+wgNq+ApsTfp3tYQWxRAU+JHdtXsoHYnAIOEg8WbGGF2GUvsfjJT1aIekGJH5PvsYDY zALyEvv2T2WFsHUk9rdOY5vAKDALSdksJGWzkJQtYGRexSiaWpBcUJyUnmuoV5yYW1yal66X nJ+7iREcws+kdjCubLA4xCjAwajEwzuBLTFYiDWxrLgy9xCjBAezkgjv0X8JwUK8KYmVValF +fFFpTmpxYcYpTlYlMR5D7RaBwoJpCeWpGanphakFsFkmTg4pRoYV+uUvVzVJ/6ZITFl6oYL nQ++vV72uyNObk6TRPxPbjv7f5a3dIr5M3P2Ptq4tvLV+X+LDYyNbaP+N3Wq5iU/3uaW49u6 LXyd24uJ+nNEnnUuL3JQVd7/ap23WXXpEg6bK5s21E+4NNVqsqrY6wcNfcdbWGfIxxnNyrVk W/aE/aA/Y++Z74lblViKMxINtZiLihMBVAMEEl0CAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wednesday, April 30, 2014 06:04:47 PM Levente Kurusa wrote: > When a ZPODD device is unbound via sysfs, the acpi notify handler > is not removed. This causes panics as observed in Bug #74601. The > panic only happens when the wake happens from outside the kernel > (i.e. inserting media or pressing a button). Implement a new > ahci_remove_one function which causes zpodd_exit to be called for all > ZPODD devices on the unbound PCI device. > > Signed-off-by: Levente Kurusa > --- > > Hi, > > I am not sure if the loop below is correct. Maybe there is a better > solution to loop through all the devices which might use ZPODD? > > Thanks, Lev. > > drivers/ata/ahci.c | 21 +++++++++++++++++++++ > drivers/ata/ahci.h | 4 ++++ > drivers/ata/libata-zpodd.c | 1 + > 3 files changed, 26 insertions(+) > > diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c > index 5a0bf8e..6d92bc9 100644 > --- a/drivers/ata/ahci.c > +++ b/drivers/ata/ahci.c > @@ -475,12 +475,33 @@ static const struct pci_device_id ahci_pci_tbl[] = { > { } /* terminate list */ > }; > > +#ifdef CONFIG_SATA_ZPODD > +void ahci_remove_one(struct pci_dev *pdev) > +{ > + struct ata_host *host = pci_get_drvdata(pdev); > + struct ata_link *link; > + struct ata_device *dev; > + int i; > + > + for (i = 0; i < host->n_ports; i++) > + ata_for_each_link(link, host->ports[i], HOST_FIRST) > + ata_for_each_dev(dev, link, ALL) > + if (dev->zpodd) > + zpodd_exit(dev); zpodd_init() is used in generic libata library code, same should be true for zpodd_exit(). Ideally, you should find some libata library function called from ata_pci_remove_one() suitable for this purpose. Hmm, actually zpodd_exit() is already used in ata_scsi_handle_link_detach() so this should also be taken into consideration.. > + ata_pci_remove_one(pdev); > +} > +#endif > > static struct pci_driver ahci_pci_driver = { > .name = DRV_NAME, > .id_table = ahci_pci_tbl, > .probe = ahci_init_one, > +#ifdef CONFIG_SATA_ZPODD > + .remove = ahci_remove_one, > +#else > .remove = ata_pci_remove_one, > +#endif > #ifdef CONFIG_PM > .suspend = ahci_pci_device_suspend, > .resume = ahci_pci_device_resume, > diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h > index 51af275..87e4e6d 100644 > --- a/drivers/ata/ahci.h > +++ b/drivers/ata/ahci.h > @@ -383,6 +383,10 @@ void ahci_print_info(struct ata_host *host, const char *scc_s); > int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis); > void ahci_error_handler(struct ata_port *ap); > > +#ifdef CONFIG_SATA_ZPODD > +extern void zpodd_exit(struct ata_device *dev); > +#endif /* CONFIG_SATA_ZPODD */ > + > static inline void __iomem *__ahci_port_base(struct ata_host *host, > unsigned int port_no) > { > diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c > index f3a65a3..fe66949 100644 > --- a/drivers/ata/libata-zpodd.c > +++ b/drivers/ata/libata-zpodd.c > @@ -281,3 +281,4 @@ void zpodd_exit(struct ata_device *dev) > kfree(dev->zpodd); > dev->zpodd = NULL; > } > +EXPORT_SYMBOL_GPL(zpodd_exit); Then you would also not need to export zpodd_exit().. Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/