From patchwork Tue Nov 24 01:33:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 331453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D60C8C2D0E4 for ; Tue, 24 Nov 2020 13:27:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 055012083E for ; Tue, 24 Nov 2020 13:27:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="QdmDvBvm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 055012083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3FFD81683; Tue, 24 Nov 2020 14:26:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3FFD81683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1606224425; bh=4Uj9+ftJ080EADuBIwMAHIr7CcQrCgxgfu2cp0fKJVM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QdmDvBvmq4Frx9G8US3MvcA6ZlK1ZaQqdRCZ4jsI/3TH8ySU56gHJP98iG8scw4sI dDI+ebYhv/O9m4zO59wo8Pl6YJJBOYMeuNDKvNNXiDq0OrItkUyxMRqLc1TV80G62F kGoy1DDoVYEiC3hboeZGHOapO+3PfaZPqBPi4iEc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B0599F80161; Tue, 24 Nov 2020 14:26:14 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 54D3FF80128; Tue, 24 Nov 2020 14:26:13 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 19BECF80128 for ; Tue, 24 Nov 2020 14:26:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 19BECF80128 IronPort-SDR: M1GgLsilSQvjfwW3GgR0iaQRNCoIpZUCCwHLnpW3sVi9lsNMaReWl/B+BvMDdsSoRz8RFhGolN T13F6gd9E+xQ== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="172039535" X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="172039535" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:02 -0800 IronPort-SDR: P15K+84n5V1KVJuVxYWzDy/ZvAifjRJWVPqU2AXI91CyqvbGYti6bxqQY52QJYsnKPqbO6x9UW XNL3nl0jeb/g== X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="546830578" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:25:58 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 1/5] soundwire: bus: add comments to explain interrupt loop filter Date: Tue, 24 Nov 2020 09:33:14 +0800 Message-Id: <20201124013318.8963-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> References: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, srinivas.kandagatla@linaro.org, jank@cadence.com, mengdong.lin@intel.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart The interrupt handling in SoundWire requires software to re-read the interrupt status after clearing an interrupt. In case the interrupt is still outstanding, the code in bus.c will loop a number of times, however that loop is limited to the interrupts detected in the first read. This strategy helps meet SoundWire requirements without remaining forever in an interrupt handler. Add a couple of comments to document this design. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index ffe4600fd95b..45131b9f5080 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1334,6 +1334,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) "SDW_DP0_INT read failed:%d\n", status2); return status2; } + /* filter to limit loop to interrupts identified in the first status read */ status &= status2; count++; @@ -1404,6 +1405,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave, "SDW_DPN_INT read failed:%d\n", status2); return status2; } + /* filter to limit loop to interrupts identified in the first status read */ status &= status2; count++; @@ -1589,7 +1591,10 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) sdca_cascade = ret & SDW_DP0_SDCA_CASCADE; } - /* Make sure no interrupts are pending */ + /* + * Make sure no interrupts are pending, but filter to limit loop + * to interrupts identified in the first status read + */ buf &= _buf; buf2[0] &= _buf2[0]; buf2[1] &= _buf2[1]; From patchwork Tue Nov 24 01:33:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 332420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEBEEC83023 for ; Tue, 24 Nov 2020 13:28:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BFE32083E for ; Tue, 24 Nov 2020 13:28:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="lEzg7hMx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BFE32083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2935816A2; Tue, 24 Nov 2020 14:27:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2935816A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1606224522; bh=vZchKs6GJWa9i156tUhfvao3KvcaUC6jPEFeZ8EBDXQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lEzg7hMxPA2A92uk4Pq3bIH/p3n72cClTTP+jBNrv3xAVZHSDVrGfKz+pVex9SX+M +UD89aZE8Hj6J2JRBhh78d2S6MTGr3PkKwlnGtHdzFHstXUZqZSHfHVTEi2UkO65Yy wFh99DMJzYUQkDnULLqO6rvOunIIFhM9TrczKlWk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C0A51F804BD; Tue, 24 Nov 2020 14:26:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5F328F802C4; Tue, 24 Nov 2020 14:26:18 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8F60EF80165 for ; Tue, 24 Nov 2020 14:26:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8F60EF80165 IronPort-SDR: SfWpRf+NWhwDW8vsL+/GuQEu0b6k0YK8UMqjAjDHWXls4l1GEJR3Y2IYeNUl5AosIuDZ1BvKxt TiYdDxuRjwNw== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="172039547" X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="172039547" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:06 -0800 IronPort-SDR: Z79BzXFxMMG9aF5DZvuzBcD+PMBJrwiMM724QUDfhkr9qZfLupN9lZPLLxScMMUuGddpYWwL/u Wxys2rA3CMYg== X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="546830597" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:02 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 2/5] soundwire: bus: reset slave_notify status at each loop Date: Tue, 24 Nov 2020 09:33:15 +0800 Message-Id: <20201124013318.8963-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> References: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, srinivas.kandagatla@linaro.org, jank@cadence.com, mengdong.lin@intel.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart The code loops multiple times to deal with pending interrupts, but we never reset the slave_notify status. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 45131b9f5080..d6e646521819 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1425,7 +1425,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) u8 clear = 0, bit, port_status[15] = {0}; int port_num, stat, ret, count = 0; unsigned long port; - bool slave_notify = false; + bool slave_notify; u8 sdca_cascade = 0; u8 buf, buf2[2], _buf, _buf2[2]; bool parity_check; @@ -1467,6 +1467,8 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) } do { + slave_notify = false; + /* * Check parity, bus clash and Slave (impl defined) * interrupt From patchwork Tue Nov 24 01:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 331451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63E18C83017 for ; Tue, 24 Nov 2020 13:28:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 92F0E206F9 for ; Tue, 24 Nov 2020 13:28:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="FBvb2CtI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92F0E206F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CE74A16AE; Tue, 24 Nov 2020 14:27:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CE74A16AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1606224528; bh=P4a8LqTrxH4OeBW42ihIdZy5Hj+Pt+hgib+3cF9IX+8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FBvb2CtIepH+9EoOhtm0VI+DRKl1o1RAl64ecbyL7QFCIv137CDte1qwMkVf5PbTr gYMnpbz7UCLUjLRt+tzxbLMHspuOo1j/5gIgFFznqVbOSKFHjHxorbP9sYakY1Be9O pmbrSN8Ze+Zhx1plpUpznN8KlwvkEYkqEC1kNtrc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AAAA4F804CB; Tue, 24 Nov 2020 14:26:21 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 64326F800C1; Tue, 24 Nov 2020 14:26:18 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A0667F80166 for ; Tue, 24 Nov 2020 14:26:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0667F80166 IronPort-SDR: fWAhkAwreSBWLMhEYBjzKlApqOhWfkqxwN6AIIB67LSwJHnRhj8Q2Ev9/wOYPsYSynFY8FDda6 9SIpsHcusZPg== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="172039557" X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="172039557" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:10 -0800 IronPort-SDR: fHdFmb8eD5rqHQHfgTS7u9kPrLx9ko70HZtRBx70s+S7BzIwmwr4GApkTc4UgBAdcJ39+fv15g 5dFHJydQTw8w== X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="546830617" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:06 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 3/5] soundwire: registers: add definitions for clearable interrupt fields Date: Tue, 24 Nov 2020 09:33:16 +0800 Message-Id: <20201124013318.8963-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> References: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, srinivas.kandagatla@linaro.org, jank@cadence.com, mengdong.lin@intel.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart DP0 has reserved fields and the read-only SDCA_CASCADE bit. We should not try to write values in these fields, so add a formal definition for clearable interrupts to be used in DP0 interrupt handling. DPN also has reserved fields so add definitions for clearable interrupts as well. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- include/linux/soundwire/sdw_registers.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/soundwire/sdw_registers.h b/include/linux/soundwire/sdw_registers.h index f420e8059779..0cb1a22685b8 100644 --- a/include/linux/soundwire/sdw_registers.h +++ b/include/linux/soundwire/sdw_registers.h @@ -41,6 +41,12 @@ #define SDW_DP0_INT_IMPDEF1 BIT(5) #define SDW_DP0_INT_IMPDEF2 BIT(6) #define SDW_DP0_INT_IMPDEF3 BIT(7) +#define SDW_DP0_INTERRUPTS (SDW_DP0_INT_TEST_FAIL | \ + SDW_DP0_INT_PORT_READY | \ + SDW_DP0_INT_BRA_FAILURE | \ + SDW_DP0_INT_IMPDEF1 | \ + SDW_DP0_INT_IMPDEF2 | \ + SDW_DP0_INT_IMPDEF3) #define SDW_DP0_PORTCTRL_DATAMODE GENMASK(3, 2) #define SDW_DP0_PORTCTRL_NXTINVBANK BIT(4) @@ -241,6 +247,11 @@ #define SDW_DPN_INT_IMPDEF1 BIT(5) #define SDW_DPN_INT_IMPDEF2 BIT(6) #define SDW_DPN_INT_IMPDEF3 BIT(7) +#define SDW_DPN_INTERRUPTS (SDW_DPN_INT_TEST_FAIL | \ + SDW_DPN_INT_PORT_READY | \ + SDW_DPN_INT_IMPDEF1 | \ + SDW_DPN_INT_IMPDEF2 | \ + SDW_DPN_INT_IMPDEF3) #define SDW_DPN_PORTCTRL_FLOWMODE GENMASK(1, 0) #define SDW_DPN_PORTCTRL_DATAMODE GENMASK(3, 2) From patchwork Tue Nov 24 01:33:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 331452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ACC7C2D0E4 for ; Tue, 24 Nov 2020 13:28:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C60892076E for ; Tue, 24 Nov 2020 13:28:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="NTB6oyW5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C60892076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C914A168F; Tue, 24 Nov 2020 14:27:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C914A168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1606224480; bh=J5GrLXeqbAXZgi/Tp5JOd62olshIV5xw9gfaAr5Pe7Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NTB6oyW5AxfZK3zGrbxwNWtBQmR0YsiD3HrvYDgSI7HaUjgg4pX2piCOsqBTtllbm Ov7nXvF16hIMVJtfK8xqrzUAic4ZS0LoR/dLjT171Pzinddck/Hhwnv1rmtH62xeY+ vPnuBlwmU6TIHOFd21UQX6SEy/8Sn3RHq2jYEMaA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 263BAF802C4; Tue, 24 Nov 2020 14:26:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2481FF804BD; Tue, 24 Nov 2020 14:26:18 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7689EF804BC for ; Tue, 24 Nov 2020 14:26:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7689EF804BC IronPort-SDR: yXoDiT6L9Ot0ZednGQXRyacR7Wnjvb5PxMyAxehx80aYHeCLXW2Een/3UuEqFjcabqzum+xqfR Y/hhc9ZLojAQ== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="172039567" X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="172039567" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:13 -0800 IronPort-SDR: CFMAu0lT0wubz9oezkMeE+x7exoMJProi5RciL3JMtyNeMfhDrJsDcHTcvBwrfsnHZk9EeL4Kw KHdyQAsLfSbQ== X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="546830645" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:10 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 4/5] soundwire: bus: only clear valid DP0 interrupts Date: Tue, 24 Nov 2020 09:33:17 +0800 Message-Id: <20201124013318.8963-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> References: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, srinivas.kandagatla@linaro.org, jank@cadence.com, mengdong.lin@intel.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart We should only access the fields that are relevant for DP0, and never write to reserved or read-only SDCA_CASCADE fields. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index d6e646521819..f66a804f9b74 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1280,7 +1280,7 @@ static int sdw_initialize_slave(struct sdw_slave *slave) static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) { - u8 clear = 0, impl_int_mask; + u8 clear, impl_int_mask; int status, status2, ret, count = 0; status = sdw_read(slave, SDW_DP0_INT); @@ -1291,6 +1291,8 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) } do { + clear = status & ~SDW_DP0_INTERRUPTS; + if (status & SDW_DP0_INT_TEST_FAIL) { dev_err(&slave->dev, "Test fail for port 0\n"); clear |= SDW_DP0_INT_TEST_FAIL; @@ -1319,7 +1321,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) *slave_status = clear; } - /* clear the interrupt */ + /* clear the interrupts but don't touch reserved and SDCA_CASCADE fields */ ret = sdw_write(slave, SDW_DP0_INT, clear); if (ret < 0) { dev_err(slave->bus->dev, @@ -1340,7 +1342,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) count++; /* we can get alerts while processing so keep retrying */ - } while (status != 0 && count < SDW_READ_INTR_CLEAR_RETRY); + } while ((status & SDW_DP0_INTERRUPTS) && (count < SDW_READ_INTR_CLEAR_RETRY)); if (count == SDW_READ_INTR_CLEAR_RETRY) dev_warn(slave->bus->dev, "Reached MAX_RETRY on DP0 read\n"); From patchwork Tue Nov 24 01:33:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 332419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F94DC82593 for ; Tue, 24 Nov 2020 13:29:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BA18204EC for ; Tue, 24 Nov 2020 13:29:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="uQlbsuk0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BA18204EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 02FB616B4; Tue, 24 Nov 2020 14:28:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 02FB616B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1606224575; bh=IRSExc5EPqBMtx9nXBUcg9vmiw/rXkwU0En6NUOJHr0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uQlbsuk0MMO0MuaJPW+Sz7Vt/rjIFySVhuPT19/6scnGDe2Wn3xBQm/TBc687ZRAp 0yqj/26LLXRAJhC9OCOj2A6eXge3ljETT3sOh0YGyedSAK/lnQcw8GQbSAlFyRbUa9 7iu0tIezegEIt6YXYJQa5OP8CAQO0IPdpsBMAiBY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F156FF804E1; Tue, 24 Nov 2020 14:26:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA714F804CC; Tue, 24 Nov 2020 14:26:20 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2275DF80166 for ; Tue, 24 Nov 2020 14:26:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2275DF80166 IronPort-SDR: 55i1ejQrj+SHlbX8SVFUTOZ/MdPTRbJW6spDGupl0cZLIwiDioKaV08/4AUSSaBmcWxxTRTRb2 BxTfXQz5CxUg== X-IronPort-AV: E=McAfee;i="6000,8403,9814"; a="172039574" X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="172039574" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:17 -0800 IronPort-SDR: O/T+2ymNcpD6lR9K7QuPFLdxhLVUivm/bSYnoehkIrziTbwPG1MHuwboS+7hmuhEI5GdYYcgbu q+G0QbvD5hPw== X-IronPort-AV: E=Sophos;i="5.78,366,1599548400"; d="scan'208";a="546830661" Received: from bard-ubuntu.sh.intel.com ([10.239.13.33]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2020 05:26:13 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH 5/5] soundwire: bus: only clear valid DPN interrupts Date: Tue, 24 Nov 2020 09:33:18 +0800 Message-Id: <20201124013318.8963-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> References: <20201124013318.8963-1-yung-chuan.liao@linux.intel.com> Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, hui.wang@canonical.com, srinivas.kandagatla@linaro.org, jank@cadence.com, mengdong.lin@intel.com, sanyog.r.kale@intel.com, rander.wang@linux.intel.com, bard.liao@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart Mirror the changes made for DP0 and don't modify reserved fields. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index f66a804f9b74..d1e8c3a54976 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1353,7 +1353,7 @@ static int sdw_handle_dp0_interrupt(struct sdw_slave *slave, u8 *slave_status) static int sdw_handle_port_interrupt(struct sdw_slave *slave, int port, u8 *slave_status) { - u8 clear = 0, impl_int_mask; + u8 clear, impl_int_mask; int status, status2, ret, count = 0; u32 addr; @@ -1370,6 +1370,8 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave, } do { + clear = status & ~SDW_DPN_INTERRUPTS; + if (status & SDW_DPN_INT_TEST_FAIL) { dev_err(&slave->dev, "Test fail for port:%d\n", port); clear |= SDW_DPN_INT_TEST_FAIL; @@ -1392,7 +1394,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave, *slave_status = clear; } - /* clear the interrupt */ + /* clear the interrupt but don't touch reserved fields */ ret = sdw_write(slave, addr, clear); if (ret < 0) { dev_err(slave->bus->dev, @@ -1413,7 +1415,7 @@ static int sdw_handle_port_interrupt(struct sdw_slave *slave, count++; /* we can get alerts while processing so keep retrying */ - } while (status != 0 && count < SDW_READ_INTR_CLEAR_RETRY); + } while ((status & SDW_DPN_INTERRUPTS) && (count < SDW_READ_INTR_CLEAR_RETRY)); if (count == SDW_READ_INTR_CLEAR_RETRY) dev_warn(slave->bus->dev, "Reached MAX_RETRY on port read");