Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3528345pxb; Mon, 4 Apr 2022 20:02:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdbPFRH4DVKU2XfTlXqLETCNWVkqEhqMeFpnezN/Lpf02RuIhbw0gNX1H0tEphlw4UphbF X-Received: by 2002:a17:90b:4a41:b0:1c7:a0d7:718c with SMTP id lb1-20020a17090b4a4100b001c7a0d7718cmr1577439pjb.57.1649127756668; Mon, 04 Apr 2022 20:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127756; cv=none; d=google.com; s=arc-20160816; b=l+t4aOC0uVWbRSpPZbHlqbW07E+4fxSExt2lFB/+3NCe1xgOy6qchiA/oEUcQE3co+ KYZ1X+AjdGiji1FR6goKHn91WZXdjgIOzoDTUA8AKiu7n2LtARQWlutI9xsGg10dV9ms 1iFt9zDNDJ2a9K5eFqwl/f9+D/sY+cUKcbg4/GqtRuAqBS9NXLLCoM+fcd2p+2TX385s HX+ul/WBP/bmnMFAq5YZozA52s+RYGzz1dYsU4eCzyd2W7jrLJMxms3xu1FJXdcYzWtZ w3IZbc9cove6Ori7SytFay/v801+0gGc7aR0Pm14raVBfous/jR84o1eNAOxLtM33weO /NnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zoe3fvE8zgv39ln4168pOaRGXstdm61bErhkt3uvmAE=; b=UDci4qK1jj1bsGndES9dZh8vtJrKz1VeBK/ZHVzuhV6RnCkjvL7FQWwo+QaGXLGal5 eL5CgL0hOmYj+GdTWcoU/Z35s3g+NkRxi23scLu2hEqWH/R3WlRTHFYeLmIErT0cm+uX W5CwGl+Nis5irhzzRqd1cS/HiUffsDRDUZ6DnMsZCWZupZDCKg1JD8t/dRO6Wlz2cICT Lgh97nlMs2EKxen6Z2uRjkMnJ5ZUWkA3VNtVGa5A4NqUf2rfIT34vK8nNeGoRd8vDntU 7qnfgRgcjg3v68XjkGt0krdxrYoUIeh6jgi+46FhIIUst6MyCnBiaG92h+nZ/r1LOonH tEpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GKcX9o0k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 19-20020a17090a1a1300b001c6ab94aa0esi864739pjk.169.2022.04.04.20.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:02:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GKcX9o0k; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E641A312B42; Mon, 4 Apr 2022 18:26:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350195AbiDDNby (ORCPT + 99 others); Mon, 4 Apr 2022 09:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiDDNbw (ORCPT ); Mon, 4 Apr 2022 09:31:52 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AAD41E3D3; Mon, 4 Apr 2022 06:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649078996; x=1680614996; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tTRFUipbpnIlHJtdlEwVC9gitLBlF0HbvPqEEMPBF44=; b=GKcX9o0k5FCH/+R59ffFm37X4EVkM4505/tIlp6apHvlyPyY8CxImVq+ KBhci4hi3ZtQzJTsoAZOaU419yKQnFoE1VnOWNfOIjPgyZIkPtICF/pxJ O68UJiDbZULuk/92IoEeShUx0vnJV4ejnGNyuFWOveiqdkGB1LyGH8oSh jFp38OYgT/L31RfjES+/7x9tps6UDMr1/YN5wp1krQBnOdRLzNIHXek5m sZqk8x/I7fL4Im5eRGtyOSdwrQdq/ttl+z/QdqtuJqxiBpBVgYEL3YQ1s JqRYqWJc+aDQF/qO67k7kKYwin4z2v12FVQwP45jUav85nYgb8VHR3tXt Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10306"; a="258094515" X-IronPort-AV: E=Sophos;i="5.90,234,1643702400"; d="scan'208";a="258094515" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2022 06:29:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,234,1643702400"; d="scan'208";a="696569602" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 04 Apr 2022 06:29:52 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 04 Apr 2022 16:29:51 +0300 Date: Mon, 4 Apr 2022 16:29:51 +0300 From: Heikki Krogerus To: Sebastian Krzyszkowiak Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , Sven Peter , Guido =?iso-8859-1?Q?G=FCnther?= , Angus Ainslie , Hector Martin , Bryan O'Donoghue , linux-kernel@vger.kernel.org, kernel@puri.sm Subject: Re: [PATCH 2/7] usb: typec: tipd: set the data role on tps IRQ Message-ID: References: <20220317154518.4082046-1-sebastian.krzyszkowiak@puri.sm> <20220317154518.4082046-3-sebastian.krzyszkowiak@puri.sm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220317154518.4082046-3-sebastian.krzyszkowiak@puri.sm> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 04:45:13PM +0100, Sebastian Krzyszkowiak wrote: > From: Angus Ainslie > > Don't immediately set the data role, only set it in response to the > negotiated value notification from the tps6589x. Otherwise data role > switch fails for DRP. > > We only use values cached from the IRQ instead of poking I2C all > the time. > > The update is moved in a function that will become more useful in later > commits. > > Fixes: 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic") > Signed-off-by: Angus Ainslie > Signed-off-by: Sebastian Krzyszkowiak Fixes tag but but no Cc: stable... tag? Is there some reason why you don't have the stable tag, i.e. why shouldn't this be added to the stable kernels? > --- > drivers/usb/typec/tipd/core.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index dfbba5ae9487..f387786ff95e 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -94,6 +94,7 @@ struct tps6598x { > struct power_supply_desc psy_desc; > enum power_supply_usb_type usb_type; > > + u32 data_status; > u16 pwr_status; > }; > > @@ -271,6 +272,15 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status) > return 0; > } > > +static int > +tps6598x_update_data_status(struct tps6598x *tps, u32 status) > +{ > + tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), > + !!(tps->data_status & TPS_DATA_STATUS_DATA_CONNECTION)); > + trace_tps6598x_data_status(tps->data_status); > + return 0; > +} > + > static void tps6598x_disconnect(struct tps6598x *tps, u32 status) > { > if (!IS_ERR(tps->partner)) > @@ -370,8 +380,6 @@ static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role) > goto out_unlock; > } > > - tps6598x_set_data_role(tps, role, true); > - > out_unlock: > mutex_unlock(&tps->lock); > > @@ -437,6 +445,7 @@ static bool tps6598x_read_data_status(struct tps6598x *tps) > dev_err(tps->dev, "failed to read data status: %d\n", ret); > return false; > } > + tps->data_status = data_status; > trace_tps6598x_data_status(data_status); > > return true; > @@ -497,10 +506,13 @@ static irqreturn_t cd321x_interrupt(int irq, void *data) > if (!tps6598x_read_power_status(tps)) > goto err_clear_ints; > > - if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE) > + if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE) { > if (!tps6598x_read_data_status(tps)) > goto err_clear_ints; > > + tps6598x_update_data_status(tps, status); > + } > + > /* Handle plug insert or removal */ > if (event & APPLE_CD_REG_INT_PLUG_EVENT) > tps6598x_handle_plug_event(tps, status); > @@ -544,10 +556,13 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) > if (!tps6598x_read_power_status(tps)) > goto err_clear_ints; > > - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) > + if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) { > if (!tps6598x_read_data_status(tps)) > goto err_clear_ints; > > + tps6598x_update_data_status(tps, status); > + } > + > /* Handle plug insert or removal */ > if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) > tps6598x_handle_plug_event(tps, status); > -- > 2.35.1 -- heikki