From: Jeff Garzik <jeff@garzik.org>
To: Tejun Heo <htejun@gmail.com>
Cc: linux-ide@vger.kernel.org, liml@rtr.ca, alan@lxorguk.ukuu.org.uk,
kngregertsen@norway.atmel.com, sonic.adi@gmail.com,
rmk@dyn-67.arm.linux.org.uk, alessandro.zummo@towertech.it,
domen.puncer@telargo.com, akira2.iguchi@toshiba.co.jp,
leoli@freescale.com
Subject: Re: [PATCH 5/9] libata: implement and use SHT initializers and ops inheritance
Date: Fri, 01 Feb 2008 15:49:40 -0500 [thread overview]
Message-ID: <47A385E4.5000901@garzik.org> (raw)
In-Reply-To: <12016853432907-git-send-email-htejun@gmail.com>
Tejun Heo wrote:
> libata lets low level drivers build scsi_host_template and
> ata_port_operations tables and register them with upper layers. This
> allows low level drivers high level of flexibility but also burdens
> them with lots of boilerplate entries in thoes data structures.
>
> This becomes worse for drivers which support related similar
> controllers which differ slightly. They share most of the operations
> except for a few. However, the driver still needs to list all
> operations for each variant. This results in large number of
> duplicate entries, which is not only inefficient but also error-prone
> as it becomes very difficult to tell what the actual differences are.
>
> This duplicate boilerplates all over the low level drivers also make
> updating the core layer exteremely difficult and error-prone. When
> compounded with multi-branched development model, it ends up
> accumulating inconsistencies over time. Some of those inconsistencies
> cause immediate problems and fixed. Others just remain there dormant
> making maintenance increasingly difficult.
>
> To rectify the problem, this patch implements SHT initializers and
> ata_port_operations inheritance. SHT initializers can be used to
> initialize all the boilerplate entries in a sht. Three variants of
> them exist - BASE, BMDMA and NCQ - for different types of drivers.
> Note that entries can be overriden by putting individual initializers
> after the helper macro.
>
> Ops handling is a bit more involved to allow LLDs to easily re-use
> their own ops tables overriding only specific methods. This is
> basically poor man's class inheritance. An ops table has ->inherits
> field which can be set to any ops table as long as it doesn't create a
> loop. When the host is started, the inheritance chain is followed and
> any operation which isn't specified is taken from the nearest ancestor
> which has it specified. This operation is called finalization and
> done only once per an ops table and the LLD doesn't have to do
> anything special about it other than making the ops table non-const
> such that libata can update it.
>
> libata provides four base ops tables lower drivers can inherit from -
> base, sata, pmp, sff and bmdma. To avoid overriding these ops
> accidentaly, these ops are declared const and LLDs should always
> inherit these instead of using them directly.
>
> After finalization, all the sht and ops table are identical before and
> after the patch except for setting .irq_handler to ata_interrupt in
> drivers which didn't use to. The .irq_handler doesn't have any actual
> effect and the field will soon be removed by later patch.
>
> * sata_sx4 is still using old style EH and currently doesn't take
> advantage of ops inheritance.
>
> Signed-off-by: Tejun Heo <htejun@gmail.com>
Two comments:
1) Please split into SHT and ops patches (SHT first, I presume)
2) It seems like inheritance would be easier and less error-prone if the
ops were copied, rather than modifying the structures in-place. Comments?
next prev parent reply other threads:[~2008-02-01 20:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-30 9:28 [PATCHSET libata-dev#upstream] clean up scsi_host_templates and ata_port_operations Tejun Heo
2008-01-30 9:28 ` [PATCH 1/9] libata: PCI device should be powered up before being accessed Tejun Heo
2008-02-01 20:44 ` Jeff Garzik
2008-02-11 19:24 ` Jeff Garzik
2008-01-30 9:28 ` [PATCH 2/9] libata: reorganize ata_port_operations Tejun Heo
2008-01-30 9:28 ` [PATCH 3/9] libata: implement and use ata_noop_irq_clear() Tejun Heo
2008-02-01 20:45 ` Jeff Garzik
2008-01-30 9:28 ` [PATCH 4/9] libata: normalize port_info, port_operations and sht tables Tejun Heo
2008-02-01 20:46 ` Jeff Garzik
2008-02-09 1:57 ` Tejun Heo
2008-02-04 14:24 ` Alan Cox
2008-02-09 6:11 ` Tejun Heo
2008-02-09 6:53 ` Tejun Heo
2008-01-30 9:28 ` [PATCH 5/9] libata: implement and use SHT initializers and ops inheritance Tejun Heo
2008-01-30 17:09 ` Mark Lord
2008-01-31 3:39 ` Tejun Heo
2008-01-31 4:04 ` Mark Lord
2008-01-31 4:12 ` Tejun Heo
2008-02-01 20:49 ` Jeff Garzik [this message]
2008-02-02 0:06 ` Tejun Heo
2008-01-30 9:29 ` [PATCH 6/9] make ata_pci_init_one() not use ops->irq_handler and pi->sht Tejun Heo
2008-01-30 9:29 ` [PATCH 7/9] libata: stop overloading port_info->private_data Tejun Heo
2008-02-04 14:26 ` Alan Cox
2008-02-09 2:07 ` Tejun Heo
2008-01-30 9:29 ` [PATCH 8/9] libata: kill port_info->sht and ->irq_handler Tejun Heo
2008-01-30 9:29 ` [PATCH 9/9] libata: make reset related methods proper port operations Tejun Heo
2008-02-01 20:52 ` Jeff Garzik
2008-01-30 9:49 ` How to verify sht-ops-conversion patch doesn't change anything Tejun Heo
2008-01-30 9:51 ` GIT tree available Tejun Heo
2008-01-31 8:29 ` [PATCHSET libata-dev#upstream] clean up scsi_host_templates and ata_port_operations Akira Iguchi
2008-02-09 1:55 ` Tejun Heo
2008-01-31 8:34 ` Akira Iguchi
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=47A385E4.5000901@garzik.org \
--to=jeff@garzik.org \
--cc=akira2.iguchi@toshiba.co.jp \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=alessandro.zummo@towertech.it \
--cc=domen.puncer@telargo.com \
--cc=htejun@gmail.com \
--cc=kngregertsen@norway.atmel.com \
--cc=leoli@freescale.com \
--cc=liml@rtr.ca \
--cc=linux-ide@vger.kernel.org \
--cc=rmk@dyn-67.arm.linux.org.uk \
--cc=sonic.adi@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.