Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5520420rdb; Sun, 31 Dec 2023 05:06:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb6QQ77C3g3pcek4JrvUjhs/OS+mKgGV+dsvCHsfB5TrYaaMx0O8UR5y4QXvH3/gTf30uq X-Received: by 2002:a17:903:210d:b0:1d4:1809:7b86 with SMTP id o13-20020a170903210d00b001d418097b86mr12287993ple.53.1704027971269; Sun, 31 Dec 2023 05:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704027971; cv=none; d=google.com; s=arc-20160816; b=L9r2UeM5Ni8NN4+3w6/YNA7rWMPHI+IX+uMDuSfa27/G2WXawR/zACkPe+WnEPQXLl NIsLGdOhJ9RPyLAPO7z/vpoZwh1hENIW958wJS7b+Mt5EaSIndC68CJiDZ7y9VY12FX6 eW3XUVFtzlUI0v+Izs13m+yxQ0l4oceoC8KSdV2TKXqLjS+onk1rWr6BfhVlQB8zf4TP lxsbf1M2UO55Q/Jch2jums2k/G9OsGZmoU/GD+e1wyH7DXb7cuG3c6vjAx+SMfItClVH C4D5mxgFX4kaacjjplk5gESszPPLSKScQroiqpwhZjlhppsjk913dTub+h8jyzJPQkv6 vpLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=8ODXawsHJR4eKKT5RiYXWxhMa6vsUAfbFsXJZGtRm/w=; fh=s5s0Ksip4jZtRADdSzBR7tgRGMqPt+QC6f65mNu017k=; b=gOZ4qqTEti0/0mQNV1cFnjRhzigzsLT7h0rRb6abTVUeFsvesCIKMeEoiSK8VWs/SU iNWws90lo5YpHTg97+5Z+EIpFRmJ7DN/s7w6qnCi0guQK/z1Rp/Ya6NDX6QsKJlNY2Iz lT0Jh//VpHJjy2YcLK3cNo/lGgXNOYimI6YWk37r6CNjk0v74CouRT5kei0KxXah3huD q+EupmBQzLonT+Phj8cOFjHBkgMNf21as21w8aohbkGcDwFli7vIuzpVcrUTklaZdUhN 0/osW/tKQ0Ji8Cyy+h4q1EJ3fvTzog6Rhg++vLjZAVcSWfYle/dyb26+JfZ1qRhVkqB0 ODuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KCF92qqm; spf=pass (google.com: domain of linux-kernel+bounces-13705-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f5-20020a17090274c500b001d366f8cfe3si16969724plt.52.2023.12.31.05.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 05:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13705-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KCF92qqm; spf=pass (google.com: domain of linux-kernel+bounces-13705-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CB8DE281C6F for ; Sun, 31 Dec 2023 13:06:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 512B4539F; Sun, 31 Dec 2023 13:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KCF92qqm" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4291A4422; Sun, 31 Dec 2023 13:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d427518d52so41462145ad.0; Sun, 31 Dec 2023 05:06:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704027959; x=1704632759; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8ODXawsHJR4eKKT5RiYXWxhMa6vsUAfbFsXJZGtRm/w=; b=KCF92qqmrZ4d96IW4hOdh6PBvEVF5keOcSsR7tPe88SqRELM/tkH272m27yUfTtoID vogyqGKDnIKwNHhoNBRVozb+sW8U5gwOHw5zUqDYWajoThTILi8FzQTGyY1uuag8G0h1 eFPMWBbgHEI0YItFqjIZQapna41icoo7A4YSTqry0cUMAmQ5VW7f74ZYPjyvWPXEgVsx 9RcZKnINWKj8naXUsk7y2drsm/LEDa3SfLXmiYulyjP3xdDSPEPAtycNAQDNLC8JhFz8 sk5UO+gw2PP5EQLES6Qdp0Y7UvBBE0liJMg4YWTNP7aJPvmbsNoPFW3wnA8I8NqNQJr2 EZww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704027959; x=1704632759; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ODXawsHJR4eKKT5RiYXWxhMa6vsUAfbFsXJZGtRm/w=; b=ctrJEgJ78OTJGK14LtQx0KuBrE7Df2TU/etEVxTPlGYl0pky0f0F+3GvvN+XBjo5yM HuMLf4NdPwNp+OeSBwzF2The3OJrvZaX/mluTEJttm9LE/vFyKneBjwxWAEHx+yu3285 0TTfghZEMW/+G8zMiu99acxuUMUMKZxLyhh4tFvf+nPdFQU8X9LnkWdNVaUO+kGCyiK9 Y7X5hMoq81kjh7D9ryVpg8sNpUJJejnS7RFfD7cHZgsS+FL1iyT2Dub/BEZ2T9H7C6C3 oUA7INSg7HWSiSERtu5aBOAv1UP96GBdMHi7baG7eGnU1c479sOTUGEDbcDHtkLUcE7d Baiw== X-Gm-Message-State: AOJu0YygoWmalnVND+0sYjontswJUYY0zxnKyaoWyY+jeP3++Tx+XC5e djG9n2TeLF7FjzF6G1ZphF8= X-Received: by 2002:a17:902:e293:b0:1d4:381c:a3e5 with SMTP id o19-20020a170902e29300b001d4381ca3e5mr12389414plc.66.1704027959481; Sun, 31 Dec 2023 05:05:59 -0800 (PST) Received: from goorm.ap-northeast-2.compute.internal (ec2-43-201-67-36.ap-northeast-2.compute.amazonaws.com. [43.201.67.36]) by smtp.gmail.com with ESMTPSA id b12-20020a655ccc000000b005cdf7923113sm13137144pgt.68.2023.12.31.05.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 05:05:59 -0800 (PST) From: yongsuyoo0215@gmail.com To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, yongsu.yoo@lge.com, v4bel@theori.io, 0215yys@hanmail.net Cc: Yongsu yoo Subject: [PATCH] [PATCH] media: dvb_ca_en50221: Add a returing EBUSY logic into CA_RESET Date: Sun, 31 Dec 2023 13:05:55 +0000 Message-Id: <20231231130555.1415-1-yongsuyoo0215@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Yongsu yoo Signed-off-by:Yongsu Yoo In source/drivers/media/dvb-core/dvb_ca_en50221.c, if the CA_RESET ioctl is called, in a normal case, the state of the thread of the dvb_ca_en50221_thread_state_machine will transit like below order. DVB_CA_SLOTSTATE_NONE -> DVB_CA_SLOTSTATE_UNINITIALISED -> DVB_CA_SLOTSTATE_WAITREADY -> DVB_CA_SLOTSTATE_VALIDATE -> DVB_CA_SLOTSTATE_WAITFR -> DVB_CA_SLOTSTATE_LINKINIT -> DVB_CA_SLOTSTATE_RUNNING But in some problem cases, the state will become DVB_CA_SLOTSTATE_INVALID. Among the above mentioned states, the DVB_CA_SLOTSTATE_NONE and the DVB_CA_SLOTSTATE_INVALID are "already stablized" states, whereas other states are "transiting" states. The "already stablized" states mean no matter how long time we wait, the state will not be changed. The "transiting" states mean the states whose final state is not yet determined. The state keeps to be changed. Only after some time passes, we get to know whether the final state will be DVB_CA_SLOTSTATE_RUNNING or DVB_CA_SLOTSTATE_INVALID. During the "transiting" states, we do not yet know whether the CA_RESET operation, which triggered the "transiting" states, will succeed or fail. For this reason, during the "transiting" states, if another CA_RESET ioctl is called and if this new CA_RESET ioctl operation begins again, it will be meaningless and waste time. For preventing this problem from happening, we make CA_RESET ioctl do nothing and only return EBUSY if the ioctl is called during the "transiting" states. --- drivers/media/dvb-core/dvb_ca_en50221.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c index baf64540dc00..506a46844ad8 100644 --- a/drivers/media/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb-core/dvb_ca_en50221.c @@ -1362,7 +1362,8 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file, struct dvb_ca_slot *sl = &ca->slot_info[slot]; mutex_lock(&sl->slot_lock); - if (sl->slot_state != DVB_CA_SLOTSTATE_NONE) { + if ((sl->slot_state == DVB_CA_SLOTSTATE_RUNNING) || + (sl->slot_state == DVB_CA_SLOTSTATE_INVALID)) { dvb_ca_en50221_slot_shutdown(ca, slot); if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) dvb_ca_en50221_camchange_irq(ca->pub, -- 2.17.1