linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Ajay Gupta <ajayg@nvidia.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 00/14] usb: typec: UCSI driver overhaul
Date: Fri, 27 Sep 2019 15:53:01 +0300	[thread overview]
Message-ID: <20190927125301.GB23773@kuha.fi.intel.com> (raw)
In-Reply-To: <BYAPR12MB272724AF8ED1C4850FB04230DC810@BYAPR12MB2727.namprd12.prod.outlook.com>

On Fri, Sep 27, 2019 at 12:13:57AM +0000, Ajay Gupta wrote:
> Hi Heikki,
> > -----Original Message-----
> > From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Sent: Thursday, September 26, 2019 3:07 AM
> > To: Ajay Gupta <ajayg@nvidia.com>
> > Cc: linux-usb@vger.kernel.org
> > Subject: [PATCH 00/14] usb: typec: UCSI driver overhaul
> > 
> > Hi Ajay,
> > 
> > Here's the pretty much complete rewrite of the I/O handling that I was
> > talking about. The first seven patches are not actually related to
> > this stuff, but I'm including them here because the rest of the series
> > is made on top of them. I'm including also that fix patch I send you
> > earlier.
> > 
> > After this it should be easier to handle quirks. My idea how to handle
> > the multi-instance connector alt modes is that we "emulate" the PPM in
> > ucsi_ccg.c in order to handle them, so ucsi.c is not touched at all.
> > 
> > We can now get the connector alternate modes that the actual
> > controller supplies during probe - before registering the ucsi
> > interface - and squash all alt modes with the same SVID into one that
> > we supply to the ucsi.c when ever it sends GET_ALTERNATE_MODES
> > command. Also other alt mode commands like SET_NEW_CAM can have
> > special processing in ucsi_ccg.c and ucsi_ccg.c alone. There should
> > not be any problem with that anymore.
> I took the changes and loaded on my GPU system and do not see
> altmode devices under /sys/bus/typec/devices/*. Its empty.
> 
> Below error is seen
> "ucsi_ccg 4-0008: con1: failed to register alternate modes"
> 
> ucsi_run_command() is returning -16.
> 
> I will review the ccg changes and try to debug above issue.

I tested this series with the NVIDIA GPU PCI card that we have. The
controller is reporting BUSY as responce to the GET_ALTERNATE_MODES
command. I added a loop to ucsi_exec_command() where I read the CCI
until the there is no UCSI_CCI_BUSY bit set, and it seems to work.

Here are both changes:

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index accf54d987ad..d70ee8006c34 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -102,6 +102,7 @@ static int ucsi_read_error(struct ucsi *ucsi)

 static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd)
 {
+       unsigned long timeout;
        u32 cci;
        int ret;

@@ -109,12 +110,15 @@ static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd)
        if (ret)
                return ret;

-       ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
-       if (ret)
-               return ret;
+       timeout = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
+       do {
+               if (time_is_before_jiffies(timeout))
+                       return -ETIMEDOUT;

-       if (cci & UCSI_CCI_BUSY)
-               return -EBUSY;
+               ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
+               if (ret)
+                       return ret;
+       } while (cci & UCSI_CCI_BUSY);

        if (!(cci & UCSI_CCI_COMMAND_COMPLETE))
                return -EIO;
@@ -330,7 +334,7 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
                command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
                command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
                command |= UCSI_GET_ALTMODE_OFFSET(i);
-               command |= UCSI_GET_ALTMODE_NUM_ALTMODES(1); /* One at a time */
+
                len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt));
                if (len <= 0)
                        return len;

Let me know if that works.

thanks,

-- 
heikki

  parent reply	other threads:[~2019-09-27 12:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26 10:07 [PATCH 00/14] usb: typec: UCSI driver overhaul Heikki Krogerus
2019-09-26 10:07 ` [PATCH 01/14] usb: typec: Copy everything from struct typec_capability during registration Heikki Krogerus
2019-09-26 10:07 ` [PATCH 02/14] usb: typec: Introduce typec_get_drvdata() Heikki Krogerus
2019-09-26 10:07 ` [PATCH 03/14] usb: typec: Separate the operations vector Heikki Krogerus
2019-09-26 10:07 ` [PATCH 04/14] usb: typec: tcpm: Start using struct typec_operations Heikki Krogerus
2019-09-26 10:07 ` [PATCH 05/14] usb: typec: tps6598x: " Heikki Krogerus
2019-09-26 10:07 ` [PATCH 06/14] usb: typec: ucsi: " Heikki Krogerus
2019-09-26 10:07 ` [PATCH 07/14] usb: typec: Remove the callback members from struct typec_capability Heikki Krogerus
2019-09-26 10:07 ` [PATCH 08/14] usb: typec: ucsi: ccg: Remove run_isr flag Heikki Krogerus
2019-09-26 10:07 ` [PATCH 09/14] usb: typec: ucsi: Simplified interface registration and I/O API Heikki Krogerus
2019-09-26 14:25 ` [PATCH 10/14] usb: typec: ucsi: acpi: Move to the new API Heikki Krogerus
2019-09-26 14:25 ` [PATCH 11/14] usb: typec: ucsi: ccg: " Heikki Krogerus
2019-09-26 14:25 ` [PATCH 12/14] usb: typec: ucsi: Remove the old API Heikki Krogerus
2019-09-26 14:25 ` [PATCH 13/14] usb: typec: ucsi: Remove struct ucsi_control Heikki Krogerus
2019-09-26 14:25 ` [PATCH 14/14] usb: typec: ucsi: Remove all bit-fields Heikki Krogerus
2019-09-27  0:13 ` [PATCH 00/14] usb: typec: UCSI driver overhaul Ajay Gupta
2019-09-27  9:44   ` Heikki Krogerus
2019-09-27 12:53   ` Heikki Krogerus [this message]
2019-09-27 16:30     ` Ajay Gupta
2019-10-01 18:36 ` Ajay Gupta
2019-10-03 14:24   ` Heikki Krogerus
2019-10-03 16:33     ` Ajay Gupta
2019-10-10 17:51       ` Ajay Gupta
2019-10-11 10:37         ` Heikki Krogerus

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=20190927125301.GB23773@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=ajayg@nvidia.com \
    --cc=linux-usb@vger.kernel.org \
    /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).