From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Tejun Heo <tj@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Kumar Gala <galak@codeaurora.org>,
linux-ide@vger.kernel.org, Nadav Haklai <nadavh@marvell.com>,
Lior Amsalem <alior@marvell.com>, Hanna Hawa <hannah@marvell.com>,
Yehuda Yitschak <yehuday@marvell.com>,
Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Gregory Clement <gregory.clement@free-electrons.com>
Subject: Re: [PATCH 1/5] ata: ahci: add support for non-standard port offset/length
Date: Wed, 27 Apr 2016 14:22:50 +0200 [thread overview]
Message-ID: <20160427142250.12764279@free-electrons.com> (raw)
In-Reply-To: <20160422175936.GU7822@mtj.duckdns.org>
Hello,
Thanks for your review and feedback!
On Fri, 22 Apr 2016 13:59:36 -0400, Tejun Heo wrote:
> On Fri, Apr 22, 2016 at 04:32:37PM +0200, Thomas Petazzoni wrote:
> > @@ -1714,10 +1714,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> >
> > for (i = 0; i < host->n_ports; i++) {
> > struct ata_port *ap = host->ports[i];
> > + unsigned int offset =
> > + hpriv->port_offset + ap->port_no * hpriv->port_length;
> >
> > ata_port_pbar_desc(ap, ahci_pci_bar, -1, "abar");
> > - ata_port_pbar_desc(ap, ahci_pci_bar,
> > - 0x100 + ap->port_no * 0x80, "port");
> > + ata_port_pbar_desc(ap, ahci_pci_bar, offset, "port");
>
> Doesn't this just affect ahci_platform?
No, because the main source of the problem is the ahci_port_base()
function, which is used all over the place in libahci.c (which is used
by all AHCI drivers, not only ahci_platform drivers). And this
ahci_port_base() currently hardcodes the 0x100 / 0x80 values:
429 static inline void __iomem *__ahci_port_base(struct ata_host *host,
430 unsigned int port_no)
431 {
432 struct ahci_host_priv *hpriv = host->private_data;
433 void __iomem *mmio = hpriv->mmio;
434
435 return mmio + 0x100 + (port_no * 0x80);
436 }
437
438 static inline void __iomem *ahci_port_base(struct ata_port *ap)
439 {
440 return __ahci_port_base(ap->host, ap->port_no);
441 }
In essence all what we want to change is the __ahci_port_base()
function so that it doesn't use hardcoded values.
> Why is ahci_init_one() being updated?
The idea why ahci_init_one() was updated is also to remove hardcoded
values. Once we have the correct values in the ahci_host_priv, why not
use them everywhere instead of keeping some hardcoded values?
> Also, who's setting port_offet and port_length for non-platform ahci
> drivers?
This is obviously a mistake in my proposal. And the non-platform
drivers are allocating manually their ahci_host_priv structure, which
makes it a bit difficult/annoying to initialize those new fields.
I see a few possibilities:
1/ Adjust all the drivers allocating manually an ahci_host_priv
structure, and make sure they initialize the fields to their default
values.
2/ Add a new helper function that allows to allocate the
ahci_host_priv structure and initialize it with sane default values,
and use this helper in all drivers.
3/ Add a flag in ahci_host_priv that tells whether non-standard port
offset/length are to be used. This is the most minimal solution,
but also maybe not the nicest one.
> If this needs to be configurable, wouldn't it be better to just let it
> be specified per port?
How could it be per-port? The base for a port is calculated as:
base + <port_offset> + (port_no * <port_length>)
So, port_offset is clearly not per-port, there's only one of them. And
if we were to make <port_length> a per-port property, then the formula
would become a lot more complicated: we would have to iterate over each
port, and see what is the length of the register area for each of them,
to calculate the base address of the registers for the n-th port. This
is clearly a complexity that is not needed for my use case: all ports
have the same register area length, it's just that this length is
non-standard.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-04-27 12:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 14:32 [PATCH 0/5] ata: add support for Marvell Armada 7K/8K AHCI Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 1/5] ata: ahci: add support for non-standard port offset/length Thomas Petazzoni
[not found] ` <1461335561-18363-2-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-04-22 17:59 ` Tejun Heo
2016-04-27 12:22 ` Thomas Petazzoni [this message]
[not found] ` <20160427142250.12764279-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-02 16:38 ` Tejun Heo
2016-04-22 14:32 ` [PATCH 2/5] ata: acard-ahci: use the new port_{offset,length} members Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 3/5] ata: ahci_ceva: " Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 4/5] ata: ahci_mvebu: add support for Armada 8K Thomas Petazzoni
2016-04-22 14:32 ` [PATCH 5/5] dt-bindings: ata: add compatible string for Armada 8K to ahci-platform Thomas Petazzoni
2016-04-25 12:47 ` Rob Herring
2016-05-19 8:19 ` [PATCH 0/5] ata: add support for Marvell Armada 7K/8K AHCI Thomas Petazzoni
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=20160427142250.12764279@free-electrons.com \
--to=thomas.petazzoni@free-electrons.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=gregory.clement@free-electrons.com \
--cc=hannah@marvell.com \
--cc=hdegoede@redhat.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jason@lakedaemon.net \
--cc=linux-ide@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nadavh@marvell.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=tj@kernel.org \
--cc=yehuday@marvell.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