All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@marvell.com>
To: Minghuan Lian <minghuan.lian@nxp.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	Pratyush Anand <pratyush.anand@gmail.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"Minghuan.Lian@freescale.com" <Minghuan.Lian@freescale.com>
Subject: Re: DesignWare ATU PCIE_ATU_TYPE_MEM usage
Date: Thu, 7 Jan 2016 16:32:11 +0800	[thread overview]
Message-ID: <20160107163211.6eec2269@xhacker> (raw)
In-Reply-To: <VI1PR04MB16158C40C78419DD02890CA7E8F50@VI1PR04MB1615.eurprd04.prod.outlook.com>

Dear Minghuan, Bjorn,

On Thu, 7 Jan 2016 07:11:59 +0000 Minghuan Lian wrote:

> Hi Bjorn,
> 
> We need at least four kinds of PCIe transactions: CFG0, CFG1, IO, MEM.
> The best solution is to assign 4 iATU to support them separately for example: ATU0- CFG0, ATU1-CFG1, ATU2-IO ATU3-MEM.

IMHO, 3 ATUs is enough, cfg0 and cfg1 can be sequenced by pci_lock as you
pointed out ;)

> So, for IO and MEM, we don't need to update iATU and for CFG, we only need to update a register to update BUS device and function number.
> Moreover, this can avoid any conflict.
> 
> But There are some SOCs that only provides two iATUs.
> So the latest driver provides a solution: ATU0 is shared by CFG0 CFG1 and IO, ATU1 is dedicated to MEM.
> The driver should first set ATU0 as IO and ATU1 as MEM. When accessing CFG0 or CFG1, ATU0 will be changed to CFG0/CFG1, then back to IO setting.
> CFG0 CFG1 can sequenced by pci_lock. But CFG IO and MEM(may be generated by PCIe device's DMA) are completely independent.
> 
> Because most PCIe device do not need IO transaction and in general CFG0 CFG1 and IO transaction is generated by PCIe device driver and rarely occurred simultaneously.
> So the current solution can minimize conflict.
> In fact, for the current pcie-designware driver, there is no way to avoid IO and CFG conflict.

The key is how to sequence IO and CFG, this may need pci subsystem to provide
the support.

> 
> 
> Thanks,
> Minghuan
> 
> 
> > -----Original Message-----
> > From: Bjorn Helgaas [mailto:helgaas@kernel.org]
> > Sent: Wednesday, January 06, 2016 6:42 AM
> > To: Jingoo Han <jingoohan1@gmail.com>; Pratyush Anand
> > <pratyush.anand@gmail.com>
> > Cc: linux-pci@vger.kernel.org; Jisheng Zhang <jszhang@marvell.com>;
> > Minghuan.Lian@freescale.com
> > Subject: DesignWare ATU PCIE_ATU_TYPE_MEM usage
> > 
> > Hi guys,
> > 
> > This code in dw_pcie_host_init() looks wrong:
> > 
> >     if (!pp->ops->rd_other_conf)
> > 	    dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
> > 				      PCIE_ATU_TYPE_MEM, pp->mem_base,
> > 				      pp->mem_bus_addr, pp->mem_size);
> > 
> >     dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
> >     ...
> >     dw_pcie_rd_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, &val);
> > 
> > Evidently you need to program the ATU with PCIE_ATU_TYPE_MEM before
> > doing config accesses on the root bus?
> > 
> > If that's the case, what about other config accesses after these few in
> > dw_pcie_host_init()?  I don't see anything that changes the ATU programming
> > for things coming through dw_pcie_wr_conf().
> > 
> > I assume you need some sort of locking around this sequence:
> > 
> >     dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0, type, ...
> >     ret = dw_pcie_cfg_read(va_cfg_base + where, size, val);
> >     dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
> > PCIE_ATU_TYPE_IO, ...
> > 
> > Are you relying on pci_lock?  If so, a comment to that effect would be nice.
> > 
> > The whole ATU management looks pretty inefficient.  It's likely that there'll be
> > a whole sequence of operations where we don't need to touch the ATU, but
> > since we don't remember its current state, we configure the whole thing from
> > scratch each time, which is at least eight register writes (plus a read for the
> > new synchronization).
> > 
> > Bjorn  


  reply	other threads:[~2016-01-07  8:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 22:42 DesignWare ATU PCIE_ATU_TYPE_MEM usage Bjorn Helgaas
2016-01-07  7:11 ` Minghuan Lian
2016-01-07  8:32   ` Jisheng Zhang [this message]
2016-01-07 10:20   ` Pratyush Anand

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=20160107163211.6eec2269@xhacker \
    --to=jszhang@marvell.com \
    --cc=Minghuan.Lian@freescale.com \
    --cc=helgaas@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=minghuan.lian@nxp.com \
    --cc=pratyush.anand@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.