Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp290765rdd; Tue, 9 Jan 2024 04:28:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvVDU5D7LLmyX+H8jZwlENuOP8n1Nk0KzcgkpLMtluUz0qyRPnik5RaV7gFLzNW9Kmhps5 X-Received: by 2002:a17:90b:1e4f:b0:28b:d55c:fdc3 with SMTP id pi15-20020a17090b1e4f00b0028bd55cfdc3mr2198994pjb.89.1704803336022; Tue, 09 Jan 2024 04:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704803336; cv=none; d=google.com; s=arc-20160816; b=eJQSZaC/tNgPxwgQmHz8QfVBExD4Ads7/XSUaQT59rhRT5/NN1s/12zbll2+pSs6bA NTo2l900bkoPF1Rat4lwU3b4gSKVx4rtb0Lo0DlvomZMdGCvqFM0excj48/Oxs+h7kc2 gxW5nzrSK4ffRuFDYtmasYbS9+0JPlLaqDH3iCiy8mgAS5z5xxDB8Kp5Xma1DNxAv5SL hhNEEA19CZcIL0dn4rdw+DV7lRl7UNNRCgE+2gjpFsC5c4//fEU5tmfQYZI/QGVIOJkk 6FkXscHG810ly35TQ8GHpXmcvk6mnwhqTb6DzUtCoFCDA0jhCHsnc2m4hCUHRMp9q9d6 Sj+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=bMieFkaeG1CJtNxgRjfc0/kcLvoYVNibgc4cmNBWXG8=; fh=HtZouS9JwFcxb6vSncPGI1UNoR7/D37bTqADUWvASVE=; b=NknB/CNGd23tcYDbpj1fWmucJ7AtuFo6gLszj5lk7ulnkLVIneeuhUZlaqvCYKvTH1 By/fTW2zBSs6l7kxp0SkK29ebXZw8Vle605w7ZEaHV+S3q2Gfxv2qQ25ZlNkAPimDOkM WIQfdPLRdBI+xs9g/3+ERoD2IkU8d4JCJ53QPBlyPW/n5Ae6vfbjKi9B7xRRUi1dv3MR ys+j50YiHBKuo18ZX44Fuy+PRxkidJrb37sqSdCZfFPzOath0LX9cqZX+hvcd5dfKObG GUjKWuZ9umEaR/RASPC5GT0cKbxpddds3f0tZrV1abRW2fIR5z+6fh9wsksA0Xz/7lwL b7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WaTUz7xG; spf=pass (google.com: domain of linux-kernel+bounces-20842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20842-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u18-20020a170903125200b001d508459686si1442137plh.533.2024.01.09.04.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 04:28:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WaTUz7xG; spf=pass (google.com: domain of linux-kernel+bounces-20842-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20842-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DED59B21FCA for ; Tue, 9 Jan 2024 12:28:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70F02381CF; Tue, 9 Jan 2024 12:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WaTUz7xG" Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (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 4CDD9381B5; Tue, 9 Jan 2024 12:28:36 +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-vk1-f172.google.com with SMTP id 71dfb90a1353d-4b79c5d035fso520978e0c.0; Tue, 09 Jan 2024 04:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704803315; x=1705408115; darn=vger.kernel.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bMieFkaeG1CJtNxgRjfc0/kcLvoYVNibgc4cmNBWXG8=; b=WaTUz7xGciX4QB5n7a2cNbkYjyh+7M2ygpOCMUTzknpsIgDM5kT6RyDk6hyN14GdDy jkc8Wcz74ErG9gpCoeDf+MFZshwEv+vR0NzLu6d+1FBLZHZxbq6j/RpcKw6DPHc6Ih6e RbVF4wEPf8n1UnkdJz7lDik67uQA8mxHwsCxBy4Nf7MQbZwuQ30/t/vGo1VVXD2dVafL 6TbZMH896S8LK1EbkEIvtPejNpRzL9A3oTqvh3Us1U8DtNYiqXbJ6/+NHZmoxgXYPnWs dRkfCxOcVJpdIc+swnQNNGDed+bpAeJnPz7bFoBZDU0UzUc7zIG5Dntg8FH8UGRpaR6t x3RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704803315; x=1705408115; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bMieFkaeG1CJtNxgRjfc0/kcLvoYVNibgc4cmNBWXG8=; b=btwysFV81CWoDLkhkmAIrjmEB0M4h1WtFmCWO8pj/y2ESjiC6RD6EUBlLMOvH35mwk 7uiEx6YYRcDtG10YayMKvPh57ydf7raXFWUvxTh/wiHXaDE7DuvsAXqT9JWpeuIPxDRk GxT5osoUS8vl72YJtyXrR7+eFWUbEcWBr6HTZ0A68dImXIYE7ee+SLf6kuqjWHhhq+QA GC4K7F3nYLKl2B7MnC8nW5cPC+1q7s79c7X5Ej5Fp9j3m5Xxbpr9fAlA3PgAiZD5Dnkd EdP8zwXkEyGEd6JKoWy8J2V1IbWKlQWnid6FkVb39/b+1lWpyvd4C7roKdIDTlGseVnq iP5g== X-Gm-Message-State: AOJu0Yy/0UgNfAfEarGt8EMZ0iJTDoPvchO9qxZYVDQiBYRbaQrUC/AE hfSz9ATObkZXKOU6n2CFN+1w4BGNFVtsufoKGMI= X-Received: by 2002:a05:6122:3683:b0:4b6:bc91:92d with SMTP id ec3-20020a056122368300b004b6bc91092dmr2671352vkb.15.1704803315093; Tue, 09 Jan 2024 04:28:35 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231231131705.2010-1-yongsuyoo0215@gmail.com> In-Reply-To: <20231231131705.2010-1-yongsuyoo0215@gmail.com> From: YongSu Yoo Date: Tue, 9 Jan 2024 21:28:23 +0900 Message-ID: Subject: Re: [PATCH] [PATCH] media: dvb_ca_en50221: Add a returing EBUSY logic into CA_RESET To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, yongsu.yoo@lge.com, v4bel@theori.io, 0215yys@hanmail.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear All Do you know how to change from [PATCH] [PATCH] media: dvb_ca_en50221: Add a returing EBUSY logic in..= . to [PATCH] media: dvb_ca_en50221: Add a returing EBUSY logic in... ? 2023=EB=85=84 12=EC=9B=94 31=EC=9D=BC (=EC=9D=BC) =EC=98=A4=ED=9B=84 10:17,= =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > 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 | 8 +++++++- > 1 file changed, 7 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..2e8aec354b7c 100644 > --- a/drivers/media/dvb-core/dvb_ca_en50221.c > +++ b/drivers/media/dvb-core/dvb_ca_en50221.c > @@ -1362,13 +1362,19 @@ static int dvb_ca_en50221_io_do_ioctl(struct file= *file, > struct dvb_ca_slot *sl =3D &ca->slot_info[slot]; > > mutex_lock(&sl->slot_lock); > - if (sl->slot_state !=3D DVB_CA_SLOTSTATE_NONE) { > + if ((sl->slot_state =3D=3D DVB_CA_SLOTSTATE_RUNNI= NG) || > + (sl->slot_state =3D=3D DVB_CA_SLOTSTATE_INVAL= ID)) { > dvb_ca_en50221_slot_shutdown(ca, slot); > if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_C= AMCHANGE) > dvb_ca_en50221_camchange_irq(ca->= pub, > slot= , > DVB_= CA_EN50221_CAMCHANGE_INSERTED); > } > + else { > + if (sl->slot_state !=3D DVB_CA_SLOTSTATE_= NONE) { > + err =3D -EBUSY; > + } > + } > mutex_unlock(&sl->slot_lock); > } > ca->next_read_slot =3D 0; > -- > 2.17.1 >