From patchwork Fri Mar 24 18:23:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9643711 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 6F9D5602C9 for ; Fri, 24 Mar 2017 18:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6509E26907 for ; Fri, 24 Mar 2017 18:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59E6926E51; Fri, 24 Mar 2017 18:26:18 +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 05A3726907 for ; Fri, 24 Mar 2017 18:26:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817AbdCXS0Q (ORCPT ); Fri, 24 Mar 2017 14:26:16 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34913 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754351AbdCXSZu (ORCPT ); Fri, 24 Mar 2017 14:25:50 -0400 Received: by mail-wm0-f67.google.com with SMTP id z133so2223163wmb.2 for ; Fri, 24 Mar 2017 11:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Bd4F/lmtN2GlplRnJ1arcPT+R58Bq6mEBHKT6Q9QBmQ=; b=hIqpRR3jI6qpGSZhBgxBOHv7roFyF4rZa+PlBisRGsLbVgfJLxz4exgS9WpKABQytQ QDAkAaxlr9BW2tl3FnCfLfwzVVuYA1dpJ8pv5OELLJIvAQD4gJ70P0R4d9XSmEEXVE8z LaaREhZCGbBU5vEoux+j99KK03fmngWcwx9dOdDGZHlanhHbxBfuQ0jNf/5Co0ZW2IQc j0xQtKBeQZbXCqDLutdLIn0TubXDVYsTb4eFcc8Wgewx5YYP1Tno8AoAMcr0FVaqsvxY ds9TBVd7bfCm8C1SAK9B7jbn91x1fTxGPsXI8Gn8lFoR45yTYodaIo7CLK6ho7tykjV2 NHtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Bd4F/lmtN2GlplRnJ1arcPT+R58Bq6mEBHKT6Q9QBmQ=; b=PV3LlK+Fe+5g8izkOn/G+esKpA2j2ILQ4O4VmbiWk+E8NVrrNDD/EEe0mlsH1oH8mN Ug4Zjyo6I3dHqwGWa+Eh/jfNiyZ1TqNCVB8djlihuNuSOKKlHsWrqYLQ8MRnFjrII4WH aiSAo9drebMi4hatqQsUSmC0YYZ4wCBKRkMnx81UXu2Z4x6mel1nfoEQZ4yz4nW1jXCa xutkAboM/+5IdTCJXRst+ppATH6vs9UH2NQabpSZi9RB/k3ie3O0Bf06mYe367xtDKSf omMnBR6fuF/23H+WqKySZcpWVZK8sHk6GXpZKFoAdlPHzS3Ij7QOYSye69L6CLKri38F xFyA== X-Gm-Message-State: AFeK/H0dNZDu1Iu0KS4t/Fcmt+UALIPrisf/yhKw7l4P/GWxB9g2pJEcHJ8ASMVpUUsFEQ== X-Received: by 10.28.148.195 with SMTP id w186mr4365752wmd.35.1490379938770; Fri, 24 Mar 2017 11:25:38 -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 w12sm3830519wra.21.2017.03.24.11.25.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Mar 2017 11:25:38 -0700 (PDT) From: Daniel Scheller To: mchehab@kernel.org, linux-media@vger.kernel.org Subject: [PATCH v2 01/12] [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional Date: Fri, 24 Mar 2017 19:23:57 +0100 Message-Id: <20170324182408.25996-2-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170324182408.25996-1-d.scheller.oss@gmail.com> References: <20170324182408.25996-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 */