From patchwork Wed Mar 29 16:43:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9651953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34F38602C8 for ; Wed, 29 Mar 2017 16:43:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26A982845F for ; Wed, 29 Mar 2017 16:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19F1028485; Wed, 29 Mar 2017 16:43:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0D3E28497 for ; Wed, 29 Mar 2017 16:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753003AbdC2QnT (ORCPT ); Wed, 29 Mar 2017 12:43:19 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:32831 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752454AbdC2QnS (ORCPT ); Wed, 29 Mar 2017 12:43:18 -0400 Received: by mail-wr0-f195.google.com with SMTP id u18so4575524wrc.0 for ; Wed, 29 Mar 2017 09:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bd4F/lmtN2GlplRnJ1arcPT+R58Bq6mEBHKT6Q9QBmQ=; b=X13PdyCEaqGOqQeW5HgHpuHHXmSe1rNE/4CNqajzS+wZDduMdAhN/d9xgvTO64NO/g MHQ8EfkdaXIWF3/DxXIoMCM2ONiX1hvWwG9X8OI/3bzmhCEGuAZo1mS2vfuiSax0JNUB JYa6XVZkUocgLfoXWZwbneeNADcc7prlGzfvergs+qWD7RlKc6fBDronSjJQTSMPVk4T GNa4yoSvZug7Z/cG80rkHL5Iys5bbMDCwmwFeu/Ys4sYmaxpjs0D+OPMBuleTd/JaFRY 3PZqdhcS3vN8T61TfrlLpY1HBzRNJ0gArn0NX5bM+demO96H7TT6uEsK+h2tQbxy2b9x is6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bd4F/lmtN2GlplRnJ1arcPT+R58Bq6mEBHKT6Q9QBmQ=; b=adTZDfqSN5sesv7yvXw8VxtQ/yDCcYb0TZ9hmGXo2VT7MYdgtEbAY9TvfsjtX0sKvY e7+YT8looADkDibGR/E1/Q1esrPvWDNRMxAGykYWBogjTUc2sSR49MDmKfr7mS8C8JF0 HhJp1aBi3siVKLLJ09+7GECqPhjxcU33c0+8HO7YMhjtBS5zu6gZP6vXtumwkZK55jG0 /5+twnjm4iMNgBnhHfb1DBjCnTbGDbuRuK/q5WONcF0djACcWiaQlKpPd/yjR4FZkiOO X2Sjfu/FQXAtYuncBosVCPuci2kDKixXp1ybqiocgx6V6HXlfABnqmEWOK5Hb2DmnnU/ FG1w== X-Gm-Message-State: AFeK/H3DlLgeGRty0FJZi9Li5mk4jblepZnwKNiu72JOdwKn5f3PaGtJaY2rQYerqbjFhQ== X-Received: by 10.223.178.172 with SMTP id g41mr1338841wrd.126.1490805796574; Wed, 29 Mar 2017 09:43:16 -0700 (PDT) Received: from dvbdev.wuest.de (ip-37-24-178-151.hsi14.unitymediagroup.de. [37.24.178.151]) by smtp.gmail.com with ESMTPSA id x127sm8835277wmf.31.2017.03.29.09.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Mar 2017 09:43:16 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org Cc: liplianin@netup.ru, rjkm@metzlerbros.de, crope@iki.fi Subject: [PATCH v3 01/13] [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional Date: Wed, 29 Mar 2017 18:43:01 +0200 Message-Id: <20170329164313.14636-2-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170329164313.14636-1-d.scheller.oss@gmail.com> References: <20170329164313.14636-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Some hardware and bridges (namely ddbridge) require that tuner access is limited to one concurrent access and wrap i2c gate control with a mutex_lock when attaching frontends. According to vendor information, this is required as concurrent tuner reconfiguration can interfere each other and at worst cause tuning fails or bad reception quality. If the demod driver does gate_ctrl before setting up tuner parameters, and the tuner does another I2C enable, it will deadlock forever when gate_ctrl is wrapped into the mutex_lock. This adds a flag and a conditional before triggering gate_ctrl in the demodulator driver. Signed-off-by: Daniel Scheller --- drivers/media/dvb-frontends/stv0367.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c index fd49c43..fc80934 100644 --- a/drivers/media/dvb-frontends/stv0367.c +++ b/drivers/media/dvb-frontends/stv0367.c @@ -89,6 +89,8 @@ struct stv0367_state { struct stv0367cab_state *cab_state; /* DVB-T */ struct stv0367ter_state *ter_state; + /* flags for operation control */ + u8 use_i2c_gatectrl; }; struct st_register { @@ -1827,10 +1829,10 @@ static int stv0367ter_set_frontend(struct dvb_frontend *fe) stv0367ter_init(fe); if (fe->ops.tuner_ops.set_params) { - if (fe->ops.i2c_gate_ctrl) + if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.tuner_ops.set_params(fe); - if (fe->ops.i2c_gate_ctrl) + if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); } @@ -2321,6 +2323,9 @@ struct dvb_frontend *stv0367ter_attach(const struct stv0367_config *config, state->fe.demodulator_priv = state; state->chip_id = stv0367_readreg(state, 0xf000); + /* demod operation options */ + state->use_i2c_gatectrl = 1; + dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); /* check if the demod is there */ @@ -3120,10 +3125,10 @@ static int stv0367cab_set_frontend(struct dvb_frontend *fe) /* Tuner Frequency Setting */ if (fe->ops.tuner_ops.set_params) { - if (fe->ops.i2c_gate_ctrl) + if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.tuner_ops.set_params(fe); - if (fe->ops.i2c_gate_ctrl) + if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); } @@ -3437,6 +3442,9 @@ struct dvb_frontend *stv0367cab_attach(const struct stv0367_config *config, state->fe.demodulator_priv = state; state->chip_id = stv0367_readreg(state, 0xf000); + /* demod operation options */ + state->use_i2c_gatectrl = 1; + dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id); /* check if the demod is there */