Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp451325pxb; Wed, 18 Nov 2020 08:34:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW0HHMeWjOJF1GiD01R/EELatWeUdDnjIS7XwCKZtOhBSGL9X/vBZf2rYZRpvMdQP7wF9I X-Received: by 2002:a50:da46:: with SMTP id a6mr22243159edk.272.1605717277549; Wed, 18 Nov 2020 08:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605717277; cv=none; d=google.com; s=arc-20160816; b=b8WFtstGY9YMUPaE4Abv8jo5B4ZHvV0eDz+YS8QbMfrA0UEG+OxMwALcnDto7MjtjU gVa3XgWi5i/2sb2/3x8VhyUHa1OSPvFNgoSgQ+lpgTR0kHUNtPLzhnNR3SNgubcuGt5U jc5ioVGK02e/2dHw3yiqO4NgX21iPVH6ae982xSGcJn8eKz797Zce+dTQl+hSkDkYvsj OPlteUNGJUWEKcYSSXFMmUlJOsi2LfIAiCCR1A3kcTBgOWNYqlA+evbvZXqFXqJOVzEw ZXv373E9F8eiNqXfPwvnTyJkwM1Wz8K5Dh4tHE67x734I8utgH0kT/e5UzJdHZ45ioHA KqKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=vsG6w93fVruNeD4Gfl+hCLvoVRW4psGAor0ggsuBozM=; b=VgAtoXnWJaKp07fXtewdpMPo9l8E7c/wcZKBnVF9jHMczvXps2rbVbpt7/6YrFQmR9 ynKQMXwbeNLsxPoKwgG0Hj0WR8KCbfj7n4OwjwK528uHpttbB6neJsC5hDhB6pmFNeui DHhyGewmelO0/iLAsXHQRAxdXShuKXxKQ+lSbVZpOA8snUzfdXwEofeI9SSFNOd6oId1 sJHxeOIg0cs68W5FR4i/MqYdXYXOuYIZRSsbOGpll4bRqRdeDXCBmldBbnm5D112VE9v xLLXcyMu5Kxnx6bi7czeUfka1eIeRofWz5tkiiqtBqvQmTf2P40SmobY7HQICZXcqHuS dP5w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si15441746eje.410.2020.11.18.08.34.09; Wed, 18 Nov 2020 08:34:37 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727955AbgKRQ3k (ORCPT + 99 others); Wed, 18 Nov 2020 11:29:40 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:51306 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727807AbgKRQ3j (ORCPT ); Wed, 18 Nov 2020 11:29:39 -0500 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id F071A8030809; Wed, 18 Nov 2020 16:29:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qaudjfTZt0c0; Wed, 18 Nov 2020 19:29:33 +0300 (MSK) Date: Wed, 18 Nov 2020 19:29:31 +0300 From: Serge Semin To: Mark Brown CC: Serge Semin , Alexey Malahov , Ramil Zaripov , Pavel Parkhomenko , , Subject: Re: [RFC PATCH] spi: Take the SPI IO-mutex in the spi_setup() method Message-ID: <20201118162931.sdpofyw74yyr5n5z@mobilestation> References: <20201117094517.5654-1-Sergey.Semin@baikalelectronics.ru> <20201118131604.GC4827@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20201118131604.GC4827@sirena.org.uk> X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 01:16:04PM +0000, Mark Brown wrote: > On Tue, Nov 17, 2020 at 12:45:17PM +0300, Serge Semin wrote: > > > method being called at the same time. In particular in calling the > > spi_set_cs(false) while there is an SPI-transfer being executed. In my > > case due to the commit cited above all CSs get to be switched off by > > calling the spi_setup() for /dev/spidev0.1 while there is an concurrent > > SPI-transfer execution performed on /dev/spidev0.0. Of course a situation > > of the spi_setup() being called while there is an SPI-transfer being > > executed for two different SPI peripheral devices of the same controller > > may happen not only for the spidev driver, but for instance for MMC SPI + > > some another device, or spi_setup() being called from an SPI-peripheral > > probe method while some other device has already been probed and is being > > used by a corresponding driver... > > It's documented that a driver's spi_setup() operation is supposed to > support being able to be called concurrently with other transfers, see > spi-summary.rst. > > > Of course I could have provided a fix affecting the DW APB SSI driver > > only, for instance, by creating a mutual exclusive access to the set_cs > > callback and setting/clearing only the bit responsible for the > > corresponding chip-select. But after a short research I've discovered that > > the problem most likely affects a lot of the other drivers: > > Yeah, problems with it are very common as the documentation has noted > since forever. IIRC there was some problem triggered by trying to force > it to be serialised but I can't remember what it was. Does it mean nack for this patch from you? So you suggest to fix the controller driver instead, right? If so the best solution would be to just lock the IO mutex in the set_cs callback of the DW APB SSI driver... -Sergey