Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2984918ybt; Mon, 29 Jun 2020 12:08:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyd5mzha/fpV6QfCHqNbFrfGUaLiDKxCm8VPhINMJ7nZ1D5qekQy+dtPG2t1F23rGAbgaQ X-Received: by 2002:a17:906:1a59:: with SMTP id j25mr14426860ejf.398.1593457693871; Mon, 29 Jun 2020 12:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593457693; cv=none; d=google.com; s=arc-20160816; b=HOENg8N5bN6F4/vivgRPj68L9ayN9lBDyo6MVM6ToScKsqidCH9cPxbc8GmLT5wqjr qOIsiYWlJ1vH2lUUvoKaIwFzFXrxaqseLjw1XUrb2WWjppVZx1NhN+rkEY2qWwcHSiab 3vh1QlEKTahdnkIto83w7BIX/zz5XLtekGOP4gA6YXkWHJcmTtF+cA/NlPmsXNjbv6Pi 5KAT0qUSWzjG2jj4P/xuIF6kJu3FmC05k6WkwEcjUEa5GEL94lNwdvoOlT5lgi3uwzoc 3x3Ld5WNhzaKAVL6bM+XIP7JI9oQw1kxVytbhEF1JbXukj16m5K6cF+2Pd1vZBEI8Elx q2Ag== 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=yfrSRiuaUcbTXY2m2QdS9YaH7D3dVduFk5gDSZ3KdZU=; b=X0rx1qHWJRMUC98DU7vb1XJ7K+RV8bdoX/QpuyqBF8inhu9pjl388XKtGqDayhBAuk Mxr2+Cc7JLNwUVsQJ+DJUT5PxpOea8trxGML8n2qg7pjUJBuGXmTKE6Kaipj7rwBJ1RS 6PFwl3fCVm3csWnj1SufC+DOgnLK4rvTF5EyXyD5m3i5Zfnznc1Jvdg16C5KeReqnSou rw2hA8rMvTYaLv7bIz0ApCYIx7iDeVgTL7xQzsXF4QXeQvaWOWl5kzLn4t5Ns8bX1ReB Sluu0D/lwod0cGPOX5nQ6oNQJ1SykeRnPbYeL9O1Wefp6pwY59u7BAfz1sb9YE1jj7bO VbEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kKInGCNG; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si317560ejq.294.2020.06.29.12.07.50; Mon, 29 Jun 2020 12:08:13 -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=@chromium.org header.s=google header.b=kKInGCNG; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730084AbgF2TEc (ORCPT + 99 others); Mon, 29 Jun 2020 15:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730520AbgF2TCn (ORCPT ); Mon, 29 Jun 2020 15:02:43 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15234C030F27 for ; Mon, 29 Jun 2020 09:37:34 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id o38so13316382qtf.6 for ; Mon, 29 Jun 2020 09:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yfrSRiuaUcbTXY2m2QdS9YaH7D3dVduFk5gDSZ3KdZU=; b=kKInGCNGk07E5wciAlG19BexLANCTvTVpJiVyDkKBcr9tsb4oTRSV9NMlNT7XlTH8O QHGuoyYMYxHbIGVTx9G9nLD+yR1qCUgZIG26pL1LlQuwCWfNDRyAru3QKW/lk2OH+f/y Wpk4VHooSMyZV/VUX+opV0hfniJIMUcgQu8Rs= 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=yfrSRiuaUcbTXY2m2QdS9YaH7D3dVduFk5gDSZ3KdZU=; b=mix+HDN9diu+z6GRNmpTUPD1NeJex0lQQiCbCQfrMPkJkTcr4UvKd3hOYkxwHJ3xt9 BqU9v1ROIze9gBIX2vBIxQSpsX5REKRPmi8HhuaJxSCvwH8Kko9JYEh66A0PsDjxht/L HPw/AaUs5zoZlqRet/zLj8KFVBTbZH2NHJ330G4kgwL6rSH0Ftfaf3yGRZeJaHXZ23An MCt23SHXHoYEfzKETFyo5OLQlDoNs5FW5k1OmmPDzGuGL/Z32J8Tm+NnGLkmU+OFdUir V9G9fJqCfBsD6JL9HvCWK+qkENxHMZnPR2WI8V9Qjz0wmfB3Wnuk0yaaAR1nzsUQ7fVA I9sQ== X-Gm-Message-State: AOAM532RZTiQXTaMRx71ZBVMgCPPpjAac7+Rsv76dTWVhg/1WVFyvOvC 8sJ1L8tGvvm0uNG1YEGyk04dXMYrwM6yFUDIN3PuwA== X-Received: by 2002:ac8:1991:: with SMTP id u17mr15979446qtj.93.1593448653276; Mon, 29 Jun 2020 09:37:33 -0700 (PDT) MIME-Version: 1.0 References: <20200629161333.2110327-1-pmalani@chromium.org> In-Reply-To: From: Prashant Malani Date: Mon, 29 Jun 2020 09:37:21 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update To: Guenter Roeck 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 Hi Guenter, Thanks for the review! On Mon, Jun 29, 2020 at 9:24 AM Guenter Roeck wrote: > > 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. Done. > > > + 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. Done. > > > + 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 > >