Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3618197ybt; Tue, 30 Jun 2020 07:24:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySJtroOcCz4PvEt4eiZJHG2dMalj5M8wqK44l33B+/5isMp0wUbgLdrhdJavoVC6//JOqH X-Received: by 2002:a50:cf43:: with SMTP id d3mr24559173edk.40.1593527050981; Tue, 30 Jun 2020 07:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593527050; cv=none; d=google.com; s=arc-20160816; b=lF6oXW1xegVvEq//BmzPlEa2w+lw3CyZ+qIogxSEizNDLjQpXpE4LntBqbFd1L1VjC 7gULTPCKbsTzo9VgFS+Z++Ceje+SZWtdaIwbhINciiMbIRw72BkD4dicegowSNc+m0cQ MIKZc6scOlOzmFBflX7t356ZuOhpxogwaMp15zTKokomQIws9OClCETleDTIXGT0yq+T vwLwWjMxJZW/giiNmN7lVNsATFTdQiwWl0LXnHpNf5uiO/6rShE6yf7oTOZM5zUxdmXw kltTu2OYBcb9CaHUMDFHjNZKTHPsoYWuP1EItzGBcfhmX7oyHWNtsFweqYf10AZjZ2dz 8hcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=hp5jVX20Dz7Mez1y3rVxGbj1P3Z0tq1LJ1Rxp6T/NQE=; b=VekCZBqNpFahKLgzn7CQK9PG/FIQeJVf/jMizVK/BFdQGIqDeCkhXwgXTbl+FQSjAh w+nhutdsO29b9I4GSPgOSeF4x7NkGEqx9fAiEv450GIX+2w8bVHaHiLrGiOHyDgechyJ 7YqrGY7B/TEV6iCY4kXdbFDTHopY56TFS19NkLft6UeWCoz0mylylDwGKLp/eQbFkpjD 3GSthx356GkwTVRu0N2M3k9MaqN+x37k/Z63xlEYT6lDGjrBnIxK+3xyMRE9VtNEaoZy Xw05bb8rjbPV6UMzauuJobeW4bylkhqDd4qfU71DNH5LZ7barugXGc/wvX8b2TvkNk6Y AaMg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y27si1832314eje.284.2020.06.30.07.23.48; Tue, 30 Jun 2020 07:24:10 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732156AbgF3OW7 (ORCPT + 99 others); Tue, 30 Jun 2020 10:22:59 -0400 Received: from mga11.intel.com ([192.55.52.93]:53658 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbgF3OW7 (ORCPT ); Tue, 30 Jun 2020 10:22:59 -0400 IronPort-SDR: CvfHlA+0aDqLdUK9ChXLaQ2yxJphb9dOycWDFLhmo8GEyLeoll6VNSxi8Y0w4DAJ0MBaJ9QReZ B9GVjt5rqJ4g== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="144419247" X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="144419247" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2020 07:22:58 -0700 IronPort-SDR: UigXKErjXKs6WPtNtfQFDGrTuG5eYxjya2rRfq29NkseFbmn3DtX2yLAT01AfBdZ9uCNyPJs5S zFeu9PVdnCSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,297,1589266800"; d="scan'208";a="386709114" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 30 Jun 2020 07:22:55 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 30 Jun 2020 17:22:54 +0300 Date: Tue, 30 Jun 2020 17:22:54 +0300 From: Heikki Krogerus To: Prashant Malani Cc: linux-kernel@vger.kernel.org, Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: Re: [PATCH v4 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update Message-ID: <20200630142254.GD856968@kuha.fi.intel.com> References: <20200629211329.2185342-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200629211329.2185342-1-pmalani@chromium.org> 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 02:13:27PM -0700, 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 Reviewed-by: Heikki Krogerus > --- > > 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 thanks, -- heikki