From patchwork Mon Feb 12 09:46:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 199629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2328059dyd; Mon, 12 Feb 2024 01:47:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw47H2Ww8+Z8VtSoU+N5k1z7Kuv3tQsAmXO+ySC+LoC3Tpau94QXs7VZJUa1qpKGfDy2XS X-Received: by 2002:a05:620a:2411:b0:785:ca66:6a93 with SMTP id d17-20020a05620a241100b00785ca666a93mr7386807qkn.28.1707731223683; Mon, 12 Feb 2024 01:47:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707731223; cv=pass; d=google.com; s=arc-20160816; b=tPa8XZB2s4ZcA8XomjS68Irp6xGML64dBqrZ/G72kuutQvZy9c+CZsZQE6tmdQ8dSf uHxJLwIb8ckxAC1IORJUn0wl80/f69Lceo6G2mVKzsuU270ghpk6tS0hZF8EhfEWlDOR 8nBYPtk0Pp4pM8ZWBJPduyLyfseCXtDHiKozfEYRLeCu/T0y1W0rGT9honuiL84Po7BP pzDwfrD9VeqCY6s4WL16JD/LdIVPLwXwhccMx4238GCo686G3M1AdAmaF+st+egAbPfJ LTqhswSVFctCcodnZYMyf9R7CmpkLhQm29sgVgivz8avlU4ZVndxUP28ysFPFDNpV6MD +mWA== 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=KUKc5T6jz5sJIbdd6jQc6nCzqLh0EGOPoc41LuhcA4g=; b=U5mnW5v+BbybeHfaeVtOsJ1utPLw4eaVAl1bLRWC1ZHIm5H6bemVvlekAiQjyDdPhr qMPJI3XGRXhD9D4MByvEccUC91gqdVAq6y0Yhj4cr8+eD4UCJ649r5nUce5zu8XgNh7W YyFSVY0106pnJCNYG5BeLnex1nSf9LQr6GvA9qqkwGTgBnH48XbNUeaIst7Mo1NhTDbJ z++30o4tYIas6AQYbwsaQOVqDTvMh91kJgVC496sId/PZnH/1z42WPuipR3gKsaiRVmA fOtthWmo/OwY0IKXdbFZPwu37D6LcG+we3h/EQKbJQ83IZ4SWkDfWR9kjUocZwWo0cje bM0Q==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61256-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVmo0W1WqkNqHXhlG/qNxS1MGogIhwyZyVJQHj4KfYaR8V2g9XMykpr6TXTjW+5l6uZllS0o0o6y+JkcxejvuaYx/Y1Jw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v7-20020a05620a090700b007836d3975b3si5261113qkv.273.2024.02.12.01.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 01:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61256-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61256-ouuuleilei=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 2EF6F1C2115B for ; Mon, 12 Feb 2024 09:47:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFF4B1863C; Mon, 12 Feb 2024 09:46:30 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790685975829327021 X-GMAIL-MSGID: 1790685975829327021 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); } From patchwork Mon Feb 12 09:46:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 199798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2435042dyd; Mon, 12 Feb 2024 05:45:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0KlMFARNwTwa6yYz7/Lvv5uQXataCxrlPjVUcVOeYtb/HcHjzJJZwn8p7PHhBWQU4KJG7 X-Received: by 2002:aa7:9ec5:0:b0:6e0:a073:711a with SMTP id r5-20020aa79ec5000000b006e0a073711amr8733182pfq.4.1707745526649; Mon, 12 Feb 2024 05:45:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745526; cv=pass; d=google.com; s=arc-20160816; b=xtvXTsDlAq/BdW01Ah9fXCtkpPK6mJlv4tK3kaJZssw51mxMeizYiHFH2WWil+HnEj ZV/PlJSC21fSh7nmUKzTY8FZOxmmP3wu8FzLsycAr3ldSLeets3sLTsjFyCou4FDclEM Z6sOVqhX593qxYextne03nrKcZ24FuR3O5Bt4zMkDkj9kEHV4kgSjeuxHi9EUmf/CS/2 F+YZAdl7+MZgwyVpXz0coISHx9h5GFj8FR9MeJyvcSKST4yuveSgXH2w+J8f260BCKDp 8R7Xr5V3TWJqe39tMPE/ZYqdmYy0PiDOtqMgCUdk00ndAcmpVKPj4GDD/LSU0oCAMHMZ ezJQ== 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=ZiQ5KNfCzz0YgKwOEIzqkx1Wssh/9jqvSL/OXrOF7X8=; fh=fE32CF3kpWuJ0BksBzGkTDZurJxhgqPSpJm+UbLOqyE=; b=SDZUIvlRGRQQ77Jej/zymzcjt4sp2WgZv2CvZJVYlF7SB77niwNeJ5g0VR8Yyv5M1y eUV8s0kfIbeE+GvREQX2veR/ir7yaoOLDpyU7Jsk9BnldM2TBiKVQHD5tcDHEZt3UuW/ 2Wx7z9qo8M1eBzvbiuknZifMLV+dlcy6SmVmV6qTrdmD7phc7wxXY/Dc/qH/fhF799UW EV8rJZkQTMGdRONgRGkLYqkw8RV2rckyQyiVHBptUyBBWqabynf8GXMp8WTBe0s66Q0i dFNpM09kqPAXVyz3Ge8UDhufpGjUYmmvaGWxoDRiF1vhVnjhBZ7LfjJdBN2Y1u01uZ+6 lFmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EccJ0nYs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61257-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCViNH0O7sSLKUJ//9+7czHcc+sEOJBUESTDhCKdiil0NaQZdpjZ4x2HlB5Wy+YjT/nT1UW03AWMU1/PRicwyt6rAhaOMQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r25-20020a638f59000000b005d8b44e7961si259974pgn.599.2024.02.12.05.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:45:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EccJ0nYs; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61257-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2BFFA284B43 for ; Mon, 12 Feb 2024 09:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 012B418658; Mon, 12 Feb 2024 09:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EccJ0nYs" 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 D70A117BA5 for ; Mon, 12 Feb 2024 09:46:26 +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=e+nVrQd61t/qL8W7BSL04iPr3sNsLnHBckVPYC7skjZntpT4s5hiKEjoxtkxh4FYKNvHGvXPJiCy+lzBvHCEEpFTsUBqXLEhMiqnEcjwcsGqeVfSqFSyyxmdjsjDgmcTKvyycF0ENPVDtrgXBfrLngUP2enhk2YnFIE6BrPWsow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707731188; c=relaxed/simple; bh=AGYbs9qPmL9iRZGFK1NI5ZkY1cRcPzC4LVGVT1LS1wE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LiHebThg3kP5m1nNverwXH9BSgK3AZDRx3SHTp0NLoXUsQeTf9+j+DowtqW3uDzddvr65aoksltgGP8je/O4SOz1PlNsQMgFx+b64eEMmGw1OMVsHe86fTDPjwDOvICcpgx6iVf8y70DCnFw13cyqw2HRXn8PrJr9rLGAOZtvQw= 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=EccJ0nYs; 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=1707731187; x=1739267187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AGYbs9qPmL9iRZGFK1NI5ZkY1cRcPzC4LVGVT1LS1wE=; b=EccJ0nYsrdcWMyFqk64oFuLw8d4atLS0NMzkngiFTIdiKMoykcf4caO6 dX0Vf0Aw4mP6PzwewO+X7L0E2TnR+hP11CK8bvfqrg9z83GoISydYFdLN QI9NkRtd1AFLoo5oeK8dYc7UHXRBsZ3xexBkqS5hmMXHvCThUVmf8OZqe ev8t3iGSBFVm6tXzqxmVc5Xl0i6fMUB7XSkOaxBZNwxMrK4P0Wa5RG1ft 7uw+npbHZNxNlNynKSCFU6YfTFic1tKyi03s/UPk6uZEmhGEXvFzcL0h5 zBXq+c+6tMmbJgn2bBdAHyBcPTi9Hketxka3ftEP09KoH+36TvRNddW9h w==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="12335879" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="12335879" 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:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="2502539" 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 9C6DB11FA12; Mon, 12 Feb 2024 11:46:20 +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 2/3] mei: vsc: Don't use sleeping condition in wait_event_timeout() Date: Mon, 12 Feb 2024 11:46:17 +0200 Message-Id: <20240212094618.344921-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790700973134288323 X-GMAIL-MSGID: 1790700973134288323 vsc_tp_wakeup_request() called wait_event_timeout() with gpiod_get_value_cansleep() which may sleep, and does so as the implementation is that of gpio-ljca. Move the GPIO state check outside the call. Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device") Signed-off-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 264ece72f0bf..200af14490d7 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -25,7 +25,8 @@ #define VSC_TP_ROM_BOOTUP_DELAY_MS 10 #define VSC_TP_ROM_XFER_POLL_TIMEOUT_US (500 * USEC_PER_MSEC) #define VSC_TP_ROM_XFER_POLL_DELAY_US (20 * USEC_PER_MSEC) -#define VSC_TP_WAIT_FW_ASSERTED_TIMEOUT (2 * HZ) +#define VSC_TP_WAIT_FW_POLL_TIMEOUT (2 * HZ) +#define VSC_TP_WAIT_FW_POLL_DELAY_US (20 * USEC_PER_MSEC) #define VSC_TP_MAX_XFER_COUNT 5 #define VSC_TP_PACKET_SYNC 0x31 @@ -103,13 +104,15 @@ static int vsc_tp_wakeup_request(struct vsc_tp *tp) gpiod_set_value_cansleep(tp->wakeupfw, 0); ret = wait_event_timeout(tp->xfer_wait, - atomic_read(&tp->assert_cnt) && - gpiod_get_value_cansleep(tp->wakeuphost), - VSC_TP_WAIT_FW_ASSERTED_TIMEOUT); + atomic_read(&tp->assert_cnt), + VSC_TP_WAIT_FW_POLL_TIMEOUT); if (!ret) return -ETIMEDOUT; - return 0; + return read_poll_timeout(gpiod_get_value_cansleep, ret, ret, + VSC_TP_WAIT_FW_POLL_DELAY_US, + VSC_TP_WAIT_FW_POLL_TIMEOUT, false, + tp->wakeuphost); } static void vsc_tp_wakeup_release(struct vsc_tp *tp) From patchwork Mon Feb 12 09:46:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 199727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2397365dyd; Mon, 12 Feb 2024 04:36:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIZL3iFyfmK72FiIcLwVSG45B0S+u9IJ83kKlzrOVBc4WU/NiCL7P08IpFaGZegjvM7S3pRT+qUjTb+NoZffwcmvfWYQ== X-Google-Smtp-Source: AGHT+IH1vnk1E+BWqMmufjvWo0DOCAvjkM0KLM3vww88wSnG0d3wYEOjvCAUf8FSo8tMCLfDTej+ X-Received: by 2002:a05:6a21:670f:b0:19e:a465:99b with SMTP id wh15-20020a056a21670f00b0019ea465099bmr4610069pzb.28.1707741380515; Mon, 12 Feb 2024 04:36:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741380; cv=pass; d=google.com; s=arc-20160816; b=OGm/e76NlPbkkkw19HQzfc6WTsid2mteabVzKK8UIiXId69Zhcl6ZzQQEcIShfnex9 lZpq8FxxvOLd1IkoaAbaS6pnqOnmOU+vOYWkI/wujCAUS2XIMDVnWPrPCHpk7+g9Ffyj cvk5ed88/6WNgJHyZICbNGP6kuiMsxm2/H1DLJEQ+0K1e/BHxwaYKwJRs3UrTUK9NKva h6K+JNL4Ua8r6VslvNjaw0kSQF9Blnxp4PccIyv4YatVSJfKTpdHixpKc91YFQ8qytPO AmrgYPGJJvhmzGvPC7G5blQ+SKdS5nNYlB9+8Zdw/3/gE8glre+loyhnnbTNzruEzBjh MQzg== 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=Ct8gFNGvPBzS+DPaw1nMUHK6yp4/uwrJiNiZGeNJ4ng=; fh=8Y4QtllbrpxEYwzePpv+6nuZUGGrJSYD49XVeyG0QUc=; b=gdL3WXxR7ti+2yvlNzpVxH8YBCj5Os0BJ5y+ZdS5hi3T5AJ7bYkkw2uWAfDJK7vBCO mQhDnEvxTecunfY85F2iPZCRtBYtmZnKU8CgASo1ij8YHscCYz4eDXNPVjN9NQaVfCEn VZp8hBfFMBH4XqZL8H7XbQjqw+eiqey5MK4N5ERwY5GCuWFhmtb79XJcEe9/4qSCFD14 03Y1RsfovpbKP+7AnBWIBGMU7RG8VqtaMKlJEWl7qpOHKmdqwI+h7Zpv0K5eQVpY12zX /FrToaIKWR6ULH+Wmv55rlt3234cAdE1D1EXBenLjN6MosRnsn28TYLNOIz8jz2a5AzZ du0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I4qcL07S; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61258-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61258-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWhpb60/XCRV2okqetINZMGOd0BKY3XcnG4I4zHQ3B/yn7ctiaeP3t3Ea3WHG9RzoBcECq9x1W2WTRI2xZITZiILJEsjw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id pf3-20020a17090b1d8300b00290191c241bsi233807pjb.19.2024.02.12.04.36.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:36:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61258-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I4qcL07S; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-61258-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61258-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 42377285127 for ; Mon, 12 Feb 2024 09:47:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 264771BC44; Mon, 12 Feb 2024 09:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="I4qcL07S" 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 61DB917BB6 for ; Mon, 12 Feb 2024 09:46:27 +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=1707731190; cv=none; b=OwMvDXVUB5wSvVdJw+zlxzSL3vgpD/rNjr1ZeB+ZconpE7NhLyS5ezoud0CGSUrrQ85fk1pHsNIfiQEV6pA1huQ3JUlZGocuGo1/PQiWOe/Yi/f5wmLPYqMeeZ3q7lwnpsVaaQInMP5oRlwAKaIW0Bk43c3N50hcGWV2AzeducU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707731190; c=relaxed/simple; bh=GCBoBAoo/8mj/fqY6112iWUXqL2JJlgA0ytaI1YG8K0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f+zYlJJgUPeqEPqpOSIu6NFrXTmaABiZIBX3KfqPPUMrOTeK2EF1aBPsbNsFd2TwXjwmMUC933rcJTPSf+Eo3zxQccLjXUH0Nrhxwk8j5iccSIw3yK+TGC/WrL6km01t/sQAuNkjHS4pi/VoxOg9JQ9Pl9Tim2yAqy1JFQwffvk= 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=I4qcL07S; 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=1707731187; x=1739267187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCBoBAoo/8mj/fqY6112iWUXqL2JJlgA0ytaI1YG8K0=; b=I4qcL07SSs2H+16O4LTsa2ZkAbQK+hKp+VFNFUA4iRu3Oo5aKoFUfOtJ 4WndixBoZisZMrlZQtPCq/DvN8v+Yqjns1dQRSG6AYxsF7XMP11oJA3Xf mrHN/mdtGFNyO1d1/sfTzOdA/wqhhMRMZ19AINE3qJ/iPkK+gjzkYi3eA zFAwyIXNNWM9ZZm20BA/YgCR6T4oPGrObWr0Kgl7XedfriygpRYvYT3gD CPSWKQSz36Z5C3lXtjLT1BlMfmPP5C0YuMXjxHkLKlpB3u9T/KiEpzhd/ F7zoDqJc3ZlP8woJSnFdfFsdMP11fpGr6lDZX+IHumh/cW4cD4KCI8L/S g==; X-IronPort-AV: E=McAfee;i="6600,9927,10981"; a="12335884" X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="12335884" 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:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,262,1701158400"; d="scan'208";a="2502543" 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:24 -0800 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 758FC11FB0F; Mon, 12 Feb 2024 11:46:21 +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 3/3] mei: vsc: Assign pinfo fields in variable declaration Date: Mon, 12 Feb 2024 11:46:18 +0200 Message-Id: <20240212094618.344921-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790686940715468372 X-GMAIL-MSGID: 1790696625582091608 Assign all possible fields of pinfo in variable declaration, instead of just zeroing it there. Signed-off-by: Sakari Ailus --- drivers/misc/mei/vsc-tp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c index 200af14490d7..1eda2860f63b 100644 --- a/drivers/misc/mei/vsc-tp.c +++ b/drivers/misc/mei/vsc-tp.c @@ -447,11 +447,16 @@ static int vsc_tp_match_any(struct acpi_device *adev, void *data) static int vsc_tp_probe(struct spi_device *spi) { - struct platform_device_info pinfo = { 0 }; + struct vsc_tp *tp; + struct platform_device_info pinfo = { + .name = "intel_vsc", + .data = &tp, + .size_data = sizeof(tp), + .id = PLATFORM_DEVID_NONE, + }; struct device *dev = &spi->dev; struct platform_device *pdev; struct acpi_device *adev; - struct vsc_tp *tp; int ret; tp = devm_kzalloc(dev, sizeof(*tp), GFP_KERNEL); @@ -508,13 +513,8 @@ static int vsc_tp_probe(struct spi_device *spi) ret = -ENODEV; goto err_destroy_lock; } - pinfo.fwnode = acpi_fwnode_handle(adev); - - pinfo.name = "intel_vsc"; - pinfo.data = &tp; - pinfo.size_data = sizeof(tp); - pinfo.id = PLATFORM_DEVID_NONE; + pinfo.fwnode = acpi_fwnode_handle(adev); pdev = platform_device_register_full(&pinfo); if (IS_ERR(pdev)) { ret = PTR_ERR(pdev);