Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1591192imm; Thu, 14 Jun 2018 00:07:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIvRfemI0BgurC0d2UFE/ne8m/1VerRBtligTZ+3uek925pUq/qRqTNIJICzUuOhwx3hkD/ X-Received: by 2002:a17:902:a703:: with SMTP id w3-v6mr1632288plq.111.1528960075620; Thu, 14 Jun 2018 00:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528960075; cv=none; d=google.com; s=arc-20160816; b=vpVkkpJC/PyV/aELMNb8USYtbercoQ6EfBgF1RrrTwn9Qk8QNez1yQBGFae8+Dx0qV VsjlqKSJ7uGTlJF5DCs3ERAJmtEM8K2l5ZsxSZIqVMwr/XPFB3iYfJMBp4M9vharAIAL kaL4Fu9GkAzb7hApPGpRo7ColvYB075p6cxIgwCx3azkrLXxlLSV9Ci5bXNVhTjgNZW5 lmV2qp1LBNhjzW0WirhFvdWK9a2XqiHTp8io5hpqCiylt/WmJ/ECJWRKC0eo+HO5FrAr GOdoDAwvjm6sFV3pg0bbg7cUg3urGqwY3CgTJQXCFVCbCDyyeXQnsT9JZvyln+fBcUET PGHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=gcdY3x9Y+vlaP+KRVhnAtIsU6Bo0p3WNQ9Qf5KcKvKY=; b=OqZQ1NsH85/KqEN8evU7m2f8ix7IS/6w2AduKFeC3OZU9WZe7m3rd2bpVt609lI/Hg cV27FvgZk9H2mXsiZ4Kjb8UjuPsHJyg65hdtWOyaT+bdtSLqjVyLDkhnklXtpYYoKiKE fSURbGfeGmhl4D92XrYtiLG7Tn3W3VBFVUe0xAFFg10ykh7qiILP57hUhLtog2GjEC/5 Iq0e+avg5Fl2clXF6AZwdb20cn4hUjVwVqnaboxoFl4f6USKyy/mf01FJZRd/QLCNzcE YMAbooRAOTZ8JstYa64WLukY5CIRE17ipbEWfOORmbPsAQKlwwflJmhqngHz2EurVJl/ skxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Nkpp97jK; dkim=pass header.i=@codeaurora.org header.s=default header.b=bJ2gFv1W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si3856792pge.684.2018.06.14.00.07.40; Thu, 14 Jun 2018 00:07:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Nkpp97jK; dkim=pass header.i=@codeaurora.org header.s=default header.b=bJ2gFv1W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754638AbeFNHHP (ORCPT + 99 others); Thu, 14 Jun 2018 03:07:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41208 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752874AbeFNHHN (ORCPT ); Thu, 14 Jun 2018 03:07:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 46F746074D; Thu, 14 Jun 2018 07:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528960033; bh=NDfBQPxdrbhj6xDZaGIQ/8ksbjVd2QPpfZlVpTSIiOs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Nkpp97jKdH2DAAbB6JPbADYPiGdcqoBlEN1uIiW0lvM06K2Mtg6+yWVwHC8igjOK6 hgxjfTsc20AxLyk041l7pYh4kWzVs1Pkv3r5kgRqbmtf9xhmNFd84r7fQYIy+CdovV cA3VGpKJ9XgauGTszbtlaPXeEbl5UPbR6aMnCDME= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail-qt0-f173.google.com (mail-qt0-f173.google.com [209.85.216.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9F0DB60159; Thu, 14 Jun 2018 07:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528960032; bh=NDfBQPxdrbhj6xDZaGIQ/8ksbjVd2QPpfZlVpTSIiOs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=bJ2gFv1W6elJCnPKEEqL8FJzIVjMTjQMx6AmWD1RypWf46fhm9sLfYgYROSmz/whn S4wG1oavahXYOveqFVO6fmKs8ng1fd/9qFtev3m7Gl2y6Fb65wsKKeHxDMWtblI0z7 ndM+D7qPjl1AEkkU0V1RHjaWCuHo7+dhF8+yhxK0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9F0DB60159 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Received: by mail-qt0-f173.google.com with SMTP id l33-v6so4850709qta.11; Thu, 14 Jun 2018 00:07:12 -0700 (PDT) X-Gm-Message-State: APt69E2owuDfHtBbX55i7vyB/R+MsSRwdYHt3Dlml/GCubQlf/f7SxRD /QeTk9wBrt5wR9U5OsrVz0FG0PVa8RI3yn2ggzk= X-Received: by 2002:a0c:e7cf:: with SMTP id c15-v6mr1156733qvo.109.1528960031883; Thu, 14 Jun 2018 00:07:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:1082:0:0:0:0:0 with HTTP; Thu, 14 Jun 2018 00:07:11 -0700 (PDT) In-Reply-To: <20180612140610.31190-1-niklas.cassel@linaro.org> References: <20180612140610.31190-1-niklas.cassel@linaro.org> From: Vivek Gautam Date: Thu, 14 Jun 2018 12:37:11 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RESEND] iommu/msm: Don't call iommu_device_{,un}link from atomic context To: Niklas Cassel Cc: Joerg Roedel , linux-arm-msm , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , open list 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 Hi NIklas, On Tue, Jun 12, 2018 at 7:36 PM, Niklas Cassel wrote: > Fixes the following splat during boot: > > BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747 > in_atomic(): 1, irqs_disabled(): 128, pid: 77, name: kworker/2:1 > 4 locks held by kworker/2:1/77: > #0: (ptrval) ((wq_completion)"events"){+.+.}, at: process_one_work+0x1fc/0x8fc > #1: (ptrval) (deferred_probe_work){+.+.}, at: process_one_work+0x1fc/0x8fc > #2: (ptrval) (&dev->mutex){....}, at: __device_attach+0x40/0x178 > #3: (ptrval) (msm_iommu_lock){....}, at: msm_iommu_add_device+0x28/0xcc > irq event stamp: 348 > hardirqs last enabled at (347): [] kfree+0xe0/0x3c0 > hardirqs last disabled at (348): [] _raw_spin_lock_irqsave+0x2c/0x68 > softirqs last enabled at (0): [] copy_process.part.5+0x280/0x1a68 > softirqs last disabled at (0): [<00000000>] (null) > Preemption disabled at: > [<00000000>] (null) > CPU: 2 PID: 77 Comm: kworker/2:1 Not tainted 4.17.0-rc5-wt-ath-01075-gaca0516bb4cf #239 > Hardware name: Generic DT based system > Workqueue: events deferred_probe_work_func > [] (unwind_backtrace) from [] (show_stack+0x20/0x24) > [] (show_stack) from [] (dump_stack+0xa0/0xcc) > [] (dump_stack) from [] (___might_sleep+0x1f8/0x2d4) > ath10k_sdio mmc2:0001:1: Direct firmware load for ath10k/QCA9377/hw1.0/board-2.bin failed with error -2 > [] (___might_sleep) from [] (__might_sleep+0x70/0xa8) > [] (__might_sleep) from [] (__mutex_lock+0x50/0xb28) > [] (__mutex_lock) from [] (mutex_lock_nested+0x2c/0x34) > ath10k_sdio mmc2:0001:1: board_file api 1 bmi_id N/A crc32 544289f7 > [] (mutex_lock_nested) from [] (kernfs_find_and_get_ns+0x30/0x5c) > [] (kernfs_find_and_get_ns) from [] (sysfs_add_link_to_group+0x28/0x58) > [] (sysfs_add_link_to_group) from [] (iommu_device_link+0x50/0xb4) > [] (iommu_device_link) from [] (msm_iommu_add_device+0xa0/0xcc) > [] (msm_iommu_add_device) from [] (add_iommu_group+0x3c/0x64) > [] (add_iommu_group) from [] (bus_for_each_dev+0x84/0xc4) > [] (bus_for_each_dev) from [] (bus_set_iommu+0xd0/0x10c) > [] (bus_set_iommu) from [] (msm_iommu_probe+0x5b8/0x66c) > [] (msm_iommu_probe) from [] (platform_drv_probe+0x60/0xbc) > [] (platform_drv_probe) from [] (driver_probe_device+0x30c/0x4cc) > [] (driver_probe_device) from [] (__device_attach_driver+0xac/0x14c) > [] (__device_attach_driver) from [] (bus_for_each_drv+0x68/0xc8) > [] (bus_for_each_drv) from [] (__device_attach+0xe4/0x178) > [] (__device_attach) from [] (device_initial_probe+0x1c/0x20) > [] (device_initial_probe) from [] (bus_probe_device+0x98/0xa0) > [] (bus_probe_device) from [] (deferred_probe_work_func+0x74/0x198) > [] (deferred_probe_work_func) from [] (process_one_work+0x2c4/0x8fc) > [] (process_one_work) from [] (worker_thread+0x2c4/0x5cc) > [] (worker_thread) from [] (kthread+0x180/0x188) > [] (kthread) from [] (ret_from_fork+0x14/0x20) > > Fixes: 42df43b36163 ("iommu/msm: Make use of iommu_device_register interface") > Signed-off-by: Niklas Cassel > --- Thanks for the patch. Reviewed-by: Vivek Gautam Best regards Vivek > drivers/iommu/msm_iommu.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c > index 0d3350463a3f..9a95c9b9d0d8 100644 > --- a/drivers/iommu/msm_iommu.c > +++ b/drivers/iommu/msm_iommu.c > @@ -395,20 +395,15 @@ static int msm_iommu_add_device(struct device *dev) > struct msm_iommu_dev *iommu; > struct iommu_group *group; > unsigned long flags; > - int ret = 0; > > spin_lock_irqsave(&msm_iommu_lock, flags); > - > iommu = find_iommu_for_dev(dev); > + spin_unlock_irqrestore(&msm_iommu_lock, flags); > + > if (iommu) > iommu_device_link(&iommu->iommu, dev); > else > - ret = -ENODEV; > - > - spin_unlock_irqrestore(&msm_iommu_lock, flags); > - > - if (ret) > - return ret; > + return -ENODEV; > > group = iommu_group_get_for_dev(dev); > if (IS_ERR(group)) > @@ -425,13 +420,12 @@ static void msm_iommu_remove_device(struct device *dev) > unsigned long flags; > > spin_lock_irqsave(&msm_iommu_lock, flags); > - > iommu = find_iommu_for_dev(dev); > + spin_unlock_irqrestore(&msm_iommu_lock, flags); > + > if (iommu) > iommu_device_unlink(&iommu->iommu, dev); > > - spin_unlock_irqrestore(&msm_iommu_lock, flags); > - > iommu_group_remove_device(dev); > } > > -- > 2.17.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation