[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87mvlef2u5.fsf@linux.intel.com>
Date: Tue, 19 Jul 2016 11:29:22 +0300
From: Felipe Balbi <felipe.balbi@...ux.intel.com>
To: Bin Gao <bin.gao@...ux.intel.com>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Bin Gao <bin.gao@...el.com>,
Chandra Sekhar Anagani <chandra.sekhar.anagani@...el.com>
Subject: Re: [PATCH 1/2] usb: typec: Add USB Power Delivery sink port support
Hi,
Bin Gao <bin.gao@...ux.intel.com> writes:
> On Mon, Jul 18, 2016 at 10:07:24AM +0300, Felipe Balbi wrote:
>>
>> Hi,
>>
>> Bin Gao <bin.gao@...ux.intel.com> writes:
>> >> > +int pd_sink_queue_msg(struct pd_sink_msg *msg)
>> >> > +{
>> >> > + unsigned long flags;
>> >> > + struct pd_sink_port *port;
>> >> > +
>> >> > + if (msg->port < 0 || msg->port >= MAX_NR_SINK_PORTS) {
>> >> > + pr_err("Invalid port number\n");
>> >> > + return -EINVAL;
>> >> > + }
>> >> > +
>> >> > + port = sink_ports[msg->port];
>> >> > +
>> >> > + spin_lock_irqsave(&port->rx_lock, flags);
>> >> > + list_add_tail(&msg->list, &port->rx_list);
>> >> > + spin_unlock_irqrestore(&port->rx_lock, flags);
>> >> > +
>> >> > + queue_work(port->rx_wq, &port->rx_work);
>> >>
>> >> can we really queue several messages at a time? It seems unfeasible to
>> >> me. It's not like we can queue several power request in a role. Why do
>> >> you need this workqueue? Why don't you process message here, in place?
>> > Some Type-C chargers send two messages in a short duration(less than 1 ms),
>> > e.g. a SOURCE_CAPABILITY follows the previous SOURCE_CAPABILITY, or a
>> > GET_SINK_CAPABILITY follows a previous SOURCE_CAPABILITY, etc. Queuing
>> > message to PD stack by Type-C phy driver typically happens in a interrupt
>> > context. So in this case a nested interrupt may happen. Our whole PD
>> > stack while processing one message is not re-entrant so the nested
>> > interrupt would cause a problem.
>>
>> keep interrupts masked for as long as necessary until your message is
>> processed.
>
> Yes, that's a right way to go.
> We'll have to document this because there might be other Type-C
> PHY drivers(other than Intel Whiskey Cove PMIC) to use the PD stack.
that's a requirement for *any* driver. You _must_ keep interrupts masked
(or disabled) while you're processing the interrupts themselves.
--
balbi
Download attachment "signature.asc" of type "application/pgp-signature" (819 bytes)
Powered by blists - more mailing lists