Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1631148pxv; Fri, 16 Jul 2021 13:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLmXrb/xmXvThQmhwnmPH1ZrTjuBkhwnjf6/ZeZkhrsh4lKtllnzkoUGp+ygo4rMP6ClA0 X-Received: by 2002:a5d:9c4a:: with SMTP id 10mr8802770iof.23.1626468915328; Fri, 16 Jul 2021 13:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626468915; cv=none; d=google.com; s=arc-20160816; b=Hpt+8kPHzab6RqYHklkSdqUEzxi60Mgfjg2OylIne3yXQqXNOkmLza2+MoaAZoG07Q p6SASFGRx6xbuN65N9jNlVpQ2/ne825ZhdMj2boZunkQliV8kHgCdxBY2RTsoAJOOCyc CY/BmL6TZr673M7Jjgwt2Dr1gHKQusGnW09cew4t8aM7QHXtfxrHoAdO+8euhJF6U6/z 4GSDSrBKw0ZdD9hpyuxOfaWzpOnQFHMsBRIqug4XdZItNQS63PKol6NYq179DhUrs5A8 2cdp404L6TK49Zpsr9XRL/y2ZjwqoZPEuWPh1Dh0J8coQ7ucqw4obUGxHClWVIQESB00 B7qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=C0RNYvxglUbK9F4HUb/2XqdgUBOpAFzYvl6A0CYT64w=; b=hqSLrwI6xVDD6vlf7dyM8983ZVh78uyZwd/5m642xXzwHn1ldXESAgpTnoXWFSkqK2 dL3PNm9nlXj2vQ0hlYFn4zXrkHQwmzk12G2BuJRk2wh+g2WH4xj1owcZ1/UsIUG8IFgH 5nVKTHxD7qR6+OvTlNLie3OGoWh5e8YxakMJik2ukRVp+zNKMh3D4hXnolRRoYP9wj6H lEJ0Inot6eZjbLJmQtIB/HrfuZrBx6+l1MtWQLyMCtwP+ISbKttlqKncgw3UCYNQIBbx /Y70qFxfohOHwSqM/jHb5z+7zal5k5Wr32zee+7CnpmactK64jKzD6NQL3GUGlvxQKQa PBgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si12409626ilk.78.2021.07.16.13.55.03; Fri, 16 Jul 2021 13:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233181AbhGPU52 (ORCPT + 99 others); Fri, 16 Jul 2021 16:57:28 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:4776 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbhGPU51 (ORCPT ); Fri, 16 Jul 2021 16:57:27 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16GKeMbw010026; Fri, 16 Jul 2021 16:54:28 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 39tw63kv3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jul 2021 16:54:28 -0400 Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 16GKsQit026940 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Jul 2021 16:54:26 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.5; Fri, 16 Jul 2021 16:54:26 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.5; Fri, 16 Jul 2021 16:54:25 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.858.5 via Frontend Transport; Fri, 16 Jul 2021 16:54:25 -0400 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 16GKsNDS003387; Fri, 16 Jul 2021 16:54:23 -0400 From: To: , , CC: , , , , , , , Alexandru Tachici Subject: [PATCH 0/1] spi: spi-bcm2835: Fix deadlock Date: Sat, 17 Jul 2021 00:02:44 +0300 Message-ID: <20210716210245.13240-1-alexandru.tachici@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: jlKMay9owrbYfMeweS0lhRrhn6FYSULv X-Proofpoint-ORIG-GUID: jlKMay9owrbYfMeweS0lhRrhn6FYSULv X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-16_09:2021-07-16,2021-07-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1011 phishscore=0 priorityscore=1501 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107160131 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Tachici The bcm2835_spi_transfer_one function can create a deadlock if it is called while another thread already has the CCF lock. This behavior was observed at boot and when trying to print the clk_summary debugfs. I had registered at the time multiple clocks of AD9545 through the CCF. Tested this using an RPi 4 connected to AD9545 through SPI. See upstream attempt here: https://lore.kernel.org/lkml/20210614070718.78041-3-alexandru.tachici@analog.com/T/ This can happen to any other clock that needs to read the rate/phase from hardware using the SPI. Because when issuing a clk_get_rate/phase, the requesting thread already holds the CCF lock. If another thread, in this case the one that does the spi transfer tries the same, it will cause a deadlock. This happens by chance because not always every spi request gets deferred to a khthread. Alexandru Tachici (1): spi: spi-bcm2835: Fix deadlock drivers/spi/spi-bcm2835.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.25.1