Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1094293imm; Wed, 19 Sep 2018 11:58:15 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbhco+JQDG+7+7wJWRwYEfy6ThjY9AWbZoOzlpjhz5CI5AJqvhJHESZhHSuUcDhtVMxepbn X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr35778826pld.289.1537383495708; Wed, 19 Sep 2018 11:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537383495; cv=none; d=google.com; s=arc-20160816; b=GxpGI3t8EHsoiBaE2DGupP+ME5j+TLXqj7jQk+qSFnh8fU64t6FHxwXUTI88DDocY4 GfQ96wmZuA92ew7R3AfsK7QJWBktp1NaGzNJn87emlGodGWoRVE7MjTadroLBq3cOvw5 QvSi/WS1IfN5SkV7ZiyDnOXM9NQwQ4x2K3ns8YwMxUPQiuB7vbtZYhK55eXu7nqfej8x yfXy2xrSWyfZ769hJt03iSsbpk3GIPKZP4N8P2Yo72+PmNnPZtMOEt05LGUr27lZhWOA C0N2UuWiwI7PfqyfPoyoSL+kmrI9UrHNLgs13VBt81VTuTQVXZLHjY6qH/xrziM6G9Hb 7IBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MZL4gfyy9fnDJwzPepvkdkBntNmOPRKo1AATrHJHZ8Q=; b=K1E65ww9K40PZqE2sFwwXpKE1fII5SKhznGlusEiadnsHXKSD3s6uR0ckpSSe6CWTc 4+3TUBDOW2CA9lxwNuTStG21xEotA8AUvVGhYbG13LoqCLDsLV4yn3rdBM24Tk5qgPHw DXYsYrGWKA5th1rnxjVOJTMcUEaVIKsgnFO3HGBZEzYAKyBBESrCyWPemn/xR9osynpK XpwipVPDTWqW4CgTr7BMg71NowIV2HzBcaKVrG9SW/h74EaybxunoJStxwAs2qdslYON 6HIgQWDCdeSWAtQoOCdTpmu2GwvSfoIhh4enmj/Q6RAaibh/urXQRUiRuQ6jicw5zT4y AsIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=I9hCEzTh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c126-v6si22422401pfa.130.2018.09.19.11.57.59; Wed, 19 Sep 2018 11:58:15 -0700 (PDT) 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=@google.com header.s=20161025 header.b=I9hCEzTh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387663AbeITAeu (ORCPT + 99 others); Wed, 19 Sep 2018 20:34:50 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39269 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387650AbeITAet (ORCPT ); Wed, 19 Sep 2018 20:34:49 -0400 Received: by mail-pg1-f196.google.com with SMTP id 85-v6so105945pge.6 for ; Wed, 19 Sep 2018 11:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MZL4gfyy9fnDJwzPepvkdkBntNmOPRKo1AATrHJHZ8Q=; b=I9hCEzThovmipZc4V6WY/QoOxEUyTi1CDYa1qVevTe/VJA32gqwCxsqv9bOjg/U6Xn J1mD5ddIWlg6RgkrwNuKkbLNkYpg1gb/BNjUOh5XQ5+9Iv6pVtCIi9LOTHqoNwsd0REl ooXjMo31aU47biLg3j4u0e53bLbztZpTmg3aAWnoFFDRRhYnO8spgvXoluJGx2ha+4cA 6x+M9/D0DuX3FHSMgOOL52MhxbR4myedrWayuVVJg80bXKwBgqW9Pq5XsjK0Lxjo+QVE 02opNghElAO8gNeC2MH/SGxOT6lURCAoWij2T3EUQvqVZElb6yt6gy3r/dMp0Ypzb2ee hGQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MZL4gfyy9fnDJwzPepvkdkBntNmOPRKo1AATrHJHZ8Q=; b=rZpXfAmoz7KjOkL15SO+N1XKliwqLQJ7kk45eQ5ugIi9g0tFtQEiB7cW4hiKDHDr17 puMP0A6/bFUEz1rRQjFu6XbmrD37m138rXXaE0Oxz3Msl9Nvzqt1HffWPsHww9b/hrYh TXuVW1k+Z/lmp2QtYj4WUA6bhUVDRuhs9YKVXQ10mfnyLF0gDlKb4rxRvids2kqYpm6L 0YueG2F0sacgxtSkb7AIJ+KK2F8eNX1UqwgwPCvmpXPWy4aGmBDeBCatUVDpc6v4drOV ekH1jwrfWCNoJ6YbCSUZaKcn5isUoTDVPUr2Vp5fb0ceeidt3VSdd0IDb+wRCUxtQa0q jX3g== X-Gm-Message-State: APzg51CcypoltH0OmRQU8g9jVw61ileeOLI+mNR3x2nYyh0XrCnhm8I4 fTsgLNpuqgnsgILMayzL0GO3Wt4W3/s7QzT+4QaEJA== X-Received: by 2002:a63:c245:: with SMTP id l5-v6mr33679929pgg.255.1537383334041; Wed, 19 Sep 2018 11:55:34 -0700 (PDT) MIME-Version: 1.0 References: <20180915054739.14117-1-natechancellor@gmail.com> <20180917193936.33e90d5a@coco.lan> In-Reply-To: <20180917193936.33e90d5a@coco.lan> From: Nick Desaulniers Date: Wed, 19 Sep 2018 11:55:21 -0700 Message-ID: Subject: Re: [PATCH] [media] dib7000p: Remove dead code To: mchehab+samsung@kernel.org Cc: Nathan Chancellor , Mauro Carvalho Chehab , linux-media@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 17, 2018 at 3:39 PM Mauro Carvalho Chehab wrote: > > Em Mon, 17 Sep 2018 10:58:32 -0700 > Nick Desaulniers escreveu: > > > On Fri, Sep 14, 2018 at 10:47 PM Nathan Chancellor > > wrote: > > > > > > Clang warns that 'interleaving' is assigned to itself in this function. > > > > > > drivers/media/dvb-frontends/dib7000p.c:1874:15: warning: explicitly > > > assigning value of variable of type 'int' to itself [-Wself-assign] > > > interleaving = interleaving; > > > ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ > > > 1 warning generated. > > > > > > It's correct. Just removing the self-assignment would sufficiently hide > > > the warning but all of this code is dead because 'tmp' is zero due to > > > being multiplied by zero. This doesn't appear to be an issue with > > > dib8000, which this code was copied from in commit 041ad449683b > > > ("[media] dib7000p: Add DVBv5 stats support"). > > > > > > Reported-by: Nick Desaulniers > > > Signed-off-by: Nathan Chancellor > > > --- > > > drivers/media/dvb-frontends/dib7000p.c | 10 ++-------- > > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c > > > index 58387860b62d..25843658fc68 100644 > > > --- a/drivers/media/dvb-frontends/dib7000p.c > > > +++ b/drivers/media/dvb-frontends/dib7000p.c > > > @@ -1800,9 +1800,8 @@ static u32 dib7000p_get_time_us(struct dvb_frontend *demod) > > > > Something looks wrong here (with this function). The patch is no > > functional change, since as you point out `interleaving` is > > initialized to 0, then never updated before read, but I think there's > > an underlying bug here that should be fixed differently. Thanks for > > the patch though, as it does raise the question. > > > > dib7000p_get_time_us has this comment above it: > > > > 1798 /* FIXME: may require changes - this one was borrowed from > > dib8000 */ > > The goal of dib7000p_get_time_us() is to estimate how much time it > takes, with current tuning parameters, to have a certain number of > DVB-T packets. This is used for block error count. That's said, > on a quick look, it seems that the code is not right on many ways. > > It should be aligned with the amount of data it is required for > dib7000 to update the block/bit error counters. There are two kinds > of implementation: > > 1) the frontend has an internal counter that it is shifted and made > available to the driver after a certain amount of received data > (usually in the order of 10^5 to 10^7 bits); > > 2) the frontend has an internal timer that shifts the data from its > internal counter after a certain amount of time (usually at the > seconds range). > > Different vendors opt for either one of the strategy. Some updates > a counter with the amount of bits taken. Unfortunately, this is not > the case of those dib* frontends. So, the Kernel has to estimate > it, based on the tuning parameters. > > From the code, it seems that, for block errors, it waits for 1,250,000 > bits to arrive (e. g. about 766 packets), so, it uses type (1) strategy: > > /* Estimate the number of packets based on bitrate */ > if (!time_us) > time_us = dib7000p_get_time_us(demod); > > if (time_us) { > blocks = 1250000ULL * 1000000ULL; // the multiply here is to convert to microsseconds... > do_div(blocks, time_us * 8 * 204); // As here it divides by the time in microsseconds > c->block_count.stat[0].scale = FE_SCALE_COUNTER; > c->block_count.stat[0].uvalue += blocks; > } > > For BER, the logic assumes that the bit error count should be divided > by 10^-8: > > c->post_bit_count.stat[0].uvalue += 100000000; > > and the counter is updated every second. So, it uses (2). > > > > > Wondering if it has the same bug, it seems it does not: > > drivers/media/dvb-frontends/dib8000.c#dib8000_get_time_us():3986 > > > > dib8000_get_time_us() seems to loop over multiple layers, and then > > assigns interleaving to the final layers interleaving (that looks like > > loop invariant code to me). > > > > Mauro, should dib7000p_get_time_us() use c->layer[???].interleaving? > > I don't think that time interleaving would affect the bit rate. > I suspect that the dead code on dib8000 is just a dead code. > > > I don't see a single reference to `layer` in > > drivers/media/dvb-frontends/dib7000p.c. > > Layers are specific for ISDB-T, but I think DVB-T (or at least DVB-T2) > may use time interleaving. > > Yet, as I said, the goal is to estimate the streaming bit rate. > > I don't remember anymore from where the dib8000 formula came. > > My guts tell that time interleaving shouldn't do much changes (if any) > to the bit rate. I suspect that removing the dead code is likely > OK, but I'll try to see if I can find something related to where this > formula came. Thanks for the detailed feedback. If you find no other references, then I assume this version of the patch is good to go. > > > > > > { > > > struct dtv_frontend_properties *c = &demod->dtv_property_cache; > > > u64 time_us, tmp64; > > > - u32 tmp, denom; > > > - int guard, rate_num, rate_denum = 1, bits_per_symbol; > > > - int interleaving = 0, fft_div; > > > + u32 denom; > > > + int guard, rate_num, rate_denum = 1, bits_per_symbol, fft_div; > > > > > > switch (c->guard_interval) { > > > case GUARD_INTERVAL_1_4: > > > @@ -1871,8 +1870,6 @@ static u32 dib7000p_get_time_us(struct dvb_frontend *demod) > > > break; > > > } > > > > > > - interleaving = interleaving; > > > - > > > denom = bits_per_symbol * rate_num * fft_div * 384; > > > > > > /* If calculus gets wrong, wait for 1s for the next stats */ > > > @@ -1887,9 +1884,6 @@ static u32 dib7000p_get_time_us(struct dvb_frontend *demod) > > > time_us += denom / 2; > > > do_div(time_us, denom); > > > > > > - tmp = 1008 * 96 * interleaving; > > > - time_us += tmp + tmp / guard; > > > - > > > return time_us; > > > } > > > > > > -- > > > 2.18.0 > > > > > > > > > > > Thanks, > Mauro -- Thanks, ~Nick Desaulniers