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=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, 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 EF8DCC433E2 for ; Wed, 16 Sep 2020 07:10:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96AC520771 for ; Wed, 16 Sep 2020 07:10:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ebzl9LNk"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="loRY0FnC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96AC520771 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=oJI9TKseCKadpmrdNryInKK6Bt78T6RrC6DcKWCNxls=; b=Ebzl9LNkl0BEvm8HkKjt0CusCv vUB5dcwCPffD/6+f0HgMtv2EA7XoGSESvi2r/98JM35dbXiOGHVQLi6j2AvpiN2nqhU2nFeHZKBhT GKCPV0ZhbrhNp5Jrk2TXwOeEg9KssE19L/x8fBuux3DlT38C+wwQFcvVeWSpfThCn7H+uR/pnIxFS 16YMhjhEKRsOgMli9BhBNqdZSvIUIjqfmcOCa7X/lNjAhCYwP2+InOIQ8yWg+wZp8gwamiX/IweIb lYssZCJx5wJWT2mnk5Di6yW4bmXxLNxS4aMiTI5ZtvqJoKlg01H2dORKjifm7yzmfgkIT3NEdpAKz PCE0vhsQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIRYi-0004jK-Rg; Wed, 16 Sep 2020 07:08:52 +0000 Received: from esa3.microchip.iphmx.com ([68.232.153.233]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIRYg-0004ip-0C for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 07:08:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1600240129; x=1631776129; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kRZu+9DWwWzAavQX/XVNxGelxwlfukUlgQUjykqNXgE=; b=loRY0FnCkB4A6xN63lNqI8mMVFZm9LV+9a0OOT5ytVghDa22tZSotAFL vmc8y2TJCW2mixxtKAXG8y01KNKE+hBRFxc+Xa+SJmiJzQELQn5/hD/ft nKPuwq9XYyFdC7gXPwq/WBAL8LF0SC1EJkedFN46QQMlDYJoOQWVfPEw7 nA/UcWGZv/AzIZy/VPjeCkhruQicRvViy2QNWtMRngsgRqrstcSzPR5F3 JESDUTrK6V81XnJEcfYyOaU0TVPyEaNBD3ipKSUIfFCKfz4ocvR3RGLdy IbU0MUCdcC2dm6rLmdnabM/j6rlWrpPV9xDX7DLhbSoNBFIXCn23oFfHe w==; IronPort-SDR: bBHBK/VezAlFji1zCJrRtPFxLjwXVigFQKQlyGvAIn6RS6fh9U3ofpmFJEG+57br9oPDxPI3qL ODMEn98DgMCAc5aHXy2cRa2YQs/AlGHowLxOnIwYsNWOO6KoNZNnURbHwoTmG6+v67FJinZOHG 2f5rLekrUieffD9dhrzmQUob/WFesDNjonG7ETXeLN39os0S/XI3Ht5kTzvo40IXMLuk/8AQI1 rH6TObkb28putEQ+xFQK51msWCzLSnzsVk+vcfZYVN9AxxbPNC9x5Ry8VqvdR8yHmoMVxCjLJs zC4= X-IronPort-AV: E=Sophos;i="5.76,431,1592895600"; d="scan'208";a="91976494" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Sep 2020 00:08:43 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 16 Sep 2020 00:08:26 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 16 Sep 2020 00:08:32 -0700 From: Eugen Hristev To: , Subject: [PATCH] iio: adc: at91-sama5d2_adc: fix DMA conversion crash Date: Wed, 16 Sep 2020 10:08:21 +0300 Message-ID: <20200916070821.118374-1-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_030850_178763_1A145855 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-iio@vger.kernel.org, Eugen Hristev , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the move of the postenable code to preenable, the DMA start was done before the DMA init, which is not correct. The DMA is initialized in set_watermark. Because of this, we need to call the DMA start functions in set_watermark, after the DMA init, instead of preenable hook, when the DMA is not properly setup yet. Fixes: f3c034f61775 ("iio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions") Signed-off-by: Eugen Hristev --- Hi, This crash is in the kernel since 5.8-rc1 Please have a look at discussion here: https://lore.kernel.org/linux-iio/CA+U=DsqRUtjjoe5nevP_wNxTgr27+O2V1h9w7d3QijBQ+5f3XA@mail.gmail.com/T/#t Thanks ! drivers/iio/adc/at91-sama5d2_adc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index de9583d6cddd..b5196797dcb8 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -884,7 +884,7 @@ static bool at91_adc_current_chan_is_touch(struct iio_dev *indio_dev) AT91_SAMA5D2_MAX_CHAN_IDX + 1); } -static int at91_adc_buffer_preenable(struct iio_dev *indio_dev) +static int at91_adc_buffer_prepare(struct iio_dev *indio_dev) { int ret; u8 bit; @@ -901,7 +901,7 @@ static int at91_adc_buffer_preenable(struct iio_dev *indio_dev) /* we continue with the triggered buffer */ ret = at91_adc_dma_start(indio_dev); if (ret) { - dev_err(&indio_dev->dev, "buffer postenable failed\n"); + dev_err(&indio_dev->dev, "buffer prepare failed\n"); return ret; } @@ -989,7 +989,6 @@ static int at91_adc_buffer_postdisable(struct iio_dev *indio_dev) } static const struct iio_buffer_setup_ops at91_buffer_setup_ops = { - .preenable = &at91_adc_buffer_preenable, .postdisable = &at91_adc_buffer_postdisable, }; @@ -1586,7 +1585,11 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) else if (val > 1) at91_adc_dma_init(to_platform_device(&indio_dev->dev)); - return 0; + /* + * We can start the DMA only after setting the watermark and + * having the DMA initialization completed + */ + return at91_adc_buffer_prepare(indio_dev); } static int at91_adc_update_scan_mode(struct iio_dev *indio_dev, -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel