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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 AB88BC433E0 for ; Fri, 15 May 2020 21:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85A1B2070A for ; Fri, 15 May 2020 21:33:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tVgKWMBH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbgEOVdM (ORCPT ); Fri, 15 May 2020 17:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726301AbgEOVdL (ORCPT ); Fri, 15 May 2020 17:33:11 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A11C061A0C for ; Fri, 15 May 2020 14:33:10 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id q24so1573277pjd.1 for ; Fri, 15 May 2020 14:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zOy7Lg4L/jx9ljWYiP2hH6zPAudKPtQ8cz2fMkkgc8M=; b=tVgKWMBHjEmtqjVpyQLXOwSF3oyli942dJLU+cFuXTl/eEOh9nZWB26fUUZltyA+tv N0FZWIRnUAawTkNNdT2NnuqiXKY6Cee6T3Wq3h40wS+3YphNxTghqoIij+nb1eAvPitI YZ6SSovQvn75a0evK5r61KuKdk+1HEnZRY/Iy4Iq71NS5+/AAAionwFw47ckleVVYnA3 0vnZVLJ7fr9N5EYOZqm2pJcLnlckFIqhYn41rz/ckZOrzp5b3c3Ycg+YuP3JMOqnPyQk co46L5xWCLmuGqzZeQtSdyDbF7B0hzNi8lIISd77hJB4VC2SSH/n0LJbEuQGIFPVxksk l/WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zOy7Lg4L/jx9ljWYiP2hH6zPAudKPtQ8cz2fMkkgc8M=; b=WgJSJttgj2wHCk4R5mBavDS2buYOiofYnG3aBQGpzM8SjQoEAo0k6gnxkp7OchlRRG qkraEzEd6V8uViBsKXiBrWGTpn/xbA1ccH/T8nd5OF/10FHn3p+KkeKHwWG6OL7FTiLE RMFaAGeaeBAOAgmCaPZiPKTImtwu2grX/lcBf1W5OZ2Mud3rVuIbQpFn4Z6PxB4zf1cI MnbNS8cC286EmDKCHf/jVo/jJ35LRedhqsYq9k2zr4rE7yetGckKA5BSCQYDL3Ffgbas 1czt5MHhSc0K2fYxTQYnzKbpjEjEKIYsGCyvFQYk/mS8gcBqW4h06EYhk07CV7auQOCU /VMQ== X-Gm-Message-State: AOAM5310+JE+aEqQcVfYWshk+vJLPBPzgyTU4RFdmIYRBw3a9L5AMhlt wTmYRa7bmUMAlpEGCxII8vyRUDVLwQltdkRPnPE= X-Google-Smtp-Source: ABdhPJyOWCf3pOcAvs0fdU97WiTRVwzsvWjRWLWWSaLTMZSflTGaJ52Q++OOOOZyIDd0ocWOOlclNJisWm7v0HKc/gU= X-Received: by 2002:a17:90b:3717:: with SMTP id mg23mr5810742pjb.129.1589578390300; Fri, 15 May 2020 14:33:10 -0700 (PDT) MIME-Version: 1.0 References: <2397dd70cdbe95e0bc4da2b9fca0f31cb94e5aed.1589557526.git.lukas@wunner.de> <20200515162903.GH5066@sirena.org.uk> <20200515164404.bev4zjzcmx4nwzhi@wunner.de> In-Reply-To: <20200515164404.bev4zjzcmx4nwzhi@wunner.de> From: Andy Shevchenko Date: Sat, 16 May 2020 00:33:00 +0300 Message-ID: Subject: Re: [PATCH 2/5] spi: bcm2835: Fix controller unregister order To: Lukas Wunner Cc: Mark Brown , Nicolas Saenz Julienne , Martin Sperl , linux-spi , linux-rpi-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org On Fri, May 15, 2020 at 7:45 PM Lukas Wunner wrote: > On Fri, May 15, 2020 at 05:29:03PM +0100, Mark Brown wrote: > > On Fri, May 15, 2020 at 05:58:02PM +0200, Lukas Wunner wrote: > > > Fix by using the non-devm variant spi_register_controller(). Note that > > > the struct spi_controller as well as the driver-private data are not > > > freed until after bcm2835_spi_remove() has finished, so accessing them > > > is safe. > > > > Why not use managed allocations of clocks and DMA channels? This is a > > standard issue with the devm APIs, if you're using them you basically > > need to use them for *everything* up to the point where you start using > > them. > > There is no devm version of clk_prepare_enable(), dma_request_chan() > and various other functions invoked on ->probe() by spi-bcm2835.c. > So tearing down DMA channels, disabling clocks etc needs to happen > in the ->remove() hook and consequently devm_spi_register_controller() > cannot be used. There is devm_add_action_or_reset (IIRC the name). It does a trick. -- With Best Regards, Andy Shevchenko