From: Jeff Garzik <jgarzik@pobox.com>
To: Tejun Heo <htejun@gmail.com>
Cc: alan@lxorguk.ukuu.org.uk, mlord@pobox.com, albertcc@tw.ibm.com,
uchang@tw.ibm.com, forrest.zhao@intel.com,
linux-ide@vger.kernel.org
Subject: Re: [PATCH 02/17] libata: implement ata_host_set_detach() and ata_host_set_free()
Date: Wed, 09 Aug 2006 00:59:39 -0400 [thread overview]
Message-ID: <44D96BBB.6080005@pobox.com> (raw)
In-Reply-To: <115491984090-git-send-email-htejun@gmail.com>
Tejun Heo wrote:
> Implement and use ata_host_set_detach() and ata_host_set_free().
> ata_host_set_detach() detaches all ports in the host_set and
> supercedes ata_port_detach(). ata_host_set() makes sure all ports are
"ata_host_set()" ?
> stopped (LLDs may stop ports beforehand if necessary), frees all ports
> and the host_set itself. ata_host_set_free() can also be used in the
> error handling path of init functions.
>
> This patch moves several memory deallocations but doesn't introduce
> any real behavior changes.
>
> This is a part of efforts to improve [de-]init paths and simplify
> LLDs.
>
> Signed-off-by: Tejun Heo <htejun@gmail.com>
>
> ---
>
> drivers/scsi/ahci.c | 13 +++------
> drivers/scsi/libata-core.c | 66 +++++++++++++++++++++++++++++++++++---------
> include/linux/libata.h | 3 +-
> 3 files changed, 60 insertions(+), 22 deletions(-)
>
> 39d12c9f4e34b2c220deec0c2dc774f7db1a2f65
> diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
> index 305663b..980a63e 100644
> --- a/drivers/scsi/ahci.c
> +++ b/drivers/scsi/ahci.c
> @@ -1634,30 +1634,27 @@ static void ahci_remove_one (struct pci_
> struct device *dev = pci_dev_to_dev(pdev);
> struct ata_host_set *host_set = dev_get_drvdata(dev);
> struct ahci_host_priv *hpriv = host_set->private_data;
> - unsigned int i;
> int have_msi;
>
> - for (i = 0; i < host_set->n_ports; i++)
> - ata_port_detach(host_set->ports[i]);
> + ata_host_set_detach(host_set);
>
> have_msi = hpriv->flags & AHCI_FLAG_MSI;
> free_irq(host_set->irq, host_set);
>
> ata_host_set_stop(host_set);
> -
> - for (i = 0; i < host_set->n_ports; i++)
> - scsi_host_put(host_set->ports[i]->host);
> - kfree(hpriv);
> pci_iounmap(pdev, host_set->mmio_base);
> - kfree(host_set);
>
> if (have_msi)
> pci_disable_msi(pdev);
> else
> pci_intx(pdev, 0);
> +
> pci_release_regions(pdev);
> pci_disable_device(pdev);
> dev_set_drvdata(dev, NULL);
> +
> + ata_host_set_free(host_set);
> + kfree(hpriv);
> }
>
> static int __init ahci_init(void)
> diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
> index b3cc2f5..f8d6bc0 100644
> --- a/drivers/scsi/libata-core.c
> +++ b/drivers/scsi/libata-core.c
> @@ -5554,11 +5554,7 @@ int ata_device_add(const struct ata_prob
> err_out_free_irq:
> free_irq(ent->irq, host_set);
> err_out:
> - ata_host_set_stop(host_set);
> -
> - for (i = 0; i < host_set->n_ports; i++)
> - scsi_host_put(host_set->ports[i]->host);
> - kfree(host_set);
> + ata_host_set_free(host_set);
> VPRINTK("EXIT, returning 0\n");
> return 0;
> }
> @@ -5574,7 +5570,7 @@ err_out:
> * LOCKING:
> * Kernel thread context (may sleep).
> */
> -void ata_port_detach(struct ata_port *ap)
> +static void ata_port_detach(struct ata_port *ap)
> {
> unsigned long flags;
> int i;
> @@ -5656,6 +5652,53 @@ void ata_host_set_stop(struct ata_host_s
> }
>
> /**
> + * ata_host_set_detach - Detach a host_set from the system
> + * @host_set: ATA host set that was removed
> + *
> + * Detach all objects associated with this host set.
> + *
> + * LOCKING:
> + * Inherited from calling layer (may sleep).
> + */
> +void ata_host_set_detach(struct ata_host_set *host_set)
> +{
> + int i;
> +
> + for (i = 0; i < host_set->n_ports; i++)
> + ata_port_detach(host_set->ports[i]);
> +}
> +
> +/**
> + * ata_host_set_free - Release a host_set
> + * @host_set: ATA host set to be freed
> + *
> + * Free all objects associated with this host set.
> + *
> + * LOCKING:
> + * Inherited from calling layer (may sleep).
> + */
> +void ata_host_set_free(struct ata_host_set *host_set)
> +{
> + int i;
> +
> + /* free(NULL) is supported */
> + if (!host_set)
> + return;
> +
> + /* make sure it's stopped */
> + ata_host_set_stop(host_set);
> +
> + /* free */
> + for (i = 0; i < host_set->n_ports; i++) {
> + struct ata_port *ap = host_set->ports[i];
> + if (ap)
> + scsi_host_put(ap->host);
for SAS this might need to be
if (ap && ap->host)
otherwise OK
next prev parent reply other threads:[~2006-08-09 5:00 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-07 3:03 [PATCHSET] libata: implement new initialization model w/ iomap support Tejun Heo
2006-08-07 3:04 ` [PATCH 05/17] libata: implement PCI init helpers for new LLD init model Tejun Heo
2006-08-09 5:11 ` Jeff Garzik
2006-08-09 5:52 ` Tejun Heo
2006-08-09 6:41 ` Jeff Garzik
2006-08-09 11:00 ` Alan Cox
2006-08-10 7:12 ` Albert Lee
2006-08-10 7:27 ` Jeff Garzik
2006-08-10 12:36 ` Alan Cox
2006-08-10 12:22 ` Tejun Heo
2006-08-09 12:54 ` Mark Lord
2006-08-09 11:02 ` Alan Cox
2006-08-09 11:13 ` Tejun Heo
2006-08-07 3:04 ` [PATCH 04/17] libata: implement several LLD init helpers Tejun Heo
2006-08-09 5:01 ` Jeff Garzik
2006-08-09 5:08 ` Tejun Heo
2006-08-07 3:04 ` [PATCH 03/17] libata: separate out ata_host_set_alloc() and ata_host_set_attach() Tejun Heo
2006-08-09 5:00 ` Jeff Garzik
2006-08-07 3:04 ` [PATCH 01/17] libata: implement ata_host_set_start/stop() Tejun Heo
2006-08-09 4:57 ` Jeff Garzik
2006-08-07 3:04 ` [PATCH 02/17] libata: implement ata_host_set_detach() and ata_host_set_free() Tejun Heo
2006-08-09 4:59 ` Jeff Garzik [this message]
2006-08-07 3:04 ` [PATCH 06/17] libata: reimplement ata_pci_init_one() using new init helpers Tejun Heo
2006-08-07 3:04 ` [PATCH 13/17] libata: move ->irq_handler from port_ops to port_info Tejun Heo
2006-08-07 3:04 ` [PATCH 12/17] libata: use LLD name where possible Tejun Heo
2006-08-07 3:04 ` [PATCH 11/17] libata: kill unused ->host_stop() operation and related functions Tejun Heo
2006-08-07 3:04 ` [PATCH 08/17] libata: update ata_pci_remove_one() using new PCI init helpers Tejun Heo
2006-08-07 3:04 ` [PATCH 09/17] libata: use remove_one() for deinit instead of ->host_stop() Tejun Heo
2006-08-07 3:04 ` [PATCH 10/17] libata: kill old init helpers Tejun Heo
2006-08-07 3:04 ` [PATCH 14/17] libata: make ata_host_set_alloc() take care of hpriv alloc/free Tejun Heo
2006-08-07 3:04 ` [PATCH 15/17] libata: make ata_pci_acquire_resources() handle iomap Tejun Heo
2006-08-07 3:04 ` [PATCH 17/17] libata: kill unused ATA_FLAG_MMIO Tejun Heo
2006-08-07 3:08 ` [git-patches] libata: implement new initialization model w/ iomap support Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44D96BBB.6080005@pobox.com \
--to=jgarzik@pobox.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertcc@tw.ibm.com \
--cc=forrest.zhao@intel.com \
--cc=htejun@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=mlord@pobox.com \
--cc=uchang@tw.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).