Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2353673rdb; Mon, 12 Feb 2024 01:46:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDXhrSbYWv7ZJ31HxFfHduChK1bTKkwdvFap/cloas2D09/HupNyrCq3Onl76+CCwu7j+a X-Received: by 2002:a1f:e084:0:b0:4c0:285e:79d with SMTP id x126-20020a1fe084000000b004c0285e079dmr2340124vkg.1.1707731203550; Mon, 12 Feb 2024 01:46:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707731203; cv=pass; d=google.com; s=arc-20160816; b=lgYReEyJnPzVCmQZ5zHZR34dUq/4HEMkENhgjCIp7hhdH5WlXzMwI4jAs2ARpO0J47 NYxP9XqHw4moIWMHj2Zy6hCh0/VHzoxGeUDQkkfVKVV+l874xA/Wn+uV3crzCbo2Pc+K Rj+WkNRvFc4ASGIlR0iLUub78eMH8JVVAmJqkRU1x7MSGOOJnK/RT34pNGK4Cpok5cSf jd8MH1IQknhwx62WoFrh83dOSrNzmzPYycgthsmranS2kxGxSlLJee7H31c53QKzGOn7 smf0fHJ7s88dTWm+T3s4KM04g+zi7Tr2YzW7q0gdOmSYPLOT+h8rcejjvD4ZKz7OX74k LiaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MQb8dCRWurqwx7ODtvg9qhwoLoDqkJKN0Z1RRpyg0zw=; fh=KBeqswOkF0V54VUeIdsBm6LNVfml8pNVMeOmsxbig6I=; b=jbzLXh5Evoci5ryLgkVJ+LPKJ8rZ6aGQS2iqsKVthYfR5F0cJC+16ZynIUy5Ua/TB8 ChIyszgAPnazmfq3wmL7DX6JA8SOKU4uI1pjt9ufA2rRTpiJ1c/9HJubRU1LakT8v9KT T4OkSpRdGmNT/JlhyNwM+RJ05qHjrXWLa5bVkLNVMUdm3N2s2Q3FvVGnDb49RrNdQiAu qacL5c6KVDdNdYI/8nwgLgXsWGc4fHZEv5EacEgyJfsrs48TpLD0J59rLoT4YCw1dDvI jkx6BHqOZ9yJvb0UWJlgzF01fMYRrtsnTDh8+y8LjfpGOLTh12D99eS426bfVMMatMnX ZoWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kjXKmUen; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61256-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVqxfVYWJMnWgFpH+efQeJa2wUto9VX1Rp1sw4Gw8SvFuDxe8Y3uk9ds1ZZg97ZUzYY2tzPxIc80TdX7O79i3uvvxt/CyZnsQaTULIygQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id iy1-20020a0562140f6100b0068cbe292070si1336qvb.77.2024.02.12.01.46.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:46:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kjXKmUen; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61256-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61256-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4DDC61C210F4 for ; Mon, 12 Feb 2024 09:46:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E360417C6F; Mon, 12 Feb 2024 09:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kjXKmUen" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D57817BA1 for ; Mon, 12 Feb 2024 09:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707731188; cv=none; b=Rs5PUkEgFMDofK9P2tXS1MqzsTAXcZ25YIhQhDsEGX45FEzpP9GS8pYDJpWdoLJ2PAaNwhNihlIKbH9k/MOo+EzRWFfKPaFcELmcA4RbuGeEXOWoSStoIYzw+u6MPoac8qaJYNK0eGAHFEXAl1ZEM0IAZZJLg8a2m4WjHkzWuSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707731188; c=relaxed/simple; bh=WmFlSgLi47sXJGi5sZiuSkwcH7ucQ1q75XcGBBFiDF8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QGxOltaPwfn6U1zZJSghyVkmt21XFfaMyd6wHzNX197w9b96iT+0WMA/T7yZW9dmNProkqndCLPr4MiSMPlTbQruCYLT4KrOaLnSpHAtWRmgNcGRb3fS0jTE4W/+0HJbR0+l2rwfNEr5OunG8mq8HqmNiHOHK1KndPKHycR4MNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kjXKmUen; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707731186; x=1739267186; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WmFlSgLi47sXJGi5sZiuSkwcH7ucQ1q75XcGBBFiDF8=; b=kjXKmUendv4DZfskhCsPWNWxNMrM6l6byM7cUu1eok/LJ4X1KMm3/XRM e/hZPq/nHCc8yBAmEINupoq66jkr56IA2TT4Og6zifxzIwKSqYNTN/7Pe usqqS7wf8Anj731FGYgk7MSbGolVW3IOrdZCT3xRqgdVLjAHrHYMRJ063 QVbv4H8kiLfkY0+GVTMbD4vzd2uIxGVsUjj5MsPcR29fxUwFsXCFykKc4 678dVXPbgJlltTxSX9VT9XWi1NtemozBLQiwptiOlqWWPt312nbDBegkf a+mbY0lcbQQfepEBmQeV62ulg/Jhw6mZHR7qBovEc+6mf+pm4aa19KVR8 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="12335875" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="12335875" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 01:46:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="2502532" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2024 01:46:23 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id A50F811F9DB; Mon, 12 Feb 2024 11:46:19 +0200 (EET) From: Sakari Ailus To: linux-kernel@vger.kernel.org Cc: Hans de Goede , Tomas Winkler , Wentong Wu , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 1/3] mei: vsc: Call wake_up() and event handler in a workqueue Date: Mon, 12 Feb 2024 11:46:16 +0200 Message-Id: <20240212094618.344921-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212094618.344921-1-sakari.ailus@linux.intel.com> References: <20240212094618.344921-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The event handler, in this case that of mei_vsc_event_cb() of platform-vsc.c, is called from a threaded interrupt handler in uninterruptible context. However there are multiple places where the handler may sleep. This patch creates a per-device workqueue and calls wake_up() and the event callback from queued work where sleeping is allowed. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Signed-off-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 6f4a4be6ccb5..264ece72f0bf 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -72,6 +72,8 @@ struct vsc_tp { atomic_t assert_cnt; wait_queue_head_t xfer_wait; + struct workqueue_struct *event_workqueue; + struct work_struct event_work; vsc_tp_event_cb_t event_notify; void *event_notify_context; @@ -416,19 +418,19 @@ static irqreturn_t vsc_tp_isr(int irq, void *data) atomic_inc(&tp->assert_cnt); - wake_up(&tp->xfer_wait); + queue_work(tp->event_workqueue, &tp->event_work); - return IRQ_WAKE_THREAD; + return IRQ_HANDLED; } -static irqreturn_t vsc_tp_thread_isr(int irq, void *data) +static void vsc_tp_event_work(struct work_struct *work) { - struct vsc_tp *tp = data; + struct vsc_tp *tp = container_of(work, struct vsc_tp, event_work);; + + wake_up(&tp->xfer_wait); if (tp->event_notify) tp->event_notify(tp->event_notify_context); - - return IRQ_HANDLED; } static int vsc_tp_match_any(struct acpi_device *adev, void *data) @@ -481,13 +483,18 @@ static int vsc_tp_probe(struct spi_device *spi) init_waitqueue_head(&tp->xfer_wait); tp->spi = spi; + tp->event_workqueue = create_singlethread_workqueue(dev_name(dev)); + if (!tp->event_workqueue) + return -ENOMEM; + + INIT_WORK(&tp->event_work, vsc_tp_event_work); + irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); - ret = devm_request_threaded_irq(dev, spi->irq, vsc_tp_isr, - vsc_tp_thread_isr, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev_name(dev), tp); + ret = devm_request_irq(dev, spi->irq, vsc_tp_isr, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + dev_name(dev), tp); if (ret) - return ret; + goto err_destroy_workqueue; mutex_init(&tp->mutex); @@ -516,6 +523,10 @@ static int vsc_tp_probe(struct spi_device *spi) return 0; +err_destroy_workqueue: + destroy_workqueue(tp->event_workqueue); + kfree(tp->event_workqueue); + err_destroy_lock: mutex_destroy(&tp->mutex); @@ -528,6 +539,8 @@ static void vsc_tp_remove(struct spi_device *spi) platform_device_unregister(tp->pdev); + destroy_workqueue(tp->event_workqueue); + kfree(tp->event_workqueue); mutex_destroy(&tp->mutex); } -- 2.39.2