Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp442744ybt; Wed, 1 Jul 2020 02:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPJPlw2YEXyCngIjrF3Jx3qqvITfld5gVY59Nkv5MhcfAST6lVHveVm33T+xHK/TNZheLK X-Received: by 2002:a17:907:72ca:: with SMTP id du10mr21668604ejc.78.1593594777097; Wed, 01 Jul 2020 02:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593594777; cv=none; d=google.com; s=arc-20160816; b=xTjjq4MFuDLRJS7+AhkIhIrOHsUSsGeDz+uhANhcfLVLG4YinAXeKfJquMZKmE2KJH 6ZGHNvQ3Z+0/X4bzaHZoyDlmayEewWFSapX1IW8P/Ke4UkEwuG7f3ukFEQOkZ5f1w09v 5w/j1UOD8vAjaq7chrRmYUCPhariPalrbcButAgKs5T8riQ/HK5yQ0zq4zPGmFNesIft NhPJgmcg2PfqgfDQdtiM0SaBSzRsXLoqp+2ria1dgeoK08pzRcK8Axjke0g1CM1EnSJt Y9UbfFB0Xbd7Wl4bwVn8gKjvkiH+m0IpRzPHBxxlZ76KS266cXR9kvqpSkxvroEaQ1iP 6WPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=pb+C9x/bCL7igXfOPb+3iiWzOGaTN/CriZZV/zNUsWA=; b=gwB1kfmrFUSOm9wmudmODyLC2fGZa9NBTT+BogMGDS5A2rt3Gk+ngAEpy7oq8/MWB0 w2/UVANUB44rYMv2gZFP0VMinNf35wEf4Il4o+6JkkZpEyhdKorPymyIdoLZ95Z7sUKS KB25iVHCED+IzNTqq66x20BrPAkXTLkHk6e4uGgOm0fe5Mryri2vmpL2OTNT0tnaFbZH Tf2tFYOoKf0HwGsfuoi3R4OPutjUWpdIQHvrXyZ3c+/3E8g14hpaUBHTUalEIfYB0Tos EAwVP1F2SDC9Xji6pX+jVzru6bvAMX8UAOVhV5hohhQfSbB8sQICjCQ0f0dTkntYFpdZ u7hw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si3366260edy.438.2020.07.01.02.12.33; Wed, 01 Jul 2020 02:12:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729598AbgGAJLR (ORCPT + 99 others); Wed, 1 Jul 2020 05:11:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726129AbgGAJLQ (ORCPT ); Wed, 1 Jul 2020 05:11:16 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A3CC061755 for ; Wed, 1 Jul 2020 02:11:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 81E282A0D02 From: Enric Balletbo i Serra Subject: Re: [PATCH v4 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update To: Prashant Malani , linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Benson Leung , Guenter Roeck References: <20200629211329.2185342-1-pmalani@chromium.org> Message-ID: <37673887-70a6-ed1e-b864-419e690899be@collabora.com> Date: Wed, 1 Jul 2020 11:11:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200629211329.2185342-1-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant, Thank you for the patch. And thanks to Guenter and Heikki for reviewing it. On 29/6/20 23:13, 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 Applied for 5.9 both patches with the corresponding reviewed tags. > --- > > 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) >