From patchwork Fri May 25 16:47:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 136969 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3824388lji; Fri, 25 May 2018 09:48:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqTRCysBZioeOT8YQDu5087Bgbv2Mm1fR1NDTHGs2rbnjs76OrL8N44UlQX1g1wvilE7JUH X-Received: by 2002:a17:902:b907:: with SMTP id bf7-v6mr3385996plb.331.1527266883094; Fri, 25 May 2018 09:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527266883; cv=none; d=google.com; s=arc-20160816; b=hum4V9QavVq8PUTzbBF+/vFQ4PqyRuttv0pJ+lwQG1EPtVyUO0iWJZw7vkDvUEg5Pf RofKYJQiDJmvZ4y6o9E1CLuppI66W8QxRcoh7owusolJqFQ/Bm+9r9C6zePPeJC9toYt jjhZZ/fYdKh4JDwyFZEF5FLlasfmQ8l1f4GzhvfForv8WwNAr9sHrwkFMMnp4hVpQvKy 34d4anNUrsC0RcfPsJBsQLjJBxqMlWfaIyAVkEgb4DSwTDIN+pVojJ3IGJJpvjknrSQt Dud5thlqmttQFVi/F6esLNMp83/bRuZRHwrCYOTsWfS//aCg5gYaJhrddIHOTVaonE1V LPMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1Hu853JCgcwdwAcQy57MIT4BGZnknm5JAoYVMvykVvk=; b=R1YRFO7o7+adFZMRfZTrTdtUaSpMQvrdvN6IsEWG889Jf/7EmRmah1iKgmvaboF7E1 2vwhM3EGIxRkmjvLTdRkCSyaHLMx2JJUjPHBytlfHk/pZLipS1OHUJTfaDHZ8KJwzFOu j6ghh3kIa7Z1G1F83Bp0L45T++/N+nkrFNObDohV8sxuvwKPvX/wRbBgaJH45kNnOV4B mc4Yb6jQqF0gEBK7GQC1tQs63SApY+68F6/rvitMFqCElfiGhbv4IZNg0pbpEX8+87L4 76nHVM0doeFH8MO9uAd3OpqMSORhpcrKG7bRD7cWHbVfE7PGo97cIcrqEcDLbr5ipPJb e4Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZKVZbBzz; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12-v6si5584757plt.209.2018.05.25.09.48.02; Fri, 25 May 2018 09:48:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ZKVZbBzz; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967268AbeEYQsB (ORCPT + 13 others); Fri, 25 May 2018 12:48:01 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53663 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967189AbeEYQsA (ORCPT ); Fri, 25 May 2018 12:48:00 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so15980231wmf.3 for ; Fri, 25 May 2018 09:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=mV2o+0geqJ5SxmVBX9NzJFCNgAhy7w/UChDCiiI3Ajg=; b=ZKVZbBzzeIU74ykIE7bRxh0kXczQ7fij3EpTfwLk3C2y/l0sSchhF7SWduaEAvIQOt wKxMkI4Piu9kvNzCaLOkH7UDjqr2v2+mmDzmDy8HOETHDrW4lHg2oasZEM1oi5VIFfbR pP2d+1fiV5TxfN1d8EznX1A9Amjea9u0bgRs4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mV2o+0geqJ5SxmVBX9NzJFCNgAhy7w/UChDCiiI3Ajg=; b=O2qiZle2MA2sEegARzjHrRdC2G0vdeFkXU8wUt+NSDZA4UDjwB58Wty/z8g7yOBkMF 68zKmTFMy97yJULICdTJm5VOIaP6vY9MWPkv9WNqlCCST8CKx0bG9F8I+lEWgz4mw3Kd xjV3/wS4ROEHeYFJVS8x5CexF10XSsReo+YT9PqWKD+wDdR485CuKV3IsBgiLuw4+/nb YqFrQE+DyILBKsKCyR1iLKP575KScsM41zh91PxrsW5OqAz1ACnQyeMVm5grIOKdixdU l6O/qpn5KfFwDvt+xrAlOGTXYjnn/SiZ5Q/6aD1FdZHn+FWMC+22ehfgDkNilrQWqvBp ksQQ== X-Gm-Message-State: ALKqPwcriuJREQ5rrPgGhuHKTT0eqSRg6yfM0laSRl99EZzhgbonFYjZ 63Pr5TWp94g96KlzS/mOlrqXtw== X-Received: by 2002:a2e:86d9:: with SMTP id n25-v6mr2232705ljj.18.1527266878804; Fri, 25 May 2018 09:47:58 -0700 (PDT) Received: from localhost.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id s24-v6sm767949lfg.4.2018.05.25.09.47.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 May 2018 09:47:58 -0700 (PDT) From: Niklas Cassel To: Joerg Roedel Cc: linux-arm-msm@vger.kernel.org, Niklas Cassel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/msm: Don't call iommu_device_{, un}link from atomic context Date: Fri, 25 May 2018 18:47:05 +0200 Message-Id: <20180525164705.11620-1-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.17.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- drivers/iommu/msm_iommu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) -- 2.17.0 -- 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 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); }