From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 72509C433E1 for ; Tue, 16 Jun 2020 15:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58D7920B1F for ; Tue, 16 Jun 2020 15:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592321937; bh=KcTahHkVoRsy+IsGjmhF3qgFZbKsfTtARSuBnB9D+Eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rqGgwLblV2qV6MAckZu+u/2dcaVanjJTRAgF4kT98vlaANkliBHWWPwImuUp763kI 6c+rpMz20RC38QCWd7B4cpDqrETcRE1pEkIUvUNfvxDhXrwmv0E9Drmk35gU4TouJm cd9Zjr3Ao7XnAJyRxmVvlVriDHj2EdrzjWHTEWo8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730803AbgFPPi4 (ORCPT ); Tue, 16 Jun 2020 11:38:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730792AbgFPPiu (ORCPT ); Tue, 16 Jun 2020 11:38:50 -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 AD3D021534; Tue, 16 Jun 2020 15:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592321930; bh=KcTahHkVoRsy+IsGjmhF3qgFZbKsfTtARSuBnB9D+Eo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QAUDUrYK6bU/BxMc53wZA1ty2yHEaP97GchYcqC6RWJ+XX7oQ5/Eqdd3/Qxm5SxbU 11VD1ErcGCp0Vm5O7GERiMwJ+uqgwsVwz384hJs32SpPrkuPsz8+fh99A0tpZb17Qd x4E+mDm5gFES80j86AUM47zRFWx3NWaCSno3l5YI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Linus Walleij , Mark Brown Subject: [PATCH 5.4 070/134] spi: Fix controller unregister order Date: Tue, 16 Jun 2020 17:34:14 +0200 Message-Id: <20200616153104.134143873@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153100.633279950@linuxfoundation.org> References: <20200616153100.633279950@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 84855678add8aba927faf76bc2f130a40f94b6f7 upstream. 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: Greg Kroah-Hartman --- drivers/spi/spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2581,6 +2581,8 @@ void spi_unregister_controller(struct sp 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); @@ -2593,7 +2595,6 @@ void spi_unregister_controller(struct sp 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);