Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2146620iof; Tue, 7 Jun 2022 21:18:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznsOrevDa8syb9tEitQSBL12cPfpZ0qZmTX3CPj65eOvPhg8LoFNQo97PfWVz3o0O+8mXZ X-Received: by 2002:a17:902:f70a:b0:153:88c7:774 with SMTP id h10-20020a170902f70a00b0015388c70774mr32069395plo.166.1654661905964; Tue, 07 Jun 2022 21:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661905; cv=none; d=google.com; s=arc-20160816; b=0yLr+NSdc7qcxn7IW7MB+QCExsW+f3aMjgtlvQ5o9nGQbpzv6V5m21jSeirBGQbJf6 LIRGcvrZmGZYMdEePTMO6DTKFCg/uVCnNSErbExFU1AqWGN//vRdP7JX2/bq2Au06pQ9 blMULTNEM/Se38pc/BhO9Qd1Uh903+OyQtfZDw12Oepdas9ytaS0dH/8J6Sc6ePhlKhA jx/JOJi0dOzOiDGQf6OIZKgPJiF3lwyGr2EYwiNcyaXsaSTt93MMPtKYZ9yn3uE+j7o1 pPTGFX7+7/K0W/VGJ6jidEhm1F3Ky2OjMhQlWDOvXXhskCjo8SbPH8p4Hlw4CYOgZs1+ 1o2w== 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=SnbLn9Bg9izKpl8rd5nLms526X+b1cMH+9qd1I603sE=; b=JmCZQg44jGjraiBD0FRFmvDyj8/O2Fn8RL2lqs5zWTbeXPnMpet9IkpcqFPRGdsxhm MRt2PaXF1G6nQ0pla8n2tAGICqwtLXaX4KSvnbGAkZ6LDma7Rw/bnZ6dkE9CME04+oYV 79LYz2M5zhoq1Un/XyeaNiBtftSexaEXyExxutt2Z8iXNNHcdxmXRSrVUs8c8jjLONfh nEIf0n9LHPADdxP8IAXdyY3H8Cjs9dDMyWZK+cLVFVm7r+GZR+bpdWkQ9rAns5CA7dgQ flI477IkOCTT5GJt/7DyiWyv4eY8uteDfwAG1a7JqlgG+Qy2M3xZbD/WeHZZAWzf0x+9 z4nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J+RsfxEv; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b9-20020a170903228900b00158d1f2d451si29027037plh.45.2022.06.07.21.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:18:25 -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=@linuxfoundation.org header.s=korg header.b=J+RsfxEv; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61D2D231CE0; Tue, 7 Jun 2022 20:49:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346381AbiFGR1D (ORCPT + 99 others); Tue, 7 Jun 2022 13:27:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346254AbiFGRXj (ORCPT ); Tue, 7 Jun 2022 13:23:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2844F109197; Tue, 7 Jun 2022 10:21:37 -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 BFE79B81F38; Tue, 7 Jun 2022 17:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39842C385A5; Tue, 7 Jun 2022 17:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622494; bh=mQu+7jJPIF9TEi1yf1eSXdv0q/LGMuG0jvAGx/7bRBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+RsfxEvVCyFdlWQz6ui8SX+Tf7cuZOfva7jt/0XGAxM4H9E6JoaOljimEZojLjVH B8VedzosEcbNVOAgywSSFAhtD11OT1PthNGxdiFCzZxBejU8yqymLJwaHeIKORcnBX sHii1enA/4L6y6jZk0FTcT6Akbk10dNkXecbgwGc= 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.10 080/452] media: cec-adap.c: fix is_configuring state Date: Tue, 7 Jun 2022 18:58:57 +0200 Message-Id: <20220607164910.936627651@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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/core/cec-adap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c index 2e5698fbc3a8..e23aa608f66f 100644 --- a/drivers/media/cec/core/cec-adap.c +++ b/drivers/media/cec/core/cec-adap.c @@ -1271,7 +1271,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) @@ -1328,7 +1328,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; cec_flush(adap); wake_up_interruptible(&adap->kthread_waitq); @@ -1520,9 +1519,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