From patchwork Fri Jun 16 13:59:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 109169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1379918vqr; Fri, 16 Jun 2023 07:21:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60MWhbRRfw3KiqBYhB6BN25A1DgDorzSBqBwB6lsj74BPk2fMtn5/a07GWOytnIDVI5bUA X-Received: by 2002:a05:6a00:c92:b0:64c:a554:f577 with SMTP id a18-20020a056a000c9200b0064ca554f577mr2904785pfv.11.1686925313367; Fri, 16 Jun 2023 07:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686925313; cv=none; d=google.com; s=arc-20160816; b=J6uPX/aQ6Z3KJA5egYfhlQhwXywK9Aci6/3hWD3enBWXY7dt7NngRaK6KjjJshuYAP ZUiH2bsOhqvcdAKVHy53RQSVi9VVmi64PfC2P8iI8HE1lzm7QoOLZx5ZcPmFLQVw3Kth YAa14pzC01e1GFBhQQ+ZMCEuatYDHCyQye0TAlJsmFSHRGhsEAfqF6GketobLliyXOox zLvA672iYgujFjE/JvXEBow/1/RwX2wDl0tgSIUCGO5lVRJyIiS/zRLPB080wlufUznE KMZqDlCVESb4FYadA/cJUpv4NKTLbXhw5MgffJdzVEGTzy6JBNGNC2pCzSsDNd7LfFNg rrkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4wXdqHu38cJAx7Ava4wt24zDIfqNSGX79Q+509LDfjI=; b=Rz3Z3a+IbxDezeiIPyjjKd2VBkwd8riaCus+Cj5sp7b3oMq/X/4WqmV4ySA7ybQfP0 bfO48t25yvkwCt7qmJpY/Ul0h6ct4lHDLOdPQmC7QCqqz6Y8qEPChaGfUI5uhQA36hy9 /f44Z7G77vIZSd4iENaNIErjNOMZtDN9xO59S4D1D+IuUOgAj/vqVKmhgndksLuvHJAF 99ph6YJezNMKLaej7A0qayyK11IPin6poZuQvKGZFnvMNmlFq0QKeni+bqC/TU8qBYMZ DXVO8ppsI6j+f9YL267pCm1q9eP66iXeKnZgC2oT/erv0xQWEhMzldL1uROsQY8th/wC 8kcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=WDSxDTRo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i185-20020a6254c2000000b00666631f7ed9si5206983pfb.82.2023.06.16.07.21.37; Fri, 16 Jun 2023 07:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=WDSxDTRo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344673AbjFPOAv (ORCPT + 99 others); Fri, 16 Jun 2023 10:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345400AbjFPOA2 (ORCPT ); Fri, 16 Jun 2023 10:00:28 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387F43A91; Fri, 16 Jun 2023 07:00:26 -0700 (PDT) Received: from desky.lan (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1038A1288; Fri, 16 Jun 2023 15:59:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686923991; bh=TK4YhOFvhaya/ewN0odVoqq5/fzBn2JCsOSBpSX+EaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WDSxDTRoWEr1DQN5TqicxHaj01o2XZhN9a+beo+jxVDyiEWrU33vNaT5QdS2r7ILu 38pVM7bU03/ARszH+h9bhXiPxKYdiJA+GGUeWNQF0UPxUQj9FeSAgiWbrb6gKRcKtM AOUk7Scrz/La0CfEJtqrKaMXxLWELqLfSS1r7FGA= From: Tomi Valkeinen To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Luca Ceresoli , Andy Shevchenko , Matti Vaittinen , Laurent Pinchart , Sakari Ailus Cc: Wolfram Sang , Rob Herring , Krzysztof Kozlowski , Mauro Carvalho Chehab , Peter Rosin , Liam Girdwood , Mark Brown , Michael Tretter , Hans Verkuil , Mike Pagano , =?utf-8?q?Krzysztof_Ha=C5=82asa?= , Marek Vasut , Satish Nagireddy , Tomi Valkeinen , Ludwig Zenz Subject: [PATCH v14 09/18] media: i2c: ds90ub960: Fix use of UB960_SR_FWD_CTL1 Date: Fri, 16 Jun 2023 16:59:13 +0300 Message-Id: <20230616135922.442979-10-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230616135922.442979-1-tomi.valkeinen@ideasonboard.com> References: <20230616135922.442979-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768869397113843262?= X-GMAIL-MSGID: =?utf-8?q?1768869397113843262?= The driver does not update the forwarding bits in the UB960_SR_FWD_CTL1 register for ports that won't be used. This might leave port forwardings enabled for unused ports, which might cause issues. Fix this by making sure all the port forwardings are disabled by default, and only enable the ones that are used. Signed-off-by: Tomi Valkeinen Reported-by: Ludwig Zenz Link: https://lore.kernel.org/all/20230516123549.3120-1-lzenz@dh-electronics.com/ --- drivers/media/i2c/ds90ub960.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index ff939300c918..e101bcf2356a 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2330,7 +2330,8 @@ static int ub960_enable_rx_port(struct ub960_data *priv, unsigned int nport) dev_dbg(dev, "enable RX port %u\n", nport); /* Enable forwarding */ - return ub960_update_bits(priv, UB960_SR_FWD_CTL1, BIT(4 + nport), 0); + return ub960_update_bits(priv, UB960_SR_FWD_CTL1, + UB960_SR_FWD_CTL1_PORT_DIS(nport), 0); } static void ub960_disable_rx_port(struct ub960_data *priv, unsigned int nport) @@ -2340,8 +2341,9 @@ static void ub960_disable_rx_port(struct ub960_data *priv, unsigned int nport) dev_dbg(dev, "disable RX port %u\n", nport); /* Disable forwarding */ - ub960_update_bits(priv, UB960_SR_FWD_CTL1, BIT(4 + nport), - BIT(4 + nport)); + ub960_update_bits(priv, UB960_SR_FWD_CTL1, + UB960_SR_FWD_CTL1_PORT_DIS(nport), + UB960_SR_FWD_CTL1_PORT_DIS(nport)); } /* @@ -2467,7 +2469,11 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv, /* Configure RX ports */ - fwd_ctl = 0; + /* + * Keep all port forwardings disabled by default. Forwarding will be + * enabled in ub960_enable_rx_port. + */ + fwd_ctl = GENMASK(7, 4); for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { struct ub960_rxport *rxport = priv->rxports[nport]; @@ -2515,10 +2521,6 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv, break; } - /* Forwarding */ - - fwd_ctl |= BIT(4 + nport); /* forward disable */ - if (rx_data[nport].tx_port == 1) fwd_ctl |= BIT(nport); /* forward to TX1 */ else