Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp41118pja; Fri, 22 Nov 2019 03:11:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwQEHSe+/vZb3axei55Cunq8zWo7V+L7vZvGeQuuyD3eoZ3tzyVBe6tBwaUmJ2Ubmh0+8fW X-Received: by 2002:a50:9e4e:: with SMTP id z72mr354151ede.185.1574421102445; Fri, 22 Nov 2019 03:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421102; cv=none; d=google.com; s=arc-20160816; b=ujaps8E07MGuR0WgDAuMNWq3HBbL5u0/4CK2kiIjBwwYq4X8giyHdtUpWeOFjfgmPA itVnyM8I5Odh14U2GhU9yzxpTnw533vbpmS0ziY7yY9H0+fUKGJCStlhAUTAnVJtO531 xJke+u0XeUShiIRIO885ulu+Zavf7h/EmhPrqYIaYy7UVufAOJcgXLmTjGiah7ylCC1j 3inOH04FNstvfqogtiMiAnzRNylrRt0wLG8TqvHZDJS/7NzPNUKP5St4ytwoYozREVIH EIjpUP8kQkcVf3BNvuKryepkw8VqP/SuORF+zdLFkuq9YxzMXeACRVZao0qK9AlbetTE R81g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pW5bnErM299vnV1E502v/Jo5+JAzAs4Wuzz74+bTjAg=; b=DLMVNADpP6DiaW4Z10xgAUNGYWcKz0F615kgNGAmKhnUkiuzFQQVo4z3C9dOIHm2yV hmkm/lCsQTcGs6tDfh+6TOO1/o0hwybHam5vZ/ZF9UoHvMkEKkMcp14JutlqPlzES3cE FtONF4sY/qg7C7PXwEt7LrZQl/bsII3ABN0eoLWUU2n59R+dIapOtxcZu9bRMBxB1pt7 FpJLdRsTohh4tJRbU+71Sa65hachaJMe5I5Dqh3a1GLkimtF0/tphjq3JHGmHGtUrjOY 96jPihCafnHd9UksxzSUKI8xB5qQWt8L5kgmskqxp/kVEdL5jSXSnlWBt18AYB9VlW87 PVuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s072tu2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h5si1254626edd.401.2019.11.22.03.11.16; Fri, 22 Nov 2019 03:11:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s072tu2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731451AbfKVLDo (ORCPT + 99 others); Fri, 22 Nov 2019 06:03:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:57978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731437AbfKVLDk (ORCPT ); Fri, 22 Nov 2019 06:03:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 92203207FC; Fri, 22 Nov 2019 11:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420620; bh=dVNRZUOppbIJs5ql/gl9Dfu+yySfO+0rBHt2dBpyjbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s072tu2MA58vMHKgF9QKhexH4N8abuDn5wkA3OceOr7qHzUe8/9rjOwbQO7kzE2V7 o40N+llf/5lgEsIkrNF0ezOzh1QWXNfs4HxXO/7DDEccV5C2hb8DlzI3pkovHIxOTs o41mb+7PMqZZM1PxsByCA8MkNT/FaUR8ayCreLQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 125/220] media: cec-gpio: select correct Signal Free Time Date: Fri, 22 Nov 2019 11:28:10 +0100 Message-Id: <20191122100921.767282759@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100912.732983531@linuxfoundation.org> References: <20191122100912.732983531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ Upstream commit c439d5c1e13dbf66cff53455432f21d4d0536c51 ] If a receive is in progress or starts before the transmit has a chance, then lower the Signal Free Time of the upcoming transmit to no more than CEC_SIGNAL_FREE_TIME_NEW_INITIATOR. This is per the specification requirements. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/cec-pin.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/media/cec/cec-pin.c b/drivers/media/cec/cec-pin.c index 0496d93b2b8fa..8f987bc0dd883 100644 --- a/drivers/media/cec/cec-pin.c +++ b/drivers/media/cec/cec-pin.c @@ -936,6 +936,17 @@ static enum hrtimer_restart cec_pin_timer(struct hrtimer *timer) /* Start bit, switch to receive state */ pin->ts = ts; pin->state = CEC_ST_RX_START_BIT_LOW; + /* + * If a transmit is pending, then that transmit should + * use a signal free time of no more than + * CEC_SIGNAL_FREE_TIME_NEW_INITIATOR since it will + * have a new initiator due to the receive that is now + * starting. + */ + if (pin->tx_msg.len && pin->tx_signal_free_time > + CEC_SIGNAL_FREE_TIME_NEW_INITIATOR) + pin->tx_signal_free_time = + CEC_SIGNAL_FREE_TIME_NEW_INITIATOR; break; } if (ktime_to_ns(pin->ts) == 0) @@ -1158,6 +1169,15 @@ static int cec_pin_adap_transmit(struct cec_adapter *adap, u8 attempts, { struct cec_pin *pin = adap->pin; + /* + * If a receive is in progress, then this transmit should use + * a signal free time of max CEC_SIGNAL_FREE_TIME_NEW_INITIATOR + * since when it starts transmitting it will have a new initiator. + */ + if (pin->state != CEC_ST_IDLE && + signal_free_time > CEC_SIGNAL_FREE_TIME_NEW_INITIATOR) + signal_free_time = CEC_SIGNAL_FREE_TIME_NEW_INITIATOR; + pin->tx_signal_free_time = signal_free_time; pin->tx_extra_bytes = 0; pin->tx_msg = *msg; -- 2.20.1