Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp416722pxb; Wed, 13 Jan 2021 06:55:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzy69KgrCBdReyAUyvtwLP/QjROcs1saDXAwZfyk3ebPbwvnl8Y/4uNSXAeKdxO2ZPBl0g1 X-Received: by 2002:a17:906:934c:: with SMTP id p12mr1865066ejw.361.1610549741927; Wed, 13 Jan 2021 06:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610549741; cv=none; d=google.com; s=arc-20160816; b=REM1gIQAYVHtTmETPJHKJOfmXiv2t9SSE1qYY4Xmmu8+k7m7Sonqd1UkKzzHKcy+/U lc1M6AnQOK4nVFV8r2KrLgLqDwMft8a48YsPApz2uKHm8MB6GJ7/NeY62+57+JRvK3yW ue6JQxKn0k2eTa3qfeNCMXqCw4WB9LtVOikj/NNBjf89nVnibL1uPhks2G4fjK93oGlK cUsEIi39RxPSEblqciiunIz/neB9u29wCnC5ak/PdmoNTycIFCcBWxlGcuw5yNPQnlTJ 58OBCcsi5GPRBXseVL9DY6wRSfqPTgxlP0+nNCCEbIkgUsEU6RqtydeAqWlP+ZUSm1YK Dgyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+m95i6hLyIdh7BIpWVUijpi7aowpeDuSUEcNUhIUflw=; b=eXVRMpEbyy/L2axZ1zkRBqw7cpy4NZuoaTC6qp4XWvlMaNll2j2l4lMuHrx2Y+V79M XGcK4hCbz96vxbT+SqBi/4yx5mqYz4zzuuILg5aLbZrsMwoViP/nMm0isO88l9AeffZ9 LF60U7wZRJHY51+Ybi9b3tTPz3scZ7SD9jjZXEOp0pcFSIKXWqPxKCzl+82JhiqbU8sL IqB3MI9iNfH6lmAfj8ddnzY0cPfWjTx2w+2VLhwffIhPfP/Tb4UgmhjYDV/WKLBtaLc0 5cWQTgeK/6TabAR4EH1C96MRrw3SaRUVfqYygOuIlaY7bYvG1HEq6Jn1qgsqc8jKqkj0 2VAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PMGyBtAH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h27si994714ejl.529.2021.01.13.06.55.18; Wed, 13 Jan 2021 06:55:41 -0800 (PST) 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=@google.com header.s=20161025 header.b=PMGyBtAH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbhAMOwT (ORCPT + 99 others); Wed, 13 Jan 2021 09:52:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727645AbhAMOwI (ORCPT ); Wed, 13 Jan 2021 09:52:08 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37931C06134C for ; Wed, 13 Jan 2021 06:50:49 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id n142so1826221qkn.2 for ; Wed, 13 Jan 2021 06:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+m95i6hLyIdh7BIpWVUijpi7aowpeDuSUEcNUhIUflw=; b=PMGyBtAHyyDHUjfhdPgvopoExP/J3PoqrqaM88SKXXr7XFW0Qn/1R9K9aFqLo76mhY IMz92xsd+GFA+UC8inMJvluF1vs5pmHzOLAcPGhswXKnRjYt5KHLONhlIshK6NBC756N oQY9WPA9ONgWH9SN3girCOAy8r4wJkZF1GVzpVDChAFusACBTd0LPUHG0jjDDhSjL6R9 iGZFL5sJVXxnTSSMhV2xdkRar4NsjvAGdoTGqP7NVKdY9WjWLmqJxAr300iNVirYKuDf wMD7O2UCSmXyjmyCdrXBX9rTWO+S42Cy/XxQbN9I6D4A35pJh9tBA5HAQPSJeIIiBiRX 5XeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+m95i6hLyIdh7BIpWVUijpi7aowpeDuSUEcNUhIUflw=; b=KPZIMvsXS+qUx2BTmN+V5NL4MKhWZapSNBcBwrFBv6SS7GL7Q5/+RtufYrZqYOvam0 5CfVaIBZOhRaBbUjWRgjyhrClW2Cw/ygWHLAEVbJvAWjNhriJ5oOcahrFJLQJm0ib41k p/HN8BRVO8pZBZAxUBv9ZUQzhU9s9viIoX78OvovoILh8Tfyoc0UhjBZX4SGNNQs52vO YH5+LC3xnsNRYB62QVUR6wArGaSv/GVtcjY6ozBiJTwTO2GuEZRjr2DkIImwsm8AKQjI AgUDfH6PtWE+v8wIp1poQkVg3veAag9+Foj1GzdUjeqUfPEFPnWiNnLmZKnmVYZYHXw7 2u6A== X-Gm-Message-State: AOAM531mdPHgVoQ4K3nVYARlrX2VDlLvtyaJJc6PTBNdZzQX5gAgP+2r zFwq3Fx8BTTTobN0geFbe7uDcirPzBL2WDFXz0ZyxA== X-Received: by 2002:a37:a747:: with SMTP id q68mr2426420qke.352.1610549448103; Wed, 13 Jan 2021 06:50:48 -0800 (PST) MIME-Version: 1.0 References: <20210105163927.1376770-1-kyletso@google.com> <20210105163927.1376770-3-kyletso@google.com> <20210112135636.GD2020859@kuha.fi.intel.com> In-Reply-To: <20210112135636.GD2020859@kuha.fi.intel.com> From: Kyle Tso Date: Wed, 13 Jan 2021 22:50:32 +0800 Message-ID: Subject: Re: [PATCH v5 2/3] usb: typec: tcpm: Protocol Error handling To: Heikki Krogerus Cc: Guenter Roeck , Greg KH , Hans de Goede , Badhri Jagan Sridharan , USB , LKML , Will McVicker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 9:56 PM Heikki Krogerus wrote: > > On Wed, Jan 06, 2021 at 12:39:26AM +0800, Kyle Tso wrote: > > PD3.0 Spec 6.8.1 describes how to handle Protocol Error. There are > > general rules defined in Table 6-61 which regulate incoming Message > > handling. If the incoming Message is unexpected, unsupported, or > > unrecognized, Protocol Error occurs. Follow the rules to handle these > > situations. Also consider PD2.0 connection (PD2.0 Spec Table 6-36) for > > backward compatibilities. > > > > To know the types of AMS in all the recipient's states, identify those > > AMS who are initiated by the port partner but not yet recorded in the > > current code. > > > > Besides, introduce a new state CHUNK_NOT_SUPP to delay the NOT_SUPPORTED > > message after receiving a chunked message. > > Looks good to me. I put a few style related nitpicks below, but > nothing major. > > > > > + if (port->pwr_role == TYPEC_SOURCE) { > > + if (port->ams == GET_SOURCE_CAPABILITIES) > > + tcpm_pd_handle_state(port, SRC_READY, NONE_AMS, > > + 0); > > + /* Unexpected Source Capabilities */ > > + else > > + tcpm_pd_handle_msg(port, > > + port->negotiated_rev < PD_REV30 ? > > + PD_MSG_CTRL_REJECT : > > + PD_MSG_CTRL_NOT_SUPP, > > + NONE_AMS); > > You can align that properly: > > tcpm_pd_handle_msg(port, > port->negotiated_rev < PD_REV30 ? > PD_MSG_CTRL_REJECT : > PD_MSG_CTRL_NOT_SUPP, > NONE_AMS); > Yes it looks better. will fix it. > > case PD_MSG_DATA_SINK_CAP: > > - tcpm_pd_send_sink_caps(port); > > + ret = tcpm_pd_send_sink_caps(port); > > + if (ret < 0) { > > + tcpm_log(port, > > + "Unable to send snk caps, ret=%d", > > + ret); > > One line is enough: > > tcpm_log(port, "Unable to send snk caps, ret=%d", ret); > will fix it in the next version. thanks, Kyle