From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbcGSIci (ORCPT ); Tue, 19 Jul 2016 04:32:38 -0400 Received: from mga11.intel.com ([192.55.52.93]:27884 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbcGSIce (ORCPT ); Tue, 19 Jul 2016 04:32:34 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,388,1464678000"; d="asc'?scan'208";a="1009614343" From: Felipe Balbi To: Bin Gao Cc: Heikki Krogerus , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Bin Gao , Chandra Sekhar Anagani Subject: Re: [PATCH 1/2] usb: typec: Add USB Power Delivery sink port support In-Reply-To: <20160719053917.GB90550@worksta> References: <20160715021405.GB128987@worksta> <87zipjgy6n.fsf@linux.intel.com> <20160715234957.GC159605@worksta> <877fcjh1ar.fsf@linux.intel.com> <20160719053917.GB90550@worksta> User-Agent: Notmuch/0.22+58~g3a45d29 (https://notmuchmail.org) Emacs/25.0.95.2 (x86_64-pc-linux-gnu) Date: Tue, 19 Jul 2016 11:29:22 +0300 Message-ID: <87mvlef2u5.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Bin Gao writes: > On Mon, Jul 18, 2016 at 10:07:24AM +0300, Felipe Balbi wrote: >>=20 >> Hi, >>=20 >> Bin Gao 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 >=3D MAX_NR_SINK_PORTS) { >> >> > + pr_err("Invalid port number\n"); >> >> > + return -EINVAL; >> >> > + } >> >> > + >> >> > + port =3D 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); >> >>=20 >> >> 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 interr= upt >> > 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. >>=20 >> keep interrupts masked for as long as necessary until your message is >> processed. > > Yes, that's a right way to go.=20 > 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. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXjeTiAAoJEIaOsuA1yqREgrEP/jFrGzOuIQ7hhJIZ1CCcloE4 QZXz+T/S9deEH834hVHYa3AzYEaOiq7jimK91uMBECbXuajVKFRMp3giq9R8eCj9 EG7mRK97hhO2TsfwAd+ahcwy83GdbFjaoaCGAF0ldNAypTxHDtwifSBf4AZltHN8 COmNbLPjiWv2+DvY4QHYwj3A8yrRmXKOJDRHrIly0Yht6KpSEvocErVUjIyGWF4a sPr7QnY3cFl+qu1EmYld8ftDrX1j8PWjlFjQ6Mm475h6wOaGLQjSJIqE9sp0voB0 xJhspHSMLcx5LkL0RpuAn50jWHTNXlEZ18FJS0QCu9YtaB56mq8HakDJeUAWxcVc xkDQpKWI1F9QnMG0HAxbxF0VfmxZ5wObupdFOL/iwQnBx+wAqGdIWd4wsJcF9LZ4 8Cy9LcL+0TQtWVXfhoXe6SGHuNknHUoDsFt7+mFVt7t5kT0EMRTNOV9R6oJopO7/ JUmEoTmZdv5qfYbUhVwqlmTjt9RLWlIAZ0aRVLI+eVcj+DW0pI1SoDrXwf7AV9g3 RK+ZetUOFOCbln7o0ly62K+cPeNygdQ2DEID6+W1mBK6P6DgK2SI0b9EIIvQHs2+ yyMHo8Cx3UkPab2VvTRCm92lXS0O8+qiSi6PJXJALoqRorIVhZafTZUjuHIHrMoh jnAvMc+cc6zo3VcaZss4 =xNX/ -----END PGP SIGNATURE----- --=-=-=--