From patchwork Wed Sep 7 08:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 603370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 09B01C38145 for ; Wed, 7 Sep 2022 08:54:02 +0000 (UTC) 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 A18F074C; Wed, 7 Sep 2022 10:53:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A18F074C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1662540840; bh=Bk8tUDxbYVEqibttEHdC9TJrVtBa+cztjHBE47nndhw=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rS9004o9CDWRBex7s6ot6sFKJ5cQFrEYo9Mq0tVSMLl1dVyEJmEXt22PWGw6O4vcT u35aWKmtCIkQtpQ+RjG1K4E2WRW9fz5BqaMvSvnMLWcGf+tzqllJWLrG+JI8JlqIgq KPKl7G+7ZAs7/wsls/Bshuz7VXNlLsI77XJFYk7s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3B4DAF80423; Wed, 7 Sep 2022 10:53:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B62E2F804B1; Wed, 7 Sep 2022 10:53:08 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 F34CBF8011C for ; Wed, 7 Sep 2022 10:53:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F34CBF8011C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="YYMg2w6H" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2877rCGG005930; Wed, 7 Sep 2022 03:53:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=uf/a9j89KomDA2V4JJLKTY/HwJy3SBHW0c3kiFGZtD4=; b=YYMg2w6HW7yv9T6rzuCYhAux5XLisO9lQxB8EsQhznqeOG44AVIzpM66rHAgwEMZeJ8N 12FU+mwVEwMaryytjln8g/pKnDUEMMadqy3A0HlrLi9cJZ7CgonVZe2DZrlr5j4HD46g orrxU0GZ772jaNXqDNhVrblf5aVIR7O9RuR7k3E/67nSSuMyswzfxsg74I9yYKjmRstU 5DJm7NKktouIPImTRn5Quw1jkxvTh5CjN0nqN7SfSbFdJnYLd2b6tA33SO6Dv/YqdWDF yDUa5lIa21fL62D6qsT5S5Uqid8VwAHZeDKQDvdNdfsCwQXzJ13GRFlxDL1xwkqZBpwa rA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3jc3bpw21n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Sep 2022 03:53:03 -0500 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Wed, 7 Sep 2022 03:53:02 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.12 via Frontend Transport; Wed, 7 Sep 2022 03:53:02 -0500 Received: from debianA11184.ad.cirrus.com (unknown [198.61.65.149]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id D0536B06; Wed, 7 Sep 2022 08:53:01 +0000 (UTC) From: Richard Fitzgerald To: , , , Subject: [PATCH v2 0/5] soundwire: Fixes for spurious and missing UNATTACH Date: Wed, 7 Sep 2022 09:52:54 +0100 Message-ID: <20220907085259.3602-1-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-GUID: CbcV0LrqhBhWd3ZXDCjVKUgSfEHRbdmE X-Proofpoint-ORIG-GUID: CbcV0LrqhBhWd3ZXDCjVKUgSfEHRbdmE X-Proofpoint-Spam-Reason: safe Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, Richard Fitzgerald , linux-kernel@vger.kernel.org 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" The bus and cadence code has several bugs that cause UNATTACH notifications to either be sent spuriously or to be missed. These can be seen occasionally with a single peripheral on the bus, but are much more frequent with multiple peripherals, where several peripherals could change state and report in consecutive PINGs. The root of all of these bugs seems to be a code design flaw that assumed every PING status change would be handled separately. However, PINGs are handled by a workqueue function and there is no guarantee when that function will be scheduled to run or how much CPU time it will receive. PINGs will continue while the work function is handling a snapshot of a previous PING so the code must take account that (a) status could change during the work function and (b) there can be a backlog of changes before the IRQ work function runs again. Tested with 4 peripherals on 1 bus, and 8 peripherals on 2 buses. CHANGES SINCE V1: Patch #3 replaced with a better solution to the same bug. Patches #4 and #5 added to fix some more bugs that were found. Richard Fitzgerald (4): soundwire: bus: Don't lose unattach notifications soundwire: bus: Don't re-enumerate before status is UNATTACHED soundwire: cadence: Fix lost ATTACHED interrupts when enumerating soundwire: bus: Don't exit early if no device IDs were programmed Simon Trimmer (1): soundwire: cadence: fix updating slave status when a bus has multiple peripherals drivers/soundwire/bus.c | 40 +++++++++++----- drivers/soundwire/cadence_master.c | 75 ++++++++++++++++-------------- 2 files changed, 68 insertions(+), 47 deletions(-)