All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Ranostay <mranostay@ti.com>
To: Vignesh Raghavendra <vigneshr@ti.com>
Cc: <robh@kernel.org>, <tjoseph@cadence.com>, <nm@ti.com>,
	<a-verma1@ti.com>, <linux-arm-kernel@lists.infradead.org>,
	<linux-pci@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] PCI: j721e: Add PCIe 4x lane selection support
Date: Tue, 25 Oct 2022 05:51:31 -0700	[thread overview]
Message-ID: <Y1fb0/ZBoy68AYV4@ubuntu> (raw)
In-Reply-To: <e33dc6fd-1227-e01f-715e-947fac2fd233@ti.com>

On Tue, Oct 25, 2022 at 05:23:20PM +0530, Vignesh Raghavendra wrote:
> Hi Matt,
> 
> On 20/10/22 6:59 am, Matt Ranostay wrote:
> > Add support for setting of two-bit field that allows selection of 4x
> > lane PCIe which was previously limited to only 2x lanes.
> > 
> > Signed-off-by: Matt Ranostay <mranostay@ti.com>
> > ---
> >  drivers/pci/controller/cadence/pci-j721e.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c
> > index a82f845cc4b5..d9b1527421c3 100644
> > --- a/drivers/pci/controller/cadence/pci-j721e.c
> > +++ b/drivers/pci/controller/cadence/pci-j721e.c
> > @@ -43,7 +43,6 @@ enum link_status {
> >  };
> >  
> >  #define J721E_MODE_RC			BIT(7)
> > -#define LANE_COUNT_MASK			BIT(8)
> >  #define LANE_COUNT(n)			((n) << 8)
> >  
> >  #define GENERATION_SEL_MASK		GENMASK(1, 0)
> > @@ -207,11 +206,15 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
> >  {
> >  	struct device *dev = pcie->cdns_pcie->dev;
> >  	u32 lanes = pcie->num_lanes;
> > +	u32 mask = GENMASK(8, 8);
> >  	u32 val = 0;
> >  	int ret;
> >  
> > +	if (lanes == 4)
> > +		mask = GENMASK(9, 8);
> 
> 
> Shouldn't we decide "mask" based on max_lanes added in 2/3 (ie how many
> lanes HW can support and thus width of this bit field) instead of
> num_lanes? Hypothetically, what if bootloader / other entity has set MSb
> but Linux is restricted to 2 lanes in DT?

Ah yes that is a very good point, and the mask should be based on max_lanes.

Will fix up in v4...

- Matt

> 
> > +
> >  	val = LANE_COUNT(lanes - 1);
> > -	ret = regmap_update_bits(syscon, offset, LANE_COUNT_MASK, val);
> > +	ret = regmap_update_bits(syscon, offset, mask, val);
> >  	if (ret)
> >  		dev_err(dev, "failed to set link count\n");
> >  

WARNING: multiple messages have this Message-ID (diff)
From: Matt Ranostay <mranostay@ti.com>
To: Vignesh Raghavendra <vigneshr@ti.com>
Cc: <robh@kernel.org>, <tjoseph@cadence.com>, <nm@ti.com>,
	<a-verma1@ti.com>, <linux-arm-kernel@lists.infradead.org>,
	<linux-pci@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] PCI: j721e: Add PCIe 4x lane selection support
Date: Tue, 25 Oct 2022 05:51:31 -0700	[thread overview]
Message-ID: <Y1fb0/ZBoy68AYV4@ubuntu> (raw)
In-Reply-To: <e33dc6fd-1227-e01f-715e-947fac2fd233@ti.com>

On Tue, Oct 25, 2022 at 05:23:20PM +0530, Vignesh Raghavendra wrote:
> Hi Matt,
> 
> On 20/10/22 6:59 am, Matt Ranostay wrote:
> > Add support for setting of two-bit field that allows selection of 4x
> > lane PCIe which was previously limited to only 2x lanes.
> > 
> > Signed-off-by: Matt Ranostay <mranostay@ti.com>
> > ---
> >  drivers/pci/controller/cadence/pci-j721e.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c
> > index a82f845cc4b5..d9b1527421c3 100644
> > --- a/drivers/pci/controller/cadence/pci-j721e.c
> > +++ b/drivers/pci/controller/cadence/pci-j721e.c
> > @@ -43,7 +43,6 @@ enum link_status {
> >  };
> >  
> >  #define J721E_MODE_RC			BIT(7)
> > -#define LANE_COUNT_MASK			BIT(8)
> >  #define LANE_COUNT(n)			((n) << 8)
> >  
> >  #define GENERATION_SEL_MASK		GENMASK(1, 0)
> > @@ -207,11 +206,15 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
> >  {
> >  	struct device *dev = pcie->cdns_pcie->dev;
> >  	u32 lanes = pcie->num_lanes;
> > +	u32 mask = GENMASK(8, 8);
> >  	u32 val = 0;
> >  	int ret;
> >  
> > +	if (lanes == 4)
> > +		mask = GENMASK(9, 8);
> 
> 
> Shouldn't we decide "mask" based on max_lanes added in 2/3 (ie how many
> lanes HW can support and thus width of this bit field) instead of
> num_lanes? Hypothetically, what if bootloader / other entity has set MSb
> but Linux is restricted to 2 lanes in DT?

Ah yes that is a very good point, and the mask should be based on max_lanes.

Will fix up in v4...

- Matt

> 
> > +
> >  	val = LANE_COUNT(lanes - 1);
> > -	ret = regmap_update_bits(syscon, offset, LANE_COUNT_MASK, val);
> > +	ret = regmap_update_bits(syscon, offset, mask, val);
> >  	if (ret)
> >  		dev_err(dev, "failed to set link count\n");
> >  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-10-25 12:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  1:29 [PATCH v3 0/3] PCI: add 4x lane support for pci-j721e controllers Matt Ranostay
2022-10-20  1:29 ` Matt Ranostay
2022-10-20  1:29 ` [PATCH v3 1/3] PCI: j721e: Add PCIe 4x lane selection support Matt Ranostay
2022-10-20  1:29   ` Matt Ranostay
2022-10-25 11:53   ` Vignesh Raghavendra
2022-10-25 11:53     ` Vignesh Raghavendra
2022-10-25 12:51     ` Matt Ranostay [this message]
2022-10-25 12:51       ` Matt Ranostay
2022-10-20  1:29 ` [PATCH v3 2/3] PCI: j721e: Add per platform maximum lane settings Matt Ranostay
2022-10-20  1:29   ` Matt Ranostay
2022-10-20  1:29 ` [PATCH v3 3/3] PCI: j721e: Add warnings on num-lanes misconfiguration Matt Ranostay
2022-10-20  1:29   ` Matt Ranostay
2022-10-20 16:58   ` Bjorn Helgaas
2022-10-20 16:58     ` Bjorn Helgaas

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=Y1fb0/ZBoy68AYV4@ubuntu \
    --to=mranostay@ti.com \
    --cc=a-verma1@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=robh@kernel.org \
    --cc=tjoseph@cadence.com \
    --cc=vigneshr@ti.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.