Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3065229ybt; Mon, 29 Jun 2020 14:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUI2HtKZie4+TxyLCsdYvjJO3Ndelnvw/wZd6rp/XSgtX23cXUjZCmuqAG3ZzKq8+YId4k X-Received: by 2002:a17:906:1998:: with SMTP id g24mr11053891ejd.11.1593465696646; Mon, 29 Jun 2020 14:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465696; cv=none; d=google.com; s=arc-20160816; b=bideoulRltX8M0fINFtrAp0PIHAq5+svNwHqh1nbmtJgEW9YtQv9yDAbMssLkyGpDk zcxuXSAFuNvOd2VGgp9Yx9/a7X9q/IlIRRQn/fempioLbBJCz8eLXSxgl+wF58VqslAb +rabMO1caOY67lyK9Uol/fAMNYM0S29KjTVb6Q0/U73/4NKJQNgyucK/gluiKzMveJKX wEldukksNHvGX0vYOCsT7L8Uest2+EvyJJVfujQkOHzlI4pPCFsuLn2oYAna4Sz8G56X PG3+7a0Z5Ir5UuBkuOJUjRSAhFIM7JWm8YY5C1WM6jT/nJKv8ZRuxDCAnBj4GWMUClXQ 4VaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ud+jy3wulB5wSts5pAy11Tc3R2svZplkU4sR98nwwJE=; b=eG/y+m9S9QRQh1etDbRGYg0Nso4gxnkBTgNIVbSHaPTe/EW2eL/nMkZxP968FFtR9e TFq/CK2Wv4jL4plMkZu7MkjXOGMIurFNABMrLqh+Bo7MOnBxrU8Bur1UBoxIkg/S+cYb 5h1b2w3F1tL0eTM7d6ptYjtzvEeL+gW3I3Hn22qqAQBzyhNXDucH9bzQWBIHbtqgqSQb C+TsW3UyWP/1lJ2iBnQaIMzR/A3Wl5CVIU/jQObFqO4P8Lb9GZ/7TIE6fBMwHPo7ImDM 2ktqXeSpfw8WNr2qU/7kkC+w8W/piwZdN9sP3ThxD5dIFDCCp/3Nu2ffT6sI10CYY7SW 8YqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="uDoV+f/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds16si682962ejc.112.2020.06.29.14.21.12; Mon, 29 Jun 2020 14:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="uDoV+f/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732059AbgF2VSi (ORCPT + 99 others); Mon, 29 Jun 2020 17:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729687AbgF2Swt (ORCPT ); Mon, 29 Jun 2020 14:52:49 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD80C030F15 for ; Mon, 29 Jun 2020 09:24:47 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id dr13so17192602ejc.3 for ; Mon, 29 Jun 2020 09:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ud+jy3wulB5wSts5pAy11Tc3R2svZplkU4sR98nwwJE=; b=uDoV+f/amMJySkjiD5nfcXFSEYKLa7JOmygbWtDrbVnsvXumsg4JB325HUaxGjw2Vi eNdd9RRj62EnIZ4pbaSVLWpw3IL0kteHloONkLXM8vzkvFt3entXOVvKORsQfBIiJ8FH xusOSAMEt1gemF6n6eornvY9U6B9dxUiqNR5UmkXigrRjgElYE81qVrgeaUwWFLy0piP oFimG/Ha18kkdW68rV9v8tq3sflRfqesYVAcwc0DVBNEd5wdvY0hty6tnKDa+73zY6Lx /l9tVNaU6LiRvD6apfQlzXRVljaVF0aJKrqm5HQOlFyJ7A2dczyLCFj9qc6OUuEBJpke wfCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ud+jy3wulB5wSts5pAy11Tc3R2svZplkU4sR98nwwJE=; b=WjO+9TQtNzVA6JLt4gip8Bnl+/GKSxgcJ3rMv2mJt0YuIkMEq+JqKnBYnW2toK+A0i QVKCqukYqCRgwfmD+aptafsuV6vqmpaNe3m6v5IYnrVIfWDpkIAW4MYk0rFpI1CP4F6g sMXxi5Vr677ajQeMgBVFQ5zIFLfip4xnmy0kevSRexgSIMdyaGGhKQmg+p9wumaqed15 RZUU8mAs8K3wtf702BkYDp9gZI9p/kuTnhFCb6uD5E7W0OPx8zG95X5VWocgj0ZPI69T 4wzSzvVaBMOsbEYhYM1TaTtgrAub8mnZrSZ6jbgG7rIL5OGSjwd2WAKPY2cFqlAl7EnE LDbw== X-Gm-Message-State: AOAM531VHvQa1naekDUlPLeRSLHwL/pZCsQrTFCUMuXR9ZPJj14ig5GA OiUtZweYGtznglTl+FjWYMkWthJVo6hoPP4fh4vMyw== X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr14263665eji.547.1593447885760; Mon, 29 Jun 2020 09:24:45 -0700 (PDT) MIME-Version: 1.0 References: <20200629161333.2110327-1-pmalani@chromium.org> In-Reply-To: <20200629161333.2110327-1-pmalani@chromium.org> From: Guenter Roeck Date: Mon, 29 Jun 2020 09:24:34 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update To: Prashant Malani Cc: linux-kernel , Heikki Krogerus , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 9:13 AM Prashant Malani wrote: > > Use a work queue to call the port update routines, instead of doing it > directly in the PD notifier callback. This will prevent other drivers > with PD notifier callbacks from being blocked on the port update routine > completing. > > Signed-off-by: Prashant Malani > --- > > Changes in v2: > - No changes. > > drivers/platform/chrome/cros_ec_typec.c | 28 ++++++++++++++++++++----- > 1 file changed, 23 insertions(+), 5 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index 0c041b79cbba..630170fb2cbe 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -58,6 +58,7 @@ struct cros_typec_data { > /* Array of ports, indexed by port number. */ > struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; > struct notifier_block nb; > + struct work_struct port_work; > }; > > static int cros_typec_parse_port_props(struct typec_capability *cap, > @@ -619,18 +620,29 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec) > return 0; > } > > -static int cros_ec_typec_event(struct notifier_block *nb, > - unsigned long host_event, void *_notify) > +static void cros_typec_port_work(struct work_struct *work) > { > - struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, > - nb); > - int ret, i; > + struct cros_typec_data *typec = container_of(work, > + struct cros_typec_data, > + port_work); Nit, but the upstream line length limit is now 100 characters, and this is a perfect example where this would come handy. > + int ret; > + int i; > > for (i = 0; i < typec->num_ports; i++) { > ret = cros_typec_port_update(typec, i); > if (ret < 0) > dev_warn(typec->dev, "Update failed for port: %d\n", i); > } > +} > + > + > +static int cros_ec_typec_event(struct notifier_block *nb, > + unsigned long host_event, void *_notify) > +{ > + struct cros_typec_data *typec = container_of(nb, struct cros_typec_data, > + nb); > + ... and even more so here. > + schedule_work(&typec->port_work); > > return NOTIFY_OK; > } > @@ -689,6 +701,12 @@ static int cros_typec_probe(struct platform_device *pdev) > if (ret < 0) > return ret; > > + INIT_WORK(&typec->port_work, cros_typec_port_work); > + > + /* > + * Safe to call port update here, since we haven't registered the > + * PD notifier yet. > + */ > for (i = 0; i < typec->num_ports; i++) { > ret = cros_typec_port_update(typec, i); > if (ret < 0) > -- > 2.27.0.212.ge8ba1cc988-goog >