From patchwork Sat Feb 11 06:32:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 55704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1362382wrn; Fri, 10 Feb 2023 22:34:43 -0800 (PST) X-Google-Smtp-Source: AK7set/xXkj9VEDZ+NBYxznxF69p3LHZIKwiAyfAz0dtj/qZNpeopVpgtHqwT52MgVgQrnIz2RbE X-Received: by 2002:a50:bb44:0:b0:4a2:1274:d0db with SMTP id y62-20020a50bb44000000b004a21274d0dbmr731711ede.19.1676097283644; Fri, 10 Feb 2023 22:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676097283; cv=none; d=google.com; s=arc-20160816; b=ra8FHXCKC1zL1pYi30MvdYtrtZJ1iOYpYv8cPfToQlqXE6HW+HgeCEgZi5xxgCYDX3 OpbKQoKN0FW2QmJj6x7Hza0HedqHya5utNB8858dd77PwlEqhLasWHRd+Dg1mW7/YPEd Z/SreknrxYNz5OEd2S06kdDBsM7sGzgbzWERSHLYgYHabRv3EUz434EKuAxzXJZs2U3A +IvjrSbPWH+p45G5h5cjTHGCPcM5pXG98FrFCYZ85F2P1hcQiS33QdNXfk9Wf1bDHqkt H1Ewwx2fxvaCdRvXWEkLKlSXbHvcXqC30BAK8Gr77Fc1WqLiWDHKcTDNe0DGeJbNQrJv 0EDA== 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=JwYrRT1enyjtloTt2q2wRTvLRmMxx2rbTkbezutUarA=; b=XdW1oeIh4yVFX/iCC2vQT5Ongp10JriWJkH8/6DBj6IeUW2eJEMoIRTo5vZcZeA4KV fxOOEkx/nYyNLxR9it6gfvUM7tDZAGZxygVWsNvmg/U9Gk/z4yLQ2X7zu8HfJiHopoGD jfBdVgVTEptsOvS4O8RGezH51qERDzjSgUz6x1SroquJnKhTWnzSfAzaLK91meWxM/6+ cTyIv8E18ybPaFYuqUgLA08wvNU9j0IlNUC4VojCrvyzCRuLPsaA/ZUao6+VlfsdzUVr IXkOU0LHYo7R4x+bhUa0JUnpnoUtYRnGUpP9tw51hlta1axz31ICBqMGAi4vTyopMHsu bzBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AELmavOk; 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 w3-20020aa7d283000000b00483bcf2ab07si7769285edq.325.2023.02.10.22.34.18; Fri, 10 Feb 2023 22:34:43 -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=AELmavOk; 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 S229655AbjBKGdX (ORCPT + 99 others); Sat, 11 Feb 2023 01:33:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjBKGdQ (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 E320B7B390; Fri, 10 Feb 2023 22:33:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676097187; x=1707633187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fqW8c5N27aHnEIPv6D4igbjXtAZiZeCdbG59Y48XwDY=; b=AELmavOkTsPCMZMd2OYD8zrYfTFhZPKCp/w+/gnXE8K1tkR0/gnQvoR/ 8r/gaU/raaYVRq3Kq4A1FBs0kyukC1E7pHHX2p7ERBETatEWBjJI83ixh RWRVSfEDZ+Gb2sdvXVQcf2HN/XNJpXwVwfDjNMg+7hXMUsn4GuLbcuuax mPLTgH7zgt8pPs+L4N4KEYHt92meaQMldwiHol6tiGYQ7DRcz8I3YXPKg GQJGZ3I5o/tNuNFyJxl6EEdpUAS3OOEUmmDuYwf+zitVwtgplNrQL8rpg EMFrvljTAkgFEp/f/OT6SM7Br/haA1EM7GAjalt5pvhCbiOIj11eysej+ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="310223201" X-IronPort-AV: E=Sophos;i="5.97,289,1669104000"; d="scan'208";a="310223201" 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="997171763" X-IronPort-AV: E=Sophos;i="5.97,289,1669104000"; d="scan'208";a="997171763" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by fmsmga005.fm.intel.com with ESMTP; 10 Feb 2023 22:33:00 -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 03/12] platform/x86: ISST: Add IOCTL default callback Date: Fri, 10 Feb 2023 22:32:48 -0800 Message-Id: <20230211063257.311746-4-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?1757515385236088262?= X-GMAIL-MSGID: =?utf-8?q?1757515385236088262?= The common IOCTL handler has a predefined list of of IOCTLs it can handle. There is no default handler, if there is no match. Allow a client driver to define their own version of default IOCTL callback. In this way the default handling is passed to the client drivers to handle. With the introduction of TPMI target, IOCTL list is extended. The additional TPMI specific IOCTLs will be passed to the TPMI client driver default IOCTL handler. Signed-off-by: Srinivas Pandruvada --- .../x86/intel/speed_select_if/isst_if_common.c | 11 +++++++++++ .../x86/intel/speed_select_if/isst_if_common.h | 4 ++++ 2 files changed, 15 insertions(+) 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 63d49fe17a16..9fef955bdedc 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 @@ -588,6 +588,7 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, struct isst_if_cmd_cb cmd_cb; struct isst_if_cmd_cb *cb; long ret = -ENOTTY; + int i; switch (cmd) { case ISST_IF_GET_PLATFORM_INFO: @@ -616,6 +617,16 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, ret = isst_if_exec_multi_cmd(argp, &cmd_cb); break; default: + for (i = 0; i < ISST_IF_DEV_MAX; ++i) { + struct isst_if_cmd_cb *cb = &punit_callbacks[i]; + int ret; + + if (cb->def_ioctl) { + ret = cb->def_ioctl(file, cmd, arg); + if (!ret) + return ret; + } + } break; } 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 967c338e83c5..34a172e5c82c 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 @@ -48,6 +48,8 @@ * response to user ioctl buffer. The "resume" argument * can be used to avoid storing the command for replay * during system resume + * @def_ioctl: Default IOCTL handler callback, if there is no match in + * the existing list of IOCTL handled by the common handler. * * This structure is used to register an handler for IOCTL. To avoid * code duplication common code handles all the IOCTL command read/write @@ -58,8 +60,10 @@ struct isst_if_cmd_cb { int registered; int cmd_size; int offset; + 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); }; /* Internal interface functions */