linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian King <brking@us.ibm.com>
To: Tejun Heo <htejun@gmail.com>
Cc: jgarzik@pobox.com, 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: [PATCHSET] libata: implement new initialization model w/ iomap support, take 2
Date: Wed, 30 Aug 2006 15:58:10 -0500	[thread overview]
Message-ID: <44F5FBE2.3030201@us.ibm.com> (raw)
In-Reply-To: <44F16FF8.7010706@gmail.com>

Tejun Heo wrote:
> Brian King wrote:
>> The idea of a static number of "ata ports" per ata host in SAS doesn't
>> really work. Since you can have ATA devices under a SAS expander, the
>> number of possible ATA devices that can be attached to a SAS adapter
>> can be rather large and can change depending on the SAS fabric. If libata
>> ever needed to iterate over the ata_port's for a SAS ata_host, then we would
>> probably need to convert the static array of ata_ports to a linked
>> list, allowing it to be more dynamic.
> 
> Making the array dynamically-sized isn't difficult at all; however, the 
> current libata code assumes that ata_host->ports[] array is packed - ie. 
> no intervening empty entry.  Can SAS keep this restriction or does it 
> need more flexibility?

This could be made to work with the addition of a new API. Rather than
having just ata_sas_port_destroy, we would need ata_sas_port_delete
and ata_sas_port_free. ata_sas_port_delete would remove the port from
the ata_host and do everything except free the ata port since there
could still be references to it. Then ata_sas_port_free would get called
once all the references were deleted.

>> Object lifetime rules also have me concerned. Currently, for SAS,
>> there are a couple objects that libata is concerned with. The first is
>> an ata_host_set, which I am allocating as part of the scsi_host struct,
>> so it inherits the object lifetime rules of that. The second is the
>> ata_port, which I allocate and free in target_alloc/target_destroy,
>> so I get refcounting for free there as well. Your patch set introduces
>> an ata_host struct, which is kmalloc'ed and doesn't inherit any of the
>> above refcounting. 
> 
> Actually, ata_host is ata_host_set.  It's just renamed recently.

Right. I saw that.

> cca3974e48607c3775dc73b544a5700b2e37c21a in libata-dev#upstream
> 
> Hmmm.... I was kind of hoping SAS could use ata_host_alloc() and store 
> its pointer and then later release it w/ ata_host_free(), hmmm.. maybe 
> you can call ata_host_free from ->slave_destroy?.  That gives libata 
> more control over the host structure (e.g. if we implement dynamic ports 
> array, it needs to be freed too).  Port lifetime rules aren't changed by 
> these updates and host free does need some changes but IMHO that 
> shouldn't be difficult.

The current design for SAS is to have a single ata_host per scsi host.
This means the ata_host is really tied to the object lifetime rules
of the scsi host. In the current SAS code, ata_host_set does not get allocated
as a separate piece of memory, but rather as part of the scsi_host
object. This means the memory for the ata_host doesn't get freed until
the last reference to the scsi host is released. Making ata_host
a separate allocation changes these rules and forces the caller to
know when to free the ata_host memory, which they currently do not know.

In order to do what you are proposing, I think we would need to add
some refcounting to the ata_host object. Each allocated ata_port would
get a reference to its parent ata_host and would put a reference when the
port is freed. Otherwise I am concerned that we would end up in the situation
where the ata_host is freed before all the ata ports and the scsi_host is
freed. It might be appropriate to create an ata_host class device and
an ata_port class device...


>>> sata_sil24.c is a pretty straight-forward example.  If you can't
>>> determine the number of ports when allocating host, please take a look
>>> at how ahci.c initializes its host.
>>>
>>> The intention was to allow SAS to use all the regular init/deinit
>>> functions just as other LLDs.  If something doesn't seem to be right,
>>> please let me know.
>> I think it can use bits of it, but I think the actual device discovery
>> process is better initiated by the SAS layer. The SAS layer knows what
>> devices are out there when it does discovery and can tell libata about
>> them.
> 
> Hmmm.... I see.  Something like ata_dev_attach(adev) after initialized 
> by SAS maybe?

