From patchwork Sat Feb 11 06:32:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 55703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1362316wrn; Fri, 10 Feb 2023 22:34:30 -0800 (PST) X-Google-Smtp-Source: AK7set9UJXgxAFOBdM/bL/4pDrFzrpNYnWvL5qqbUelS4MY8UQ6ei11CyT9iyXc7VtZfgX9IuGI+ X-Received: by 2002:a17:907:3e23:b0:8af:2fa1:2226 with SMTP id hp35-20020a1709073e2300b008af2fa12226mr12333133ejc.6.1676097270275; Fri, 10 Feb 2023 22:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676097270; cv=none; d=google.com; s=arc-20160816; b=wcNsGY7AmHOeXmx/AkJFEhg+2PxyF4TSypzMYl2jBj36I/CIjWR9uxfJaM6hoHrGEm /4eJrq43fAS1IvcCGmYPdgRHpddrOU1buGANal5bjeVdn9/pjvty/iIk+tfEwUiFXHEl s23Z/4ZGKOPIAmjFRwC1x8qFUeUxR6g1AYmFuqx4ekSY4VTOuk4oRHH4Qs7MShwT25qd /Ao1EFcDOaFsOdwIE2ZLIBWZgIuepVyDeeqj6pjmf1Fb5UQ9Wos7+rYq9Rz94vs4Dcsq Jh0SDNwjxUIPaRS/Ao+aVS7IspaSg+3etbZAb5wS50dQuZAeMhPwcZvxeB/Apmy27Vo5 On0Q== 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=JBHM1eYQmfvCO5stIGOfV+dvdNM69a//Ik8s4K3HRro=; b=f27xZOuZUqhFN7Ra1vUf9r0b7Rb1QQJphxsIyn3L+MHBfp92mNGNTyD90IhEw91w00 7XXobPIupwxp2h3Q9LRC8TXJcMICC12i9qGmcwVzdCn6UiX2LC6G6oE10Qzqvyg8cOCT TxfkvHJUdbCXkviQCmnvhQ6kqt8+6EdlWS7g6iRJeUGCz4xWTSLEwkr3H+uPldfjvKSx X8rFHjxQp+SHCiyREWD83Az7YydpQBpbc+zxeOPYoa6z6BCmdfEbU3AlmSJK02HONWrh 53rDiy5yPIhl+rE+YTjeIoSBBv31RZG3m9CUcTKlAvXpfKOdWfrz7n8hCQ4mtsuHbbWA EvCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kEooXt9m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ka23-20020a170907921700b00877817a13ddsi6755572ejb.878.2023.02.10.22.34.07; Fri, 10 Feb 2023 22:34:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kEooXt9m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjBKGd0 (ORCPT + 99 others); Sat, 11 Feb 2023 01:33:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjBKGdQ (ORCPT ); Sat, 11 Feb 2023 01:33:16 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015C87BFE5; Fri, 10 Feb 2023 22:33:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676097188; x=1707633188; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0JlOSadLZTIZHVM2qZRsqf/jURAo7n/PnYciNcJuWpE=; b=kEooXt9mIrz2e1z3jN5WwQLb0RRV6RyZBbp9ilVJ0BZCA5mcAyOCkLK8 fHYHiqR3MkntYvP3Of0k/Mu9pUpwEQWzo4ekqx1xQWkgivVZKIw3AXlRB lfct8/ihBBDCgpCHCeK/tYddSlRTaEbAs56w2QBYKjKrLOs+h0rsnDarc gOYrNPNsUTkd9JPgfCgeUOTVeoZx9h7pDX9l6pa6tgwqDjEdHbpjcBdfv GMkPW3LcytuTgNPmYZ7NyQh1+DvCjMNFJhwxvQ1XXcNffvmpmBsKwlN6J WV457b7Ve0zh4SVvY2w1HydxCOIa/zCMAO8cwL4PQugik3XoxWSplx5cq g==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="310223204" X-IronPort-AV: E=Sophos;i="5.97,289,1669104000"; d="scan'208";a="310223204" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 22:33:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="997171764" X-IronPort-AV: E=Sophos;i="5.97,289,1669104000"; d="scan'208";a="997171764" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by fmsmga005.fm.intel.com with ESMTP; 10 Feb 2023 22:33:01 -0800 From: Srinivas Pandruvada To: hdegoede@redhat.com, markgross@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 04/12] platform/x86: ISST: Add API version of the target Date: Fri, 10 Feb 2023 22:32:49 -0800 Message-Id: <20230211063257.311746-5-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230211063257.311746-1-srinivas.pandruvada@linux.intel.com> References: <20230211063257.311746-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757515370785431350?= X-GMAIL-MSGID: =?utf-8?q?1757515370785431350?= User space can get the API version using IOCTL ISST_IF_GET_PLATFORM_INFO. This information can be used to get IOCTLs supported by the kernel driver. This version is hardcoded in the driver. Allow the registered client to specify the supported API version. In this way a registered client can specify a higher API version to extend IOCTL set. Signed-off-by: Srinivas Pandruvada --- .../platform/x86/intel/speed_select_if/isst_if_common.c | 8 +++++++- .../platform/x86/intel/speed_select_if/isst_if_common.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c index 9fef955bdedc..60e58b0b3835 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_if_common.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_if_common.c @@ -262,11 +262,13 @@ bool isst_if_mbox_cmd_set_req(struct isst_if_mbox_cmd *cmd) } EXPORT_SYMBOL_GPL(isst_if_mbox_cmd_set_req); +static int isst_if_api_version; + static int isst_if_get_platform_info(void __user *argp) { struct isst_if_platform_info info; - info.api_version = ISST_IF_API_VERSION; + info.api_version = isst_if_api_version; info.driver_version = ISST_IF_DRIVER_VERSION; info.max_cmds_per_ioctl = ISST_IF_CMD_LIMIT; info.mbox_supported = punit_callbacks[ISST_IF_DEV_MBOX].registered; @@ -767,6 +769,10 @@ int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb) mutex_unlock(&punit_misc_dev_open_lock); return -EAGAIN; } + if (!cb->api_version) + cb->api_version = ISST_IF_API_VERSION; + if (cb->api_version > isst_if_api_version) + isst_if_api_version = cb->api_version; memcpy(&punit_callbacks[device_type], cb, sizeof(*cb)); punit_callbacks[device_type].registered = 1; mutex_unlock(&punit_misc_dev_open_lock); diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_common.h b/drivers/platform/x86/intel/speed_select_if/isst_if_common.h index 34a172e5c82c..1004f2c9cca8 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_if_common.h +++ b/drivers/platform/x86/intel/speed_select_if/isst_if_common.h @@ -41,6 +41,7 @@ * @offset: Offset to the first valid member in command structure. * This will be the offset of the start of the command * after command count field + * @api_version: API version supported for this target. 0, if none. * @owner: Registered module owner * @cmd_callback: Callback function to handle IOCTL. The callback has the * command pointer with data for command. There is a pointer @@ -60,7 +61,7 @@ struct isst_if_cmd_cb { int registered; int cmd_size; int offset; - + int api_version; struct module *owner; long (*cmd_callback)(u8 *ptr, int *write_only, int resume); long (*def_ioctl)(struct file *file, unsigned int cmd, unsigned long arg);