Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp445248iog; Mon, 13 Jun 2022 06:08:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd5XRQOuls/lFJslv/i2R2RVt9OB8GasbIqRxo4BKA+G72nWNtTCPFPNtJnbodQT7jDBF+ X-Received: by 2002:a17:907:d90:b0:711:d151:51aa with SMTP id go16-20020a1709070d9000b00711d15151aamr36785179ejc.452.1655125685846; Mon, 13 Jun 2022 06:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125685; cv=none; d=google.com; s=arc-20160816; b=DVM+twoFX4xNvbyCQ8vbiSMl0YoGG4LT3jwTmwuBvrDmHg/v6nwb7aAQ9ntyGetmuy s7mZ2G+obtIZPxEryBEaqHlqQ+7C/Kdhjqtj8kSepHpYkVja8+lde2r6z2/oFz0TSzg2 UPblRegzZVHSBQqL24g9QeVgz123hY5K2obp+/CcqWaVtj51yqEG8d+K4JZl/ItEnxwu GpLv9S9M0emUBM9169qmlOYyoFQVxkerabNqXZ0IQ1Zo4gt+UhsYgQLwt+6C58zAZmFr xj+aShgAiJcWwceuyw1kq+cadlAMWOVA2ofDT0gPgWH4CdRKv7cgMrIacgx2M50a0KYw 8AMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mmph8xgVDHUzfio4YhWmSHhsJl4pSuEBzAZ3EDZqhLE=; b=VCqwtSVDlOFU0Tl2PPoOqLBycCLVGsT2WYjNEOStPr+IV9C7Rysztd4yu1Y3xMlhus 4bZMB8jCbaQo/164xKlfkJ2xL06sZH1obHlVfzf/TJnUsbYlpwCvJK5wkTQQHNeO5e9o bM5tYE2gAFNKXQUH69JdGYYtjapr5ohcDVirc4P5YDr4Nc/ixREK5s0ZVhEOo0zOyfjg 18jJXKMztjgS9fsdj2eTu5YKFeyJH2x4KvxvhpmFhOqg67Ly4KX2FUkZHyRt7mBTVrsw nigZZT9EIecJkl/++79fDlEYDaXSbbFZCMLgl4NjQTwqjYnXCa9SblUWjg8LkfGfhOEs yLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DSEuQQAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a17090672c600b006f3a0ad9695si7714162ejl.81.2022.06.13.06.07.39; Mon, 13 Jun 2022 06:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DSEuQQAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351149AbiFMLD2 (ORCPT + 99 others); Mon, 13 Jun 2022 07:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350565AbiFMKy6 (ORCPT ); Mon, 13 Jun 2022 06:54:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD2272127E; Mon, 13 Jun 2022 03:31:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 42910B80E95; Mon, 13 Jun 2022 10:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8755BC3411C; Mon, 13 Jun 2022 10:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116300; bh=LwQYWt8RcYawY9dcDrj6e1/FgVm0e/k1MIM239Db11s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DSEuQQAlW6WpDYZfs9GZuYD53hjT/dCA3A+4aukr8VUwwcCM1W4W1B2pWspRB0Qv1 iBlbRk4vKCGLGoA6Jh2OZ7h1JNK68RPMA8p9GnsxEKnX5n8A1q6+lb9kUdoeyHhs/0 IkTfj/EPS9fseIqE7nU9ShDHsoczsjlO/f8xk5dw= 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 5.4 051/411] media: cec-adap.c: fix is_configuring state Date: Mon, 13 Jun 2022 12:05:24 +0200 Message-Id: <20220613094930.040892857@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Hans Verkuil [ Upstream commit 59267fc34f4900dcd2ec3295f6be04b79aee2186 ] If an adapter is trying to claim a free logical address then it is in the 'is_configuring' state. If during that process the cable is disconnected (HPD goes low, which in turn invalidates the physical address), then cec_adap_unconfigure() is called, and that set the is_configuring boolean to false, even though the thread that's trying to claim an LA is still running. Don't touch the is_configuring bool in cec_adap_unconfigure(), it will eventually be cleared by the thread. By making that change the cec_config_log_addr() function also had to change: it was aborting if is_configuring became false (since that is what cec_adap_unconfigure() did), but that no longer works. Instead check if the physical address is invalid. That is a much more appropriate check anyway. This fixes a bug where the the adapter could be disabled even though the device was still configuring. This could cause POLL transmits to time out. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/cec-adap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 56857ac0a0be..c665f7d20c44 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -1263,7 +1263,7 @@ static int cec_config_log_addr(struct cec_adapter *adap, * While trying to poll the physical address was reset * and the adapter was unconfigured, so bail out. */ - if (!adap->is_configuring) + if (adap->phys_addr == CEC_PHYS_ADDR_INVALID) return -EINTR; if (err) @@ -1321,7 +1321,6 @@ static void cec_adap_unconfigure(struct cec_adapter *adap) adap->phys_addr != CEC_PHYS_ADDR_INVALID) WARN_ON(adap->ops->adap_log_addr(adap, CEC_LOG_ADDR_INVALID)); adap->log_addrs.log_addr_mask = 0; - adap->is_configuring = false; adap->is_configured = false; memset(adap->phys_addrs, 0xff, sizeof(adap->phys_addrs)); cec_flush(adap); @@ -1514,9 +1513,10 @@ static int cec_config_thread_func(void *arg) for (i = 0; i < las->num_log_addrs; i++) las->log_addr[i] = CEC_LOG_ADDR_INVALID; cec_adap_unconfigure(adap); + adap->is_configuring = false; adap->kthread_config = NULL; - mutex_unlock(&adap->lock); complete(&adap->config_completion); + mutex_unlock(&adap->lock); return 0; } -- 2.35.1