Possibly. Are you proposing that ata_dev_attach would then end up calling
scsi_add_device after doing the ATA initialization stuff?


Brian

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

  reply	other threads:[~2006-08-30 20:58 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-19  8:57 [PATCHSET] libata: implement new initialization model w/ iomap support, take 2 Tejun Heo
2006-08-19  8:59 ` [PATCH 2/20] libata: implement ata_host_start/stop() Tejun Heo
2006-08-19  8:59 ` [PATCH 1/20] libata: kill ata_host_stop() Tejun Heo
2006-08-19 14:51   ` Jeff Garzik
2006-08-19 15:29     ` Tejun Heo
2006-09-19  4:46   ` Jeff Garzik
2006-09-19  4:50     ` Tejun Heo
2006-08-19  8:59 ` [PATCH 5/20] libata: implement several LLD init helpers Tejun Heo
2006-08-22 22:11   ` Brian King
2006-08-27  9:52     ` Tejun Heo
2006-08-30 21:16       ` Brian King
2006-09-19  5:16   ` Jeff Garzik
2006-09-19  5:57     ` Tejun Heo
2006-08-19  8:59 ` [PATCH 3/20] libata: implement ata_host_detach() and ata_host_free() Tejun Heo
2006-09-19  4:59   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 6/20] libata: implement legacy ATA init helpers Tejun Heo
2006-09-19  5:26   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 7/20] libata: implement PCI " Tejun Heo
2006-09-19  5:29   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 4/20] libata: separate out ata_host_alloc() and ata_host_attach() Tejun Heo
2006-09-19  5:08   ` Jeff Garzik
2006-09-19  5:48     ` Tejun Heo
2006-08-19  8:59 ` [PATCH 13/20] libata: kill unused ->host_stop() operation and related functions Tejun Heo
2006-09-19  5:42   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 10/20] libata: reimplement ata_pci_remove_one() using new PCI init helpers Tejun Heo
2006-08-19  8:59 ` [PATCH 11/20] libata: use remove_one() for deinit instead of ->host_stop() Tejun Heo
2006-09-19  5:42   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 8/20] libata: reimplement ata_pci_init_one() using new init helpers Tejun Heo
2006-09-19  5:32   ` Jeff Garzik
2006-09-19  6:04     ` Tejun Heo
2006-09-19  6:09       ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 12/20] libata: kill old " Tejun Heo
2006-08-19  8:59 ` [PATCH 16/20] libata: make ata_host_alloc() take care of hpriv alloc/free Tejun Heo
2006-09-19  5:45   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 19/20] libata: kill unused ATA_FLAG_MMIO Tejun Heo
2006-08-19  8:59 ` [PATCH 15/20] libata: move ->irq_handler from port_ops to port_info Tejun Heo
2006-09-19  5:43   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 17/20] libata: make ata_pci_acquire_resources() handle iomap Tejun Heo
2006-09-19  5:47   ` Jeff Garzik
2006-09-19  6:27     ` Tejun Heo
2006-09-19  6:32       ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 14/20] libata: use LLD name where possible Tejun Heo
2006-09-19  5:43   ` Jeff Garzik
2006-08-19  8:59 ` [PATCH 20/20] libata: move scattered PCI ATA functions into liata-pci.c Tejun Heo
2006-09-19  5:50   ` Jeff Garzik
2006-08-22 22:10 ` [PATCHSET] libata: implement new initialization model w/ iomap support, take 2 Brian King
2006-08-27 10:12   ` Tejun Heo
2006-08-30 20:58     ` Brian King [this message]
2006-09-01 13:45       ` Tejun Heo
2006-09-07 13:22         ` Brian King

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=44F5FBE2.3030201@us.ibm.com \
    --to=brking@us.ibm.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=forrest.zhao@intel.com \
    --cc=htejun@gmail.com \
    --cc=jgarzik@pobox.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).