Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp727123rdg; Wed, 11 Oct 2023 04:02:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1X7qcHSZCYBmXZYXrdEaASg4L9H8KSPxiORP0MvTA6N1qjtQtTaCy+dM2yXg45PNx0SMq X-Received: by 2002:a05:6a20:a115:b0:14c:f16a:2b78 with SMTP id q21-20020a056a20a11500b0014cf16a2b78mr23265926pzk.45.1697022158186; Wed, 11 Oct 2023 04:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697022158; cv=none; d=google.com; s=arc-20160816; b=U5fwDqiwr9UOp3XtqmhngD9ROp9guOR3FIh7taqzepyhyZeK55MRfZsuN01JX3Ac5C DPSET/n6Knk7slU0sUSEmnrpbonVfIrwAX3J5H12oYGnY79Jo7p5gRhWLs/g+7y8igZI onAld2POj0JHdT7PQ/h5T9u+VIxVmLcx4Y+KgBka1HK6oiRutYJidh0f/5mbF93DGG6j RIjlMfl+DGDID/qwMWpWGlRSmpD9AX8aPFnH3aSIOip5s8jqVZrt9tqIE8bFPQ9tB9/9 NDNVtKEQfdg3nx131C3eMa+fY+PbCeYi9JLRoehIJwd1t/70Xjoq+KUPRQ51EnsnKaMo O6FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ymZpjsU4pNShe3LMspv55m8UHWXGnygY6l28w6eHvvo=; fh=2YBdpFWZEnGvnEE29/DshKCRvJhAQXTDnV2k5FsjgR0=; b=FqyRA3WyOh7jJDEy2g3+JD8n76oPjRQof+IZLjvs466Rtc7bk5tLuUGGs//QJAa+84 TOkOoYD7g1C4lUZIoA4WmqdNYS6GOvrb8JXeC/pKWW/Bl6ABJ0UU3coSetmLhaSYmY5B eUji6j2S52Uxm3TN19uVI1EHXx71CzrDyiVkflqa0E9oJtgGO2oQK+TRF7g3uUW+yPZX lBXWmVVzEpOY5oKpKPB/4e3QTAcddtK0k3T7Bd7Y+21AonXRPS9EAV183+TPCNGEHXPd XrGQ41HRk2/7jYsPyA5mBl33iOg8qY/NP2yQizl1cCClbZZso05yFSsbPkKtkzGT03Sm DUGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UPzaMpsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q12-20020a635c0c000000b00563d9ff5158si13829597pgb.350.2023.10.11.04.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UPzaMpsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 418A2814555B; Wed, 11 Oct 2023 04:02:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346611AbjJKLCS (ORCPT + 99 others); Wed, 11 Oct 2023 07:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346329AbjJKLCN (ORCPT ); Wed, 11 Oct 2023 07:02:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4880898 for ; Wed, 11 Oct 2023 04:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697022132; x=1728558132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jX49b7tx6A7Zo7jAUVrcHlfA6tQul/wKjIem8aDMzX0=; b=UPzaMpsvTLrfxBDZRT7mvEKvkBH2tK8E5V93SW+4u+Ik1oBtuJXYMH/z hIyqbVm5A5NxfwNjkj9mlU9IlSqZrAq5EVrUDk/g01elFAFDvlJbYKd/D nm0EjTSgxs+ltd+6b17xcByn+DU1gWOU84LezMCRxoPx8co0e3fZH0M+V aRu2Muv1jpTz5bldHe8WgRmoDBychLvZQ4+cD0ynMPZ/P9oyMx38SLdnq cM7k6p8bSuS+qri3kONH7GieI55YtFPMKP789tASXaIZ+OETxbx4wae5N rCLUsvwTCRfzzO5XmYeBzbuWjBjG8PWj73mzhkx5yjpvMikUIAjBhZuUj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="369696904" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="369696904" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:02:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="788960271" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="788960271" Received: from twinkler-lnx.jer.intel.com ([10.12.231.216]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 04:02:09 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , Vitaly Lubart , linux-kernel@vger.kernel.org, Alan Previn , Tomas Winkler Subject: [char-misc-next 1/4] mei: bus: add send and recv api with timeout Date: Wed, 11 Oct 2023 14:01:54 +0300 Message-ID: <20231011110157.247552-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231011110157.247552-1-tomas.winkler@intel.com> References: <20231011110157.247552-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:02:28 -0700 (PDT) X-Spam-Level: ** From: Alexander Usyskin Add variation of the send and recv functions on bus that define timeout. Caller can use such functions in flow that can stuck to bail out and not to put down the whole system. Signed-off-by: Alexander Usyskin Signed-off-by: Alan Previn Signed-off-by: Tomas Winkler --- drivers/misc/mei/bus.c | 88 +++++++++++++++++++++++++++++++++++++- include/linux/mei_cl_bus.h | 8 ++++ 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 67557c67bd214415b8dc6747..f9bcff197615128d72f17590 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -257,7 +257,7 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag, } /** - * mei_cldev_send_vtag - me device send with vtag (write) + * mei_cldev_send_vtag - me device send with vtag (write) * * @cldev: me client device * @buf: buffer to send @@ -278,6 +278,29 @@ ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, } EXPORT_SYMBOL_GPL(mei_cldev_send_vtag); +/** + * mei_cldev_send_vtag_timeout - me device send with vtag and timeout (write) + * + * @cldev: me client device + * @buf: buffer to send + * @length: buffer length + * @vtag: virtual tag + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * written size in bytes + * * < 0 on error + */ + +ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, u8 vtag, unsigned long timeout) +{ + struct mei_cl *cl = cldev->cl; + + return __mei_cl_send_timeout(cl, buf, length, vtag, MEI_CL_IO_TX_BLOCKING, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_send_vtag_timeout); + /** * mei_cldev_recv_vtag - client receive with vtag (read) * @@ -323,7 +346,49 @@ ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, EXPORT_SYMBOL_GPL(mei_cldev_recv_nonblock_vtag); /** - * mei_cldev_send - me device send (write) + * mei_cldev_recv_timeout - client receive with timeout (read) + * + * @cldev: me client device + * @buf: buffer to receive + * @length: buffer length + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * read size in bytes + * * < 0 on error + */ +ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + unsigned long timeout) +{ + return mei_cldev_recv_vtag_timeout(cldev, buf, length, NULL, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_recv_timeout); + +/** + * mei_cldev_recv_vtag_timeout - client receive with vtag (read) + * + * @cldev: me client device + * @buf: buffer to receive + * @length: buffer length + * @vtag: virtual tag + * @timeout: recv timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * read size in bytes + * * < 0 on error + */ + +ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + u8 *vtag, unsigned long timeout) +{ + struct mei_cl *cl = cldev->cl; + + return __mei_cl_recv(cl, buf, length, vtag, 0, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_recv_vtag_timeout); + +/** + * mei_cldev_send - me device send (write) * * @cldev: me client device * @buf: buffer to send @@ -339,6 +404,25 @@ ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length } EXPORT_SYMBOL_GPL(mei_cldev_send); +/** + * mei_cldev_send_timeout - me device send with timeout (write) + * + * @cldev: me client device + * @buf: buffer to send + * @length: buffer length + * @timeout: send timeout in milliseconds, 0 for infinite timeout + * + * Return: + * * written size in bytes + * * < 0 on error + */ +ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, size_t length, + unsigned long timeout) +{ + return mei_cldev_send_vtag_timeout(cldev, buf, length, 0, timeout); +} +EXPORT_SYMBOL_GPL(mei_cldev_send_timeout); + /** * mei_cldev_recv - client receive (read) * diff --git a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h index c9af62e54577033bf9bae0e4..b38a56a13f39277f948c53b8 100644 --- a/include/linux/mei_cl_bus.h +++ b/include/linux/mei_cl_bus.h @@ -94,15 +94,23 @@ void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv); ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length); +ssize_t mei_cldev_send_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, unsigned long timeout); ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length); ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf, size_t length); +ssize_t mei_cldev_recv_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + unsigned long timeout); ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, size_t length, u8 vtag); +ssize_t mei_cldev_send_vtag_timeout(struct mei_cl_device *cldev, const u8 *buf, + size_t length, u8 vtag, unsigned long timeout); ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, u8 *vtag); ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, u8 *vtag); +ssize_t mei_cldev_recv_vtag_timeout(struct mei_cl_device *cldev, u8 *buf, size_t length, + u8 *vtag, unsigned long timeout); int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb); int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, -- 2.41.0