Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2972603ybt; Mon, 29 Jun 2020 11:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ+MJA8pZ3oF+4o9sqTATRGbOChFRrd9nL7LjU1K+eLelw//gmiFk9FzgqaouLJWwaCvjK X-Received: by 2002:a17:906:1d5b:: with SMTP id o27mr10044104ejh.367.1593456611835; Mon, 29 Jun 2020 11:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593456611; cv=none; d=google.com; s=arc-20160816; b=i7qtj7kEKXUfoAAzbqg+ZR77bfNTTEWMis3D6zEKxnf1CODgcgbN84RRTeVxYknXP1 WkWR9C/O10+nMvN6izc9pABoeUVXD0wt5Yjy0rjaTM6Bk3aaeFX713qoeCTM0oJwSbO5 ZMsxHdsG6Sy40xtJhOJx3lvAc0/UovTIeZE2PwDv5K5D4jYoEBNREsGe9qkBKFAuVUcO F+JuTjj2bDWRNNxFo7i90kGsP7BgyJq21sXVJEvTo10k4qY0qNY0EI+pdeuPZ6fbwj+t OYtbwpMed3rMiN8HrlFn4ou/lK9Sh8HEcuKCFE9z9EDcYFWowz3zxnR592IQntshZFBM tKgQ== 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=Oa3EF7aSEKdwkHWtdSERQEKRvSSaqtA5gAFV/UpMSiI=; b=oY8QRniuhApBa1sVShSLUp2MccJRmaBDGTZrJkAmHTxGoV/BZSP3GUG/0i8fgeFjvO jAZI+9X8pZwGKEjr1egQM/6rWWeKI9z7lU6ch6yYivl521OasIjquTJDwNTtCrlVyW6y E0ciEamI+DgVFA7Ndu980eFHmQbFSxYx15i4y16WKAljH3mJwKkQRXbIMP345zKLSyN6 TU2aZhKdvEtqQpMnYsc35LzcZ1k1GZYPknxosUMKkSGe1ZRf1GdaQnBf1HVrLrU211E1 ZEMI7toOdRzo5DUd1sEYRAIiMd7EaIV4F2bbUDMo/zwFKF2hqUaHqvAZ4vxLdIahbvVZ RwoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jNiNWESK; 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 x9si218223edj.121.2020.06.29.11.49.48; Mon, 29 Jun 2020 11:50:11 -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=jNiNWESK; 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 S1729439AbgF2Stn (ORCPT + 99 others); Mon, 29 Jun 2020 14:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbgF2Smw (ORCPT ); Mon, 29 Jun 2020 14:42:52 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF6C8C030F06 for ; Mon, 29 Jun 2020 09:13:38 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id a14so3535933pfi.2 for ; Mon, 29 Jun 2020 09:13:38 -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=Oa3EF7aSEKdwkHWtdSERQEKRvSSaqtA5gAFV/UpMSiI=; b=jNiNWESKoWrBIC7iQzZO+r/PpaaeHXKFyuEozVow4Hezk19h6rckiPRJfpN3iIDUk4 jdAeRldMjXlB05SU3Up49L0iCNPvl97Ov0hhJdbTfJL0JoxHCeM1XzA3vOGJnY+BZfQ8 lYNoEcwy3tMrEIE8KXm6O6fiHw0QEaiqKo4/s= 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=Oa3EF7aSEKdwkHWtdSERQEKRvSSaqtA5gAFV/UpMSiI=; b=nO5LEZZ37Ln3wu2wGN6CdrgnV2DNg4c9v4TEPxFzOqHGGh3vJu46/jvfPKItg6GizQ c07xi5rhd884s0prkbuBdWBRnFnJbdQoaxOxw/bTjHDVLOOVdtbLf0Na6FjD5y2+T31f xrujB6lt6P1PpQw7uc/U4XTeYzUm9vHfJQsledI+3dteumZq8yJjUK29WlVy27oqziLn tI1uqO7Fdl3k5Cxjm+iQC1bQ746YGX/Lt9gISMtG2t96pkI/6lmFH8XZbzt76zDMlTku tnyIOsvjM494FgfAnkurxXTTNqubfbvv0TSTsYPD966GFZlDu1mZQcpWfJkiYVXSAq6d VzxA== X-Gm-Message-State: AOAM532rjngnupdbl0/Lt0vLwvSjF0iozEycUE0fuh7cwF3xh4CXk9DM 5sOVcNRwmfzlT1sM/MRmBI6G3TE/8fg= X-Received: by 2002:a63:3d42:: with SMTP id k63mr10987331pga.330.1593447218014; Mon, 29 Jun 2020 09:13:38 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id d5sm188462pfa.71.2020.06.29.09.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 09:13:37 -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 v2 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update Date: Mon, 29 Jun 2020 09:13:32 -0700 Message-Id: <20200629161333.2110327-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 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); + 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); + + 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