Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2984913ybt; Mon, 29 Jun 2020 12:08:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcbMiIfEZmNJrdwkkDgE0oFn6HbJx+DERyQuQfbZ+W8ZGOGLQCsX1DZXTPBAvgCBt2CMrW X-Received: by 2002:a17:906:4bcf:: with SMTP id x15mr6515411ejv.188.1593457693735; Mon, 29 Jun 2020 12:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593457693; cv=none; d=google.com; s=arc-20160816; b=arpUo4XPFGE3+NYn+6Be0QLu2WhwnI83fLjzO/u2uQS96ws7KYc4CnRPvonddIOHKH GIZMEmA3/zLaqNCoX8mwyYE2arGm4TLtKraEAy+O258AX/uvFC3OdFrCvs2tqRHGLwC6 CBw5MhpGLb+DkX2UOCeZBxFQeASgIb1V+wyCzNVqcUlz8v/t1phPDcKCCDM2NEjyCu3p fanah6SEdpQXRGwqQd3BhyLQ9ZyQ1a7RWEeEFjYBEfJSFtOYHQ3lcb8QgC3qiJ5BxSOY ecTnMLxVYTamamBT/aq+UyM49SdTR+nuc9y08a5Tkcu9ugC5yarLebCYYm2DFc4WlYBY B2Uw== 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=WwUSLGARJc0tc0i7e9PAJ1aEIwQmah2Mj+7/Lw4GWVQ=; b=q8abA9C2+gp7xBrKkCDWarHkXypv5p6JKLwUSpLexU19IcPOnP1vtnj4NioU7jYhOt Y8yuSltMktLFyBk4yNIXP6v0xwL6W7ypqWiKt1DsUhSsfEKkG3IOybMR8ow2qO98m8m1 9tCq+YwmE7w3oooxq5XOcQJMtrTKcMmkhHgJtB1pQoKZnngaR36zfKTy//9YKyTLaK2q pIJAv2kn8nvxSqt99zPGjkElwzp74GQXpkfPaXx675io0hlNT50w57krYwppOVIvBGwc qe44NqrYWwfdLbwCewpR2HWbkabJ1K194TkVMDQw0pBhbNFETpauANjK2TughuC4rMx4 zfWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=O5LrA0hv; 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 n3si293600eji.720.2020.06.29.12.07.50; Mon, 29 Jun 2020 12:08:13 -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=O5LrA0hv; 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 S1730655AbgF2THp (ORCPT + 99 others); Mon, 29 Jun 2020 15:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729786AbgF2THm (ORCPT ); Mon, 29 Jun 2020 15:07:42 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8F6C030F29 for ; Mon, 29 Jun 2020 09:38:57 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id o1so734193plk.1 for ; Mon, 29 Jun 2020 09:38:57 -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=WwUSLGARJc0tc0i7e9PAJ1aEIwQmah2Mj+7/Lw4GWVQ=; b=O5LrA0hvh6pdSNYojIfuGO/VrkNKrM+IJqkHmMn4yck9UH4KIOfGZ880eO68An1QrF pqMdoHrQrlzvSd7H5nTCyPiX3zdnX4gvVQZCrr6gRBFxqzAcC4zmzK9J3FECjM1JAo4i tdb5Mpm6Rm+PiwgvaQZ3UxOSezJDzGlrQFIAU= 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=WwUSLGARJc0tc0i7e9PAJ1aEIwQmah2Mj+7/Lw4GWVQ=; b=lpHlgJC7czyIXDbso2D3a+weSyKcpGP70IEqrtSxSjRyuC9Abtca69WIqAfnO8l7Cl C5fkJwtnyknMfWsi3YVzMg4EPgBuMiUzNZZ/gjFcL2EtKf2bhdtwZiatXMdiKkqRrzYq XBQRomaPDktLvTlgcaZ99ujOk/2n+knMyf2yD6G1nMlWur9qtBXYOHlKrumB0jtDIPTx UAttujJEx4DyD7ppaOScrodg3l6CYFvvu3M5Bo92u4y0EJPT6Ic1eyro954p5rqFtBh8 RhnuYZW95G9mb5kYqmP9bJggBApcutMjbEBa9QLgaD0y6ur/K7PXf2+Rmd8GM/mBfnXW v1fQ== X-Gm-Message-State: AOAM532zMw9KBcb5kw8FgrqaVg4kl8t8VB8H2Q3pplYvzhMtugyRtyXI CCY9RIWFM9ZgyTCi9zhl2atjwUztBCw= X-Received: by 2002:a17:90a:d587:: with SMTP id v7mr7889439pju.29.1593448737198; Mon, 29 Jun 2020 09:38:57 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:476b:691:abc3:38db]) by smtp.gmail.com with ESMTPSA id s6sm79060pfd.20.2020.06.29.09.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 09:38:56 -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 v3 1/2] platform/chrome: cros_ec_typec: Use workqueue for port update Date: Mon, 29 Jun 2020 09:38:50 -0700 Message-Id: <20200629163851.2130450-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 v3: - Use new 100 character line length limit. Changes in v2: - No changes. drivers/platform/chrome/cros_ec_typec.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 0c041b79cbba..0beb62bf5adf 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,26 @@ 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 +698,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