From patchwork Tue Jun 12 14:06:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 138350 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5401579lji; Tue, 12 Jun 2018 07:06:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLXdauBg8q2fz8NDwCuqVGd3xyGMs3HFPR+Pu/JXF1k3MAXxGAT1VobJ1jTWFq8rzLu63F5 X-Received: by 2002:a62:9d58:: with SMTP id i85-v6mr588762pfd.76.1528812399924; Tue, 12 Jun 2018 07:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528812399; cv=none; d=google.com; s=arc-20160816; b=oBeg6Ub27LRalbAeUVOk+0X7kx2MaGVmc6Zxx1mjorNch4nA1g9LHWgZyLb/2fq6y3 62RktKiEElL207exrDMSbiW2VMLDWZL941vsz7YI1Vk6cWUgcOmUIqevbBAPbUICgPYo mx80swxbtMgVgGXM9xHnFaTguE/6MWL0ksQFXGUy/DEZ6TRyHgSIx18djTNbzyEKTA3r IUS84x9/IDFiEubcybKTVusDJ8Mbe2Sq8J3lpDURp+cC8w+3cg9JZdpjUW1k3As1Y3qF p9CdiFmKAXR0rbjZTD44kgyFllxIA3uNelrrKVlX6nDdy0K0tVs89jLc86yVtRfk3/MQ mU/w== 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=gSfDRA343U4wN8tXeu7U1X4Wt7mOLKgzeH5PSzloXak=; b=AslR9itcEtJHkF09bdVmisRyeSsxYMvgb5pEoJrAySYCY5Rrak9e8D5sHGa2hvGyFy 1XCWaEh/ViY7shX7xI+S8KFNKBK+LeZB3tYeJNbq5tZLUjJm+PI/QRksRpO93Trpu031 7/WzuFavXJuZpYjyaCiPnOH+JlRhf7ug9rjTh6KrrlkjuBpRFtz9OIGUSBTlqRr8t1cX sSCoomAay8rhfJKuIlKnFmW71s9lE8BpklYGuf3yjg3mrPLvEw7w+B1xJ1Vgq8mqnrJV oJ+UUZVBpmKjntwIBo7mbU0rbBw+ksfgRScnjK5A5Oqrm4PaYm153/PoxltGnkuf5gU+ QcLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gNcqRb0f; 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 f2-v6si180764pgu.457.2018.06.12.07.06.39; Tue, 12 Jun 2018 07:06:39 -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=gNcqRb0f; 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 S933408AbeFLOGi (ORCPT + 13 others); Tue, 12 Jun 2018 10:06:38 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:44632 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933295AbeFLOGh (ORCPT ); Tue, 12 Jun 2018 10:06:37 -0400 Received: by mail-lf0-f68.google.com with SMTP id 36-v6so36193713lfr.11 for ; Tue, 12 Jun 2018 07:06:36 -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=bbYeUhSZMyYlqPxKC4a0fHeNlHuE1zrgnUaaMS2fhN8=; b=gNcqRb0fy36Zt6OBN2yDbB8loauSoFqV+ucACccZHu2utICLpdcrFcr7aTdGLLNBHD 6GuVeQjx+uvGJPuadmOul6xsknsfKR1VPKeKcnP8tHEzgXGusPLTJ3M4AkVE0lwXn5gx DiSbQ7Svt4jAtAdSHvs+2FqBzj41D/eHe7zlE= 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=bbYeUhSZMyYlqPxKC4a0fHeNlHuE1zrgnUaaMS2fhN8=; b=khmyh+6fKy7i6sfDtggL79YZgmBJiAciLENdXZhmQnOn1nfhpbMNegk3Ljj2SyC0MI 1J+cyMFspUH40wdfbq+cvwwTTN5x4it+OjHRXD3zp+GVnrS2crwqnjlEsga28evz9Qov 6idPrigPE3DE4r+7STFRp7fRxJ0tPGAwNarNQhs54/AkmE2IFeNKGgXueU7LsEfiPphv 5AJgQJRxT4dcdlg0yedJvUSaVsNzE86c8eNTytC3rhFAQU3o9SFsjNFe+1oloKacgmBk xTqH5QpwzvgTVZ0VdnM8R+aJcwRnWUykpLqQqsRtjidKKFhAJznlS7hGWp3DmLQSv/pc /Nwg== X-Gm-Message-State: APt69E0Alf72DG591RpMCmyWH38xKNzy7+b0tLjfW/zMgQpfP56poSYn ygSzev5zpija/wqKGWsSfJrPdVeMC60= X-Received: by 2002:a19:cb96:: with SMTP id b144-v6mr331700lfg.72.1528812396033; Tue, 12 Jun 2018 07:06:36 -0700 (PDT) Received: from centauri.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id o25-v6sm50854lfg.41.2018.06.12.07.06.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 07:06:35 -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 RESEND] iommu/msm: Don't call iommu_device_{, un}link from atomic context Date: Tue, 12 Jun 2018 16:06:10 +0200 Message-Id: <20180612140610.31190-1-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.17.1 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.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 Reviewed-by: Vivek Gautam 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); }