Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3065319ybt; Mon, 29 Jun 2020 14:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTBzSLegKv+LAARbd7HO1OEpZmjnZ3YmK7mnNRsDScARPT0a2rD29+dgMGewNYZCTpY9T/ X-Received: by 2002:a17:906:6b95:: with SMTP id l21mr16123967ejr.32.1593465705198; Mon, 29 Jun 2020 14:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465705; cv=none; d=google.com; s=arc-20160816; b=jqg6laV4zltGG/UyJXAUV0Om8Mu8U8Xiyde+PMbdwUQh7Y+oB2FvfaXvij++Xr/LDn QWblJW5Y7+A3MPzoAQleUGfsYa25OPUqifpPDMdpC72nb4vwWEZFm0w2CkatpfzTsNhK t6hfVqGDOQT/U1DeJr1avim4wDCZHr3VHc/GCUO8JsJ3xXKRHAZplV6piv3vzVYD8zwJ Gs8DPVpi/Qj2qwRqd8uIab01nee2zXORoRo4cmN0tzfTTnQYxrcdyysTFyUx29XhiBCw 4YJ9+qdZd6DuDZWjidQSBv8nz4cJ5O0dINn6WvF2tQD0LouQH5jRhyVmIk6Pg/SnYvwb SkqA== 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=k3u8HXAMPWhEhabpqjdYJ146WuNuaOg2EhIYFRuXqpM=; b=jo+APhzOLqI8Rh6WfMpNwqARKgGP4qxPLHDdbW4w/HY00H2UA6HIeb7yPO0CTPDoAH 2f47GPsT4vyS/I8IqbBVpoRTpoB3aGN/Ko8ggWKx9gImO9X8nyX55gBCb0PdTN3Deu7q aowqyDO3qR0xlNKuAVoc62t2FcrfbmlGYR5ektcEL22VR8aKtH8q2cT0MEZKDCJTPgez TkYpvqUPXnyhwwOqhDVGyKxd+NGnZhUxGjOBYfd/6RflEMLhTuM9yMpjmzUY1CW552yV qzAUNSP5I1N01G7Uryzi6fBczIaXubJFTU9BqGxliiM2WyWsYAA4lT9QiUYwRBd6LEVY 1pXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QmjgHMCP; 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 c94si369990edf.589.2020.06.29.14.21.22; Mon, 29 Jun 2020 14:21:45 -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=QmjgHMCP; 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 S2388570AbgF2VSH (ORCPT + 99 others); Mon, 29 Jun 2020 17:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729796AbgF2VSF (ORCPT ); Mon, 29 Jun 2020 17:18:05 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE572C061755 for ; Mon, 29 Jun 2020 14:18:04 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id n26so4347710ejx.0 for ; Mon, 29 Jun 2020 14:18:04 -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=k3u8HXAMPWhEhabpqjdYJ146WuNuaOg2EhIYFRuXqpM=; b=QmjgHMCPFtCfnd59WVkDYYDiCvQJ9TLMoKuXhlgAiNXcDkkFsNyOXAh0kOxXWFEiDT 81VLh016Tri13UHQ7NSxRn8xP5ymt1ZMTpuNM8uz/KZ6WQCLFkfurQOO0rly/X+Jucs/ A1qCYgMyWxe7vr921ErrncDcDEzz5AkoHqEtC/blRCUiNzOtz17KT7vgZsm33z4WgzN3 MHKvpcINhb5Iznv0VUNmFulPauzyQf/+ojmfY0KPNuzUC5ck0A2iBFLMxrH1Kfu+zQmX wzwgFkdU4USwX2P7373AMUo7uLfXYWPKvfF/g5OM5KMN315qZdMTsRszkPTyeK3DnJZl TBKw== 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=k3u8HXAMPWhEhabpqjdYJ146WuNuaOg2EhIYFRuXqpM=; b=B+pE0eq69x517LwhcTQqv910rwCOK0Rs0GGOf0MifnpH8IyCX9pnfcpD+KU8XYPBhS ZzYj8P5YP4cjfPySw9TILcUUL9iXYARbzvANBALyc4lPEBnaolIvxNoibEu5cp1rMoqp cjOy8W0mauBtKORSxeHSUQAX8yBa1T9bAS2FMy2Wlz6d2SgDI5joapVfkAhp0Xbgw5Kg 9fq4JuLtXHQLJZVvO27A1Y8Sc8Rtow35yjEq00jm6K3weXQPPLEFDCjL0EkbGsDrbgsh 3guxmB4zlolsu3g67WfOgYr5ebIMeHFeXMrjPNgKO8nI4B37DiugDO0Kd6uYzHUpq7ea c9/w== X-Gm-Message-State: AOAM532OOfwymQJs89P2WpA/K6AXQLNalUvlIGXeDBlBfrVhmfXjSd/4 I1IqPPOjbYftC1l/yoTrIQs1nisOpgV1evDbX8ZWpbQWyK1YVg== X-Received: by 2002:a17:906:899:: with SMTP id n25mr14799477eje.298.1593465483433; Mon, 29 Jun 2020 14:18:03 -0700 (PDT) MIME-Version: 1.0 References: <20200629211329.2185342-1-pmalani@chromium.org> In-Reply-To: <20200629211329.2185342-1-pmalani@chromium.org> From: Guenter Roeck Date: Mon, 29 Jun 2020 14:17:52 -0700 Message-ID: Subject: Re: [PATCH v4 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 2:13 PM 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 I can see you are having fun with me :-) > - int ret, i; > + int i, ret; Reviewed-by: Guenter Roeck > --- > > Changes in v4: > - Removed extra newline. > - Moved both variable declarations into one line. > > Changes in v3: > - Use new 100 character line length limit. > > Changes in v2: > - No changes. > > drivers/platform/chrome/cros_ec_typec.c | 23 ++++++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index 0c041b79cbba..69c4118e280c 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,24 @@ 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); > + int i, ret; > > 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); > + > + schedule_work(&typec->port_work); > > return NOTIFY_OK; > } > @@ -689,6 +696,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 >