From patchwork Fri Jun 19 14:30:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223782 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 59886C433DF for ; Fri, 19 Jun 2020 16:26:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BCEA21707 for ; Fri, 19 Jun 2020 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592583998; bh=Tq7cuTcF0tIxFTpSSYiEXO2XTBuptqKup8wVy1mdzPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Qn9xw8MaJ+0Ch05zkt2ECYwmttJStm6vji1CWjPeC8M8prDPzoyrKzT3G1+qJnJ8C McO1SLzpdnpVjqiFqhCC6BSOUAy6JhSE3TjzdnV+jb5hBl4T+4zfAQmXesDIQIgo9Q EqC8iNYMihuu+ngxJ4YIRepJ5IYU353xxa9cv5Sc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390069AbgFSQ0g (ORCPT ); Fri, 19 Jun 2020 12:26:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390155AbgFSO4y (ORCPT ); Fri, 19 Jun 2020 10:56:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C86C921919; Fri, 19 Jun 2020 14:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578614; bh=Tq7cuTcF0tIxFTpSSYiEXO2XTBuptqKup8wVy1mdzPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vcyc3zbh7g9J7USzpSfKp1hbZ8d1ClbDQkmnN86GbOBMPwaTLsc2dNr0xFtbkxiq0 F5CcwM8X0wFd+biGoc7INAlKeHgbv158BwuGLD20EFn9xqhHyHO7qugdM7vENAz8P7 McZrW6lXFp8QOH9pjmmw1FaaVuY6/gweWZ3Lk5qE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Linus Walleij , Mark Brown , Sasha Levin Subject: [PATCH 4.19 059/267] spi: Fix controller unregister order Date: Fri, 19 Jun 2020 16:30:44 +0200 Message-Id: <20200619141651.697715454@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lukas Wunner [ Upstream commit 84855678add8aba927faf76bc2f130a40f94b6f7 ] When an SPI controller unregisters, it unbinds all its slave devices. For this, their drivers may need to access the SPI bus, e.g. to quiesce interrupts. However since commit ffbbdd21329f ("spi: create a message queueing infrastructure"), spi_destroy_queue() is executed before unbinding the slaves. It sets ctlr->running = false, thereby preventing SPI bus access and causing unbinding of slave devices to fail. Fix by unbinding slaves before calling spi_destroy_queue(). Fixes: ffbbdd21329f ("spi: create a message queueing infrastructure") Signed-off-by: Lukas Wunner Cc: stable@vger.kernel.org # v3.4+ Cc: Linus Walleij Link: https://lore.kernel.org/r/8aaf9d44c153fe233b17bc2dec4eb679898d7e7b.1589557526.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 0022a49797f9..f589d8100e95 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2306,6 +2306,8 @@ void spi_unregister_controller(struct spi_controller *ctlr) struct spi_controller *found; int id = ctlr->bus_num; + device_for_each_child(&ctlr->dev, NULL, __unregister); + /* First make sure that this controller was ever added */ mutex_lock(&board_lock); found = idr_find(&spi_master_idr, id); @@ -2318,7 +2320,6 @@ void spi_unregister_controller(struct spi_controller *ctlr) list_del(&ctlr->list); mutex_unlock(&board_lock); - device_for_each_child(&ctlr->dev, NULL, __unregister); device_unregister(&ctlr->dev); /* free bus id */ mutex_lock(&board_lock);