Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3042592pxa; Tue, 18 Aug 2020 05:15:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzupdEFJoGRi0juS0JM+ypn9Mlr3Ip6Uaowo60dc+ao6vLLs3OXtiEx4bEKIzSNrI/8mpM7 X-Received: by 2002:aa7:df8a:: with SMTP id b10mr18970800edy.62.1597752911654; Tue, 18 Aug 2020 05:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597752911; cv=none; d=google.com; s=arc-20160816; b=zL7MYp+Fv3XfmHpE85GZiCu6b4qzEabYpPeJaFvb5Y6Luq/DD7vUYXVRfvDoPn5tyz mQ6y/x5de+/Tjedx4S4BPqEspvP+DmDWDYbnk1q8btD4Ujiq2v+GMF6V3xLENoC4/w6T iQjutkRWbvf8hamaMZbjOT9nCBN0/2tAZOn++kb0T1RujO4Z42Q7Fdz0zRaP8NUhNWOA rXO5CuLaj6sweid9lEvM0yrqT+vkFwn0wFBKGUf6kHd1Iv16dtpaazFlE7N7qQghBkLn JWNVuDiKAIlr2UinqJpNvGwGEhILd6zAre6PmuuIaVdNzeA1mGWyuT5lg7utC6xOnTzD ReSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=8WYDgJYXIZsebyFGFE3Vq4AZtaJCwiS3fBsNlBfDz8Y=; b=IWfN9mNJFHuZF9YZXFCfm3QNDzJGSgZNsmkTSot6Cv5Z6thoYIB0qJRp2mlaauZ4gs tcF3+AJqmCn1l0monCxfWMTvYZL7rwI/bURerVTSokc/9oF34YkubHsIrGztL6kLePyK 09AI3u7+k9FzInYfPa8N3hlERGac5QOcquYVkTKbLlMXEFnoIVAC3IfcwT4kXVb0D7Ry +MeFoOjiM1tofrn42CTdNfZgnXDv9H0oWq1RSIZV8TwHlzexJ9+ns6WxklLABFywWl0s 6iJ2f10D5H5vqIM3CIgl7RUqOtKlX3IsPpwAzqJiaPT4DBiryGw3N3MaACyd43R+cJ++ c09A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs8si13176315ejb.665.2020.08.18.05.14.47; Tue, 18 Aug 2020 05:15:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbgHRMK6 (ORCPT + 99 others); Tue, 18 Aug 2020 08:10:58 -0400 Received: from mga07.intel.com ([134.134.136.100]:58738 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbgHRMKV (ORCPT ); Tue, 18 Aug 2020 08:10:21 -0400 IronPort-SDR: Qr9FqWjiTP6L8hrZdKd+C6OYo5Ui53HNVRo5gPlJa7B5/4TLTq9jBK8Jr/GTtTVahlfLwOAJR3 BQWP+zZp3hWg== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="219200400" X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="219200400" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Aug 2020 05:10:20 -0700 IronPort-SDR: nTd3h3+oObJSYkT1KRpalDVCQ0oWImq4U2yt5oeIcAaBwEHFyL/ErUWnfix6hw31bQ/9uQkGAS Q1cenOMyDOGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,327,1592895600"; d="scan'208";a="326713041" Received: from twinkler-lnx.jer.intel.com ([10.12.91.138]) by orsmga008.jf.intel.com with ESMTP; 18 Aug 2020 05:10:17 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next 09/13] mei: bus: use zero vtag for bus clients. Date: Tue, 18 Aug 2020 14:51:43 +0300 Message-Id: <20200818115147.2567012-10-tomas.winkler@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200818115147.2567012-1-tomas.winkler@intel.com> References: <20200818115147.2567012-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin The zero vtag is required for the read flow to work also for devices on the mei client bus. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- drivers/misc/mei/bus.c | 72 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index fc20a0da5c24..9cdaa7f3af23 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -495,6 +495,68 @@ static void mei_cl_bus_module_put(struct mei_cl_device *cldev) module_put(cldev->bus->dev->driver->owner); } +/** + * mei_cl_bus_vtag - get bus vtag entry wrapper + * The tag for bus client is always first. + * + * @cl: host client + * + * Return: bus vtag or NULL + */ +static inline struct mei_cl_vtag *mei_cl_bus_vtag(struct mei_cl *cl) +{ + return list_first_entry_or_null(&cl->vtag_map, + struct mei_cl_vtag, list); +} + +/** + * mei_cl_bus_vtag_alloc - add bus client entry to vtag map + * + * @cldev: me client device + * + * Return: + * * 0 on success + * * -ENOMEM if memory allocation failed + */ +static int mei_cl_bus_vtag_alloc(struct mei_cl_device *cldev) +{ + struct mei_cl *cl = cldev->cl; + struct mei_cl_vtag *cl_vtag; + + /* + * Bail out if the client does not supports vtags + * or has already allocated one + */ + if (mei_cl_vt_support_check(cl) || mei_cl_bus_vtag(cl)) + return 0; + + cl_vtag = mei_cl_vtag_alloc(NULL, 0); + if (IS_ERR(cl_vtag)) + return -ENOMEM; + + list_add_tail(&cl_vtag->list, &cl->vtag_map); + + return 0; +} + +/** + * mei_cl_bus_vtag_free - remove the bus entry from vtag map + * + * @cldev: me client device + */ +static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) +{ + struct mei_cl *cl = cldev->cl; + struct mei_cl_vtag *cl_vtag; + + cl_vtag = mei_cl_bus_vtag(cl); + if (!cl_vtag) + return; + + list_del(&cl_vtag->list); + kfree(cl_vtag); +} + /** * mei_cldev_enable - enable me client device * create connection with me client @@ -531,9 +593,15 @@ int mei_cldev_enable(struct mei_cl_device *cldev) goto out; } + ret = mei_cl_bus_vtag_alloc(cldev); + if (ret) + goto out; + ret = mei_cl_connect(cl, cldev->me_cl, NULL); - if (ret < 0) + if (ret < 0) { dev_err(&cldev->dev, "cannot connect\n"); + mei_cl_bus_vtag_free(cldev); + } out: mutex_unlock(&bus->device_lock); @@ -586,6 +654,8 @@ int mei_cldev_disable(struct mei_cl_device *cldev) mutex_lock(&bus->device_lock); + mei_cl_bus_vtag_free(cldev); + if (!mei_cl_is_connected(cl)) { dev_dbg(bus->dev, "Already disconnected\n"); err = 0; -- 2.25.4