Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3061248ybt; Mon, 29 Jun 2020 14:15:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF/D0j455+S6yaDnh+lCXyvyFqwqJSY2K8pSZuKTr3cWIUhkc6swFa7jfPIMvgJZoQGZ10 X-Received: by 2002:a17:907:20b4:: with SMTP id pw20mr16216990ejb.225.1593465312095; Mon, 29 Jun 2020 14:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593465312; cv=none; d=google.com; s=arc-20160816; b=SrVkcGHvuK2dbuahHoEZrdLvu+ek4V0JvOfh19BTfO2RHanQMujP6r7ys74bj14dAr kBS21vUg3p46PM3XyIRVt01iRXxpBkDXoij+llyHdleuqKc3g4/yFI7muTVYyjwCC88W BvotZWCZItEfhNqMU0v4DGB9ysXZ6mU0YNmMODK1woGAmmwlfz+1xJ4LtPjkg+mwfG2P b7l4XgzJlefI9pmwwGfcKalM/1DA3d+FMIDtJAsgwAV7Idhwf26WuNq2MjArEhXriky0 5fgH9OlbmnicqD9QN3AvFtOhDgM0RG3zXO7Vc3/6J6EFP2ds3VX5w5VUBhtMaAUW299/ b14w== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5sFF8DS0umZeNWR3A7XVhtrJ8Q+yiyanzVjLicQ+JyQ=; b=BtlbGbxb31Q2gvJkLMqLCZbZiVPPJNt0A4F3Wh5Z8BUAGFGnuIhCexaiAc+GqIWT1v v15OmfjvwmEA5wuOXmItLx45zAyR2eIC8D8a1KKiG0XsF7HLCznSjer1rrz3E5BYSnz3 dr9pVpxSuRP1M/4iDf/ay9zM8hzsV4KZlyIWkv7EoNqT3MOc053IiJ9JNgP+K5t6e1bE PI2UK0lAB1hZ6/SRozTJ6IaAm+L8dKLUII58yC33aUhb0RuEIW/9zzFayez+R4Pqm0Jq NHykIHHYEPwbBchJhE9qAui34vaqMo3NkxiEM0vZlrJUATcRD0nVXc7L1ni5N7gP2JgE cWgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dgH7HjBA; 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 i16si327505eds.541.2020.06.29.14.14.49; Mon, 29 Jun 2020 14:15:12 -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=dgH7HjBA; 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 S1731130AbgF2VNg (ORCPT + 99 others); Mon, 29 Jun 2020 17:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728519AbgF2VNe (ORCPT ); Mon, 29 Jun 2020 17:13:34 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1B2C03E979 for ; Mon, 29 Jun 2020 14:13:33 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id f2so7577483plr.8 for ; Mon, 29 Jun 2020 14:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5sFF8DS0umZeNWR3A7XVhtrJ8Q+yiyanzVjLicQ+JyQ=; b=dgH7HjBAGSJvBsOEE9v9R4TD1e1BoBv6nV40psJt2v/1As5vgP62vWuaq8Bw2et23C tiqk9xc0o1ne4bZ7eGQ8NCKsJTdDKwxyJAIHyVx89Jqe1xKe2rGXE1R6T6WENXe6QO9V x4748h2V5i42cov7xOw9MWB7U6UKN7fcexNmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5sFF8DS0umZeNWR3A7XVhtrJ8Q+yiyanzVjLicQ+JyQ=; b=bwU+5ACcsWQ8VfI0QF97rXDRKD9BGNrBeBogQQkA/YrKKiRvAOlQTnzsq37tzoYtGs IiZNoeh/1yN6lHLmG7+DVC3vqx0+0XU17Uzdmk3mgoJ0cwiDbUfv5rktN36QwMhWwsFD nUtIs1tPk9II3LJIUznVnYGEQ93XVSGHmaYXk5UcVMABPehiwldFgx4tiNUxjlXp5HeV 1cjqkftmBJ368SYXFNdqSpxmm+DB1u93EY4rF1jo4dKNKpKfCsaOTPSo5Rxy74sHeu+F 6Viv4ETxkPjlRUONlamyLFoRGCG3mJ86q/pMECnc7VesA2KSb2bTXASJX1SDqsls1062 5tGA== X-Gm-Message-State: AOAM530dZC/esV2lo40pWx+hx0ld43BAnB6Uq0WSjUdh8gw8HwfN61KO lqf0X4Q2w2BaVaA0mQWd6AJrJ4X5N3Y= X-Received: by 2002:a17:90a:22ab:: with SMTP id s40mr20513101pjc.117.1593465213098; Mon, 29 Jun 2020 14:13:33 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id y19sm508354pfc.135.2020.06.29.14.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 14:13:32 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Prashant Malani , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH v4 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update Date: Mon, 29 Jun 2020 14:13:27 -0700 Message-Id: <20200629211329.2185342-1-pmalani@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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