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=-3.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 1CB3BC433DF for ; Sun, 14 Jun 2020 13:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F16EF20714 for ; Sun, 14 Jun 2020 13:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T0mKqtpA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727807AbgFNNnm (ORCPT ); Sun, 14 Jun 2020 09:43:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbgFNNnm (ORCPT ); Sun, 14 Jun 2020 09:43:42 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3B91C05BD43; Sun, 14 Jun 2020 06:43:41 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id o15so14593553ejm.12; Sun, 14 Jun 2020 06:43:41 -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=2JK7KGekdKk92ix3V6dwBOemAX4+Cg95WIG/xENrDWE=; b=T0mKqtpAN81wMzgDobYRYrqAnj8bInha1NepnPIo9ZA5+Lgsq36OAfiUIraExtvObP CrNmGqwyEEpj1gHZySt2CgOFimTsdV3zTGEDo8vYKz0QFdhHJajZT7X9U3cjIAmPkHbW RXX3igy5p/2eRLIfSBepdR9Ix295sfi8U+dh9zSmiK6OWk4ZLo3UGq1YQGdcqSOJHh5u bhdP4H9INgNyhIDQzbh0jpChNy4VySKyAixC0Ad1jkpiWLmh9/XO8syEL4IJO7Ez3LhX AnrtXna3C68MG6yDx/dKeH50IwTMlHacBYPkOD8kTL+Id72b9gj/vjPPHZiKd5fkywKI uOLQ== 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=2JK7KGekdKk92ix3V6dwBOemAX4+Cg95WIG/xENrDWE=; b=OztdUO/8RtSSAS6eUDcniga6zzC67yY6Yc8VkqcIx9dFC1WM8i5RxHrzuLX0/UHXIN +5+RcRWRektJnJRiHtUuzqoN+hvBWkWLJSiBi8zrI6+TauXsGnaOWBlbWx642iyuQlK4 jAviZob+mb8hCheIVGdn7N8xD9zvclttgGpzGaja4IQ+dfRCfNGLNzaVVV68F7aMIF2F j2+cAWPDQmlajNZIMKoSKSaYchRD5f0Y4U9WoJSz48qYDrcdgSzRTUJ1U4tL5A6rMQ/z 9xmpb/AKlN/muoMzXORPnNHuKgvX91QEq9K2l4yI9nMyvXJqQpnRkKWUl3xjJJ2uR30O f7ww== X-Gm-Message-State: AOAM532jAZNtvHx0CaYi08SVF6UIi+8HyEjtnDr8AV735IJwwqr1V6np +V1JbxjCLoKWJIn2X5Qi+TR20hqrHlCzpAR2bWvAx9Ow X-Google-Smtp-Source: ABdhPJxiLRhSn1vMvYdXG7qmdlKCmTZBmxhXrnyzgCKNUwOdM4r6MtZBxiGiHYXZfbA+EBEpchAae7BeldKLnUxJ7T0= X-Received: by 2002:a17:906:1149:: with SMTP id i9mr22576193eja.100.1592142220162; Sun, 14 Jun 2020 06:43:40 -0700 (PDT) MIME-Version: 1.0 References: <1592132154-20175-1-git-send-email-krzk@kernel.org> <1592132154-20175-2-git-send-email-krzk@kernel.org> <20200614111829.GA9694@kozik-lap> In-Reply-To: From: Vladimir Oltean Date: Sun, 14 Jun 2020 16:43:28 +0300 Message-ID: Subject: Re: [PATCH 2/2] spi: spi-fsl-dspi: Initialize completion before possible interrupt To: Krzysztof Kozlowski Cc: Mark Brown , Vladimir Oltean , linux-spi , lkml , Pengutronix Kernel Team , Marc Kleine-Budde , Wolfram Sang , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 14 Jun 2020 at 16:39, Vladimir Oltean wrote: > > On Sun, 14 Jun 2020 at 14:18, Krzysztof Kozlowski wrote: > > > > On Sun, Jun 14, 2020 at 02:14:15PM +0300, Vladimir Oltean wrote: > > > On Sun, 14 Jun 2020 at 13:56, Krzysztof Kozlowski wrote: > > > > > > > > If interrupt fires early, the dspi_interrupt() could complete > > > > (dspi->xfer_done) before its initialization happens. > > > > > > > > Fixes: 4f5ee75ea171 ("spi: spi-fsl-dspi: Replace interruptible wait queue with a simple completion") Also please note that this patch merely replaced an init_waitqueue_head with init_completion. But the "bug" (if we can call it that) originates from even before. > > > > Cc: > > > > Signed-off-by: Krzysztof Kozlowski > > > > --- > > > > > > Why would an interrupt fire before spi_register_controller, therefore > > > before dspi_transfer_one_message could get called? > > > Is this master or slave mode? > > > > I guess practically it won't fire. It's more of a matter of logical > > order and: > > 1. Someone might fix the CONFIG_DEBUG_SHIRQ_FIXME one day, > > And what if CONFIG_DEBUG_SHIRQ_FIXME gets fixed? I uncommented it, and > still no issues. dspi_interrupt checks the status bit of the hw, sees > there's nothing to do, and returns IRQ_NONE. > > > 2. The hardware is actually initialized before and someone could attach > > to SPI bus some weird device. > > > > Some weird device that does what? > > > Best regards, > > Krzysztof > > > > Thanks, > -Vladimir