From 244e32c29ea2d483b128bb877935368722fb10c6 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 18:02:17 +0530 Subject: [PATCH 01/11] ATH9K naming conflicts --- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 6 +++--- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 2 +- drivers/net/wireless/ath/ath9k/htc_hst.c | 6 +++--- drivers/net/wireless/ath/ath9k/htc_hst.h | 6 +++--- drivers/net/wireless/ath/ath9k/wmi.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index ff61ae34ecdf0..bfea782e342ed 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -134,7 +134,7 @@ static inline int ath9k_htc_connect_svc(struct ath9k_htc_priv *priv, req.ep_callbacks.rx = ath9k_htc_rxep; req.ep_callbacks.tx = tx; - return htc_connect_service(priv->htc, &req, ep_id); + return htc_connect_service_hst(priv->htc, &req, ep_id); } static int ath9k_init_htc_services(struct ath9k_htc_priv *priv, u16 devid, diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index 2b7832b1c8008..075b716b836e7 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -226,7 +226,7 @@ void ath9k_htc_reset(struct ath9k_htc_priv *priv) WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode); WMI_CMD(WMI_ENABLE_INTR_CMDID); - htc_start(priv->htc); + htc_start_hst(priv->htc); ath9k_htc_vif_reconfig(priv); ieee80211_wake_queues(priv->hw); @@ -302,7 +302,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv, if (ret) goto err; - htc_start(priv->htc); + htc_start_hst(priv->htc); if (!test_bit(ATH_OP_SCANNING, &common->op_flags) && !(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) @@ -955,7 +955,7 @@ static int ath9k_htc_start(struct ieee80211_hw *hw) "Failed to update capability in target\n"); clear_bit(ATH_OP_INVALID, &common->op_flags); - htc_start(priv->htc); + htc_start_hst(priv->htc); spin_lock_bh(&priv->tx.tx_lock); priv->tx.flags &= ~ATH9K_HTC_OP_TX_QUEUES_STOP; diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c index 0bdc4dcb7b8fe..de31be3a10f8a 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c @@ -543,7 +543,7 @@ void ath9k_htc_tx_drain(struct ath9k_htc_priv *priv) * Ensure that all pending TX frames are flushed, * and that the TX completion/failed tasklets is killed. */ - htc_stop(priv->htc); + htc_stop_hst(priv->htc); tasklet_kill(&priv->wmi->wmi_event_tasklet); tasklet_kill(&priv->tx_failed_tasklet); diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 510e61e97dbcb..ac4a6725995dd 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c @@ -231,7 +231,7 @@ int htc_init(struct htc_target *target) return htc_setup_complete(target); } -int htc_connect_service(struct htc_target *target, +int htc_connect_service_hst(struct htc_target *target, struct htc_service_connreq *service_connreq, enum htc_endpoint_id *conn_rsp_epid) { @@ -304,12 +304,12 @@ int htc_send_epid(struct htc_target *target, struct sk_buff *skb, return htc_issue_send(target, skb, skb->len, 0, epid); } -void htc_stop(struct htc_target *target) +void htc_stop_hst(struct htc_target *target) { target->hif->stop(target->hif_dev); } -void htc_start(struct htc_target *target) +void htc_start_hst(struct htc_target *target) { target->hif->start(target->hif_dev); } diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h index 06474ccc76965..0bd3e6b7199bf 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.h +++ b/drivers/net/wireless/ath/ath9k/htc_hst.h @@ -203,14 +203,14 @@ struct htc_comp_msg { } __packed; int htc_init(struct htc_target *target); -int htc_connect_service(struct htc_target *target, +int htc_connect_service_hst(struct htc_target *target, struct htc_service_connreq *service_connreq, enum htc_endpoint_id *conn_rsp_eid); int htc_send(struct htc_target *target, struct sk_buff *skb); int htc_send_epid(struct htc_target *target, struct sk_buff *skb, enum htc_endpoint_id epid); -void htc_stop(struct htc_target *target); -void htc_start(struct htc_target *target); +void htc_stop_hst(struct htc_target *target); +void htc_start_hst(struct htc_target *target); void htc_sta_drain(struct htc_target *target, u8 idx); void ath9k_htc_rx_msg(struct htc_target *htc_handle, diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c index fe29ad4b9023c..a1c2309309a32 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -264,7 +264,7 @@ int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi, connect.ep_callbacks.rx = ath9k_wmi_ctrl_rx; connect.service_id = WMI_CONTROL_SVC; - ret = htc_connect_service(htc, &connect, &wmi->ctrl_epid); + ret = htc_connect_service_hst(htc, &connect, &wmi->ctrl_epid); if (ret) return ret; From 2738d3ada1d553b4f8426bc967f9054503268973 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 18:03:12 +0530 Subject: [PATCH 02/11] Wifi Injection Pathc --- .../wireless/realtek/rtl818x/rtl8187/dev.c | 11 ++++++++++- drivers/net/wireless/zydas/zd1211rw/zd_mac.c | 18 ++++++++++++------ net/mac80211/cfg.c | 3 ++- net/mac80211/tx.c | 19 +++++++++++++++---- net/wireless/chan.c | 6 ++++-- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c index eb68b2d3caa12..789db12bc9fcd 100644 --- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c @@ -248,8 +248,17 @@ static void rtl8187_tx(struct ieee80211_hw *dev, flags |= RTL818X_TX_DESC_FLAG_NO_ENC; flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24; + + // When this flag is set the firmware waits untill ALL fragments have + // reached the USB device. Then it sends the first fragment and waits + // for ACKS's. Of course in monitor mode it won't detect these ACK's. if (ieee80211_has_morefrags(tx_hdr->frame_control)) - flags |= RTL818X_TX_DESC_FLAG_MOREFRAG; + { + // If info->control.vif is NULL it's most likely in monitor mode + if (likely(info->control.vif != NULL && info->control.vif->type != NL80211_IFTYPE_MONITOR)) { + flags |= RTL818X_TX_DESC_FLAG_MOREFRAG; + } + } /* HW will perform RTS-CTS when only RTS flags is set. * HW will perform CTS-to-self when both RTS and CTS flags are set. diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c index 3ef8533205f91..193bd301d89eb 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c @@ -229,14 +229,19 @@ void zd_mac_clear(struct zd_mac *mac) static int set_rx_filter(struct zd_mac *mac) { unsigned long flags; - u32 filter = STA_RX_FILTER; + struct zd_ioreq32 ioreqs[] = { + {CR_RX_FILTER, STA_RX_FILTER}, + { CR_SNIFFER_ON, 0U }, + }; spin_lock_irqsave(&mac->lock, flags); - if (mac->pass_ctrl) - filter |= RX_FILTER_CTRL; + if (mac->pass_ctrl) { + ioreqs[0].value |= 0xFFFFFFFF; + ioreqs[1].value = 0x1; + } spin_unlock_irqrestore(&mac->lock, flags); - return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); + return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs)); } static int set_mac_and_bssid(struct zd_mac *mac) @@ -1042,7 +1047,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) /* Caller has to ensure that length >= sizeof(struct rx_status). */ status = (struct rx_status *) (buffer + (length - sizeof(struct rx_status))); - if (status->frame_status & ZD_RX_ERROR) { + if ((status->frame_status & ZD_RX_ERROR) || + (status->frame_status & ~0x21)) { if (mac->pass_failed_fcs && (status->frame_status & ZD_RX_CRC32_ERROR)) { stats.flag |= RX_FLAG_FAILED_FCS_CRC; @@ -1385,7 +1391,7 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) ieee80211_hw_set(hw, MFP_CAPABLE); ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING); ieee80211_hw_set(hw, RX_INCLUDES_FCS); - ieee80211_hw_set(hw, SIGNAL_UNSPEC); + ieee80211_hw_set(hw, SIGNAL_DBM); hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_MESH_POINT) | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 6a96deded7632..a87e4dc119432 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -796,7 +796,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy, ret = ieee80211_vif_use_channel(sdata, chandef, IEEE80211_CHANCTX_EXCLUSIVE); } - } else if (local->open_count == local->monitors) { + // Patch: Always allow channel change, even if a normal virtual interface is present + } else /*if (local->open_count == local->monitors)*/ { local->_oper_chandef = *chandef; ieee80211_hw_config(local, 0); } diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 1d8526d89505f..b4db6a12161fb 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -814,11 +814,19 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx) /* * Packet injection may want to control the sequence - * number, if we have no matching interface then we - * neither assign one ourselves nor ask the driver to. + * number, so if an injected packet is found, skip + * renumbering it. Also make the packet NO_ACK to avoid + * excessive retries (ACKing and retrying should be + * handled by the injecting application). + * FIXME This may break hostapd and some other injectors. + * This should be done using a radiotap flag. */ - if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR)) + if (unlikely((info->flags & IEEE80211_TX_CTL_INJECTED) && + !(tx->sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES))) { + if (!ieee80211_has_morefrags(hdr->frame_control)) + info->flags |= IEEE80211_TX_CTL_NO_ACK; return TX_CONTINUE; + } if (unlikely(ieee80211_is_ctl(hdr->frame_control))) return TX_CONTINUE; @@ -2026,7 +2034,10 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, } } - ieee80211_set_qos_hdr(sdata, skb); + // Don't overwrite QoS header in monitor mode + if (likely(info->control.vif->type != NL80211_IFTYPE_MONITOR)) { + ieee80211_set_qos_hdr(sdata, skb); + } ieee80211_tx(sdata, sta, skb, false); } diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 22d1779ab2b1b..e440612f478c0 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -1238,8 +1238,10 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, { if (!rdev->ops->set_monitor_channel) return -EOPNOTSUPP; - if (!cfg80211_has_monitors_only(rdev)) - return -EBUSY; + // Always allow user to change channel, even if there is another normal + // virtual interface using the device. + //if (!cfg80211_has_monitors_only(rdev)) + // return -EBUSY; return rdev_set_monitor_channel(rdev, chandef); } From c50c034200d7ddf08e1621fe0b68d9be6a215b1b Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 18:04:35 +0530 Subject: [PATCH 03/11] HWID fix --- drivers/misc/Kconfig | 6 + drivers/misc/Makefile | 1 + drivers/misc/gpio-testing-mode.c | 2 +- drivers/misc/hwid.c | 200 +++++++++++++++++++++++++++++++ drivers/net/wireless/cnss2/qmi.c | 3 +- include/linux/hwid.h | 79 ++++++++++++ 6 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 drivers/misc/hwid.c create mode 100644 include/linux/hwid.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 3b36274df8173..9bec0fa4c44a1 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -527,6 +527,12 @@ config LDO_WL2866D help This driver provides support for the voltage regulators and top-level chip enablement of WL2866 + +config MI_HARDWARE_ID + tristate "Register xiaomi hwid module" + default n + help + This adds support for mi hwid. source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index d59926ac8e28a..8f1c6aa9a7af5 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -56,6 +56,7 @@ obj-y += cardreader/ obj-y += mi-memory/ obj-y += mi-ioturbo/ obj-y += mi-power/ +obj-$(CONFIG_MI_HARDWARE_ID) += hwid.o obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE) += uacce/ diff --git a/drivers/misc/gpio-testing-mode.c b/drivers/misc/gpio-testing-mode.c index c71b20f9e16d7..b3dc2e1f862a0 100644 --- a/drivers/misc/gpio-testing-mode.c +++ b/drivers/misc/gpio-testing-mode.c @@ -17,7 +17,7 @@ #include #include #include -#include "hwid.h" +#include struct gpio_data { int irq; int gpio_num; diff --git a/drivers/misc/hwid.c b/drivers/misc/hwid.c new file mode 100644 index 0000000000000..008662e9de461 --- /dev/null +++ b/drivers/misc/hwid.c @@ -0,0 +1,200 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * HwId Module driver for mi dirver acquire some hwid build info, + * which is only used for xiaomi corporation internally. + * + * Copyright (c) 2020 xiaomi inc. + * Copyright (C) 2021 XiaoMi, Inc. + */ + +/***************************************************************************** +* Included header files +*****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/***************************************************************************** +* Global variable or extern global variabls +*****************************************************************************/ +static uint hwid_value; +module_param(hwid_value, uint, 0444); +MODULE_PARM_DESC(hwid_value, "xiaomi hwid value correspondingly different build"); + +static uint project; +module_param(project, uint, 0444); +MODULE_PARM_DESC(project, "xiaomi project serial num predefine"); + +static uint build_adc; +module_param(build_adc, uint, 0444); +MODULE_PARM_DESC(build_adc, "xiaomi adc value of build resistance"); + +static uint project_adc; +module_param(project_adc, uint, 0444); +MODULE_PARM_DESC(project_adc, "xiaomi adc value of project resistance"); + +static struct kobject *hwid_kobj; +#define hwid_attr(_name) \ +static struct kobj_attribute _name##_attr = { \ + .attr = { \ + .name = __stringify(_name), \ + .mode = 0444, \ + }, \ + .show = _name##_show, \ + .store = NULL, \ +} + +/***************************************************************************** +* Global variable or extern global functions +*****************************************************************************/ +static ssize_t hwid_project_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", project); +} + +static ssize_t hwid_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", hwid_value); +} + +static ssize_t hwid_project_adc_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", project_adc); +} + +static ssize_t hwid_build_adc_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", build_adc); +} + +const char *product_name_get(void) +{ + switch (project){ + case HARDWARE_PROJECT_L2: return "zeus"; + case HARDWARE_PROJECT_L3: return "cupid"; + default: return "unknown"; + } +} +EXPORT_SYMBOL(product_name_get); + +uint32_t get_hw_project_adc(void) +{ + return project_adc; +} +EXPORT_SYMBOL(get_hw_project_adc); + +uint32_t get_hw_build_adc(void) +{ + return build_adc; +} +EXPORT_SYMBOL(get_hw_build_adc); + +uint32_t get_hw_version_platform(void) +{ + return project; +} +EXPORT_SYMBOL(get_hw_version_platform); + + +uint32_t get_hw_id_value(void) +{ + return hwid_value; +} +EXPORT_SYMBOL(get_hw_id_value); + +uint32_t get_hw_country_version(void) +{ + return (hwid_value & HW_COUNTRY_VERSION_MASK) >> HW_COUNTRY_VERSION_SHIFT; +} +EXPORT_SYMBOL(get_hw_country_version); + +uint32_t get_hw_version_major(void) +{ + return (hwid_value & HW_MAJOR_VERSION_MASK) >> HW_MAJOR_VERSION_SHIFT; +} +EXPORT_SYMBOL(get_hw_version_major); + +uint32_t get_hw_version_minor(void) +{ + return (hwid_value & HW_MINOR_VERSION_MASK) >> HW_MINOR_VERSION_SHIFT; +} +EXPORT_SYMBOL(get_hw_version_minor); + +uint32_t get_hw_version_build(void) +{ + return (hwid_value & HW_BUILD_VERSION_MASK) >> HW_BUILD_VERSION_SHIFT; +} +EXPORT_SYMBOL(get_hw_version_build); + +hwid_attr(hwid_project); +hwid_attr(hwid_value); +hwid_attr(hwid_project_adc); +hwid_attr(hwid_build_adc); + +static struct attribute *hwid_attrs[] = { + &hwid_project_attr.attr, + &hwid_value_attr.attr, + &hwid_project_adc_attr.attr, + &hwid_build_adc_attr.attr, + NULL, +}; + +static struct attribute_group attr_group = { + .attrs = hwid_attrs, +}; + +/***************************************************************************** +* Name: hwid_module_init +*****************************************************************************/ +static int __init hwid_module_init(void) +{ + int ret = -ENOMEM; + + hwid_kobj = kobject_create_and_add("hwid", NULL); + if (!hwid_kobj) { + pr_err("hwid: hwid module init failed\n"); + goto fail; + } + + ret = sysfs_create_group(hwid_kobj, &attr_group); + if (ret) { + pr_err("hwid: sysfs register failed\n"); + goto sys_fail; + } + +sys_fail: + kobject_del(hwid_kobj); +fail: + return ret; +} + +/***************************************************************************** +* Name: hwid_module_exit +*****************************************************************************/ +static void __exit hwid_module_exit(void) +{ + if (hwid_kobj) { + sysfs_remove_group(hwid_kobj, &attr_group); + kobject_del(hwid_kobj); + } + pr_info("hwid: hwid module exit success\n"); +} + +subsys_initcall(hwid_module_init); +module_exit(hwid_module_exit); + +MODULE_AUTHOR("weixiaotian1@xiaomi.com"); +MODULE_DESCRIPTION("Hwid Module Driver for Xiaomi Corporation"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/wireless/cnss2/qmi.c b/drivers/net/wireless/cnss2/qmi.c index 9c7a3b9a0f7e5..f72b394693339 100644 --- a/drivers/net/wireless/cnss2/qmi.c +++ b/drivers/net/wireless/cnss2/qmi.c @@ -4,13 +4,14 @@ #include #include +#include #include "bus.h" #include "debug.h" #include "main.h" #include "qmi.h" #include "genl.h" -#include "hwid.h" + #define WLFW_SERVICE_INS_ID_V01 1 #define WLFW_CLIENT_ID 0x4b4e454c diff --git a/include/linux/hwid.h b/include/linux/hwid.h new file mode 100644 index 0000000000000..21c95f5ab0681 --- /dev/null +++ b/include/linux/hwid.h @@ -0,0 +1,79 @@ +#ifndef __HWID_H__ +#define __HWID_H__ + +#define MAX_PRODUCT_SIZE 16 +#define MAX_REVIRSION_SIZE 8 +#define MAX_COUNTRY_SIZE 8 + +#define HARDWARE_PROJECT_UNKNOWN 0 +#define HARDWARE_PROJECT_L2 1 +#define HARDWARE_PROJECT_L3 2 + +#define HW_MAJOR_VERSION_SHIFT 16 +#define HW_MINOR_VERSION_SHIFT 0 +#define HW_COUNTRY_VERSION_SHIFT 20 +#define HW_BUILD_VERSION_SHIFT 16 +#define HW_MAJOR_VERSION_MASK 0xFFFF0000 +#define HW_MINOR_VERSION_MASK 0x0000FFFF +#define HW_COUNTRY_VERSION_MASK 0xFFF00000 +#define HW_BUILD_VERSION_MASK 0x000F0000 + +#define SMEM_ID_VENDOR1 135 +#define ADCDEV_MAJOR 0 +#define ADCDEV_MINOR 200 +#define XIAOMI_ADC_MODULE "xiaomi_adc_module" +#define XIAOMI_ADC_DEVICE "xiaomi_adc_device" +#define XIAOMI_ADC_CLASS "xiaomi_adc_class" + +typedef enum { + CountryCN = 0x00, + CountryGlobal = 0x01, + CountryIndia = 0x02, + CountryJapan = 0x03, + INVALID = 0x04, + CountryIDMax = 0x7FFFFFFF +} CountryType; + +typedef enum { + CHIPINFO_ID_UNKNOWN = 0x00, + CHIPINFO_ID_MAX = 0x7FFFFFFF +}ChipInfoIdType; + +typedef enum { + PROJECT_ID_UNKNOWN = 0x00, + PROJECT_ID_MAX = 0x7FFFFFFF +}ProjectInfoType; + +/** + Stores the target project and the hw version. + */ +struct project_info +{ + ChipInfoIdType chiptype; /* Chip identification type */ + uint32_t pro_r1; /* resistance of the project*/ + uint32_t pr_min_adc; /* min adc value from project resistance*/ + uint32_t pr_max_adc; /* max adc value from project resistance*/ + ProjectInfoType project; /* Project type of the mi predefine*/ + char productname[MAX_PRODUCT_SIZE]; /* product name*/ + uint32_t hw_r1; /* resistance of the hwid*/ + uint32_t hr_min_adc; /* min adc value from hwid resistance*/ + uint32_t hr_max_adc; /* max adc value from hwid resistance*/ + char hw_level[MAX_REVIRSION_SIZE]; /* hardware reversion*/ + char hw_country[MAX_COUNTRY_SIZE]; /* hardware country*/ + uint32_t hw_id; /* hardware id*/ + uint8_t ddr_id; /* ddr id */ + uint32_t reserved1; /* reserved field1 for further*/ + uint32_t reserved2; /* reserved field2 for further*/ +}; + +const char *product_name_get(void); +uint32_t get_hw_version_platform(void); +uint32_t get_hw_country_version(void); +uint32_t get_hw_version_major(void); +uint32_t get_hw_version_minor(void); +uint32_t get_hw_version_build(void); +uint32_t get_hw_project_adc(void); +uint32_t get_hw_build_adc(void); +uint32_t get_hw_id_value(void); + +#endif From e7c014f88e73529cb495d1021c3f65c5b9fbb9ea Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 23:37:17 +0530 Subject: [PATCH 04/11] HWIF fix --- drivers/misc/Kconfig | 2 -- drivers/misc/Makefile | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 9bec0fa4c44a1..1480a3ccc4088 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -549,9 +549,7 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" -source "drivers/misc/hwid/Kconfig" source "drivers/misc/mi-memory/Kconfig" source "drivers/misc/mi_gamekey/Kconfig" source "drivers/misc/mi-power/Kconfig" -source "drivers/misc/plaid/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 8f1c6aa9a7af5..a0d0436e33094 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -68,7 +68,6 @@ obj-$(CONFIG_QSEECOM) += qseecom-mod.o qseecom-mod-$(CONFIG_QSEECOM) := qseecom.o qseecom-mod-$(CONFIG_COMPAT) += compat_qseecom.o obj-$(CONFIG_WIGIG_SENSING_SPI) += wigig_sensing.o -obj-y += hwid/ obj-$(CONFIG_PERF_HELPER) += perf_helper.o obj-$(CONFIG_MI_GAMEKEY) += mi_gamekey/ obj-$(CONFIG_LDO_WL2866D) += wl2866d.o From 6a1ae54a81cbc03df1144ef49d8d7cc730c77091 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 23:38:00 +0530 Subject: [PATCH 05/11] qmi.c fix --- drivers/net/wireless/cnss2/qmi.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/net/wireless/cnss2/qmi.c b/drivers/net/wireless/cnss2/qmi.c index f72b394693339..09cca1b2a6cf2 100644 --- a/drivers/net/wireless/cnss2/qmi.c +++ b/drivers/net/wireless/cnss2/qmi.c @@ -605,13 +605,6 @@ static int cnss_get_bdf_file_name(struct cnss_plat_data *plat_priv, else snprintf(filename_tmp, filename_len, ELF_BDF_FILE_NAME_L3_GF); - } else if (hw_platform_ver == HARDWARE_PROJECT_L10) { - if ((uint32_t)CountryGlobal == hw_country_ver) - snprintf(filename_tmp, filename_len, - ELF_BDF_FILE_NAME_L10_GF_GLOBAL); - else - snprintf(filename_tmp, filename_len, - ELF_BDF_FILE_NAME_L10_GF); } else snprintf(filename_tmp, filename_len, ELF_BDF_FILE_NAME_GF); @@ -629,13 +622,6 @@ static int cnss_get_bdf_file_name(struct cnss_plat_data *plat_priv, else snprintf(filename_tmp, filename_len, ELF_BDF_FILE_NAME_L3); - } else if (hw_platform_ver == HARDWARE_PROJECT_L10) { - if ((uint32_t)CountryGlobal == hw_country_ver) - snprintf(filename_tmp, filename_len, - ELF_BDF_FILE_NAME_L10_GLOBAL); - else - snprintf(filename_tmp, filename_len, - ELF_BDF_FILE_NAME_L10); } else snprintf(filename_tmp, filename_len, ELF_BDF_FILE_NAME); From b80126d960039f07507baece43f1f385394bfcde Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 23:38:40 +0530 Subject: [PATCH 06/11] multipal redefination fix --- drivers/usb/gadget/udc/core.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c index 122e5891d0a4f..584e2ea0debea 100644 --- a/drivers/usb/gadget/udc/core.c +++ b/drivers/usb/gadget/udc/core.c @@ -1183,21 +1183,6 @@ static inline void usb_gadget_udc_set_speed(struct usb_udc *udc, gadget->ops->udc_set_speed(gadget, s); } -static inline void usb_gadget_enable_async_callbacks(struct usb_udc *udc) -{ - struct usb_gadget *gadget = udc->gadget; - - if (gadget->ops->udc_async_callbacks) - gadget->ops->udc_async_callbacks(gadget, true); -} - -static inline void usb_gadget_disable_async_callbacks(struct usb_udc *udc) -{ - struct usb_gadget *gadget = udc->gadget; - - if (gadget->ops->udc_async_callbacks) - gadget->ops->udc_async_callbacks(gadget, false); -} /** * usb_gadget_enable_async_callbacks - tell usb device controller to enable asynchronous callbacks From d102c8472049995a40ff6219a58b1a6a7a32f0de Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sat, 29 Apr 2023 23:39:03 +0530 Subject: [PATCH 07/11] missing files fix --- drivers/mihw/Kconfig | 67 +++++++++++++++++++ drivers/mihw/Makefile | 4 ++ drivers/mihw/game/Makefile | 4 ++ drivers/mihw/game/glk.c | 52 +++++++++++++++ drivers/mihw/game/migt_ca.c | 21 ++++++ drivers/mihw/game/migt_main.c | 48 ++++++++++++++ drivers/mihw/include/mi_module.h | 46 +++++++++++++ drivers/mihw/mi_sched/Makefile | 2 + drivers/mihw/mi_sched/mi_sched.c | 56 ++++++++++++++++ drivers/mihw/millet/Makefile | 8 +++ drivers/mihw/millet/binder_gki.c | 29 +++++++++ drivers/mihw/millet/millet_binder.c | 31 +++++++++ drivers/mihw/millet/millet_core.c | 35 ++++++++++ drivers/mihw/millet/millet_hs.c | 22 +++++++ drivers/mihw/millet/millet_pkg.c | 37 +++++++++++ drivers/mihw/millet/millet_sig.c | 17 +++++ drivers/mihw/millet/oem_cgroup.c | 19 ++++++ drivers/mihw/turbo_sched/Makefile | 1 + drivers/mihw/turbo_sched/turbo_sched.c | 90 ++++++++++++++++++++++++++ 19 files changed, 589 insertions(+) create mode 100644 drivers/mihw/Kconfig create mode 100644 drivers/mihw/Makefile create mode 100644 drivers/mihw/game/Makefile create mode 100644 drivers/mihw/game/glk.c create mode 100644 drivers/mihw/game/migt_ca.c create mode 100644 drivers/mihw/game/migt_main.c create mode 100644 drivers/mihw/include/mi_module.h create mode 100755 drivers/mihw/mi_sched/Makefile create mode 100755 drivers/mihw/mi_sched/mi_sched.c create mode 100644 drivers/mihw/millet/Makefile create mode 100644 drivers/mihw/millet/binder_gki.c create mode 100644 drivers/mihw/millet/millet_binder.c create mode 100644 drivers/mihw/millet/millet_core.c create mode 100644 drivers/mihw/millet/millet_hs.c create mode 100644 drivers/mihw/millet/millet_pkg.c create mode 100644 drivers/mihw/millet/millet_sig.c create mode 100644 drivers/mihw/millet/oem_cgroup.c create mode 100644 drivers/mihw/turbo_sched/Makefile create mode 100644 drivers/mihw/turbo_sched/turbo_sched.c diff --git a/drivers/mihw/Kconfig b/drivers/mihw/Kconfig new file mode 100644 index 0000000000000..d21b3994fe153 --- /dev/null +++ b/drivers/mihw/Kconfig @@ -0,0 +1,67 @@ +config MILLET_CGROUP + tristate "frozen framework cgroup" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_SIG + tristate "frozen framework signal" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_BINDER + tristate "frozen framework binder" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_PKG + tristate "frozen framework pkg" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_BINDER_GKI + tristate "frozen framework binder gki" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_CORE + tristate "frozen framework core" + depends on MIHW + default n + help + Mi frozen function + +config MILLET_HS + tristate "frozen framework hs" + depends on MIHW + default n + help + Mi frozen function + +config MI_SCHED + tristate "schedule policy defined by xiaomi" + depends on MIHW && MI_SCHED_WALT + default n + help + This option can show package runtime info in sup/big/little core. + +config MIGT + tristate "mi game turbo" + depends on MI_SCHED && SCHED_WALT && MIGT_WALT + help + Improve game peformance and power. + +config TURBO_SCHED + tristate "mi turbo sched" + depends on MIHW && MI_SCHED + help + Tuning mi-scheduler policy diff --git a/drivers/mihw/Makefile b/drivers/mihw/Makefile new file mode 100644 index 0000000000000..45f9d2b808e60 --- /dev/null +++ b/drivers/mihw/Makefile @@ -0,0 +1,4 @@ +obj-y += millet/ +obj-y += mi_sched/ +obj-y += game/ +obj-y += turbo_sched/ diff --git a/drivers/mihw/game/Makefile b/drivers/mihw/game/Makefile new file mode 100644 index 0000000000000..cf4d0513721d7 --- /dev/null +++ b/drivers/mihw/game/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_MIGT) += migt.o +migt-$(CONFIG_MIGT) += migt_main.o +migt-$(CONFIG_MIGT) += migt_ca.o +migt-$(CONFIG_MIGT) += glk.o diff --git a/drivers/mihw/game/glk.c b/drivers/mihw/game/glk.c new file mode 100644 index 0000000000000..a5b6823e72d54 --- /dev/null +++ b/drivers/mihw/game/glk.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) Xiaomi Technologies Co., Ltd. 2019. All rights reserved. + * Copyright (C) 2021 XiaoMi, Inc. + * + * File name: glk.c + * Descrviption: Game load tracking + * Author: guchao1@xiaomi.com + * Version: 1.0 + * Date: 2019/12/03 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#define pr_fmt(fmt) "glk: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void set_next_freq(void *nouse, unsigned long util, unsigned long freq, unsigned long max, + unsigned long *next_freq, struct cpufreq_policy *policy, bool *need_freq_update) +{ + return; +} + +int game_load_init(void) +{ + register_trace_android_vh_map_util_freq(set_next_freq, NULL); + pr_err("game load init success\n"); + return 0; +} +EXPORT_SYMBOL_GPL(game_load_init); +//late_initcall(game_load_init); + diff --git a/drivers/mihw/game/migt_ca.c b/drivers/mihw/game/migt_ca.c new file mode 100644 index 0000000000000..f81b599e5c7af --- /dev/null +++ b/drivers/mihw/game/migt_ca.c @@ -0,0 +1,21 @@ + +#define pr_fmt(fmt) "migt-gtc: " fmt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + + + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("vip-task detected by David"); + diff --git a/drivers/mihw/game/migt_main.c b/drivers/mihw/game/migt_main.c new file mode 100644 index 0000000000000..d2faf6846299e --- /dev/null +++ b/drivers/mihw/game/migt_main.c @@ -0,0 +1,48 @@ +#define pr_fmt(fmt) "migt: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static unsigned int migt_debug; +module_param(migt_debug, uint, 0644); + + + +static int migt_init(void) +{ + return 0; +} + +static void __exit migt_exit() +{ + return; +} + +late_initcall(migt_init); +module_exit(migt_exit); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("migt-driver by David"); diff --git a/drivers/mihw/include/mi_module.h b/drivers/mihw/include/mi_module.h new file mode 100644 index 0000000000000..ab6609ea2436d --- /dev/null +++ b/drivers/mihw/include/mi_module.h @@ -0,0 +1,46 @@ +#ifndef MI_MODULE_H +#define MI_MODULE_H + +#include + +typedef void (*mi_walt_get_indicies)(struct task_struct *, int *, int *, int, bool *); +typedef void (*mi_find_energy_efficient_cpu) (struct task_struct *, bool *); + +typedef void (*update_task_load_hook)(struct task_struct *tsk, int cpu, int flag, + u64 wallclock, u64 delta); +typedef void (*mi_enqueue_task_fair) (struct rq *, struct task_struct *); +typedef void (*mi_dequeue_task_fair) (struct rq *, struct task_struct *); + +enum MI_SCHED_MOD{ + GT_TASK, + SCHED_TYPES, +}; + +struct sched_load_update_hooks { + update_task_load_hook f; +}; + +static inline void init_gt_task(struct mi_task_struct *tsk) +{ + int i; + struct gt_task *gt_tsk = &tsk->migt; + + gt_tsk->migt_count = 0; + gt_tsk->prev_sum = 0; + gt_tsk->max_exec = 0; + gt_tsk->fps_exec = 0; + gt_tsk->fps_mexec = 0; + gt_tsk->flag = MIGT_NORMAL_TASK; + gt_tsk->run_times = 0; + gt_tsk->wake_render = 0; + gt_tsk->boost_end = 0; + + for (i = 0; i < NUM_MIGT_BUCKETS; i++) { + gt_tsk->bucket[i] = 0; +#ifdef VTASK_BOOST_DEBUG + gt_tsk->boostat[i] = 0; +#endif + } +} + +#endif diff --git a/drivers/mihw/mi_sched/Makefile b/drivers/mihw/mi_sched/Makefile new file mode 100755 index 0000000000000..1362b583f3b60 --- /dev/null +++ b/drivers/mihw/mi_sched/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_MI_SCHED) += mi_schedule.o +mi_schedule-$(CONFIG_MI_SCHED) += mi_sched.o diff --git a/drivers/mihw/mi_sched/mi_sched.c b/drivers/mihw/mi_sched/mi_sched.c new file mode 100755 index 0000000000000..70de9bbadc3b0 --- /dev/null +++ b/drivers/mihw/mi_sched/mi_sched.c @@ -0,0 +1,56 @@ +#define pr_fmt(fmt) "mi-sched: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/mi_module.h" +#include "../../../kernel/sched/sched.h" + +static int mi_sched_debug = 0; + + +void mi_sched_tick(void *nouse, struct rq *rq)/*should run in timer interrupt*/ +{ + if (!mi_sched_debug) + return; + + printk("mi_sched_tick: %d", rq->nr_running); +} +EXPORT_SYMBOL(mi_sched_tick); + + +void free_mi_task_struct(void *nouse, struct task_struct *tsk) +{ + if (!mi_sched_debug) + return; + + printk("free mi_task_struct: %s,%d\n", tsk->comm, tsk->pid); +} +EXPORT_SYMBOL(free_mi_task_struct); + +static int __init mi_sched_init(void) +{ + register_trace_android_vh_free_task(free_mi_task_struct, NULL); + register_trace_android_vh_scheduler_tick(mi_sched_tick, NULL); + return 0; + +} + +static void __exit mi_sched_exit(void) +{ + printk(KERN_ERR "in %s\n", __func__); +} + +module_init(mi_sched_init); +module_exit(mi_sched_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("pkg runtime info calc by David"); diff --git a/drivers/mihw/millet/Makefile b/drivers/mihw/millet/Makefile new file mode 100644 index 0000000000000..d521d8d9788ff --- /dev/null +++ b/drivers/mihw/millet/Makefile @@ -0,0 +1,8 @@ +obj-$(CONFIG_MILLET_BINDER_GKI) += binder_gki.o +obj-$(CONFIG_MILLET_CORE) += millet_core.o +obj-$(CONFIG_MILLET_PKG) += millet_pkg.o +obj-$(CONFIG_MILLET_HS) += millet_hs.o +obj-$(CONFIG_MILLET_BINDER) += millet_binder.o +obj-$(CONFIG_MILLET_SIG) += millet_sig.o +obj-$(CONFIG_MILLET_CGROUP) += millet_oem_cgroup.o +millet_oem_cgroup-$(CONFIG_MILLET_CGROUP) += oem_cgroup.o diff --git a/drivers/mihw/millet/binder_gki.c b/drivers/mihw/millet/binder_gki.c new file mode 100644 index 0000000000000..9a9935b236f14 --- /dev/null +++ b/drivers/mihw/millet/binder_gki.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) Xiaomi Technologies Co., Ltd. 2020. All rights reserved. + * Copyright (C) 2021 XiaoMi, Inc. + * + * File name: oem_binder.c + * Description: millet-binder-driver + * Author: guchao1@xiaomi.com + * Version: 1.0 + * Date: 2020/9/9 + */ +#define pr_fmt(fmt) "millet-binder_gki: " fmt + +#include +#include +#include +#include +#include +#include + +static int __init init_binder_gki(void) +{ + pr_err("enter init_binder_gki func!\n"); + return 0; +} + +module_init(init_binder_gki); + +MODULE_LICENSE("GPL"); + diff --git a/drivers/mihw/millet/millet_binder.c b/drivers/mihw/millet/millet_binder.c new file mode 100644 index 0000000000000..bd00f3891ed19 --- /dev/null +++ b/drivers/mihw/millet/millet_binder.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) Xiaomi Technologies Co., Ltd. 2020. All rights reserved. + * Copyright (C) 2021 XiaoMi, Inc. + * + * File name: oem_binder.c + * Description: millet-binder-driver + * Author: guchao1@xiaomi.com + * Version: 1.0 + * Date: 2020/9/9 + */ +#define pr_fmt(fmt) "millet_millet-binder: " fmt + +#include +#include +#include +#include +#include +#include + +static int __init init_millet_binder_drv(void) +{ + + pr_err("enter init_millet_binder_drv func!\n"); + + return 0; +} + +module_init(init_millet_binder_drv); + +MODULE_LICENSE("GPL"); + diff --git a/drivers/mihw/millet/millet_core.c b/drivers/mihw/millet/millet_core.c new file mode 100644 index 0000000000000..d3d0b9de85e96 --- /dev/null +++ b/drivers/mihw/millet/millet_core.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) Xiaomi Technologies Co., Ltd. 2019. All rights reserved. + * Copyright (C) 2021 XiaoMi, Inc. + * + * File name: millet.c + * Description: smart frozen control + * Author: guchao1@xiaomi.com + * Version: 1.0 + * Date: 2019/11/27 + */ + +#define pr_fmt(fmt) "millet_millet-core: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static int __init millet_init(void) +{ + + pr_err("enter millet_init func!\n"); + + return 0; +} + +late_initcall(millet_init); + +MODULE_LICENSE("GPL"); diff --git a/drivers/mihw/millet/millet_hs.c b/drivers/mihw/millet/millet_hs.c new file mode 100644 index 0000000000000..98d57d1926c2c --- /dev/null +++ b/drivers/mihw/millet/millet_hs.c @@ -0,0 +1,22 @@ +#define pr_fmt(fmt) "millet-millet_hs: " fmt + +#include +#include +#include + +static int __init millet_hs_init(void) +{ + + pr_err("enter millet_hs_init func!\n"); + return 0; +} + +static void __exit millet_hs_exit(void) +{ + return; +} + +module_init(millet_hs_init); +module_exit(millet_hs_exit); + +MODULE_LICENSE("GPL"); diff --git a/drivers/mihw/millet/millet_pkg.c b/drivers/mihw/millet/millet_pkg.c new file mode 100644 index 0000000000000..50bd9ffa71777 --- /dev/null +++ b/drivers/mihw/millet/millet_pkg.c @@ -0,0 +1,37 @@ +#define pr_fmt(fmt) "millet-millet_pkg: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int __init millet_pkg_init(void) +{ + pr_err("enter millet_pkg_init\n"); + return 0; +} + +static void __exit millet_pkg_exit(void) +{ + return; +} + + +module_init(millet_pkg_init); +module_exit(millet_pkg_exit); + +MODULE_LICENSE("GPL"); diff --git a/drivers/mihw/millet/millet_sig.c b/drivers/mihw/millet/millet_sig.c new file mode 100644 index 0000000000000..3de7c2577ecd9 --- /dev/null +++ b/drivers/mihw/millet/millet_sig.c @@ -0,0 +1,17 @@ +#define pr_fmt(fmt) "millet_millet-sig: " fmt + +#include +#include +#include +#include + +static int __init sig_mod_init(void) +{ + pr_err("enter sig_mod_init func!\n"); + + return 0; +} + +module_init(sig_mod_init); +MODULE_LICENSE("GPL"); + diff --git a/drivers/mihw/millet/oem_cgroup.c b/drivers/mihw/millet/oem_cgroup.c new file mode 100644 index 0000000000000..2cf08de3e4098 --- /dev/null +++ b/drivers/mihw/millet/oem_cgroup.c @@ -0,0 +1,19 @@ +#define pr_fmt(fmt) "millet-oem_cgroup: " fmt + +#include +#include +#include +#include +#include +#include <../../kernel/cgroup/cgroup-internal.h> + +static __init int oem_cgrp_init(void) +{ + pr_err("enter oem_cgrp_init func!\n"); + return 0; +} + +module_init(oem_cgrp_init); + +MODULE_LICENSE("GPL"); + diff --git a/drivers/mihw/turbo_sched/Makefile b/drivers/mihw/turbo_sched/Makefile new file mode 100644 index 0000000000000..ce5bd24449a9d --- /dev/null +++ b/drivers/mihw/turbo_sched/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_TURBO_SCHED) += turbo_sched.o diff --git a/drivers/mihw/turbo_sched/turbo_sched.c b/drivers/mihw/turbo_sched/turbo_sched.c new file mode 100644 index 0000000000000..7ab8128e15fd3 --- /dev/null +++ b/drivers/mihw/turbo_sched/turbo_sched.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) Xiaomi Technologies Co., Ltd. 2021. All rights reserved. + * Copyright (C) 2021 XiaoMi, Inc. + * + * File name: turbo_sched.c + * Descrviption: turbo sched + * Author: guchao1@xiaomi.com + * Version: 3.0 + * Date: 2021/05/01 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#define pr_fmt(fmt) "turbo-sched: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/mi_module.h" + +unsigned int tsched_debug; +module_param(tsched_debug, uint, 0644); + +void mi_cpuset_fork(void *nouse, struct task_struct *tsk, int *forbidden) +{ + if (!tsched_debug) + return; + + pr_info ("forbidden : %d", forbidden); +} + +void mi_sched_setaffinity(void *nouse, struct task_struct *p, + const struct cpumask * in_mask, int *skip) +{ + if (!tsched_debug) + return; + + printk("debug_setaffinity: current : %s %d %d, setaffinity target : %s %d %d\n", + current->comm, task_uid(current).val ,current->pid, + p->comm, task_uid(p).val ,p->pid); + printk("debug_setaffinity: cpumask is : %d \n", *in_mask); +} + +void mi_set_cpus_allowed_comm(void *nouse, struct task_struct *p, + const struct cpumask * in_mask) +{ + if (!tsched_debug) + return; + + pr_info ("p->pid : %d", p->pid); +} + +static int __init turbo_sched_init(void) +{ + register_trace_android_rvh_cpuset_fork(mi_cpuset_fork, NULL); + register_trace_android_vh_sched_setaffinity_early(mi_sched_setaffinity, NULL); + register_trace_android_rvh_set_cpus_allowed_comm(mi_set_cpus_allowed_comm, NULL); + + return 0; +} + +static void __exit turbo_sched_exit(void) +{ + return; +} + +module_init(turbo_sched_init); +module_exit(turbo_sched_exit); +MODULE_LICENSE("GPL"); From 2c83056836f836801bebd682bbbe1943e266c697 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sun, 30 Apr 2023 21:41:36 +0530 Subject: [PATCH 08/11] missing file fix --- include/trace/hooks/thermal.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 include/trace/hooks/thermal.h diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h new file mode 100644 index 0000000000000..944454ca0e481 --- /dev/null +++ b/include/trace/hooks/thermal.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM thermal + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_THERMAL_H + +#include +#include + +DECLARE_HOOK(android_vh_enable_thermal_genl_check, + TP_PROTO(int event, int tz_id, int *enable_thermal_genl), + TP_ARGS(event, tz_id, enable_thermal_genl)); + +struct thermal_zone_device; +DECLARE_HOOK(android_vh_thermal_pm_notify_suspend, + TP_PROTO(struct thermal_zone_device *tz, int *irq_wakeable), + TP_ARGS(tz, irq_wakeable)); + +#endif /* _TRACE_HOOK_THERMAL_H */ +/* This part must be outside protection */ +#include + From 4d3e4e9acb3f55d7bcc5e460b6a33d08407a98d2 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sun, 30 Apr 2023 21:42:32 +0530 Subject: [PATCH 09/11] fixing: undiclared functions/extra --- kernel/sched/walt/walt.c | 75 ++++++++++++++----------------------- kernel/sched/walt/walt_rt.c | 8 ---- 2 files changed, 29 insertions(+), 54 deletions(-) diff --git a/kernel/sched/walt/walt.c b/kernel/sched/walt/walt.c index 34ca01aad7cad..2e59b9722435c 100644 --- a/kernel/sched/walt/walt.c +++ b/kernel/sched/walt/walt.c @@ -31,12 +31,6 @@ #include "../../../drivers/mihw/include/mi_module.h" #endif -#ifdef CONFIG_MI_SCHED_WALT -extern void update_pkg_load(struct task_struct *tsk, int cpu, int flag, - u64 wallclock, u64 delta); -extern bool pkg_enable(void); -extern void mi_task_fork(void *nouse, struct task_struct *tsk); -#endif #ifdef CONFIG_MIGT_WALT mi_enqueue_task_fair mi_enqueue_task_fair_func = NULL; @@ -421,8 +415,9 @@ update_window_start(struct rq *rq, u64 wallclock, int event) delta = wallclock - wrq->window_start; if (delta < 0) { - printk_deferred("WALT-BUG CPU%d; wallclock=%llu is lesser than window_start=%llu", - rq->cpu, wallclock, wrq->window_start); + printk_deferred("WALT-BUG CPU%d; wallclock=%llu(0x%llx) is lesser than window_start=%llu(0x%llx)", + rq->cpu, wallclock, wallclock, + wrq->window_start, wrq->window_start); WALT_PANIC(1); } if (delta < sched_ravg_window) @@ -2231,9 +2226,9 @@ update_task_rq_cpu_cycles(struct task_struct *p, struct rq *rq, int event, time_delta = wallclock - wts->mark_start; if ((s64)time_delta < 0) { - printk_deferred("WALT-BUG pid=%u CPU%d wallclock=%llu < mark_start=%llu event=%d irqtime=%llu", - p->pid, rq->cpu, wallclock, - wts->mark_start, event, irqtime); + printk_deferred("WALT-BUG pid=%u CPU%d wallclock=%llu(0x%llx) < mark_start=%llu(0x%llx) event=%d irqtime=%llu", + p->pid, rq->cpu, wallclock, wallclock, + wts->mark_start, wts->mark_start, event, irqtime); WALT_PANIC((s64)time_delta < 0); } @@ -2297,23 +2292,6 @@ static void walt_update_task_ravg(struct task_struct *p, struct rq *rq, int even if (event == PUT_PREV_TASK && p->state) wts->iowaited = p->in_iowait; -#ifdef CONFIG_MI_SCHED_WALT - if (pkg_enable()) { - int fstat = 0; - u64 delta = 0; - int pkg_task_busy = account_pkg_busy_time(rq, p, event); - if (pkg_task_busy) { - fstat |= PKG_TASK_BUSY; - if (is_idle_task(p)) - delta = irqtime; - else - delta = wallclock - wts->mark_start; - delta = scale_exec_time(delta, rq); - update_pkg_load(p, rq->cpu, fstat, wallclock, delta); - } - } -#endif - trace_sched_update_task_ravg(p, rq, event, wallclock, irqtime, &wrq->grp_time, wrq, wts); trace_sched_update_task_ravg_mini(p, rq, event, wallclock, irqtime, @@ -2324,11 +2302,8 @@ static void walt_update_task_ravg(struct task_struct *p, struct rq *rq, int even run_walt_irq_work(old_window_start, rq); } -#ifdef CONFIG_MIGT_3_0_WALT -EXPORT_SYMBOL_GPL(walt_update_task_ravg); -#endif -static void __sched_fork_init(struct task_struct *p) +static inline void __sched_fork_init(struct task_struct *p) { struct walt_task_struct *wts = (struct walt_task_struct *) p->android_vendor_data1; @@ -3885,31 +3860,37 @@ static void walt_cpu_frequency_limits(void *unused, struct cpufreq_policy *polic */ static void android_rvh_update_cpu_capacity(void *unused, int cpu, unsigned long *capacity) { - unsigned long max_capacity = arch_scale_cpu_capacity(cpu); + unsigned long fmax_capacity = arch_scale_cpu_capacity(cpu); unsigned long thermal_pressure = arch_scale_thermal_pressure(cpu); - unsigned long thermal_cap; + unsigned long thermal_cap, old; + unsigned long rt_pressure = fmax_capacity - *capacity; struct walt_sched_cluster *cluster; - unsigned long rt_pressure = max_capacity - *capacity; + struct rq *rq = cpu_rq(cpu); if (unlikely(walt_disabled)) return; /* - * thermal_pressure = max_capacity - curr_cap_as_per_thermal. + * thermal_pressure = cpu_scale - curr_cap_as_per_thermal. * so, - * curr_cap_as_per_thermal = max_capacity - thermal_pressure. + * curr_cap_as_per_thermal = cpu_scale - thermal_pressure. */ - thermal_cap = max_capacity - thermal_pressure; + thermal_cap = fmax_capacity - thermal_pressure; cluster = cpu_cluster(cpu); - /* reduce the max_capacity under cpufreq constraints */ + /* reduce the fmax_capacity under cpufreq constraints */ if (cluster->max_freq != cluster->max_possible_freq) - max_capacity = mult_frac(max_capacity, cluster->max_freq, + fmax_capacity = mult_frac(fmax_capacity, cluster->max_freq, cluster->max_possible_freq); - cpu_rq(cpu)->cpu_capacity_orig = min(max_capacity, thermal_cap); - *capacity = cpu_rq(cpu)->cpu_capacity_orig - rt_pressure; + old = rq->cpu_capacity_orig; + rq->cpu_capacity_orig = min(fmax_capacity, thermal_cap); + + if (old != rq->cpu_capacity_orig) + trace_update_cpu_capacity(cpu, rt_pressure, *capacity); + + *capacity = max(rq->cpu_capacity_orig - rt_pressure, 1UL); } static void android_rvh_sched_cpu_starting(void *unused, int cpu) @@ -4265,9 +4246,6 @@ static void android_rvh_sched_fork_init(void *unused, struct task_struct *p) if (unlikely(walt_disabled)) return; -#ifdef CONFIG_MI_SCHED_WALT - mi_task_fork(NULL, p); -#endif __sched_fork_init(p); } @@ -4365,10 +4343,15 @@ static int walt_init_stop_handler(void *data) struct task_struct *g, *p; u64 window_start_ns, nr_windows; struct walt_rq *wrq; + int level = 0; read_lock(&tasklist_lock); for_each_possible_cpu(cpu) { - raw_spin_lock(&cpu_rq(cpu)->lock); + if (level == 0) + raw_spin_lock(&cpu_rq(cpu)->lock); + else + raw_spin_lock_nested(&cpu_rq(cpu)->lock, level); + level++; } do_each_thread(g, p) { diff --git a/kernel/sched/walt/walt_rt.c b/kernel/sched/walt/walt_rt.c index cf247c230741f..936f95a7d3ea6 100644 --- a/kernel/sched/walt/walt_rt.c +++ b/kernel/sched/walt/walt_rt.c @@ -140,11 +140,6 @@ static inline bool walt_should_honor_rt_sync(struct rq *rq, struct task_struct * rq->rt.rt_nr_running <= 2; } -#ifdef CONFIG_TURBO_WALT -extern void mi_select_task_rq_fair(struct task_struct *p, int prev_cpu, - int sd_flag, int wake_flags, int *target_cpu); -#endif - static void walt_select_task_rq_rt(void *unused, struct task_struct *task, int cpu, int sd_flag, int wake_flags, int *new_cpu) { @@ -155,9 +150,6 @@ static void walt_select_task_rq_rt(void *unused, struct task_struct *task, int c int ret, target = -1, this_cpu; struct cpumask *lowest_mask; -#ifdef CONFIG_TURBO_WALT - mi_select_task_rq_fair(task, cpu, sd_flag, wake_flags, new_cpu); -#endif if (unlikely(walt_disabled)) return; From c32458dcc852b26c421d307c6d4e3d04ed6a9855 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sun, 30 Apr 2023 21:43:33 +0530 Subject: [PATCH 10/11] fixing: undiclared functions/extra --- drivers/power/supply/qti_battery_charger.c | 55 +++++++++++++++++++++- drivers/soc/qcom/minidump_log.c | 5 -- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/qti_battery_charger.c b/drivers/power/supply/qti_battery_charger.c index fbbb6b75adad4..8dbddb2419884 100644 --- a/drivers/power/supply/qti_battery_charger.c +++ b/drivers/power/supply/qti_battery_charger.c @@ -265,6 +265,30 @@ enum xm_property_id { XM_PROP_FG1_TFULLQ, XM_PROP_FG1_RSOC, XM_PROP_FG1_AI, + XM_PROP_SLAVE_CHIP_OK, + XM_PROP_SLAVE_AUTHENTIC, + XM_PROP_FG1_VOL, + XM_PROP_FG1_SOC, + XM_PROP_FG1_TEMP, + XM_PROP_FG1_IBATT, + XM_PROP_FG2_VOL, + XM_PROP_FG2_SOC, + XM_PROP_FG2_TEMP, + XM_PROP_FG2_IBATT, + XM_PROP_FG2_QMAX, + XM_PROP_FG2_RM, + XM_PROP_FG2_FCC, + XM_PROP_FG2_SOH, + XM_PROP_FG2_FCC_SOH, + XM_PROP_FG2_CYCLE, + XM_PROP_FG2_FAST_CHARGE, + XM_PROP_FG2_CURRENT_MAX, + XM_PROP_FG2_VOL_MAX, + XM_PROP_FG2_TSIM, + XM_PROP_FG2_TAMBIENT, + XM_PROP_FG2_TREMQ, + XM_PROP_FG2_TFULLQ, + XM_PROP_FG_VENDOR_ID, XM_PROP_FG1_CELL1_VOL, XM_PROP_FG1_CELL2_VOL, XM_PROP_MAX, @@ -379,6 +403,8 @@ struct xm_verify_digest_resp_msg { struct pmic_glink_hdr hdr; u32 property_id; u8 digest[BATTERY_DIGEST_LEN]; + /*dual battery master and slave flag*/ + bool slave_fg; }; struct battery_charger_shutdown_req_msg { @@ -452,6 +478,8 @@ struct battery_chg_dev { bool shutdown_delay_en; bool support_2s_charging; bool report_power_absent; + /*dual battery authentic flag*/ + bool slave_fg_verify_flag; /*battery auth check for ssr*/ bool battery_auth; @@ -709,12 +737,37 @@ static int read_verify_digest_property_id(struct battery_chg_dev *bcdev, req_msg.hdr.owner = MSG_OWNER_BC; req_msg.hdr.type = MSG_TYPE_REQ_RESP; req_msg.hdr.opcode = pst->opcode_get; - pr_debug("psy: %s prop_id: %u\n", pst->psy->desc->name, req_msg.property_id); return battery_chg_write(bcdev, &req_msg, sizeof(req_msg)); } +static ssize_t verify_slave_flag_store(struct class *c, + struct class_attribute *attr, + const char *buf, size_t count) +{ + struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, + battery_class); + bool val; + + if (kstrtobool(buf, &val)) + return -EINVAL; + + bcdev->slave_fg_verify_flag = val; + pr_err("verify_digest_flag :%d \n", val); + + return count; +} + +static ssize_t verify_slave_flag_show(struct class *c, + struct class_attribute *attr, char *buf) +{ + struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, + battery_class); + + return scnprintf(buf, PAGE_SIZE, "%u\n", bcdev->slave_fg_verify_flag); +} +static CLASS_ATTR_RW(verify_slave_flag); #if defined(CONFIG_MI_WIRELESS) static int write_wls_bin_prop_id(struct battery_chg_dev *bcdev, struct psy_state *pst, diff --git a/drivers/soc/qcom/minidump_log.c b/drivers/soc/qcom/minidump_log.c index de6d0e9782152..7555530eec901 100644 --- a/drivers/soc/qcom/minidump_log.c +++ b/drivers/soc/qcom/minidump_log.c @@ -682,11 +682,6 @@ static void md_dump_task_info(struct task_struct *task, char *status, seq_buf_printf(md_runq_seq_buf, " prio: %d aff: %*pb", task->prio, cpumask_pr_args(&task->cpus_mask)); -#ifdef CONFIG_SCHED_WALT - seq_buf_printf(md_runq_seq_buf, " enq: %lu wake: %lu sleep: %lu", - task->wts.last_enqueued_ts, task->wts.last_wake_ts, - task->wts.last_sleep_ts); -#endif seq_buf_printf(md_runq_seq_buf, " vrun: %lu arr: %lu sum_ex: %lu\n", (unsigned long)se->vruntime, From 451722e2b422ccb192af7a32d9e0a8f208b369e0 Mon Sep 17 00:00:00 2001 From: IamCOD3X Date: Sun, 30 Apr 2023 21:43:53 +0530 Subject: [PATCH 11/11] NUKE warnings --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 213b6b9b549c4..7ccc5e1e32c41 100644 --- a/Makefile +++ b/Makefile @@ -512,6 +512,8 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wno-format-security \ -std=gnu89 +KBUILD_CFLAGS += $(call cc-disable-warning, implicit-function-declaration) +KBUILD_CFLAGS += $(call cc-disable-warning, inline-asm) KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL :=