thunderbolt: Change downstream router's TMU rate in both TMU uni/bidir mode
Subsystems (25)
Sasha Levin
maintainerPATCH 1/64 thunderbolt: Change downstream router's TMU rate in both TMU uni/bidir mode
From: Gil Fine <[email protected]>
[ Upstream commit 5fd6b9a5cbe63fea4c490fee8af34144a139a266 ]
In case of uni-directional time sync, TMU handshake is initiated by upstream router. In case of bi-directional time sync, TMU handshake is initiated by downstream router. In order to handle correctly the case of uni-directional mode, we avoid changing the upstream router's rate to off, because it might have another downstream router plugged that is set to uni-directional mode (and we don't want to change its mode). Instead, we always change downstream router's rate.
--- drivers/thunderbolt/tmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/thunderbolt/tmu.c +7 -6
@@ -359,13 +359,14 @@ int tb_switch_tmu_disable(struct tb_switch *sw)* In case of uni-directional time sync, TMU handshake is * initiated by upstream router. In case of bi-directional * time sync, TMU handshake is initiated by downstream router. -* Therefore, we change the rate to off in the respective -* router. +* We change downstream router's rate to off for both uni/bidir +* cases although it is needed only for the bi-directional mode. +* We avoid changing upstream router's mode since it might +* have another downstream router plugged, that is set to +* uni-directional mode and we don't want to change it's TMU +* mode. */ -if (unidirectional) -tb_switch_tmu_rate_write (parent,TB_SWITCH_TMU_RATE_OFF ); -else -tb_switch_tmu_rate_write (sw,TB_SWITCH_TMU_RATE_OFF ); +tb_switch_tmu_rate_write (sw,TB_SWITCH_TMU_RATE_OFF );tb_port_tmu_time_sync_disable (up); ret =tb_port_tmu_time_sync_disable (down);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 2/64 HID: multitouch: new device class fix Lenovo X12 trackpad sticky
From: Tao Jin <[email protected]>
[ Upstream commit 54eed5c7b938dc4ef6b14d4ee048bbdafdbce352 ]
The trackpad of the given device sends continuous report of pointers status as per wxn8 spec. However, the spec did not clarify when the fingers are lifted so fast that between the interval of two report frames fingers on pad reduced from >=2 to 0. The second last report contains >=2 fingers with tip state 1 and the last report contains only 1 finger with tip state 0. Although this can happen unfrequently, a
quick fix will be improve the consistency to 100%. A quick fix is to
disable MT_QUIRK_ALWAYS_VALID and enable MT_QUIRK_NOT_SEEN_MEANS_UP.
Test for hid-tools is added in [1]
In addition to this, I2C device 04CA:00B1 may also need similar class but with MT_QUIRK_FORCE_MULTI_INPUT disabled (but it does not harm to
enable it on non-multi-input device either). The respective owner has
been notified and a patch may coming soon after test.
[1]: https://gitlab.freedesktop.org/libevdev/hid-tools/-/merge_requests/130
--- drivers/hid/hid-multitouch.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/hid/hid-multitouch.c +12 -1
@@ -194,6 +194,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);#define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015#define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016#define MT_CLS_WIN_8_NO_STICKY_FINGERS 0x0017 +#define MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU 0x0018/* vendor specific classes */ #define MT_CLS_3M 0x0101
@@ -286,6 +287,15 @@ static const struct mt_class mt_classes[] = {MT_QUIRK_WIN8_PTP_BUTTONS | MT_QUIRK_FORCE_MULTI_INPUT, .export_all_inputs = true }, + { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, + .quirks =MT_QUIRK_IGNORE_DUPLICATES | +MT_QUIRK_HOVERING | +MT_QUIRK_CONTACT_CNT_ACCURATE | +MT_QUIRK_STICKY_FINGERS | +MT_QUIRK_WIN8_PTP_BUTTONS | +MT_QUIRK_FORCE_MULTI_INPUT | + MT_QUIRK_NOT_SEEN_MEANS_UP, + .export_all_inputs = true }, { .name = MT_CLS_WIN_8_DISABLE_WAKEUP, .quirks =MT_QUIRK_ALWAYS_VALID | MT_QUIRK_IGNORE_DUPLICATES |
@@ -783,6 +793,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,case HID_DG_CONFIDENCE :if ((cls->name ==MT_CLS_WIN_8 || cls->name ==MT_CLS_WIN_8_FORCE_MULTI_INPUT || + cls->name ==MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU || cls->name ==MT_CLS_WIN_8_DISABLE_WAKEUP ) && (field->application ==HID_DG_TOUCHPAD || field->application ==HID_DG_TOUCHSCREEN ))
@@ -2035,7 +2046,7 @@ static const struct hid_device_id mt_devices[] = { USB_DEVICE_ID_LENOVO_X1_TAB3) },/* Lenovo X12 TAB Gen 1 */ - { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT, + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU,HID_DEVICE (BUS_USB ,HID_GROUP_MULTITOUCH_WIN_8 ,USB_VENDOR_ID_LENOVO , USB_DEVICE_ID_LENOVO_X12_TAB) },
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 3/64 PCI: Add ACS quirk for Broadcom BCM5750x NICs
In reply to Sasha LevinFrom: Pavan Chebbi <[email protected]>
[ Upstream commit afd306a65cedb9589564bdb23a0c368abc4215fd ]
The Broadcom BCM5750x NICs may be multi-function devices. They do not advertise ACS capability. Peer-to-peer transactions are not possible between the individual functions, so it is safe to treat them as fully isolated.
Add an ACS quirk for these devices so the functions can be in independent IOMMU groups and attached individually to userspace applications using VFIO.
--- drivers/pci/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/quirks.c +3 -0
@@ -4924,6 +4924,9 @@ static const struct pci_dev_acs_enabled { { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs },/* Broadcom multi-function device */ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1750, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1751, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0x1752, pci_quirk_mf_endpoint_acs }, { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },/* Amazon Annapurna Labs */ { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 4/64 platform/chrome: cros_ec_proto: don't show MKBP version if unsupported
In reply to Sasha LevinFrom: Tzung-Bi Shih <[email protected]>
[ Upstream commit b36f0643ff14a2fb281b105418e4e73c9d7c11d0 ]
It wrongly showed the following message when it doesn't support MKBP:
"MKBP support version 4294967295".
Fix it.
--- drivers/platform/chrome/cros_ec_proto.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_proto.c +4 -4
@@ -509,13 +509,13 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) ret =cros_ec_get_host_command_version_mask (ec_dev,EC_CMD_GET_NEXT_EVENT , &ver_mask); -if (ret <0 || ver_mask ==0 ) +if (ret <0 || ver_mask ==0 ) { ec_dev->mkbp_event_supported =0 ; -else + }else { ec_dev->mkbp_event_supported =fls (ver_mask); -dev_dbg (ec_dev->dev,"MKBP support version %u\n" , - ec_dev->mkbp_event_supported -1 ); +dev_dbg (ec_dev->dev,"MKBP support version %u\n" , ec_dev->mkbp_event_supported -1 ); + }/* Probe if host sleep v1 is supported for S0ix failure detection. */ ret = cros_ec_get_host_command_version_mask(ec_dev,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 5/64 staging: r8188eu: add error handling of rtw_read8
In reply to Sasha LevinFrom: Pavel Skripkin <[email protected]>
[ Upstream commit 857fe9e5efc09833fe1110e99d8baba954a86abb ]
rtw_read8() reads data from device via USB API which may fail. In case of any failure previous code returned stack data to callers, which is wrong.
Fix it by changing rtw_read8() prototype and prevent caller from touching random stack data
--- drivers/staging/r8188eu/core/rtw_efuse.c | 13 +- drivers/staging/r8188eu/core/rtw_fw.c | 56 ++++-- drivers/staging/r8188eu/core/rtw_led.c | 16 +- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 48 ++++- drivers/staging/r8188eu/core/rtw_wlan_util.c | 20 +- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 18 +- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 9 +- drivers/staging/r8188eu/hal/hal_com.c | 27 ++- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 37 +++- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 6 +- .../staging/r8188eu/hal/rtl8188e_hal_init.c | 69 +++++-- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 10 +- drivers/staging/r8188eu/hal/usb_halinit.c | 171 +++++++++++++++--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 7 +- drivers/staging/r8188eu/include/rtw_io.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 11 +- 16 files changed, 418 insertions(+), 102 deletions(-)
drivers/staging/r8188eu/core/rtw_efuse.c +11 -2
@@ -28,14 +28,21 @@ ReadEFuseByte(u32 value32;u8 readbyte;u16 retry; +int res;/* Write Address */ rtw_write8 (Adapter,EFUSE_CTRL +1 , (_offset &0xff )); - readbyte =rtw_read8 (Adapter,EFUSE_CTRL +2 ); + res =rtw_read8 (Adapter,EFUSE_CTRL +2 , &readbyte); +if (res) +return ; +rtw_write8 (Adapter,EFUSE_CTRL +2 , ((_offset >>8 ) &0x03 ) | (readbyte &0xfc ));/* Write bit 32 0 */ - readbyte =rtw_read8 (Adapter,EFUSE_CTRL +3 ); + res =rtw_read8 (Adapter,EFUSE_CTRL +3 , &readbyte); +if (res) +return ; +rtw_write8 (Adapter,EFUSE_CTRL +3 , (readbyte &0x7f ));/* Check bit 32 read-ready */
@@ -54,6 +61,8 @@ ReadEFuseByte( value32 =rtw_read32 (Adapter,EFUSE_CTRL ); *pbuf = (u8)(value32 &0xff ); + +/* FIXME: return an error to caller */ }/*-----------------------------------------------------------------------------
drivers/staging/r8188eu/core/rtw_fw.c +43 -13
107 lines not on this page · raw message
drivers/staging/r8188eu/core/rtw_led.c +13 -3
@@ -35,11 +35,15 @@ static void ResetLedStatus(struct LED_871x *pLed)static void SwLedOn (struct adapter *padapter,struct LED_871x *pLed) {u8 LedCfg; +int res;if (padapter->bSurpriseRemoved || padapter->bDriverStopped)return ; - LedCfg =rtw_read8 (padapter,REG_LEDCFG2 ); + res =rtw_read8 (padapter,REG_LEDCFG2 , &LedCfg); +if (res) +return ; +rtw_write8 (padapter,REG_LEDCFG2 , (LedCfg &0xf0 ) |BIT (5 ) |BIT (6 ));/* SW control led0 on. */ pLed->bLedOn = true; }
@@ -47,15 +51,21 @@ static void SwLedOn(struct adapter *padapter, struct LED_871x *pLed)static void SwLedOff (struct adapter *padapter,struct LED_871x *pLed) {u8 LedCfg; +int res;if (padapter->bSurpriseRemoved || padapter->bDriverStopped) goto exit; - LedCfg =rtw_read8 (padapter,REG_LEDCFG2 );/* 0x4E */ + res =rtw_read8 (padapter,REG_LEDCFG2 , &LedCfg);/* 0x4E */ +if (res) + goto exit; LedCfg &=0x90 ;/* Set to software control. */ rtw_write8 (padapter,REG_LEDCFG2 , (LedCfg |BIT (3 ))); - LedCfg =rtw_read8 (padapter,REG_MAC_PINMUX_CFG ); + res =rtw_read8 (padapter,REG_MAC_PINMUX_CFG , &LedCfg); +if (res) + goto exit; + LedCfg &=0xFE ;rtw_write8 (padapter,REG_MAC_PINMUX_CFG , LedCfg); exit:
drivers/staging/r8188eu/core/rtw_mlme_ext.c +40 -8
108 lines not on this page · raw message
drivers/staging/r8188eu/core/rtw_wlan_util.c +17 -3
@@ -279,8 +279,13 @@ void Restore_DM_Func_Flag(struct adapter *padapter)void Set_MSR (struct adapter *padapter,u8 type) {u8 val8; +int res; - val8 =rtw_read8 (padapter,MSR ) &0x0c ; + res =rtw_read8 (padapter,MSR , &val8); +if (res) +return ; + + val8 &=0x0c ; val8 |= type;rtw_write8 (padapter,MSR , val8); }
@@ -505,7 +510,11 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)static void set_acm_ctrl (struct adapter *adapter,u8 acm_mask) { -u8 acmctrl =rtw_read8 (adapter,REG_ACMHWCTRL ); +u8 acmctrl; +int res =rtw_read8 (adapter,REG_ACMHWCTRL , &acmctrl); + +if (res) +return ;if (acm_mask >1 ) acmctrl = acmctrl |0x1 ;
@@ -765,6 +774,7 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)static void set_min_ampdu_spacing (struct adapter *adapter,u8 spacing) {u8 sec_spacing; +int res;if (spacing <=7 ) {switch (adapter->securitypriv.dot11PrivacyAlgrthm) {
@@ -786,8 +796,12 @@ static void set_min_ampdu_spacing(struct adapter *adapter, u8 spacing)if (spacing < sec_spacing) spacing = sec_spacing; + res =rtw_read8 (adapter,REG_AMPDU_MIN_SPACE , &sec_spacing); +if (res) +return ; +rtw_write8 (adapter,REG_AMPDU_MIN_SPACE , - (rtw_read8 (adapter,REG_AMPDU_MIN_SPACE ) &0xf8 ) | spacing); + (sec_spacing &0xf8 ) | spacing); } }
drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +15 -3
@@ -463,6 +463,7 @@ void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup } } +/* FIXME: return an error to caller */ static void _PHY_SaveMACRegisters( struct adapter *adapt, u32 *MACReg,
@@ -470,9 +471,17 @@ static void _PHY_SaveMACRegisters( ) {u32 i; +int res; -for (i =0 ; i < (IQK_MAC_REG_NUM -1 ); i++) - MACBackup[i] =rtw_read8 (adapt, MACReg[i]); +for (i =0 ; i < (IQK_MAC_REG_NUM -1 ); i++) { +u8 reg; + + res =rtw_read8 (adapt, MACReg[i], ®); +if (res) +return ; + + MACBackup[i] = reg; + } MACBackup[i] =rtw_read32 (adapt, MACReg[i]); }
@@ -739,9 +748,12 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt) {u8 tmpreg;u32 RF_Amode =0 , LC_Cal; +int res;/* Check continuous TX and Packet TX */ - tmpreg =rtw_read8 (adapt,0xd03 ); + res =rtw_read8 (adapt,0xd03 , &tmpreg); +if (res) +return ;if ((tmpreg &0x70 ) !=0 )/* Deal with contisuous TX case */ rtw_write8 (adapt,0xd03 , tmpreg &0x8F );/* disable all continuous TX */
drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +7 -2
@@ -12,6 +12,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[])u32 offset =0 ;u32 poll_count =0 ;/* polling autoload done. */ u32 max_poll_count =5000 ; +int res; do { pwrcfgcmd = pwrseqcmd[aryidx];
@@ -21,7 +22,9 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[]) offset =GET_PWR_CFG_OFFSET (pwrcfgcmd);/* Read the value from system register */ - value =rtw_read8 (padapter, offset); + res =rtw_read8 (padapter, offset, &value); +if (res) +return false; value &= ~(GET_PWR_CFG_MASK (pwrcfgcmd)); value |= (GET_PWR_CFG_VALUE (pwrcfgcmd) &GET_PWR_CFG_MASK (pwrcfgcmd));
@@ -33,7 +36,9 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[]) poll_bit = false; offset =GET_PWR_CFG_OFFSET (pwrcfgcmd); do { - value = rtw_read8(padapter, offset); + res = rtw_read8(padapter, offset, &value); + if (res) + return false; value &= GET_PWR_CFG_MASK(pwrcfgcmd); if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)))
drivers/staging/r8188eu/hal/hal_com.c +21 -6
@@ -303,7 +303,9 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf)if (!buf) goto exit; - trigger =rtw_read8 (adapter,REG_C2HEVT_CLEAR ); + ret =rtw_read8 (adapter,REG_C2HEVT_CLEAR , &trigger); +if (ret) +return _FAIL;if (trigger ==C2H_EVT_HOST_CLOSE ) goto exit;/* Not ready */
@@ -314,13 +316,26 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf)memset (c2h_evt,0 ,16 ); - *buf =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL ); - *(buf +1 ) =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL +1 ); + ret =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL , buf); +if (ret) { + ret = _FAIL; + goto clear_evt; + } + ret =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL +1 , buf +1 ); +if (ret) { + ret = _FAIL; + goto clear_evt; + }/* Read the content */ -for (i =0 ; i < c2h_evt->plen; i++) - c2h_evt->payload[i] =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL + -sizeof (*c2h_evt) + i); +for (i =0 ; i < c2h_evt->plen; i++) { + ret =rtw_read8 (adapter,REG_C2HEVT_MSG_NORMAL + +sizeof (*c2h_evt) + i, c2h_evt->payload + i); +if (ret) { + ret = _FAIL; + goto clear_evt; + } + } ret = _SUCCESS;
drivers/staging/r8188eu/hal/rtl8188e_cmd.c +31 -6
@@ -18,13 +18,18 @@static u8 _is_fw_read_cmd_down (struct adapter *adapt,u8 msgbox_num) { -u8 read_down = false; +u8 read_down = false, reg;int retry_cnts =100 ; +int res;u8 valid;do { - valid =rtw_read8 (adapt,REG_HMETFR ) &BIT (msgbox_num); + res =rtw_read8 (adapt,REG_HMETFR , ®); +if (res) +continue ; + + valid = reg &BIT (msgbox_num);if (0 == valid) read_down = true; }while ((!read_down) && (retry_cnts--));
@@ -533,6 +538,8 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus)bool bcn_valid = false;u8 DLBcnCount =0 ;u32 poll =0 ; +u8 reg; +int res;if (mstatus ==1 ) {/* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */
@@ -547,8 +554,17 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus)/* Disable Hw protection for a time which revserd for Hw sending beacon. */ /* Fix download reserved page packet fail that access collision with the protection time. */ /* 2010.05.11. Added by tynli. */ -rtw_write8 (adapt,REG_BCN_CTRL ,rtw_read8 (adapt,REG_BCN_CTRL ) & (~BIT (3 ))); -rtw_write8 (adapt,REG_BCN_CTRL ,rtw_read8 (adapt,REG_BCN_CTRL ) |BIT (4 )); + res =rtw_read8 (adapt,REG_BCN_CTRL , ®); +if (res) +return ; + +rtw_write8 (adapt,REG_BCN_CTRL , reg & (~BIT (3 ))); + + res =rtw_read8 (adapt,REG_BCN_CTRL , ®); +if (res) +return ; + +rtw_write8 (adapt,REG_BCN_CTRL , reg |BIT (4 ));if (haldata->RegFwHwTxQCtrl &BIT (6 )) bSendBeacon = true;
@@ -581,8 +597,17 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus)/* */ /* Enable Bcn */ -rtw_write8 (adapt,REG_BCN_CTRL ,rtw_read8 (adapt,REG_BCN_CTRL ) |BIT (3 )); -rtw_write8 (adapt,REG_BCN_CTRL ,rtw_read8 (adapt,REG_BCN_CTRL ) & (~BIT (4 ))); + res =rtw_read8 (adapt,REG_BCN_CTRL , ®); +if (res) +return ; + +rtw_write8 (adapt,REG_BCN_CTRL , reg |BIT (3 )); + + res =rtw_read8 (adapt,REG_BCN_CTRL , ®); +if (res) +return ; + +rtw_write8 (adapt,REG_BCN_CTRL , reg & (~BIT (4 )));/* To make sure that if there exists an adapter which would like to send beacon. */ /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */
drivers/staging/r8188eu/hal/rtl8188e_dm.c +5 -1
@@ -12,8 +12,12 @@static void dm_InitGPIOSetting (struct adapter *Adapter) {u8 tmp1byte; +int res; + + res =rtw_read8 (Adapter,REG_GPIO_MUXCFG , &tmp1byte); +if (res) +return ; - tmp1byte =rtw_read8 (Adapter,REG_GPIO_MUXCFG ); tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT );rtw_write8 (Adapter,REG_GPIO_MUXCFG , tmp1byte);
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +55 -14
120 lines not on this page · raw message
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +8 -2
@@ -594,6 +594,7 @@ _PHY_SetBWMode92C(struct hal_data_8188e *pHalData = &Adapter->haldata;u8 regBwOpMode;u8 regRRSR_RSC; +int res;if (Adapter->bDriverStopped)return ;
@@ -602,8 +603,13 @@ _PHY_SetBWMode92C(/* 3<1>Set MAC register */ /* 3 */ - regBwOpMode =rtw_read8 (Adapter,REG_BWOPMODE ); - regRRSR_RSC =rtw_read8 (Adapter,REG_RRSR +2 ); + res =rtw_read8 (Adapter,REG_BWOPMODE , ®BwOpMode); +if (res) +return ; + + res =rtw_read8 (Adapter,REG_RRSR +2 , ®RRSR_RSC); +if (res) +return ;switch (pHalData->CurrentChannelBW) {case HT_CHANNEL_WIDTH_20 :
drivers/staging/r8188eu/hal/usb_halinit.c +141 -30
339 lines not on this page · raw message
drivers/staging/r8188eu/hal/usb_ops_linux.c +2 -5
@@ -94,16 +94,13 @@ static int usb_write(struct intf_hdl *intf, u16 value, void *data, u8 size)return status; } -u8 rtw_read8 (struct adapter *adapter,u32 addr) +int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data) {struct io_priv *io_priv = &adapter->iopriv;struct intf_hdl *intf = &io_priv->intf;u16 value = addr &0xffff ; -u8 data; -usb_read (intf, value, &data,1 ); - -return data; +return usb_read (intf, value, data,1 ); }u16 rtw_read16 (struct adapter *adapter,u32 addr)
drivers/staging/r8188eu/include/rtw_io.h +1 -1
@@ -220,7 +220,7 @@ void unregister_intf_hdl(struct intf_hdl *pintfhdl);void _rtw_attrib_read (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem);void _rtw_attrib_write (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem); -u8 rtw_read8 (struct adapter *adapter,u32 addr); +int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data);u16 rtw_read16 (struct adapter *adapter,u32 addr);u32 rtw_read32 (struct adapter *adapter,u32 addr);void _rtw_read_mem (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem);
drivers/staging/r8188eu/os_dep/ioctl_linux.c +8 -3
@@ -3178,6 +3178,7 @@ static void rtw_set_dynamic_functions(struct adapter *adapter, u8 dm_func) {struct hal_data_8188e *haldata = &adapter->haldata;struct odm_dm_struct *odmpriv = &haldata->odmpriv; +int res;switch (dm_func) {case 0 :
@@ -3193,7 +3194,9 @@ static void rtw_set_dynamic_functions(struct adapter *adapter, u8 dm_func)if (!(odmpriv->SupportAbility &DYNAMIC_BB_DIG )) {struct rtw_dig *digtable = &odmpriv->DM_DigTable; - digtable->CurIGValue =rtw_read8 (adapter,0xc50 ); + res =rtw_read8 (adapter,0xc50 , &digtable->CurIGValue); + (void )res; +/* FIXME: return an error to caller */ } odmpriv->SupportAbility =DYNAMIC_ALL_FUNC_ENABLE ;break ;
@@ -3329,8 +3332,9 @@ static int rtw_dbg_port(struct net_device *dev,u16 reg = arg;u16 start_value =0 ;u32 write_num = extra_arg; -int i; +int i, res;struct xmit_frame *xmit_frame; +u8 val8; xmit_frame =rtw_IOL_accquire_xmit_frame (padapter);if (!xmit_frame) {
@@ -3343,7 +3347,8 @@ static int rtw_dbg_port(struct net_device *dev,if (rtl8188e_IOL_exec_cmds_sync (padapter, xmit_frame,5000 ,0 ) != _SUCCESS) ret = -EPERM ; -rtw_read8 (padapter, reg); +/* FIXME: is this read necessary? */ + res =rtw_read8 (padapter, reg, &val8); }break ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 6/64 staging: r8188eu: add error handling of rtw_read16
In reply to Sasha LevinFrom: Pavel Skripkin <[email protected]>
[ Upstream commit fed9e604eeb6150847d9757f6b056c12912d468b ]
rtw_read16() reads data from device via USB API which may fail. In case of any failure previous code returned stack data to callers, which is wrong.
Fix it by changing rtw_read16() prototype and prevent caller from touching random stack data
--- .../staging/r8188eu/hal/rtl8188e_hal_init.c | 29 +++++++++++++++---- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 +++-- drivers/staging/r8188eu/hal/usb_halinit.c | 27 ++++++++++++++--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 13 ++++++--- drivers/staging/r8188eu/include/rtw_io.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 9 ++++-- drivers/staging/r8188eu/os_dep/os_intfs.c | 6 +++- 7 files changed, 73 insertions(+), 21 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +23 -6
@@ -200,7 +200,8 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf)kfree (eFuseWord); } -static void efuse_read_phymap_from_txpktbuf( +/* FIXME: add error handling in callers */ +static int efuse_read_phymap_from_txpktbuf( struct adapter *adapter, int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ u8 *content, /* buffer to store efuse physical map */
@@ -219,7 +220,7 @@ static void efuse_read_phymap_from_txpktbuf(if (bcnhead <0 ) {/* if not valid */ res =rtw_read8 (adapter,REG_TDECTRL +1 , ®);if (res) -return ; +return res; bcnhead = reg; }
@@ -249,11 +250,15 @@ static void efuse_read_phymap_from_txpktbuf( hi32 =cpu_to_le32 (rtw_read32 (adapter,REG_PKTBUF_DBG_DATA_H ));if (i ==0 ) { +u16 reg; +/* Although lenc is only used in a debug statement, * do not remove it as the rtw_read16() call consumes * 2 bytes from the EEPROM source. */ -rtw_read16 (adapter,REG_PKTBUF_DBG_DATA_L ); + res =rtw_read16 (adapter,REG_PKTBUF_DBG_DATA_L , ®); +if (res) +return res; len =le32_to_cpu (lo32) &0x0000ffff ;
@@ -280,6 +285,8 @@ static void efuse_read_phymap_from_txpktbuf( }rtw_write8 (adapter,REG_PKT_BUFF_ACCESS_CTRL ,DISABLE_TRXPKT_BUF_ACCESS ); *size = count; + +return 0 ; }static s32 iol_read_efuse (struct adapter *padapter,u8 txpktbuf_bndy,u16 offset,u16 size_byte,u8 *logical_map)
@@ -355,25 +362,35 @@ int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmitvoid rtl8188e_EfusePowerSwitch (struct adapter *pAdapter,u8 PwrState) {u16 tmpV16; +int res;if (PwrState) {rtw_write8 (pAdapter,REG_EFUSE_ACCESS ,EFUSE_ACCESS_ON );/* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ - tmpV16 =rtw_read16 (pAdapter,REG_SYS_ISO_CTRL ); + res =rtw_read16 (pAdapter,REG_SYS_ISO_CTRL , &tmpV16); +if (res) +return ; +if (!(tmpV16 &PWC_EV12V )) { tmpV16 |=PWC_EV12V ;rtw_write16 (pAdapter,REG_SYS_ISO_CTRL , tmpV16); }/* Reset: 0x0000h[28], default valid */ - tmpV16 =rtw_read16 (pAdapter,REG_SYS_FUNC_EN ); + res =rtw_read16 (pAdapter,REG_SYS_FUNC_EN , &tmpV16); +if (res) +return ; +if (!(tmpV16 &FEN_ELDR )) { tmpV16 |=FEN_ELDR ;rtw_write16 (pAdapter,REG_SYS_FUNC_EN , tmpV16); }/* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpV16 =rtw_read16 (pAdapter,REG_SYS_CLKR ); + res =rtw_read16 (pAdapter,REG_SYS_CLKR , &tmpV16); +if (res) +return ; +if ((!(tmpV16 &LOADER_CLK_EN )) || (!(tmpV16 &ANA8M ))) { tmpV16 |= (LOADER_CLK_EN |ANA8M );rtw_write16 (pAdapter,REG_SYS_CLKR , tmpV16);
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +6 -2
@@ -484,13 +484,17 @@ PHY_BBConfig8188E( {int rtStatus = _SUCCESS;struct hal_data_8188e *pHalData = &Adapter->haldata; -u32 RegVal; +u16 RegVal;u8 CrystalCap; +int res;phy_InitBBRFRegisterDefinition (Adapter);/* Enable BB and RF */ - RegVal =rtw_read16 (Adapter,REG_SYS_FUNC_EN ); + res =rtw_read16 (Adapter,REG_SYS_FUNC_EN , &RegVal); +if (res) +return _FAIL; +rtw_write16 (Adapter,REG_SYS_FUNC_EN , (u16)(RegVal |BIT (13 ) |BIT (0 ) |BIT (1 )));/* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */
drivers/staging/r8188eu/hal/usb_halinit.c +23 -4
@@ -52,6 +52,8 @@ void rtl8188eu_interface_configure(struct adapter *adapt)u32 rtl8188eu_InitPowerOn (struct adapter *adapt) {u16 value16; +int res; +/* HW Power on sequence */ struct hal_data_8188e *haldata = &adapt->haldata;if (haldata->bMacPwrCtrlOn)
@@ -65,7 +67,10 @@ u32 rtl8188eu_InitPowerOn(struct adapter *adapt)rtw_write16 (adapt,REG_CR ,0x00 );/* suggseted by zhouzhou, by page, 20111230 */ /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ - value16 =rtw_read16 (adapt,REG_CR ); + res =rtw_read16 (adapt,REG_CR , &value16); +if (res) +return _FAIL; + value16 |= (HCI_TXDMA_EN |HCI_RXDMA_EN |TXDMA_EN |RXDMA_EN |PROTOCOL_EN |SCHEDULE_EN |ENSEC |CALTMR_EN );/* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */
@@ -166,7 +171,14 @@ static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, u16 hiQ) { - u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); + u16 value16; +int res; + + res =rtw_read16 (Adapter,REG_TRXDMA_CTRL , &value16); +if (res) +return ; + + value16 &=0x7 ; value16 |=_TXDMA_BEQ_MAP (beQ) |_TXDMA_BKQ_MAP (bkQ) | _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) |
@@ -640,7 +652,10 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)/* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ /* */ /* Enable MACTXEN/MACRXEN block */ - value16 =rtw_read16 (Adapter,REG_CR ); + res =rtw_read16 (Adapter,REG_CR , &value16); +if (res) +return _FAIL; + value16 |= (MACTXEN |MACRXEN );rtw_write8 (Adapter,REG_CR , value16);
@@ -713,7 +728,11 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)rtw_write16 (Adapter,REG_TX_RPT_TIME ,0x3DF0 );/* enable tx DMA to drop the redundate data of packet */ -rtw_write16 (Adapter,REG_TXDMA_OFFSET_CHK , (rtw_read16 (Adapter,REG_TXDMA_OFFSET_CHK ) |DROP_DATA_EN )); + res =rtw_read16 (Adapter,REG_TXDMA_OFFSET_CHK , &value16); +if (res) +return _FAIL; + +rtw_write16 (Adapter,REG_TXDMA_OFFSET_CHK , (value16 |DROP_DATA_EN ));/* 2010/08/26 MH Merge from 8192CE. */ if (pwrctrlpriv->rf_pwrstate == rf_on) {
drivers/staging/r8188eu/hal/usb_ops_linux.c +9 -4
@@ -103,16 +103,21 @@ int __must_check rtw_read8(struct adapter *adapter, u32 addr, u8 *data)return usb_read (intf, value, data,1 ); } -u16 rtw_read16 (struct adapter *adapter,u32 addr) +int __must_check rtw_read16 (struct adapter *adapter,u32 addr,u16 *data) {struct io_priv *io_priv = &adapter->iopriv;struct intf_hdl *intf = &io_priv->intf;u16 value = addr &0xffff ; -__le16 data; +__le16 le_data; +int res; -usb_read (intf, value, &data,2 ); + res =usb_read (intf, value, &le_data,2 ); +if (res) +return res; -return le16_to_cpu (data); + *data =le16_to_cpu (le_data); + +return 0 ; }u32 rtw_read32 (struct adapter *adapter,u32 addr)
drivers/staging/r8188eu/include/rtw_io.h +1 -1
@@ -221,7 +221,7 @@ void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);void _rtw_attrib_write (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem);int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data); -u16 rtw_read16 (struct adapter *adapter,u32 addr); +int __must_check rtw_read16 (struct adapter *adapter,u32 addr,u16 *data);u32 rtw_read32 (struct adapter *adapter,u32 addr);void _rtw_read_mem (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem);u32 rtw_read_port (struct adapter *adapter,u8 *pmem);
drivers/staging/r8188eu/os_dep/ioctl_linux.c +6 -3
@@ -3349,6 +3349,7 @@ static int rtw_dbg_port(struct net_device *dev,/* FIXME: is this read necessary? */ res =rtw_read8 (padapter, reg, &val8); + (void )res; }break ;
@@ -3357,8 +3358,8 @@ static int rtw_dbg_port(struct net_device *dev,u16 reg = arg;u16 start_value =200 ;u32 write_num = extra_arg; - -int i; +u16 val16; +int i, res;struct xmit_frame *xmit_frame; xmit_frame =rtw_IOL_accquire_xmit_frame (padapter);
@@ -3372,7 +3373,9 @@ static int rtw_dbg_port(struct net_device *dev,if (rtl8188e_IOL_exec_cmds_sync (padapter, xmit_frame,5000 ,0 ) != _SUCCESS) ret = -EPERM ; -rtw_read16 (padapter, reg); +/* FIXME: is this read necessary? */ + res =rtw_read16 (padapter, reg, &val16); + (void )res; }break ;case 0x08 :/* continuous write dword test */
drivers/staging/r8188eu/os_dep/os_intfs.c +5 -1
@@ -740,12 +740,16 @@ static void rtw_fifo_cleanup(struct adapter *adapter) {struct pwrctrl_priv *pwrpriv = &adapter->pwrctrlpriv;u8 trycnt =100 ; +int res;/* pause tx */ rtw_write8 (adapter,REG_TXPAUSE ,0xff );/* keep sn */ - adapter->xmitpriv.nqos_ssn =rtw_read16 (adapter,REG_NQOS_SEQ ); +/* FIXME: return an error to caller */ + res =rtw_read16 (adapter,REG_NQOS_SEQ , &adapter->xmitpriv.nqos_ssn); +if (res) +return ;if (!pwrpriv->bkeepfwalive) {/* RX DMA stop */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 7/64 staging: r8188eu: add error handling of rtw_read32
In reply to Sasha LevinFrom: Pavel Skripkin <[email protected]>
[ Upstream commit b9c5e272062708680d47df433bfbfe5299ad1a63 ]
rtw_read32() reads data from device via USB API which may fail. In case of any failure previous code returned stack data to callers, which is wrong.
Fix it by changing rtw_read32() prototype and prevent caller from touching random stack data
--- drivers/staging/r8188eu/core/rtw_cmd.c | 15 +++++- drivers/staging/r8188eu/core/rtw_efuse.c | 20 ++++--- drivers/staging/r8188eu/core/rtw_fw.c | 16 ++++-- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 14 ++++- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 9 +++- .../r8188eu/hal/Hal8188ERateAdaptive.c | 21 ++++++-- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 3 +- .../staging/r8188eu/hal/rtl8188e_hal_init.c | 40 +++++++++----- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 12 ++++- drivers/staging/r8188eu/hal/usb_halinit.c | 53 ++++++++++++++++--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 13 +++-- drivers/staging/r8188eu/include/rtw_io.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 27 ++++++++-- drivers/staging/r8188eu/os_dep/os_intfs.c | 13 ++++- 14 files changed, 202 insertions(+), 56 deletions(-)
drivers/staging/r8188eu/core/rtw_cmd.c +13 -2
@@ -898,8 +898,12 @@ static void traffic_status_watchdog(struct adapter *padapter)static void rtl8188e_sreset_xmit_status_check (struct adapter *padapter) {u32 txdma_status; +int res; + + res =rtw_read32 (padapter,REG_TXDMA_STATUS , &txdma_status); +if (res) +return ; - txdma_status =rtw_read32 (padapter,REG_TXDMA_STATUS );if (txdma_status !=0x00 )rtw_write32 (padapter,REG_TXDMA_STATUS , txdma_status);/* total xmit irp = 4 */
@@ -1177,7 +1181,14 @@ u8 rtw_ps_cmd(struct adapter *padapter)static bool rtw_is_hi_queue_empty (struct adapter *adapter) { -return (rtw_read32 (adapter,REG_HGQ_INFORMATION ) &0x0000ff00 ) ==0 ; +int res; +u32 reg; + + res =rtw_read32 (adapter,REG_HGQ_INFORMATION , ®); +if (res) +return false; + +return (reg &0x0000ff00 ) ==0 ; }static void rtw_chk_hi_queue_hdl (struct adapter *padapter)
drivers/staging/r8188eu/core/rtw_efuse.c +14 -6
@@ -46,11 +46,17 @@ ReadEFuseByte(rtw_write8 (Adapter,EFUSE_CTRL +3 , (readbyte &0x7f ));/* Check bit 32 read-ready */ - retry =0 ; - value32 =rtw_read32 (Adapter,EFUSE_CTRL ); -while (!(((value32 >>24 ) &0xff ) &0x80 ) && (retry <10000 )) { - value32 =rtw_read32 (Adapter,EFUSE_CTRL ); - retry++; + res =rtw_read32 (Adapter,EFUSE_CTRL , &value32); +if (res) +return ; + +for (retry =0 ; retry <10000 ; retry++) { + res =rtw_read32 (Adapter,EFUSE_CTRL , &value32); +if (res) +continue ; + +if (((value32 >>24 ) &0xff ) &0x80 ) +break ; }/* 20100205 Joseph: Add delay suggested by SD1 Victor. */
@@ -58,7 +64,9 @@ ReadEFuseByte(/* Designer says that there shall be some delay after ready bit is set, or the */ /* result will always stay on last data we read. */ udelay (50 ); - value32 =rtw_read32 (Adapter,EFUSE_CTRL ); + res =rtw_read32 (Adapter,EFUSE_CTRL , &value32); +if (res) +return ; *pbuf = (u8)(value32 &0xff );
drivers/staging/r8188eu/core/rtw_fw.c +12 -4
@@ -194,10 +194,14 @@ static int fw_free_to_go(struct adapter *padapter) {u32 counter =0 ;u32 value32; +int res;/* polling CheckSum report */ do { - value32 =rtw_read32 (padapter,REG_MCUFWDL ); + res =rtw_read32 (padapter,REG_MCUFWDL , &value32); +if (res) +continue ; +if (value32 &FWDL_CHKSUM_RPT )break ; }while (counter++ <POLLING_READY_TIMEOUT_COUNT );
@@ -205,7 +209,10 @@ static int fw_free_to_go(struct adapter *padapter)if (counter >=POLLING_READY_TIMEOUT_COUNT )return _FAIL; - value32 =rtw_read32 (padapter,REG_MCUFWDL ); + res =rtw_read32 (padapter,REG_MCUFWDL , &value32); +if (res) +return _FAIL; + value32 |=MCUFWDL_RDY ; value32 &= ~WINTINI_RDY ;rtw_write32 (padapter,REG_MCUFWDL , value32);
@@ -215,9 +222,10 @@ static int fw_free_to_go(struct adapter *padapter)/* polling for FW ready */ counter =0 ;do { - value32 =rtw_read32 (padapter,REG_MCUFWDL ); -if (value32 &WINTINI_RDY ) + res =rtw_read32 (padapter,REG_MCUFWDL , &value32); +if (!res && value32 &WINTINI_RDY )return _SUCCESS; +udelay (5 ); }while (counter++ <POLLING_READY_TIMEOUT_COUNT );
drivers/staging/r8188eu/core/rtw_mlme_ext.c +12 -2
@@ -6017,6 +6017,7 @@ static void mlme_join(struct adapter *adapter, int type) {struct mlme_priv *mlmepriv = &adapter->mlmepriv;u8 retry_limit =0x30 , reg; +u32 reg32;int res;switch (type) {
@@ -6025,8 +6026,12 @@ static void mlme_join(struct adapter *adapter, int type)/* enable to rx data frame, accept all data frame */ rtw_write16 (adapter,REG_RXFLTMAP2 ,0xFFFF ); + res =rtw_read32 (adapter,REG_RCR , ®32); +if (res) +return ; +rtw_write32 (adapter,REG_RCR , -rtw_read32 (adapter,REG_RCR ) |RCR_CBSSID_DATA |RCR_CBSSID_BCN ); + reg32 |RCR_CBSSID_DATA |RCR_CBSSID_BCN );if (check_fwstate (mlmepriv,WIFI_STATION_STATE )) { retry_limit =48 ;
@@ -6839,9 +6844,14 @@ static u8 chk_ap_is_alive(struct sta_info *psta)static int rtl8188e_sreset_linked_status_check (struct adapter *padapter) { -u32 rx_dma_status =rtw_read32 (padapter,REG_RXDMA_STATUS ); +u32 rx_dma_status; +int res;u8 reg; + res =rtw_read32 (padapter,REG_RXDMA_STATUS , &rx_dma_status); +if (res) +return res; +if (rx_dma_status !=0x00 )rtw_write32 (padapter,REG_RXDMA_STATUS , rx_dma_status);
drivers/staging/r8188eu/core/rtw_pwrctrl.c +8 -1
@@ -229,6 +229,9 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_astatic bool lps_rf_on (struct adapter *adapter) { +int res; +u32 reg; +/* When we halt NIC, we should check if FW LPS is leave. */ if (adapter->pwrctrlpriv.rf_pwrstate == rf_off) {/* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */
@@ -236,7 +239,11 @@ static bool lps_rf_on(struct adapter *adapter)return true; } -if (rtw_read32 (adapter,REG_RCR ) &0x00070000 ) + res =rtw_read32 (adapter,REG_RCR , ®); +if (res) +return false; + +if (reg &0x00070000 )return false;return true;
drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +17 -4
@@ -279,6 +279,7 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf {/* Wilson 2011/10/26 */ u32 MaskFromReg;s8 i; +int res;switch (pRaInfo->RateID) {case RATR_INX_WIRELESS_NGB :
@@ -303,19 +304,31 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf pRaInfo->RAUseRate = (pRaInfo->RateMask) &0x0000000d ;break ;case 12 : - MaskFromReg =rtw_read32 (dm_odm->Adapter,REG_ARFR0 ); + res =rtw_read32 (dm_odm->Adapter,REG_ARFR0 , &MaskFromReg); +if (res) +return res; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;break ;case 13 : - MaskFromReg =rtw_read32 (dm_odm->Adapter,REG_ARFR1 ); + res =rtw_read32 (dm_odm->Adapter,REG_ARFR1 , &MaskFromReg); +if (res) +return res; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;break ;case 14 : - MaskFromReg =rtw_read32 (dm_odm->Adapter,REG_ARFR2 ); + res =rtw_read32 (dm_odm->Adapter,REG_ARFR2 , &MaskFromReg); +if (res) +return res; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;break ;case 15 : - MaskFromReg =rtw_read32 (dm_odm->Adapter,REG_ARFR3 ); + res =rtw_read32 (dm_odm->Adapter,REG_ARFR3 , &MaskFromReg); +if (res) +return res; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg;break ;default :
drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +2 -1
@@ -483,7 +483,8 @@ static void _PHY_SaveMACRegisters( MACBackup[i] = reg; } - MACBackup[i] =rtw_read32 (adapt, MACReg[i]); + res =rtw_read32 (adapt, MACReg[i], MACBackup + i); + (void )res; }static void reload_adda_reg (struct adapter *adapt,u32 *ADDAReg,u32 *ADDABackup,u32 RegiesterNum)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +26 -14
@@ -216,6 +216,7 @@ static int efuse_read_phymap_from_txpktbuf(u16 limit = *size;u8 reg;u8 *pos = content; +u32 reg32;if (bcnhead <0 ) {/* if not valid */ res =rtw_read8 (adapter,REG_TDECTRL +1 , ®);
@@ -246,8 +247,17 @@ static int efuse_read_phymap_from_txpktbuf( }while (time_before (jiffies, timeout));/* data from EEPROM needs to be in LE */ - lo32 =cpu_to_le32 (rtw_read32 (adapter,REG_PKTBUF_DBG_DATA_L )); - hi32 =cpu_to_le32 (rtw_read32 (adapter,REG_PKTBUF_DBG_DATA_H )); + res =rtw_read32 (adapter,REG_PKTBUF_DBG_DATA_L , ®32); +if (res) +return res; + + lo32 =cpu_to_le32 (reg32); + + res =rtw_read32 (adapter,REG_PKTBUF_DBG_DATA_H , ®32); +if (res) +return res; + + hi32 =cpu_to_le32 (reg32);if (i ==0 ) {u16 reg;
@@ -548,8 +558,12 @@ void rtl8188e_read_chip_version(struct adapter *padapter)u32 value32;struct HAL_VERSION ChipVersion;struct hal_data_8188e *pHalData = &padapter->haldata; +int res; + + res =rtw_read32 (padapter,REG_SYS_CFG , &value32); +if (res) +return ; - value32 =rtw_read32 (padapter,REG_SYS_CFG ); ChipVersion.ChipType = ((value32 &RTL_ID ) ?TEST_CHIP :NORMAL_CHIP ); ChipVersion.VendorType = ((value32 &VENDOR_ID ) ?CHIP_VENDOR_UMC :CHIP_VENDOR_TSMC );
@@ -596,26 +610,24 @@ void hal_notch_filter_8188e(struct adapter *adapter, bool enable)/* */ static s32 _LLTWrite (struct adapter *padapter,u32 address,u32 data) { -s32 status = _SUCCESS; -s32 count =0 ; +s32 count;u32 value =_LLT_INIT_ADDR (address) |_LLT_INIT_DATA (data) |_LLT_OP (_LLT_WRITE_ACCESS);u16 LLTReg =REG_LLT_INIT ; +int res;rtw_write32 (padapter, LLTReg, value);/* polling */ -do { - value =rtw_read32 (padapter, LLTReg); -if (_LLT_NO_ACTIVE ==_LLT_OP_VALUE (value)) -break ; +for (count =0 ; count <=POLLING_LLT_THRESHOLD ; count++) { + res =rtw_read32 (padapter, LLTReg, &value); +if (res) +continue ; -if (count >POLLING_LLT_THRESHOLD ) { - status = _FAIL; +if (_LLT_NO_ACTIVE ==_LLT_OP_VALUE (value))break ; - } - }while (count++); + } -return status; +return count >POLLING_LLT_THRESHOLD ? _FAIL : _SUCCESS; }s32 InitLLTTable (struct adapter *padapter,u8 txpktbuf_bndy)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +10 -2
@@ -56,8 +56,12 @@ rtl8188e_PHY_QueryBBReg( ) {u32 ReturnValue =0 , OriginalValue, BitShift; +int res; + + res =rtw_read32 (Adapter, RegAddr, &OriginalValue); +if (res) +return 0 ; - OriginalValue =rtw_read32 (Adapter, RegAddr); BitShift =phy_CalculateBitShift (BitMask); ReturnValue = (OriginalValue & BitMask) >> BitShift;return ReturnValue;
@@ -84,9 +88,13 @@ rtl8188e_PHY_QueryBBReg(void rtl8188e_PHY_SetBBReg (struct adapter *Adapter,u32 RegAddr,u32 BitMask,u32 Data) {u32 OriginalValue, BitShift; +int res;if (BitMask != bMaskDWord) {/* if not "double word" write */ - OriginalValue =rtw_read32 (Adapter, RegAddr); + res =rtw_read32 (Adapter, RegAddr, &OriginalValue); +if (res) +return ; + BitShift =phy_CalculateBitShift (BitMask); Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); }
drivers/staging/r8188eu/hal/usb_halinit.c +45 -8
124 lines not on this page · raw message
drivers/staging/r8188eu/hal/usb_ops_linux.c +9 -4
@@ -120,16 +120,21 @@ int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data)return 0 ; } -u32 rtw_read32 (struct adapter *adapter,u32 addr) +int __must_check rtw_read32 (struct adapter *adapter,u32 addr,u32 *data) {struct io_priv *io_priv = &adapter->iopriv;struct intf_hdl *intf = &io_priv->intf;u16 value = addr &0xffff ; -__le32 data; +__le32 le_data; +int res; -usb_read (intf, value, &data,4 ); + res =usb_read (intf, value, &le_data,4 ); +if (res) +return res; -return le32_to_cpu (data); + *data =le32_to_cpu (le_data); + +return 0 ; }int rtw_write8 (struct adapter *adapter,u32 addr,u8 val)
drivers/staging/r8188eu/include/rtw_io.h +1 -1
@@ -222,7 +222,7 @@ void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data);int __must_check rtw_read16 (struct adapter *adapter,u32 addr,u16 *data); -u32 rtw_read32 (struct adapter *adapter,u32 addr); +int __must_check rtw_read32 (struct adapter *adapter,u32 addr,u32 *data);void _rtw_read_mem (struct adapter *adapter,u32 addr,u32 cnt,u8 *pmem);u32 rtw_read_port (struct adapter *adapter,u8 *pmem);void rtw_read_port_cancel (struct adapter *adapter);
drivers/staging/r8188eu/os_dep/ioctl_linux.c +22 -5
@@ -3126,18 +3126,29 @@ static int rtw_rereg_nd_name(struct net_device *dev,static void mac_reg_dump (struct adapter *padapter) {int i, j =1 ; +u32 reg; +int res; +pr_info ("\n ======= MAC REG =======\n" );for (i =0x0 ; i <0x300 ; i +=4 ) {if (j %4 ==1 )pr_info ("0x%02x" , i); -pr_info (" 0x%08x " ,rtw_read32 (padapter, i)); + + res =rtw_read32 (padapter, i, ®); +if (!res) +pr_info (" 0x%08x " , reg); +if ((j++) %4 ==0 )pr_info ("\n" ); }for (i =0x400 ; i <0x800 ; i +=4 ) {if (j %4 ==1 )pr_info ("0x%02x" , i); -pr_info (" 0x%08x " ,rtw_read32 (padapter, i)); + + res =rtw_read32 (padapter, i, ®); +if (!res) +pr_info (" 0x%08x " , reg); +if ((j++) %4 ==0 )pr_info ("\n" ); }
@@ -3145,13 +3156,18 @@ static void mac_reg_dump(struct adapter *padapter)static void bb_reg_dump (struct adapter *padapter) { -int i, j =1 ; +int i, j =1 , res; +u32 reg; +pr_info ("\n ======= BB REG =======\n" );for (i =0x800 ; i <0x1000 ; i +=4 ) {if (j %4 ==1 )pr_info ("0x%02x" , i); -pr_info (" 0x%08x " ,rtw_read32 (padapter, i)); + res =rtw_read32 (padapter, i, ®); +if (!res) +pr_info (" 0x%08x " , reg); +if ((j++) %4 ==0 )pr_info ("\n" ); }
@@ -3398,7 +3414,8 @@ static int rtw_dbg_port(struct net_device *dev,if (rtl8188e_IOL_exec_cmds_sync (padapter, xmit_frame,5000 ,0 ) != _SUCCESS) ret = -EPERM ; -rtw_read32 (padapter, reg); +/* FIXME: is this read necessary? */ + ret =rtw_read32 (padapter, reg, &write_num); }break ; }
drivers/staging/r8188eu/os_dep/os_intfs.c +11 -2
@@ -741,6 +741,7 @@ static void rtw_fifo_cleanup(struct adapter *adapter)struct pwrctrl_priv *pwrpriv = &adapter->pwrctrlpriv;u8 trycnt =100 ;int res; +u32 reg;/* pause tx */ rtw_write8 (adapter,REG_TXPAUSE ,0xff );
@@ -753,10 +754,18 @@ static void rtw_fifo_cleanup(struct adapter *adapter)if (!pwrpriv->bkeepfwalive) {/* RX DMA stop */ + res =rtw_read32 (adapter,REG_RXPKT_NUM , ®); +if (res) +return ; +rtw_write32 (adapter,REG_RXPKT_NUM , - (rtw_read32 (adapter,REG_RXPKT_NUM ) |RW_RELEASE_EN )); + (reg |RW_RELEASE_EN ));do { -if (!(rtw_read32 (adapter,REG_RXPKT_NUM ) &RXDMA_IDLE )) + res =rtw_read32 (adapter,REG_RXPKT_NUM , ®); +if (res) +continue ; + +if (!(reg &RXDMA_IDLE ))break ; }while (trycnt--);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 8/64 usb: cdns3 fix use-after-free at workaround 2
In reply to Sasha LevinFrom: Frank Li <[email protected]>
[ Upstream commit 7d602f30149a117eea260208b1661bc404c21dfd ]
BUG: KFENCE: use-after-free read in __list_del_entry_valid+0x10/0xac
cdns3_wa2_remove_old_request()
{
...
kfree(priv_req->request.buf);
cdns3_gadget_ep_free_request(&priv_ep->endpoint, &priv_req->request);
list_del_init(&priv_req->list);
^^^ use after free
...
}cdns3_gadget_ep_free_request() free the space pointed by priv_req, but priv_req is used in the following list_del_init().
This patch move list_del_init() before cdns3_gadget_ep_free_request().
--- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +1 -1
@@ -625,9 +625,9 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep)trace_cdns3_wa2 (priv_ep,"removes eldest request" );kfree (priv_req->request.buf); +list_del_init (&priv_req->list);cdns3_gadget_ep_free_request (&priv_ep->endpoint, &priv_req->request); -list_del_init (&priv_req->list); --priv_ep->wa2_counter;if (!chain)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 9/64 usb: cdns3: fix random warning message when driver load
In reply to Sasha LevinFrom: Frank Li <[email protected]>
[ Upstream commit 8659ab3d936fcf0084676f98b75b317017aa8f82 ]
Warning log:
[ 4.141392] Unexpected gfp: 0x4 (GFP_DMA32). Fixing up to gfp: 0xa20 (GFP_ATOMIC). Fix your code! [ 4.150340] CPU: 1 PID: 175 Comm: 1-0050 Not tainted 5.15.5-00039-g2fd9ae1b568c #20 [ 4.158010] Hardware name: Freescale i.MX8QXP MEK (DT) [ 4.163155] Call trace: [ 4.165600] dump_backtrace+0x0/0x1b0 [ 4.169286] show_stack+0x18/0x68 [ 4.172611] dump_stack_lvl+0x68/0x84 [ 4.176286] dump_stack+0x18/0x34 [ 4.179613] kmalloc_fix_flags+0x60/0x88 [ 4.183550] new_slab+0x334/0x370 [ 4.186878] ___slab_alloc.part.108+0x4d4/0x748 [ 4.191419] __slab_alloc.isra.109+0x30/0x78 [ 4.195702] kmem_cache_alloc+0x40c/0x420 [ 4.199725] dma_pool_alloc+0xac/0x1f8 [ 4.203486] cdns3_allocate_trb_pool+0xb4/0xd0
pool_alloc_page(struct dma_pool *pool, gfp_t mem_flags)
{
...
page = kmalloc(sizeof(*page), mem_flags);
page->vaddr = dma_alloc_coherent(pool->dev, pool->allocation,
&page->dma, mem_flags);
...
}kmalloc was called with mem_flags, which is passed down in cdns3_allocate_trb_pool() and have GFP_DMA32 flags. kmall_fix_flags() report warning.
GFP_DMA32 is not useful at all. dma_alloc_coherent() will handle DMA memory region correctly by pool->dev. GFP_DMA32 can be removed safely.
--- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +1 -1
@@ -220,7 +220,7 @@ int cdns3_allocate_trb_pool(struct cdns3_endpoint *priv_ep)if (!priv_ep->trb_pool) { priv_ep->trb_pool =dma_pool_alloc (priv_dev->eps_dma_pool, -GFP_DMA32 |GFP_ATOMIC , +GFP_ATOMIC , &priv_ep->trb_pool_dma);if (!priv_ep->trb_pool)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 10/64 usb: gadget: uvc: calculate the number of request depending on framesize
In reply to Sasha LevinFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 87d76b5f1d8eeb49efa16e2018e188864cbb9401 ]
The current limitation of possible number of requests being handled is dependent on the gadget speed. It makes more sense to depend on the typical frame size when calculating the number of requests. This patch is changing this and is using the previous limits as boundaries for reasonable minimum and maximum number of requests.
For a 1080p jpeg encoded video stream with a maximum imagesize of e.g. 800kB with a maxburst of 8 and an multiplier of 1 the resulting number of requests is calculated to 49.
800768 1
nreqs = ------ * -------------- ~= 49
2 (1024 * 8 * 1)--- drivers/usb/gadget/function/uvc_queue.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/usb/gadget/function/uvc_queue.c +12 -5
@@ -44,7 +44,8 @@ static int uvc_queue_setup(struct vb2_queue *vq, {struct uvc_video_queue *queue =vb2_get_drv_priv (vq); struct uvc_video *video = container_of(queue, struct uvc_video, queue); -struct usb_composite_dev *cdev = video->uvc->func.config->cdev; +unsigned int req_size; +unsigned int nreq;if (*nbuffers >UVC_MAX_VIDEO_BUFFERS ) *nbuffers =UVC_MAX_VIDEO_BUFFERS ;
@@ -53,10 +54,16 @@ static int uvc_queue_setup(struct vb2_queue *vq, sizes[0 ] = video->imagesize; -if (cdev->gadget->speed <USB_SPEED_SUPER ) - video->uvc_num_requests =4 ; -else - video->uvc_num_requests =64 ; + req_size = video->ep->maxpacket + * max_t(unsigned int, video->ep->maxburst, 1) + * (video->ep->mult); + +/* We divide by two, to increase the chance to run +* into fewer requests for smaller framesizes. +*/ + nreq =DIV_ROUND_UP (DIV_ROUND_UP (sizes[0 ],2 ), req_size); + nreq =clamp (nreq,4U ,64U ); + video->uvc_num_requests = nreq;return 0 ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 11/64 usb: gadget: uvc: call uvc uvcg_warn on completed status instead of uvcg_info
In reply to Sasha LevinFrom: Michael Grzeschik <[email protected]>
[ Upstream commit a725d0f6dfc5d3739d6499f30ec865305ba3544d ]
Likewise to the uvcvideo hostside driver, this patch is changing the usb_request message of an non zero completion handler call from dev_info to dev_warn.
--- drivers/usb/gadget/function/uvc_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/uvc_video.c +1 -1
@@ -261,7 +261,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)break ;default : -uvcg_info (&video->uvc->func, +uvcg_warn (&video->uvc->func,"VS request completed with status %d.\n" , req->status);uvcg_queue_cancel (queue,0 );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 12/64 PCI: aardvark: Fix reporting Slot capabilities on emulated bridge
In reply to Sasha LevinFrom: Pali Rohár <[email protected]>
[ Upstream commit bcdb6fd4f3e9ac1097698c8d8f56b70853b49873 ]
Slot capabilities are currently not reported because emulated bridge does not report the PCI_EXP_FLAGS_SLOT flag.
Set PCI_EXP_FLAGS_SLOT to let the kernel know that PCI_EXP_SLT* registers are supported.
Move setting of PCI_EXP_SLTCTL register from "dynamic" pcie_conf_read function to static buffer as it is only statically filled the PCI_EXP_SLTSTA_PDS flag and dynamic read callback is not needed for this register.
Set Presence State Bit to 1 since there is no support for unplugging the card and there is currently no platform able to detect presence of a card - in such a case the bit needs to be set to 1.
Finally correctly set Physical Slot Number to 1 since there is only one port and zero value is reserved for ports within the same silicon as Root Port which is not our case for Aardvark HW.
--- drivers/pci/controller/pci-aardvark.c | 33 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-)
drivers/pci/controller/pci-aardvark.c +24 -9
@@ -8,6 +8,7 @@* Author: Hezi Shahmoon <[email protected]> */ +#include <linux/bitfield.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h>
@@ -857,14 +858,11 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,switch (reg) { -case PCI_EXP_SLTCTL : - *value =PCI_EXP_SLTSTA_PDS <<16 ; -return PCI_BRIDGE_EMUL_HANDLED ; -/* -* PCI_EXP_RTCTL and PCI_EXP_RTSTA are also supported, but do not need -* to be handled here, because their values are stored in emulated -* config space buffer, and we read them from there when needed. +* PCI_EXP_SLTCAP, PCI_EXP_SLTCTL, PCI_EXP_RTCTL and PCI_EXP_RTSTA are +* also supported, but do not need to be handled here, because their +* values are stored in emulated config space buffer, and we read them +* from there when needed. */ case PCI_EXP_LNKCAP : {
@@ -977,8 +975,25 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie)/* Support interrupt A for MSI feature */ bridge->conf.intpin =PCI_INTERRUPT_INTA ; -/* Aardvark HW provides PCIe Capability structure in version 2 */ - bridge->pcie_conf.cap =cpu_to_le16 (2 ); +/* +* Aardvark HW provides PCIe Capability structure in version 2 and +* indicate slot support, which is emulated. +*/ + bridge->pcie_conf.cap =cpu_to_le16 (2 |PCI_EXP_FLAGS_SLOT ); + +/* +* Set Presence Detect State bit permanently since there is no support +* for unplugging the card nor detecting whether it is plugged. (If a +* platform exists in the future that supports it, via a GPIO for +* example, it should be implemented via this bit.) +* +* Set physical slot number to 1 since there is only one port and zero +* value is reserved for ports within the same silicon as Root Port +* which is not our case. +*/ + bridge->pcie_conf.slotcap =cpu_to_le32 (FIELD_PREP (PCI_EXP_SLTCAP_PSN , +1 )); + bridge->pcie_conf.slotsta =cpu_to_le16 (PCI_EXP_SLTSTA_PDS );/* Indicates supports for Completion Retry Status */ bridge->pcie_conf.rootcap =cpu_to_le16 (PCI_EXP_RTCAP_CRSVIS );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 13/64 scsi: ufs: core: Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS
In reply to Sasha LevinFrom: Yoshihiro Shimoda <[email protected]>
[ Upstream commit 6554400d6f66b9494a0c0f07712ab0a9d307eb01 ]
Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS for host controllers which do not support 64-bit addressing.
--- drivers/ufs/core/ufshcd.c | 2 ++ include/ufs/ufshcd.h | 6 ++++++ 2 files changed, 8 insertions(+)
drivers/ufs/core/ufshcd.c +2 -0
@@ -2227,6 +2227,8 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)int err; hba->capabilities =ufshcd_readl (hba,REG_CONTROLLER_CAPABILITIES ); +if (hba->quirks &UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS ) + hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT ;/* nutrs and nutmrs are 0 based values */ hba->nutrs = (hba->capabilities &MASK_TRANSFER_REQUESTS_SLOTS ) +1 ;
include/ufs/ufshcd.h +6 -0
@@ -577,6 +577,12 @@ enum ufshcd_quirks {* support physical host configuration. */ UFSHCD_QUIRK_SKIP_PH_CONFIGURATION =1 <<16 , + +/* +* This quirk needs to be enabled if the host controller has +* 64-bit addressing supported capability but it doesn't work. +*/ + UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS = 1 << 17, }; enum ufshcd_caps {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 14/64 scsi: ufs: core: Add UFSHCD_QUIRK_HIBERN_FASTAUTO
In reply to Sasha LevinFrom: Yoshihiro Shimoda <[email protected]>
[ Upstream commit 2f11bbc2c7f37e3a6151ac548b1c0679cc90ea83 ]
Add UFSHCD_QUIRK_HIBERN_FASTAUTO quirk for host controllers which supports auto-hibernate the capability but only FASTAUTO mode.
--- drivers/ufs/core/ufshcd.c | 9 +++++++-- include/ufs/ufshcd.h | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +7 -2
@@ -4292,8 +4292,13 @@ static int ufshcd_get_max_pwr_mode(struct ufs_hba *hba)if (hba->max_pwr_info.is_valid)return 0 ; - pwr_info->pwr_tx =FAST_MODE ; - pwr_info->pwr_rx =FAST_MODE ; +if (hba->quirks &UFSHCD_QUIRK_HIBERN_FASTAUTO ) { + pwr_info->pwr_tx =FASTAUTO_MODE ; + pwr_info->pwr_rx =FASTAUTO_MODE ; + }else { + pwr_info->pwr_tx =FAST_MODE ; + pwr_info->pwr_rx =FAST_MODE ; + } pwr_info->hs_rate =PA_HS_MODE_B ;/* Get the connected lane count */
include/ufs/ufshcd.h +6 -0
@@ -583,6 +583,12 @@ enum ufshcd_quirks {* 64-bit addressing supported capability but it doesn't work. */ UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS =1 <<17 , + +/* +* This quirk needs to be enabled if the host controller has +* auto-hibernate capability but it's FASTAUTO only. +*/ + UFSHCD_QUIRK_HIBERN_FASTAUTO = 1 << 18, }; enum ufshcd_caps {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 15/64 irqchip/tegra: Fix overflow implicit truncation warnings
In reply to Sasha LevinFrom: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 443685992bda9bb4f8b17fc02c9f6c60e62b1461 ]
Fix -Woverflow warnings for tegra irqchip driver which is a result of moving arm64 custom MMIO accessor macros to asm-generic function implementations giving a bonus type-checking now and uncovering these overflow warnings.
drivers/irqchip/irq-tegra.c: In function ‘tegra_ictlr_suspend’:drivers/irqchip/irq-tegra.c:151:18: warning: large integer implicitly truncated to unsigned type [-Woverflow]
writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
^--- drivers/irqchip/irq-tegra.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-tegra.c +5 -5
@@ -148,10 +148,10 @@ static int tegra_ictlr_suspend(void) lic->cop_iep[i] =readl_relaxed (ictlr +ICTLR_COP_IEP_CLASS );/* Disable COP interrupts */ -writel_relaxed (~0ul , ictlr +ICTLR_COP_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_COP_IER_CLR );/* Disable CPU interrupts */ -writel_relaxed (~0ul , ictlr +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_CPU_IER_CLR );/* Enable the wakeup sources of ictlr */ writel_relaxed (lic->ictlr_wake_mask[i], ictlr +ICTLR_CPU_IER_SET );
@@ -172,12 +172,12 @@ static void tegra_ictlr_resume(void)writel_relaxed (lic->cpu_iep[i], ictlr +ICTLR_CPU_IEP_CLASS ); -writel_relaxed (~0ul , ictlr +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_CPU_IER_CLR );writel_relaxed (lic->cpu_ier[i], ictlr +ICTLR_CPU_IER_SET );writel_relaxed (lic->cop_iep[i], ictlr +ICTLR_COP_IEP_CLASS ); -writel_relaxed (~0ul , ictlr +ICTLR_COP_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), ictlr +ICTLR_COP_IER_CLR );writel_relaxed (lic->cop_ier[i], ictlr +ICTLR_COP_IER_SET ); }
@@ -312,7 +312,7 @@ static int __init tegra_ictlr_init(struct device_node *node, lic->base[i] = base;/* Disable all interrupts */ -writel_relaxed (~0UL , base +ICTLR_CPU_IER_CLR ); +writel_relaxed (GENMASK (31 ,0 ), base +ICTLR_CPU_IER_CLR );/* All interrupts target IRQ */ writel_relaxed (0 , base +ICTLR_CPU_IEP_CLASS );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 16/64 drm/meson: Fix overflow implicit truncation warnings
In reply to Sasha LevinFrom: Sai Prakash Ranjan <[email protected]>
[ Upstream commit 98692f52c588225034cbff458622c2c06dfcb544 ]
Fix -Woverflow warnings for drm/meson driver which is a result of moving arm64 custom MMIO accessor macros to asm-generic function implementations giving a bonus type-checking now and uncovering these overflow warnings.
drivers/gpu/drm/meson/meson_viu.c: In function ‘meson_viu_init’:drivers/gpu/drm/meson/meson_registers.h:1826:48: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
#define VIU_OSD_BLEND_REORDER(dest, src) ((src) << (dest * 4))
^
drivers/gpu/drm/meson/meson_viu.c:472:18: note: in expansion of macro ‘VIU_OSD_BLEND_REORDER’
writel_relaxed(VIU_OSD_BLEND_REORDER(0, 1) |
^~~~~~~~~~~~~~~~~~~~~--- drivers/gpu/drm/meson/meson_viu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/meson/meson_viu.c +11 -11
@@ -469,17 +469,17 @@ void meson_viu_init(struct meson_drm *priv) priv->io_base + _REG(VD2_IF0_LUMA_FIFO_SIZE));if (meson_vpu_is_compatible (priv,VPU_COMPATIBLE_G12A )) { -writel_relaxed (VIU_OSD_BLEND_REORDER (0 ,1 ) | -VIU_OSD_BLEND_REORDER (1 ,0 ) | -VIU_OSD_BLEND_REORDER (2 ,0 ) | -VIU_OSD_BLEND_REORDER (3 ,0 ) | -VIU_OSD_BLEND_DIN_EN (1 ) | -VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 | -VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 | -VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 | -VIU_OSD_BLEND_BLEN2_PREMULT_EN (1 ) | -VIU_OSD_BLEND_HOLD_LINES (4 ), - priv->io_base +_REG (VIU_OSD_BLEND_CTRL )); +u32 val = (u32 )VIU_OSD_BLEND_REORDER (0 ,1 ) | + (u32 )VIU_OSD_BLEND_REORDER (1 ,0 ) | + (u32 )VIU_OSD_BLEND_REORDER (2 ,0 ) | + (u32 )VIU_OSD_BLEND_REORDER (3 ,0 ) | + (u32 )VIU_OSD_BLEND_DIN_EN (1 ) | + (u32 )VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 | + (u32 )VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 | + (u32 )VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 | + (u32 )VIU_OSD_BLEND_BLEN2_PREMULT_EN (1 ) | + (u32 )VIU_OSD_BLEND_HOLD_LINES (4 ); +writel_relaxed (val, priv->io_base +_REG (VIU_OSD_BLEND_CTRL ));writel_relaxed (OSD_BLEND_PATH_SEL_ENABLE , priv->io_base +_REG (OSD1_BLEND_SRC_CTRL ));
Signature · 7 lines
2.35.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Sasha Levin
maintainerPATCH 17/64 clk: ti: Stop using legacy clkctrl names for omap4 and 5
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 255584b138343d4a28c6d25bd82d04b09460d672 ]
With the addition of clock-output-names, we can now unify the internal clock naming for omap4 and 5 to follow the other TI SoCs.
We are still using legacy clkctrl names for omap4 and 5 based on the clock manager name which is wrong. Instead, we want to use the clkctrl clock based naming.
We must now also drop the legacy TI_CLK_CLKCTRL_COMPAT quirk for the clkctrl clock.
This change will allow further devicetree warning cleanup as already done for am3/4 and dra7.
--- drivers/clk/ti/clk-44xx.c | 210 +++++++++++++++++++------------------- drivers/clk/ti/clk-54xx.c | 160 ++++++++++++++--------------- drivers/clk/ti/clkctrl.c | 4 - 3 files changed, 185 insertions(+), 189 deletions(-)
drivers/clk/ti/clk-44xx.c +105 -105
@@ -56,7 +56,7 @@ static const struct omap_clkctrl_bit_data omap4_aess_bit_data[] __initconst = { };static const char *const omap4_func_dmic_abe_gfclk_parents[]__initconst = { -"abe_cm:clk:0018:26" , +"abe-clkctrl:0018:26" ,"pad_clks_ck" ,"slimbus_clk" ,NULL ,
@@ -76,7 +76,7 @@ static const struct omap_clkctrl_bit_data omap4_dmic_bit_data[] __initconst = { };static const char *const omap4_func_mcasp_abe_gfclk_parents[]__initconst = { -"abe_cm:clk:0020:26" , +"abe-clkctrl:0020:26" ,"pad_clks_ck" ,"slimbus_clk" ,NULL ,
@@ -89,7 +89,7 @@ static const struct omap_clkctrl_bit_data omap4_mcasp_bit_data[] __initconst = { };static const char *const omap4_func_mcbsp1_gfclk_parents[]__initconst = { -"abe_cm:clk:0028:26" , +"abe-clkctrl:0028:26" ,"pad_clks_ck" ,"slimbus_clk" ,NULL ,
@@ -102,7 +102,7 @@ static const struct omap_clkctrl_bit_data omap4_mcbsp1_bit_data[] __initconst = };static const char *const omap4_func_mcbsp2_gfclk_parents[]__initconst = { -"abe_cm:clk:0030:26" , +"abe-clkctrl:0030:26" ,"pad_clks_ck" ,"slimbus_clk" ,NULL ,
@@ -115,7 +115,7 @@ static const struct omap_clkctrl_bit_data omap4_mcbsp2_bit_data[] __initconst = };static const char *const omap4_func_mcbsp3_gfclk_parents[]__initconst = { -"abe_cm:clk:0038:26" , +"abe-clkctrl:0038:26" ,"pad_clks_ck" ,"slimbus_clk" ,NULL ,
@@ -183,18 +183,18 @@ static const struct omap_clkctrl_bit_data omap4_timer8_bit_data[] __initconst =static const struct omap_clkctrl_reg_data omap4_abe_clkctrl_regs[]__initconst = { {OMAP4_L4_ABE_CLKCTRL ,NULL ,0 ,"ocp_abe_iclk" }, - {OMAP4_AESS_CLKCTRL , omap4_aess_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0008:24" }, + {OMAP4_AESS_CLKCTRL , omap4_aess_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0008:24" }, {OMAP4_MCPDM_CLKCTRL ,NULL ,CLKF_SW_SUP ,"pad_clks_ck" }, - {OMAP4_DMIC_CLKCTRL , omap4_dmic_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0018:24" }, - {OMAP4_MCASP_CLKCTRL , omap4_mcasp_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0020:24" }, - {OMAP4_MCBSP1_CLKCTRL , omap4_mcbsp1_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0028:24" }, - {OMAP4_MCBSP2_CLKCTRL , omap4_mcbsp2_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0030:24" }, - {OMAP4_MCBSP3_CLKCTRL , omap4_mcbsp3_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0038:24" }, - {OMAP4_SLIMBUS1_CLKCTRL , omap4_slimbus1_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0040:8" }, - {OMAP4_TIMER5_CLKCTRL , omap4_timer5_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0048:24" }, - {OMAP4_TIMER6_CLKCTRL , omap4_timer6_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0050:24" }, - {OMAP4_TIMER7_CLKCTRL , omap4_timer7_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0058:24" }, - {OMAP4_TIMER8_CLKCTRL , omap4_timer8_bit_data,CLKF_SW_SUP ,"abe_cm:clk:0060:24" }, + {OMAP4_DMIC_CLKCTRL , omap4_dmic_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0018:24" }, + {OMAP4_MCASP_CLKCTRL , omap4_mcasp_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0020:24" }, + {OMAP4_MCBSP1_CLKCTRL , omap4_mcbsp1_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0028:24" }, + {OMAP4_MCBSP2_CLKCTRL , omap4_mcbsp2_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0030:24" }, + {OMAP4_MCBSP3_CLKCTRL , omap4_mcbsp3_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0038:24" }, + {OMAP4_SLIMBUS1_CLKCTRL , omap4_slimbus1_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0040:8" }, + {OMAP4_TIMER5_CLKCTRL , omap4_timer5_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0048:24" }, + {OMAP4_TIMER6_CLKCTRL , omap4_timer6_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0050:24" }, + {OMAP4_TIMER7_CLKCTRL , omap4_timer7_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0058:24" }, + {OMAP4_TIMER8_CLKCTRL , omap4_timer8_bit_data,CLKF_SW_SUP ,"abe-clkctrl:0060:24" }, {OMAP4_WD_TIMER3_CLKCTRL ,NULL ,CLKF_SW_SUP ,"sys_32k_ck" }, {0 }, };
@@ -287,7 +287,7 @@ static const struct omap_clkctrl_bit_data omap4_fdif_bit_data[] __initconst = {static const struct omap_clkctrl_reg_data omap4_iss_clkctrl_regs[]__initconst = { {OMAP4_ISS_CLKCTRL , omap4_iss_bit_data,CLKF_SW_SUP ,"ducati_clk_mux_ck" }, - {OMAP4_FDIF_CLKCTRL , omap4_fdif_bit_data,CLKF_SW_SUP ,"iss_cm:clk:0008:24" }, + {OMAP4_FDIF_CLKCTRL , omap4_fdif_bit_data,CLKF_SW_SUP ,"iss-clkctrl:0008:24" }, {0 }, };
@@ -320,7 +320,7 @@ static const struct omap_clkctrl_bit_data omap4_dss_core_bit_data[] __initconst };static const struct omap_clkctrl_reg_data omap4_l3_dss_clkctrl_regs[]__initconst = { - {OMAP4_DSS_CORE_CLKCTRL , omap4_dss_core_bit_data,CLKF_SW_SUP ,"l3_dss_cm:clk:0000:8" }, + {OMAP4_DSS_CORE_CLKCTRL , omap4_dss_core_bit_data,CLKF_SW_SUP ,"l3-dss-clkctrl:0000:8" }, {0 }, };
@@ -336,7 +336,7 @@ static const struct omap_clkctrl_bit_data omap4_gpu_bit_data[] __initconst = { };static const struct omap_clkctrl_reg_data omap4_l3_gfx_clkctrl_regs[]__initconst = { - {OMAP4_GPU_CLKCTRL , omap4_gpu_bit_data,CLKF_SW_SUP ,"l3_gfx_cm:clk:0000:24" }, + {OMAP4_GPU_CLKCTRL , omap4_gpu_bit_data,CLKF_SW_SUP ,"l3-gfx-clkctrl:0000:24" }, {0 }, };
@@ -372,12 +372,12 @@ static const struct omap_clkctrl_bit_data omap4_hsi_bit_data[] __initconst = { };static const char *const omap4_usb_host_hs_utmi_p1_clk_parents[]__initconst = { -"l3_init_cm:clk:0038:24" , +"l3-init-clkctrl:0038:24" ,NULL , };static const char *const omap4_usb_host_hs_utmi_p2_clk_parents[]__initconst = { -"l3_init_cm:clk:0038:25" , +"l3-init-clkctrl:0038:25" ,NULL , };
@@ -418,7 +418,7 @@ static const struct omap_clkctrl_bit_data omap4_usb_host_hs_bit_data[] __initcon };static const char *const omap4_usb_otg_hs_xclk_parents[]__initconst = { -"l3_init_cm:clk:0040:24" , +"l3-init-clkctrl:0040:24" ,NULL , };
@@ -452,14 +452,14 @@ static const struct omap_clkctrl_bit_data omap4_ocp2scp_usb_phy_bit_data[] __ini };static const struct omap_clkctrl_reg_data omap4_l3_init_clkctrl_regs[]__initconst = { - {OMAP4_MMC1_CLKCTRL , omap4_mmc1_bit_data,CLKF_SW_SUP ,"l3_init_cm:clk:0008:24" }, - {OMAP4_MMC2_CLKCTRL , omap4_mmc2_bit_data,CLKF_SW_SUP ,"l3_init_cm:clk:0010:24" }, - {OMAP4_HSI_CLKCTRL , omap4_hsi_bit_data,CLKF_HW_SUP ,"l3_init_cm:clk:0018:24" }, + {OMAP4_MMC1_CLKCTRL , omap4_mmc1_bit_data,CLKF_SW_SUP ,"l3-init-clkctrl:0008:24" }, + {OMAP4_MMC2_CLKCTRL , omap4_mmc2_bit_data,CLKF_SW_SUP ,"l3-init-clkctrl:0010:24" }, + {OMAP4_HSI_CLKCTRL , omap4_hsi_bit_data,CLKF_HW_SUP ,"l3-init-clkctrl:0018:24" }, {OMAP4_USB_HOST_HS_CLKCTRL , omap4_usb_host_hs_bit_data,CLKF_SW_SUP ,"init_60m_fclk" }, {OMAP4_USB_OTG_HS_CLKCTRL , omap4_usb_otg_hs_bit_data,CLKF_HW_SUP ,"l3_div_ck" }, {OMAP4_USB_TLL_HS_CLKCTRL , omap4_usb_tll_hs_bit_data,CLKF_HW_SUP ,"l4_div_ck" }, {OMAP4_USB_HOST_FS_CLKCTRL ,NULL ,CLKF_SW_SUP ,"func_48mc_fclk" }, - {OMAP4_OCP2SCP_USB_PHY_CLKCTRL , omap4_ocp2scp_usb_phy_bit_data,CLKF_HW_SUP ,"l3_init_cm:clk:00c0:8" }, + {OMAP4_OCP2SCP_USB_PHY_CLKCTRL , omap4_ocp2scp_usb_phy_bit_data,CLKF_HW_SUP ,"l3-init-clkctrl:00c0:8" }, {0 }, };
@@ -530,7 +530,7 @@ static const struct omap_clkctrl_bit_data omap4_gpio6_bit_data[] __initconst = { };static const char *const omap4_per_mcbsp4_gfclk_parents[]__initconst = { -"l4_per_cm:clk:00c0:26" , +"l4-per-clkctrl:00c0:26" ,"pad_clks_ck" ,NULL , };
@@ -570,12 +570,12 @@ static const struct omap_clkctrl_bit_data omap4_slimbus2_bit_data[] __initconst };static const struct omap_clkctrl_reg_data omap4_l4_per_clkctrl_regs[]__initconst = { - {OMAP4_TIMER10_CLKCTRL , omap4_timer10_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0008:24" }, - {OMAP4_TIMER11_CLKCTRL , omap4_timer11_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0010:24" }, - {OMAP4_TIMER2_CLKCTRL , omap4_timer2_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0018:24" }, - {OMAP4_TIMER3_CLKCTRL , omap4_timer3_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0020:24" }, - {OMAP4_TIMER4_CLKCTRL , omap4_timer4_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0028:24" }, - {OMAP4_TIMER9_CLKCTRL , omap4_timer9_bit_data,CLKF_SW_SUP ,"l4_per_cm:clk:0030:24" }, + {OMAP4_TIMER10_CLKCTRL , omap4_timer10_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0008:24" }, + {OMAP4_TIMER11_CLKCTRL , omap4_timer11_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0010:24" }, + {OMAP4_TIMER2_CLKCTRL , omap4_timer2_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0018:24" }, + {OMAP4_TIMER3_CLKCTRL , omap4_timer3_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0020:24" }, + {OMAP4_TIMER4_CLKCTRL , omap4_timer4_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0028:24" }, + {OMAP4_TIMER9_CLKCTRL , omap4_timer9_bit_data,CLKF_SW_SUP ,"l4-per-clkctrl:0030:24" }, {OMAP4_ELM_CLKCTRL ,NULL ,0 ,"l4_div_ck" }, {OMAP4_GPIO2_CLKCTRL , omap4_gpio2_bit_data,CLKF_HW_SUP ,"l4_div_ck" }, {OMAP4_GPIO3_CLKCTRL , omap4_gpio3_bit_data,CLKF_HW_SUP ,"l4_div_ck" },
@@ -588,14 +588,14 @@ static const struct omap_clkctrl_reg_data omap4_l4_per_clkctrl_regs[] __initcons { OMAP4_I2C3_CLKCTRL, NULL, CLKF_SW_SUP, "func_96m_fclk" }, { OMAP4_I2C4_CLKCTRL, NULL, CLKF_SW_SUP, "func_96m_fclk" }, { OMAP4_L4_PER_CLKCTRL, NULL, 0, "l4_div_ck" }, - { OMAP4_MCBSP4_CLKCTRL, omap4_mcbsp4_bit_data, CLKF_SW_SUP, "l4_per_cm:clk:00c0:24" }, + { OMAP4_MCBSP4_CLKCTRL, omap4_mcbsp4_bit_data, CLKF_SW_SUP, "l4-per-clkctrl:00c0:24" }, { OMAP4_MCSPI1_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_MCSPI2_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_MCSPI3_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_MCSPI4_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_MMC3_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_MMC4_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, - { OMAP4_SLIMBUS2_CLKCTRL, omap4_slimbus2_bit_data, CLKF_SW_SUP, "l4_per_cm:clk:0118:8" }, + { OMAP4_SLIMBUS2_CLKCTRL, omap4_slimbus2_bit_data, CLKF_SW_SUP, "l4-per-clkctrl:0118:8" }, { OMAP4_UART1_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_UART2_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" }, { OMAP4_UART3_CLKCTRL, NULL, CLKF_SW_SUP, "func_48m_fclk" },
@@ -630,7 +630,7 @@ static const struct omap_clkctrl_reg_data omap4_l4_wkup_clkctrl_regs[] __initcon { OMAP4_L4_WKUP_CLKCTRL, NULL, 0, "l4_wkup_clk_mux_ck" }, { OMAP4_WD_TIMER2_CLKCTRL, NULL, CLKF_SW_SUP, "sys_32k_ck" }, { OMAP4_GPIO1_CLKCTRL, omap4_gpio1_bit_data, CLKF_HW_SUP, "l4_wkup_clk_mux_ck" }, - { OMAP4_TIMER1_CLKCTRL, omap4_timer1_bit_data, CLKF_SW_SUP, "l4_wkup_cm:clk:0020:24" }, + { OMAP4_TIMER1_CLKCTRL, omap4_timer1_bit_data, CLKF_SW_SUP, "l4-wkup-clkctrl:0020:24" }, { OMAP4_COUNTER_32K_CLKCTRL, NULL, 0, "sys_32k_ck" }, { OMAP4_KBD_CLKCTRL, NULL, CLKF_SW_SUP, "sys_32k_ck" }, { 0 },
@@ -644,7 +644,7 @@ static const char * const omap4_pmd_stm_clock_mux_ck_parents[] __initconst = { };static const char *const omap4_trace_clk_div_div_ck_parents[]__initconst = { -"emu_sys_cm:clk:0000:22" , +"emu-sys-clkctrl:0000:22" ,NULL , };
@@ -662,7 +662,7 @@ static const struct omap_clkctrl_div_data omap4_trace_clk_div_div_ck_data __init };static const char *const omap4_stm_clk_div_ck_parents[]__initconst = { -"emu_sys_cm:clk:0000:20" , +"emu-sys-clkctrl:0000:20" ,NULL , };
@@ -716,73 +716,73 @@ static struct ti_dt_clk omap44xx_clks[] = {* hwmod support. Once hwmod is removed, these can be removed * also. */ -DT_CLK (NULL ,"aess_fclk" ,"abe_cm:0008:24" ), -DT_CLK (NULL ,"cm2_dm10_mux" ,"l4_per_cm:0008:24" ), -DT_CLK (NULL ,"cm2_dm11_mux" ,"l4_per_cm:0010:24" ), -DT_CLK (NULL ,"cm2_dm2_mux" ,"l4_per_cm:0018:24" ), -DT_CLK (NULL ,"cm2_dm3_mux" ,"l4_per_cm:0020:24" ), -DT_CLK (NULL ,"cm2_dm4_mux" ,"l4_per_cm:0028:24" ), -DT_CLK (NULL ,"cm2_dm9_mux" ,"l4_per_cm:0030:24" ), -DT_CLK (NULL ,"dmic_sync_mux_ck" ,"abe_cm:0018:26" ), -DT_CLK (NULL ,"dmt1_clk_mux" ,"l4_wkup_cm:0020:24" ), -DT_CLK (NULL ,"dss_48mhz_clk" ,"l3_dss_cm:0000:9" ), -DT_CLK (NULL ,"dss_dss_clk" ,"l3_dss_cm:0000:8" ), -DT_CLK (NULL ,"dss_sys_clk" ,"l3_dss_cm:0000:10" ), -DT_CLK (NULL ,"dss_tv_clk" ,"l3_dss_cm:0000:11" ), -DT_CLK (NULL ,"fdif_fck" ,"iss_cm:0008:24" ), -DT_CLK (NULL ,"func_dmic_abe_gfclk" ,"abe_cm:0018:24" ), -DT_CLK (NULL ,"func_mcasp_abe_gfclk" ,"abe_cm:0020:24" ), -DT_CLK (NULL ,"func_mcbsp1_gfclk" ,"abe_cm:0028:24" ), -DT_CLK (NULL ,"func_mcbsp2_gfclk" ,"abe_cm:0030:24" ), -DT_CLK (NULL ,"func_mcbsp3_gfclk" ,"abe_cm:0038:24" ), -DT_CLK (NULL ,"gpio1_dbclk" ,"l4_wkup_cm:0018:8" ), -DT_CLK (NULL ,"gpio2_dbclk" ,"l4_per_cm:0040:8" ), -DT_CLK (NULL ,"gpio3_dbclk" ,"l4_per_cm:0048:8" ), -DT_CLK (NULL ,"gpio4_dbclk" ,"l4_per_cm:0050:8" ), -DT_CLK (NULL ,"gpio5_dbclk" ,"l4_per_cm:0058:8" ), -DT_CLK (NULL ,"gpio6_dbclk" ,"l4_per_cm:0060:8" ), -DT_CLK (NULL ,"hsi_fck" ,"l3_init_cm:0018:24" ), -DT_CLK (NULL ,"hsmmc1_fclk" ,"l3_init_cm:0008:24" ), -DT_CLK (NULL ,"hsmmc2_fclk" ,"l3_init_cm:0010:24" ), -DT_CLK (NULL ,"iss_ctrlclk" ,"iss_cm:0000:8" ), -DT_CLK (NULL ,"mcasp_sync_mux_ck" ,"abe_cm:0020:26" ), -DT_CLK (NULL ,"mcbsp1_sync_mux_ck" ,"abe_cm:0028:26" ), -DT_CLK (NULL ,"mcbsp2_sync_mux_ck" ,"abe_cm:0030:26" ), -DT_CLK (NULL ,"mcbsp3_sync_mux_ck" ,"abe_cm:0038:26" ), -DT_CLK (NULL ,"mcbsp4_sync_mux_ck" ,"l4_per_cm:00c0:26" ), -DT_CLK (NULL ,"ocp2scp_usb_phy_phy_48m" ,"l3_init_cm:00c0:8" ), -DT_CLK (NULL ,"otg_60m_gfclk" ,"l3_init_cm:0040:24" ), -DT_CLK (NULL ,"per_mcbsp4_gfclk" ,"l4_per_cm:00c0:24" ), -DT_CLK (NULL ,"pmd_stm_clock_mux_ck" ,"emu_sys_cm:0000:20" ), -DT_CLK (NULL ,"pmd_trace_clk_mux_ck" ,"emu_sys_cm:0000:22" ), -DT_CLK (NULL ,"sgx_clk_mux" ,"l3_gfx_cm:0000:24" ), -DT_CLK (NULL ,"slimbus1_fclk_0" ,"abe_cm:0040:8" ), -DT_CLK (NULL ,"slimbus1_fclk_1" ,"abe_cm:0040:9" ), -DT_CLK (NULL ,"slimbus1_fclk_2" ,"abe_cm:0040:10" ), -DT_CLK (NULL ,"slimbus1_slimbus_clk" ,"abe_cm:0040:11" ), -DT_CLK (NULL ,"slimbus2_fclk_0" ,"l4_per_cm:0118:8" ), -DT_CLK (NULL ,"slimbus2_fclk_1" ,"l4_per_cm:0118:9" ), -DT_CLK (NULL ,"slimbus2_slimbus_clk" ,"l4_per_cm:0118:10" ), -DT_CLK (NULL ,"stm_clk_div_ck" ,"emu_sys_cm:0000:27" ), -DT_CLK (NULL ,"timer5_sync_mux" ,"abe_cm:0048:24" ), -DT_CLK (NULL ,"timer6_sync_mux" ,"abe_cm:0050:24" ), -DT_CLK (NULL ,"timer7_sync_mux" ,"abe_cm:0058:24" ), -DT_CLK (NULL ,"timer8_sync_mux" ,"abe_cm:0060:24" ), -DT_CLK (NULL ,"trace_clk_div_div_ck" ,"emu_sys_cm:0000:24" ), -DT_CLK (NULL ,"usb_host_hs_func48mclk" ,"l3_init_cm:0038:15" ), -DT_CLK (NULL ,"usb_host_hs_hsic480m_p1_clk" ,"l3_init_cm:0038:13" ), -DT_CLK (NULL ,"usb_host_hs_hsic480m_p2_clk" ,"l3_init_cm:0038:14" ), -DT_CLK (NULL ,"usb_host_hs_hsic60m_p1_clk" ,"l3_init_cm:0038:11" ), -DT_CLK (NULL ,"usb_host_hs_hsic60m_p2_clk" ,"l3_init_cm:0038:12" ), -DT_CLK (NULL ,"usb_host_hs_utmi_p1_clk" ,"l3_init_cm:0038:8" ), -DT_CLK (NULL ,"usb_host_hs_utmi_p2_clk" ,"l3_init_cm:0038:9" ), -DT_CLK (NULL ,"usb_host_hs_utmi_p3_clk" ,"l3_init_cm:0038:10" ), -DT_CLK (NULL ,"usb_otg_hs_xclk" ,"l3_init_cm:0040:8" ), -DT_CLK (NULL ,"usb_tll_hs_usb_ch0_clk" ,"l3_init_cm:0048:8" ), -DT_CLK (NULL ,"usb_tll_hs_usb_ch1_clk" ,"l3_init_cm:0048:9" ), -DT_CLK (NULL ,"usb_tll_hs_usb_ch2_clk" ,"l3_init_cm:0048:10" ), -DT_CLK (NULL ,"utmi_p1_gfclk" ,"l3_init_cm:0038:24" ), -DT_CLK (NULL ,"utmi_p2_gfclk" ,"l3_init_cm:0038:25" ), +DT_CLK (NULL ,"aess_fclk" ,"abe-clkctrl:0008:24" ), +DT_CLK (NULL ,"cm2_dm10_mux" ,"l4-per-clkctrl:0008:24" ), +DT_CLK (NULL ,"cm2_dm11_mux" ,"l4-per-clkctrl:0010:24" ), +DT_CLK (NULL ,"cm2_dm2_mux" ,"l4-per-clkctrl:0018:24" ), +DT_CLK (NULL ,"cm2_dm3_mux" ,"l4-per-clkctrl:0020:24" ), +DT_CLK (NULL ,"cm2_dm4_mux" ,"l4-per-clkctrl:0028:24" ), +DT_CLK (NULL ,"cm2_dm9_mux" ,"l4-per-clkctrl:0030:24" ), +DT_CLK (NULL ,"dmic_sync_mux_ck" ,"abe-clkctrl:0018:26" ), +DT_CLK (NULL ,"dmt1_clk_mux" ,"l4-wkup-clkctrl:0020:24" ), +DT_CLK (NULL ,"dss_48mhz_clk" ,"l3-dss-clkctrl:0000:9" ), +DT_CLK (NULL ,"dss_dss_clk" ,"l3-dss-clkctrl:0000:8" ), +DT_CLK (NULL ,"dss_sys_clk" ,"l3-dss-clkctrl:0000:10" ), +DT_CLK (NULL ,"dss_tv_clk" ,"l3-dss-clkctrl:0000:11" ), +DT_CLK (NULL ,"fdif_fck" ,"iss-clkctrl:0008:24" ), +DT_CLK (NULL ,"func_dmic_abe_gfclk" ,"abe-clkctrl:0018:24" ), +DT_CLK (NULL ,"func_mcasp_abe_gfclk" ,"abe-clkctrl:0020:24" ), +DT_CLK (NULL ,"func_mcbsp1_gfclk" ,"abe-clkctrl:0028:24" ), +DT_CLK (NULL ,"func_mcbsp2_gfclk" ,"abe-clkctrl:0030:24" ), +DT_CLK (NULL ,"func_mcbsp3_gfclk" ,"abe-clkctrl:0038:24" ), +DT_CLK (NULL ,"gpio1_dbclk" ,"l4-wkup-clkctrl:0018:8" ), +DT_CLK (NULL ,"gpio2_dbclk" ,"l4-per-clkctrl:0040:8" ), +DT_CLK (NULL ,"gpio3_dbclk" ,"l4-per-clkctrl:0048:8" ), +DT_CLK (NULL ,"gpio4_dbclk" ,"l4-per-clkctrl:0050:8" ), +DT_CLK (NULL ,"gpio5_dbclk" ,"l4-per-clkctrl:0058:8" ), +DT_CLK (NULL ,"gpio6_dbclk" ,"l4-per-clkctrl:0060:8" ), +DT_CLK (NULL ,"hsi_fck" ,"l3-init-clkctrl:0018:24" ), +DT_CLK (NULL ,"hsmmc1_fclk" ,"l3-init-clkctrl:0008:24" ), +DT_CLK (NULL ,"hsmmc2_fclk" ,"l3-init-clkctrl:0010:24" ), +DT_CLK (NULL ,"iss_ctrlclk" ,"iss-clkctrl:0000:8" ), +DT_CLK (NULL ,"mcasp_sync_mux_ck" ,"abe-clkctrl:0020:26" ), +DT_CLK (NULL ,"mcbsp1_sync_mux_ck" ,"abe-clkctrl:0028:26" ), +DT_CLK (NULL ,"mcbsp2_sync_mux_ck" ,"abe-clkctrl:0030:26" ), +DT_CLK (NULL ,"mcbsp3_sync_mux_ck" ,"abe-clkctrl:0038:26" ), +DT_CLK (NULL ,"mcbsp4_sync_mux_ck" ,"l4-per-clkctrl:00c0:26" ), +DT_CLK (NULL ,"ocp2scp_usb_phy_phy_48m" ,"l3-init-clkctrl:00c0:8" ), +DT_CLK (NULL ,"otg_60m_gfclk" ,"l3-init-clkctrl:0040:24" ), +DT_CLK (NULL ,"per_mcbsp4_gfclk" ,"l4-per-clkctrl:00c0:24" ), +DT_CLK (NULL ,"pmd_stm_clock_mux_ck" ,"emu-sys-clkctrl:0000:20" ), +DT_CLK (NULL ,"pmd_trace_clk_mux_ck" ,"emu-sys-clkctrl:0000:22" ), +DT_CLK (NULL ,"sgx_clk_mux" ,"l3-gfx-clkctrl:0000:24" ), +DT_CLK (NULL ,"slimbus1_fclk_0" ,"abe-clkctrl:0040:8" ), +DT_CLK (NULL ,"slimbus1_fclk_1" ,"abe-clkctrl:0040:9" ), +DT_CLK (NULL ,"slimbus1_fclk_2" ,"abe-clkctrl:0040:10" ), +DT_CLK (NULL ,"slimbus1_slimbus_clk" ,"abe-clkctrl:0040:11" ), +DT_CLK (NULL ,"slimbus2_fclk_0" ,"l4-per-clkctrl:0118:8" ), +DT_CLK (NULL ,"slimbus2_fclk_1" ,"l4-per-clkctrl:0118:9" ), +DT_CLK (NULL ,"slimbus2_slimbus_clk" ,"l4-per-clkctrl:0118:10" ), +DT_CLK (NULL ,"stm_clk_div_ck" ,"emu-sys-clkctrl:0000:27" ), +DT_CLK (NULL ,"timer5_sync_mux" ,"abe-clkctrl:0048:24" ), +DT_CLK (NULL ,"timer6_sync_mux" ,"abe-clkctrl:0050:24" ), +DT_CLK (NULL ,"timer7_sync_mux" ,"abe-clkctrl:0058:24" ), +DT_CLK (NULL ,"timer8_sync_mux" ,"abe-clkctrl:0060:24" ), +DT_CLK (NULL ,"trace_clk_div_div_ck" ,"emu-sys-clkctrl:0000:24" ), +DT_CLK (NULL ,"usb_host_hs_func48mclk" ,"l3-init-clkctrl:0038:15" ), +DT_CLK (NULL ,"usb_host_hs_hsic480m_p1_clk" ,"l3-init-clkctrl:0038:13" ), +DT_CLK (NULL ,"usb_host_hs_hsic480m_p2_clk" ,"l3-init-clkctrl:0038:14" ), +DT_CLK (NULL ,"usb_host_hs_hsic60m_p1_clk" ,"l3-init-clkctrl:0038:11" ), +DT_CLK (NULL ,"usb_host_hs_hsic60m_p2_clk" ,"l3-init-clkctrl:0038:12" ), +DT_CLK (NULL ,"usb_host_hs_utmi_p1_clk" ,"l3-init-clkctrl:0038:8" ), +DT_CLK (NULL ,"usb_host_hs_utmi_p2_clk" ,"l3-init-clkctrl:0038:9" ), +DT_CLK (NULL ,"usb_host_hs_utmi_p3_clk" ,"l3_init-clkctrl:0038:10" ), +DT_CLK (NULL ,"usb_otg_hs_xclk" ,"l3-init-clkctrl:0040:8" ), +DT_CLK (NULL ,"usb_tll_hs_usb_ch0_clk" ,"l3-init-clkctrl:0048:8" ), +DT_CLK (NULL ,"usb_tll_hs_usb_ch1_clk" ,"l3-init-clkctrl:0048:9" ), +DT_CLK (NULL ,"usb_tll_hs_usb_ch2_clk" ,"l3-init-clkctrl:0048:10" ), +DT_CLK (NULL ,"utmi_p1_gfclk" ,"l3-init-clkctrl:0038:24" ), +DT_CLK (NULL ,"utmi_p2_gfclk" ,"l3-init-clkctrl:0038:25" ), { .node_name = NULL }, };
drivers/clk/ti/clk-54xx.c +80 -80
249 lines not on this page · raw message
drivers/clk/ti/clkctrl.c +0 -4
@@ -528,10 +528,6 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)char *c;u16 soc_mask =0 ; -if (!(ti_clk_get_features ()->flags &TI_CLK_CLKCTRL_COMPAT ) && -of_node_name_eq (node,"clk" )) - ti_clk_features.flags |=TI_CLK_CLKCTRL_COMPAT ; - addrp =of_get_address (node,0 ,NULL ,NULL ); addr = (u32 )of_translate_address (node, addrp);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 18/64 scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators
In reply to Sasha LevinFrom: Po-Wen Kao <[email protected]>
[ Upstream commit 3fd23b8dfb54d9b74eba6dfdd3225db3ac116785 ]
Currently the LPM configurations of device regulators may not work since VCC is not disabled yet while ufs_mtk_vreg_set_lpm() is executed.
Fix this by changing the timing of invoking ufs_mtk_vreg_set_lpm().
--- drivers/ufs/host/ufs-mediatek.c | 58 ++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-)
drivers/ufs/host/ufs-mediatek.c +53 -5
@@ -1026,7 +1026,6 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,* ufshcd_suspend() re-enabling regulators while vreg is still * in low-power mode. */ -ufs_mtk_vreg_set_lpm (hba, true); err =ufs_mtk_mphy_power_on (hba, false);if (err) goto fail;
@@ -1050,12 +1049,13 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) {int err; +if (hba->ufshcd_state !=UFSHCD_STATE_OPERATIONAL ) +ufs_mtk_vreg_set_lpm (hba, false); + err =ufs_mtk_mphy_power_on (hba, true);if (err) goto fail; -ufs_mtk_vreg_set_lpm (hba, false); -if (ufshcd_is_link_hibern8 (hba)) { err =ufs_mtk_link_set_hpm (hba);if (err)
@@ -1220,9 +1220,57 @@ static int ufs_mtk_remove(struct platform_device *pdev)return 0 ; } +int ufs_mtk_system_suspend (struct device *dev) +{ +struct ufs_hba *hba =dev_get_drvdata (dev); +int ret; + + ret =ufshcd_system_suspend (dev); +if (ret) +return ret; + +ufs_mtk_vreg_set_lpm (hba, true); + +return 0 ; +} + +int ufs_mtk_system_resume (struct device *dev) +{ +struct ufs_hba *hba =dev_get_drvdata (dev); + +ufs_mtk_vreg_set_lpm (hba, false); + +return ufshcd_system_resume (dev); +} + +int ufs_mtk_runtime_suspend (struct device *dev) +{ +struct ufs_hba *hba =dev_get_drvdata (dev); +int ret =0 ; + + ret =ufshcd_runtime_suspend (dev); +if (ret) +return ret; + +ufs_mtk_vreg_set_lpm (hba, true); + +return 0 ; +} + +int ufs_mtk_runtime_resume (struct device *dev) +{ +struct ufs_hba *hba =dev_get_drvdata (dev); + +ufs_mtk_vreg_set_lpm (hba, false); + +return ufshcd_runtime_resume (dev); +} +static const struct dev_pm_ops ufs_mtk_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume) -SET_RUNTIME_PM_OPS (ufshcd_runtime_suspend, ufshcd_runtime_resume,NULL ) + SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, + ufs_mtk_system_resume) +SET_RUNTIME_PM_OPS (ufs_mtk_runtime_suspend, + ufs_mtk_runtime_resume,NULL ) .prepare = ufshcd_suspend_prepare, .complete = ufshcd_resume_complete, };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 19/64 usb: typec: mux: Add CONFIG guards for functions
In reply to Sasha LevinFrom: Prashant Malani <[email protected]>
[ Upstream commit a37599ebfb656c2af4ca119de556eba29b6926d6 ]
There are some drivers that can use the Type C mux API, but don't have to. Introduce CONFIG guards for the mux functions so that drivers can include the header file and not run into compilation errors on systems which don't have CONFIG_TYPEC enabled. When CONFIG_TYPEC is not enabled, the Type C mux functions will be stub versions of the original calls.
--- include/linux/usb/typec_mux.h | 44 ++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-)
include/linux/usb/typec_mux.h +38 -6
@@ -58,17 +58,13 @@ struct typec_mux_desc {void *drvdata; }; +#if IS_ENABLED (CONFIG_TYPEC ) +struct typec_mux *fwnode_typec_mux_get (struct fwnode_handle *fwnode,const struct typec_altmode_desc *desc);void typec_mux_put (struct typec_mux *mux);int typec_mux_set (struct typec_mux *mux,struct typec_mux_state *state); -static inline struct typec_mux * -typec_mux_get (struct device *dev,const struct typec_altmode_desc *desc) -{ -return fwnode_typec_mux_get (dev_fwnode (dev), desc); -} -struct typec_mux_dev *typec_mux_register (struct device *parent,const struct typec_mux_desc *desc);void typec_mux_unregister (struct typec_mux_dev *mux);
@@ -76,4 +72,40 @@ void typec_mux_unregister(struct typec_mux_dev *mux);void typec_mux_set_drvdata (struct typec_mux_dev *mux,void *data);void *typec_mux_get_drvdata (struct typec_mux_dev *mux); +#else + +static inline struct typec_mux *fwnode_typec_mux_get (struct fwnode_handle *fwnode, +const struct typec_altmode_desc *desc) +{ +return NULL ; +} + +static inline void typec_mux_put (struct typec_mux *mux) {} + +static inline int typec_mux_set (struct typec_mux *mux,struct typec_mux_state *state) +{ +return 0 ; +} + +static inline struct typec_mux_dev * +typec_mux_register (struct device *parent,const struct typec_mux_desc *desc) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline void typec_mux_unregister (struct typec_mux_dev *mux) {} + +static inline void typec_mux_set_drvdata (struct typec_mux_dev *mux,void *data) {} +static inline void *typec_mux_get_drvdata (struct typec_mux_dev *mux) +{ +return ERR_PTR (-EOPNOTSUPP ); +} + +#endif /* CONFIG_TYPEC */ + +static inline struct typec_mux * +typec_mux_get (struct device *dev,const struct typec_altmode_desc *desc) +{ +return fwnode_typec_mux_get (dev_fwnode (dev), desc); +} +#endif /* __USB_TYPEC_MUX */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 20/64 usb: host: ohci-ppc-of: Fix refcount leak bug
In reply to Sasha LevinFrom: Liang He <[email protected]>
[ Upstream commit 40a959d7042bb7711e404ad2318b30e9f92c6b9b ]
In ohci_hcd_ppc_of_probe(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
--- drivers/usb/host/ohci-ppc-of.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-ppc-of.c +1 -0
@@ -166,6 +166,7 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)release_mem_region (res.start,0x4 ); }else pr_debug ("%s: cannot get ehci offset from fdt\n" , __FILE__); +of_node_put (np); }irq_dispose_mapping (irq);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 21/64 usb: renesas: Fix refcount leak bug
In reply to Sasha LevinFrom: Liang He <[email protected]>
[ Upstream commit 9d6d5303c39b8bc182475b22f45504106a07f086 ]
In usbhs_rza1_hardware_init(), of_find_node_by_name() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
--- drivers/usb/renesas_usbhs/rza.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/renesas_usbhs/rza.c +4 -0
@@ -23,6 +23,10 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev) extal_clk =of_find_node_by_name (NULL ,"extal" );of_property_read_u32 (usb_x1_clk,"clock-frequency" , &freq_usb);of_property_read_u32 (extal_clk,"clock-frequency" , &freq_extal); + +of_node_put (usb_x1_clk); +of_node_put (extal_clk); +if (freq_usb ==0 ) {if (freq_extal ==12000000 ) {/* Select 12MHz XTAL */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 22/64 scsi: iscsi: Fix HW conn removal use after free
In reply to Sasha LevinFrom: Mike Christie <[email protected]>
[ Upstream commit c577ab7ba5f3bf9062db8a58b6e89d4fe370447e ]
If qla4xxx doesn't remove the connection before the session, the iSCSI class tries to remove the connection for it. We were doing a iscsi_put_conn() in the iter function which is not needed and will result in a use after free because iscsi_remove_conn() will free the connection.
--- drivers/scsi/scsi_transport_iscsi.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +0 -2
@@ -2143,8 +2143,6 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data)return 0 ;iscsi_remove_conn (iscsi_dev_to_conn (dev)); -iscsi_put_conn (iscsi_dev_to_conn (dev)); -return 0 ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 23/64 usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit db638c6500abaffb8f7770b2a69c40d003d54ae1 ]
When using usb-role-switch, D+ pull-up is set as soon as DTCL_SFTDISCON is cleared, whatever the vbus valid signal state is. The pull-up should not be set when vbus isn't present (this is determined by the drd controller).
This patch ensures that B-Session (so Peripheral role + vbus valid signal) is valid before clearing the DCTL_SFTDISCON bit when role switch is used. Keep original behavior when usb-role-switch isn't used.
--- drivers/usb/dwc2/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc2/gadget.c +2 -1
@@ -3594,7 +3594,8 @@ void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)void dwc2_hsotg_core_connect (struct dwc2_hsotg *hsotg) {/* remove the soft-disconnect and let's go */ -dwc2_clear_bit (hsotg,DCTL ,DCTL_SFTDISCON ); +if (!hsotg->role_sw || (dwc2_readl (hsotg,GOTGCTL ) &GOTGCTL_BSESVLD )) +dwc2_clear_bit (hsotg,DCTL ,DCTL_SFTDISCON ); }/**
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 24/64 vboxguest: Do not use devm for irq
In reply to Sasha LevinFrom: Pascal Terjan <[email protected]>
[ Upstream commit 6169525b76764acb81918aa387ac168fb9a55575 ]
When relying on devm it doesn't get freed early enough which causes the following warning when unloading the module:
[249348.837181] remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'vboxguest' [249348.837219] WARNING: CPU: 0 PID: 6708 at fs/proc/generic.c:715 remove_proc_entry+0x119/0x140
[249348.837379] Call Trace: [249348.837385] unregister_irq_proc+0xbd/0xe0 [249348.837392] free_desc+0x23/0x60 [249348.837396] irq_free_descs+0x4a/0x70 [249348.837401] irq_domain_free_irqs+0x160/0x1a0 [249348.837452] mp_unmap_irq+0x5c/0x60 [249348.837458] acpi_unregister_gsi_ioapic+0x29/0x40 [249348.837463] acpi_unregister_gsi+0x17/0x30 [249348.837467] acpi_pci_irq_disable+0xbf/0xe0 [249348.837473] pcibios_disable_device+0x20/0x30 [249348.837478] pci_disable_device+0xef/0x120 [249348.837482] vbg_pci_remove+0x6c/0x70 [vboxguest]
--- drivers/virt/vboxguest/vboxguest_linux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/virt/vboxguest/vboxguest_linux.c +6 -3
@@ -356,8 +356,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) goto err_vbg_core_exit; } - ret =devm_request_irq (dev, pci->irq, vbg_core_isr,IRQF_SHARED , -DEVICE_NAME , gdev); + ret =request_irq (pci->irq, vbg_core_isr,IRQF_SHARED ,DEVICE_NAME , + gdev);if (ret) {vbg_err ("vboxguest: Error requesting irq: %d\n" , ret); goto err_vbg_core_exit;
@@ -367,7 +367,7 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)if (ret) {vbg_err ("vboxguest: Error misc_register %s failed: %d\n" ,DEVICE_NAME , ret); - goto err_vbg_core_exit; + goto err_free_irq; } ret =misc_register (&gdev->misc_device_user);
@@ -403,6 +403,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)misc_deregister (&gdev->misc_device_user); err_unregister_misc_device:misc_deregister (&gdev->misc_device); +err_free_irq: +free_irq (pci->irq, gdev); err_vbg_core_exit:vbg_core_exit (gdev); err_disable_pcidev:
@@ -419,6 +421,7 @@ static void vbg_pci_remove(struct pci_dev *pci) vbg_gdev =NULL ;mutex_unlock (&vbg_gdev_mutex); +free_irq (pci->irq, gdev);device_remove_file (gdev->dev, &dev_attr_host_features);device_remove_file (gdev->dev, &dev_attr_host_version);misc_deregister (&gdev->misc_device_user);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 25/64 clk: qcom: ipq8074: dont disable gcc_sleep_clk_src
In reply to Sasha LevinFrom: Robert Marko <[email protected]>
[ Upstream commit 1bf7305e79aab095196131bdc87a97796e0e3fac ]
Once the usb sleep clocks are disabled, clock framework is trying to disable the sleep clock source also.
However, it seems that it cannot be disabled and trying to do so produces:
[ 245.436390] ------------[ cut here ]------------ [ 245.441233] gcc_sleep_clk_src status stuck at 'on' [ 245.441254] WARNING: CPU: 2 PID: 223 at clk_branch_wait+0x130/0x140 [ 245.450435] Modules linked in: xhci_plat_hcd xhci_hcd dwc3 dwc3_qcom leds_gpio [ 245.456601] CPU: 2 PID: 223 Comm: sh Not tainted 5.18.0-rc4 #215 [ 245.463889] Hardware name: Xiaomi AX9000 (DT) [ 245.470050] pstate: 204000c5 (nzCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 245.474307] pc : clk_branch_wait+0x130/0x140 [ 245.481073] lr : clk_branch_wait+0x130/0x140 [ 245.485588] sp : ffffffc009f2bad0 [ 245.489838] x29: ffffffc009f2bad0 x28: ffffff8003e6c800 x27: 0000000000000000 [ 245.493057] x26: 0000000000000000 x25: 0000000000000000 x24: ffffff800226ef20 [ 245.500175] x23: ffffffc0089ff550 x22: 0000000000000000 x21: ffffffc008476ad0 [ 245.507294] x20: 0000000000000000 x19: ffffffc00965ac70 x18: fffffffffffc51a7 [ 245.514413] x17: 68702e3030303837 x16: 3a6d726f6674616c x15: ffffffc089f2b777 [ 245.521531] x14: ffffffc0095c9d18 x13: 0000000000000129 x12: 0000000000000129 [ 245.528649] x11: 00000000ffffffea x10: ffffffc009621d18 x9 : 0000000000000001 [ 245.535767] x8 : 0000000000000001 x7 : 0000000000017fe8 x6 : 0000000000000001 [ 245.542885] x5 : ffffff803fdca6d8 x4 : 0000000000000000 x3 : 0000000000000027 [ 245.550002] x2 : 0000000000000027 x1 : 0000000000000023 x0 : 0000000000000026 [ 245.557122] Call trace: [ 245.564229] clk_branch_wait+0x130/0x140 [ 245.566490] clk_branch2_disable+0x2c/0x40 [ 245.570656] clk_core_disable+0x60/0xb0 [ 245.574561] clk_core_disable+0x68/0xb0 [ 245.578293] clk_disable+0x30/0x50 [ 245.582113] dwc3_qcom_remove+0x60/0xc0 [dwc3_qcom] [ 245.585588] platform_remove+0x28/0x60 [ 245.590361] device_remove+0x4c/0x80 [ 245.594179] device_release_driver_internal+0x1dc/0x230 [ 245.597914] device_driver_detach+0x18/0x30 [ 245.602861] unbind_store+0xec/0x110 [ 245.607027] drv_attr_store+0x24/0x40 [ 245.610847] sysfs_kf_write+0x44/0x60 [ 245.614405] kernfs_fop_write_iter+0x128/0x1c0 [ 245.618052] new_sync_write+0xc0/0x130 [ 245.622391] vfs_write+0x1d4/0x2a0 [ 245.626123] ksys_write+0x58/0xe0 [ 245.629508] __arm64_sys_write+0x1c/0x30 [ 245.632895] invoke_syscall.constprop.0+0x5c/0x110 [ 245.636890] do_el0_svc+0xa0/0x150 [ 245.641488] el0_svc+0x18/0x60 [ 245.644872] el0t_64_sync_handler+0xa4/0x130 [ 245.647914] el0t_64_sync+0x174/0x178 [ 245.652340] ---[ end trace 0000000000000000 ]---
So, add CLK_IS_CRITICAL flag to the clock so that the kernel won't try to disable the sleep clock.
--- drivers/clk/qcom/gcc-ipq8074.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/qcom/gcc-ipq8074.c +1 -0
@@ -662,6 +662,7 @@ static struct clk_branch gcc_sleep_clk_src = { }, .num_parents = 1, .ops = &clk_branch2_ops, + .flags = CLK_IS_CRITICAL, }, }, };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 26/64 uacce: Handle parent device removal or parent driver module rmmod
In reply to Sasha LevinFrom: Jean-Philippe Brucker <[email protected]>
[ Upstream commit 80fc671bcc0173836e9032b0c698ea74c13b9d7c ]
The uacce driver must deal with a possible removal of the parent device or parent driver module rmmod at any time.
Although uacce_remove(), called on device removal and on driver unbind, prevents future use of the uacce fops by removing the cdev, fops that were called before that point may still be running.
Serialize uacce_fops_open() and uacce_remove() with uacce->mutex. Serialize other fops against uacce_remove() with q->mutex. Since we need to protect uacce_fops_poll() which gets called on the fast path, replace uacce->queues_lock with q->mutex to improve scalability. The other fops are only used during setup.
uacce_queue_is_valid(), checked under q->mutex or uacce->mutex, denotes whether uacce_remove() has disabled all queues. If that is the case, don't go any further since the parent device is being removed and uacce->ops should not be called anymore.
--- drivers/misc/uacce/uacce.c | 133 ++++++++++++++++++++++++------------- include/linux/uacce.h | 6 +- 2 files changed, 91 insertions(+), 48 deletions(-)
drivers/misc/uacce/uacce.c +87 -46
@@ -9,43 +9,38 @@static struct class *uacce_class;static dev_t uacce_devt; -static DEFINE_MUTEX (uacce_mutex);static DEFINE_XARRAY_ALLOC (uacce_xa); -static int uacce_start_queue (struct uacce_queue *q) +/* +* If the parent driver or the device disappears, the queue state is invalid and +* ops are not usable anymore. +*/ +static bool uacce_queue_is_valid (struct uacce_queue *q) { -int ret =0 ; +return q->state ==UACCE_Q_INIT || q->state ==UACCE_Q_STARTED ; +} -mutex_lock (&uacce_mutex); +static int uacce_start_queue (struct uacce_queue *q) +{ +int ret; -if (q->state !=UACCE_Q_INIT ) { - ret = -EINVAL ; - goto out_with_lock; - } +if (q->state !=UACCE_Q_INIT ) +return -EINVAL ;if (q->uacce->ops->start_queue) { ret = q->uacce->ops->start_queue (q);if (ret <0 ) - goto out_with_lock; +return ret; } q->state =UACCE_Q_STARTED ; - -out_with_lock: -mutex_unlock (&uacce_mutex); - -return ret; +return 0 ; }static int uacce_put_queue (struct uacce_queue *q) {struct uacce_device *uacce = q->uacce; -mutex_lock (&uacce_mutex); - -if (q->state ==UACCE_Q_ZOMBIE ) - goto out; -if ((q->state ==UACCE_Q_STARTED ) && uacce->ops->stop_queue) uacce->ops->stop_queue (q);
@@ -54,8 +49,6 @@ static int uacce_put_queue(struct uacce_queue *q) uacce->ops->put_queue (q); q->state =UACCE_Q_ZOMBIE ; -out: -mutex_unlock (&uacce_mutex);return 0 ; }
@@ -65,20 +58,36 @@ static long uacce_fops_unl_ioctl(struct file *filep, {struct uacce_queue *q = filep->private_data;struct uacce_device *uacce = q->uacce; +long ret = -ENXIO ; + +/* +* uacce->ops->ioctl() may take the mmap_lock when copying arg to/from +* user. Avoid a circular lock dependency with uacce_fops_mmap(), which +* gets called with mmap_lock held, by taking uacce->mutex instead of +* q->mutex. Doing this in uacce_fops_mmap() is not possible because +* uacce_fops_open() calls iommu_sva_bind_device(), which takes +* mmap_lock, while holding uacce->mutex. +*/ +mutex_lock (&uacce->mutex); +if (!uacce_queue_is_valid (q)) + goto out_unlock;switch (cmd) {case UACCE_CMD_START_Q : -return uacce_start_queue (q); - + ret =uacce_start_queue (q); +break ;case UACCE_CMD_PUT_Q : -return uacce_put_queue (q); - + ret =uacce_put_queue (q); +break ;default : -if (!uacce->ops->ioctl) -return -EINVAL ; - -return uacce->ops->ioctl (q, cmd, arg); +if (uacce->ops->ioctl) + ret = uacce->ops->ioctl (q, cmd, arg); +else + ret = -EINVAL ; } +out_unlock: +mutex_unlock (&uacce->mutex); +return ret; }#ifdef CONFIG_COMPAT
@@ -136,6 +145,13 @@ static int uacce_fops_open(struct inode *inode, struct file *filep)if (!q)return -ENOMEM ; +mutex_lock (&uacce->mutex); + +if (!uacce->parent) { + ret = -EINVAL ; + goto out_with_mem; + } + ret =uacce_bind_queue (uacce, q);if (ret) goto out_with_mem;
@@ -152,10 +168,9 @@ static int uacce_fops_open(struct inode *inode, struct file *filep) filep->private_data = q; uacce->inode = inode; q->state =UACCE_Q_INIT ; - -mutex_lock (&uacce->queues_lock); +mutex_init (&q->mutex);list_add (&q->list, &uacce->queues); -mutex_unlock (&uacce->queues_lock); +mutex_unlock (&uacce->mutex);return 0 ;
@@ -163,18 +178,20 @@ static int uacce_fops_open(struct inode *inode, struct file *filep)uacce_unbind_queue (q); out_with_mem:kfree (q); +mutex_unlock (&uacce->mutex);return ret; }static int uacce_fops_release (struct inode *inode,struct file *filep) {struct uacce_queue *q = filep->private_data; +struct uacce_device *uacce = q->uacce; -mutex_lock (&q->uacce->queues_lock); -list_del (&q->list); -mutex_unlock (&q->uacce->queues_lock); +mutex_lock (&uacce->mutex);uacce_put_queue (q);uacce_unbind_queue (q); +list_del (&q->list); +mutex_unlock (&uacce->mutex);kfree (q);return 0 ;
@@ -217,10 +234,9 @@ static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma) vma->vm_private_data = q; qfr->type = type; -mutex_lock (&uacce_mutex); - -if (q->state !=UACCE_Q_INIT && q->state !=UACCE_Q_STARTED ) { - ret = -EINVAL ; +mutex_lock (&q->mutex); +if (!uacce_queue_is_valid (q)) { + ret = -ENXIO ; goto out_with_lock; }
@@ -248,12 +264,12 @@ static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma) } q->qfrs[type] = qfr; -mutex_unlock (&uacce_mutex); +mutex_unlock (&q->mutex);return ret; out_with_lock: -mutex_unlock (&uacce_mutex); +mutex_unlock (&q->mutex);kfree (qfr);return ret; }
@@ -262,12 +278,20 @@ static __poll_t uacce_fops_poll(struct file *file, poll_table *wait) {struct uacce_queue *q = file->private_data;struct uacce_device *uacce = q->uacce; +__poll_t ret =0 ; + +mutex_lock (&q->mutex); +if (!uacce_queue_is_valid (q)) + goto out_unlock;poll_wait (file, &q->wait, wait); +if (uacce->ops->is_q_updated && uacce->ops->is_q_updated (q)) -return EPOLLIN |EPOLLRDNORM ; + ret =EPOLLIN |EPOLLRDNORM ; -return 0 ; +out_unlock: +mutex_unlock (&q->mutex); +return ret; }static const struct file_operations uacce_fops = {
@@ -450,7 +474,7 @@ struct uacce_device *uacce_alloc(struct device *parent, goto err_with_uacce;INIT_LIST_HEAD (&uacce->queues); -mutex_init (&uacce->queues_lock); +mutex_init (&uacce->mutex);device_initialize (&uacce->dev); uacce->dev.devt =MKDEV (MAJOR (uacce_devt), uacce->dev_id); uacce->dev.class = uacce_class;
@@ -507,13 +531,23 @@ void uacce_remove(struct uacce_device *uacce)if (uacce->inode)unmap_mapping_range (uacce->inode->i_mapping,0 ,0 ,1 ); +/* +* uacce_fops_open() may be running concurrently, even after we remove +* the cdev. Holding uacce->mutex ensures that open() does not obtain a +* removed uacce device. +*/ +mutex_lock (&uacce->mutex);/* ensure no open queue remains */ -mutex_lock (&uacce->queues_lock);list_for_each_entry_safe (q, next_q, &uacce->queues, list) { +/* +* Taking q->mutex ensures that fops do not use the defunct +* uacce->ops after the queue is disabled. +*/ +mutex_lock (&q->mutex);uacce_put_queue (q); +mutex_unlock (&q->mutex);uacce_unbind_queue (q); } -mutex_unlock (&uacce->queues_lock);/* disable sva now since no opened queues */ uacce_disable_sva (uacce);
@@ -521,6 +555,13 @@ void uacce_remove(struct uacce_device *uacce)if (uacce->cdev)cdev_device_del (uacce->cdev, &uacce->dev);xa_erase (&uacce_xa, uacce->dev_id); +/* +* uacce exists as long as there are open fds, but ops will be freed +* now. Ensure that bugs cause NULL deref rather than use-after-free. +*/ + uacce->ops =NULL ; + uacce->parent =NULL ; +mutex_unlock (&uacce->mutex);put_device (&uacce->dev); }EXPORT_SYMBOL_GPL (uacce_remove);
include/linux/uacce.h +4 -2
@@ -70,6 +70,7 @@ enum uacce_q_state {* @wait: wait queue head * @list: index into uacce queues list * @qfrs: pointer of qfr regions +* @mutex: protects queue state * @state: queue state machine * @pasid: pasid associated to the mm * @handle: iommu_sva handle returned by iommu_sva_bind_device()
@@ -80,6 +81,7 @@ struct uacce_queue {wait_queue_head_t wait;struct list_head list;struct uacce_qfile_region *qfrs[UACCE_MAX_REGION ]; +struct mutex mutex;enum uacce_q_state state;u32 pasid;struct iommu_sva *handle;
@@ -97,9 +99,9 @@ struct uacce_queue {* @dev_id: id of the uacce device * @cdev: cdev of the uacce * @dev: dev of the uacce +* @mutex: protects uacce operation * @priv: private pointer of the uacce * @queues: list of queues -* @queues_lock: lock for queues list * @inode: core vfs */ struct uacce_device {
@@ -113,9 +115,9 @@ struct uacce_device {u32 dev_id;struct cdev *cdev;struct device dev; +struct mutex mutex;void *priv;struct list_head queues; -struct mutex queues_lock;struct inode *inode; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 27/64 zram: do not lookup algorithm in backends table
In reply to Sasha LevinFrom: Sergey Senozhatsky <[email protected]>
[ Upstream commit dc89997264de565999a1cb55db3f295d3a8e457b ]
Always use crypto_has_comp() so that crypto can lookup module, call usermodhelper to load the modules, wait for usermodhelper to finish and so on. Otherwise crypto will do all of these steps under CPU hot-plug lock and this looks like too much stuff to handle under the CPU hot-plug lock. Besides this can end up in a deadlock when usermodhelper triggers a code path that attempts to lock the CPU hot-plug lock, that zram already holds.
An example of such deadlock:
- path A. zram grabs CPU hot-plug lock, execs /sbin/modprobe from crypto and waits for modprobe to finish
disksize_store
zcomp_create
__cpuhp_state_add_instance
__cpuhp_state_add_instance_cpuslocked
zcomp_cpu_up_prepare
crypto_alloc_base
crypto_alg_mod_lookup
call_usermodehelper_exec
wait_for_completion_killable
do_wait_for_common
schedule
- path B. async work kthread that brings in scsi device. It wants to register CPUHP states at some point, and it needs the CPU hot-plug lock for that, which is owned by zram.
async_run_entry_fn
scsi_probe_and_add_lun
scsi_mq_alloc_queue
blk_mq_init_queue
blk_mq_init_allocated_queue
blk_mq_realloc_hw_ctxs
__cpuhp_state_add_instance
__cpuhp_state_add_instance_cpuslocked
mutex_lock
schedule
- path C. modprobe sleeps, waiting for all aync works to finish.
load_module
do_init_module
async_synchronize_full
async_synchronize_cookie_domain
schedule
--- drivers/block/zram/zcomp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/block/zram/zcomp.c +5 -6
@@ -63,12 +63,6 @@ static int zcomp_strm_init(struct zcomp_strm *zstrm, struct zcomp *comp)bool zcomp_available_algorithm (const char *comp) { -int i; - - i =sysfs_match_string (backends, comp); -if (i >=0 ) -return true; -/* * Crypto does not ignore a trailing new line symbol, * so make sure you don't supply a string containing
@@ -217,6 +211,11 @@ struct zcomp *zcomp_create(const char *compress)struct zcomp *comp;int error; +/* +* Crypto API will execute /sbin/modprobe if the compression module +* is not loaded yet. We must do it here, otherwise we are about to +* call /sbin/modprobe under CPU hot-plug lock. +*/ if (!zcomp_available_algorithm (compress))return ERR_PTR (-EINVAL );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 28/64 clk: qcom: clk-alpha-pll: fix clk_trion_pll_configure description
In reply to Sasha LevinFrom: Vladimir Zapolskiy <[email protected]>
[ Upstream commit 94bed9bb05c7850ff5d80b87cc29004901f37956 ]
After merging lucid and trion pll functions in commit 0b01489475c6 ("clk: qcom: clk-alpha-pll: same regs and ops for trion and lucid") the function clk_trion_pll_configure() is left with an old description header, which results in a W=2 compile time warning, fix it.
--- drivers/clk/qcom/clk-alpha-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/clk-alpha-pll.c +1 -1
@@ -1439,7 +1439,7 @@ const struct clk_ops clk_alpha_pll_postdiv_fabia_ops = {EXPORT_SYMBOL_GPL (clk_alpha_pll_postdiv_fabia_ops);/** -* clk_lucid_pll_configure - configure the lucid pll +* clk_trion_pll_configure - configure the trion pll * * @pll: clk alpha pll * @regmap: register map
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 29/64 scsi: lpfc: Prevent buffer overflow crashes in debugfs with malformed user input
In reply to Sasha LevinFrom: James Smart <[email protected]>
[ Upstream commit f8191d40aa612981ce897e66cda6a88db8df17bb ]
Malformed user input to debugfs results in buffer overflow crashes. Adapt input string lengths to fit within internal buffers, leaving space for NULL terminators.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +10 -10
@@ -2607,8 +2607,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,struct lpfc_sli4_hdw_queue *qp;struct lpfc_multixri_pool *multixri_pool; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2688,8 +2688,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,if (!phba->targetport)return -ENXIO ; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2826,8 +2826,8 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,char mybuf[64 ];char *pbuf; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,char mybuf[64 ];char *pbuf; -if (nbytes >63 ) - nbytes =63 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
@@ -3060,8 +3060,8 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,char *pbuf;int i; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >sizeof (mybuf) -1 ) + nbytes =sizeof (mybuf) -1 ;memset (mybuf,0 ,sizeof (mybuf));
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 30/64 scsi: lpfc: Fix possible memory leak when failing to issue CMF WQE
In reply to Sasha LevinFrom: James Smart <[email protected]>
[ Upstream commit 2f67dc7970bce3529edce93a0a14234d88b3fcd5 ]
There is no corresponding free routine if lpfc_sli4_issue_wqe fails to issue the CMF WQE in lpfc_issue_cmf_sync_wqe.
If ret_val is non-zero, then free the iocbq request structure.
--- drivers/scsi/lpfc/lpfc_sli.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +3 -1
@@ -2003,10 +2003,12 @@ lpfc_issue_cmf_sync_wqe(struct lpfc_hba *phba, u32 ms, u64 total) sync_buf->cmd_flag |=LPFC_IO_CMF ; ret_val =lpfc_sli4_issue_wqe (phba, &phba->sli4_hba.hdwq[0 ], sync_buf); -if (ret_val) +if (ret_val) {lpfc_printf_log (phba,KERN_INFO ,LOG_CGN_MGMT ,"6214 Cannot issue CMF_SYNC_WQE: x%x\n" , ret_val); +__lpfc_sli_release_iocbq (phba, sync_buf); + } out_unlock:spin_unlock_irqrestore (&phba->hbalock, iflags);return ret_val;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 31/64 gadgetfs: ep_io - wait until IRQ finishes
In reply to Sasha LevinFrom: Jozef Martiniak <[email protected]>
[ Upstream commit 04cb742d4d8f30dc2e83b46ac317eec09191c68e ]
after usb_ep_queue() if wait_for_completion_interruptible() is interrupted we need to wait until IRQ gets finished.
Otherwise complete() from epio_complete() can corrupt stack.
--- drivers/usb/gadget/legacy/inode.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/legacy/inode.c +1 -0
@@ -362,6 +362,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)spin_unlock_irq (&epdata->dev->lock);DBG (epdata->dev,"endpoint gone\n" ); +wait_for_completion (&done); epdata->status = -ENODEV ; } }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 32/64 coresight: etm4x: avoid build failure with unrolled loops
In reply to Sasha LevinFrom: Nick Desaulniers <[email protected]>
[ Upstream commit 4d45bc82df667ad9e9cb8361830e54fc1264e993 ]
When the following configs are enabled:
* CORESIGHT
* CORESIGHT_SOURCE_ETM4X
* UBSAN
* UBSAN_TRAP
Clang fails assemble the kernel with the error:
<instantiation>:1:7: error: expected constant expression in '.inst' directive
.inst (0xd5200000|((((2) << 19) | ((1) << 16) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 7) & 0x7)) << 12) | ((((((((((0x160 + (i * 4))))) >> 2))) & 0xf)) << 8) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 4) & 0x7)) << 5)))|(.L__reg_num_x8))
^
drivers/hwtracing/coresight/coresight-etm4x-core.c:702:4: note: while in macro instantiationetm4x_relaxed_read32(csa, TRCCNTVRn(i));
^drivers/hwtracing/coresight/coresight-etm4x.h:403:4: note: expanded from macro 'etm4x_relaxed_read32' read_etm4x_sysreg_offset((offset), false)))
^drivers/hwtracing/coresight/coresight-etm4x.h:383:12: note: expanded from macro 'read_etm4x_sysreg_offset'
__val = read_etm4x_sysreg_const_offset((offset)); \
^drivers/hwtracing/coresight/coresight-etm4x.h:149:2: note: expanded from macro 'read_etm4x_sysreg_const_offset' READ_ETM4x_REG(ETM4x_OFFSET_TO_REG(offset))
^drivers/hwtracing/coresight/coresight-etm4x.h:144:2: note: expanded from macro 'READ_ETM4x_REG' read_sysreg_s(ETM4x_REG_NUM_TO_SYSREG((reg)))
^arch/arm64/include/asm/sysreg.h:1108:15: note: expanded from macro 'read_sysreg_s'
asm volatile(__mrs_s("%0", r) : "=r" (__val)); \
^arch/arm64/include/asm/sysreg.h:1074:2: note: expanded from macro '__mrs_s'
" mrs_s " v ", " __stringify(r) "\n" \
^
Consider the definitions of TRCSSCSRn and TRCCNTVRn:drivers/hwtracing/coresight/coresight-etm4x.h:56
#define TRCCNTVRn(n) (0x160 + (n * 4))drivers/hwtracing/coresight/coresight-etm4x.h:81
#define TRCSSCSRn(n) (0x2A0 + (n * 4))
Where the macro parameter is expanded to i; a loop induction variable from etm4_disable_hw.
When any compiler can determine that loops may be unrolled, then the __builtin_constant_p check in read_etm4x_sysreg_offset() defined in drivers/hwtracing/coresight/coresight-etm4x.h may evaluate to true. This can lead to the expression (0x160 + (i * 4)) being passed to read_etm4x_sysreg_const_offset. Via the trace above, this is passed through READ_ETM4x_REG, read_sysreg_s, and finally to __mrs_s where it is string-ified and used directly in inline asm.
Regardless of which compiler or compiler options determine whether a loop can or can't be unrolled, which determines whether __builtin_constant_p evaluates to true when passed an expression using a loop induction variable, it is NEVER safe to allow the preprocessor to construct inline asm like:
asm volatile (".inst (0x160 + (i * 4))" : "=r"(__val));
^ expected constant expression
Instead of read_etm4x_sysreg_offset() using __builtin_constant_p(), use __is_constexpr from include/linux/const.h instead to ensure only expressions that are valid integer constant expressions get passed through to read_sysreg_s().
This is not a bug in clang; it's a potentially unsafe use of the macro arguments in read_etm4x_sysreg_offset dependent on __builtin_constant_p.
--- drivers/hwtracing/coresight/coresight-etm4x.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-etm4x.h +2 -1
@@ -7,6 +7,7 @@#define _CORESIGHT_CORESIGHT_ETM_H#include <asm/local.h> +#include <linux/const.h> #include <linux/spinlock.h> #include <linux/types.h> #include "coresight-priv.h"
@@ -515,7 +516,7 @@ ({ \ u64 __val; \ \ - if (__builtin_constant_p((offset))) \ + if (__is_constexpr((offset))) \ __val = read_etm4x_sysreg_const_offset((offset)); \ else \ __val = etm4x_sysreg_read((offset), true, (_64bit)); \
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 33/64 habanalabs: add terminating NULL to attrs arrays
In reply to Sasha LevinFrom: Dafna Hirschfeld <[email protected]>
[ Upstream commit 78d503087be190eab36290644ccec050135e7c70 ]
Arrays of struct attribute are expected to be NULL terminated. This is required by API methods such as device_add_groups. This fixes a crash when loading the driver for Goya device.
--- drivers/misc/habanalabs/common/sysfs.c | 2 ++ drivers/misc/habanalabs/gaudi/gaudi.c | 1 + drivers/misc/habanalabs/goya/goya_hwmgr.c | 2 ++ 3 files changed, 5 insertions(+)
drivers/misc/habanalabs/common/sysfs.c +2 -0
@@ -73,6 +73,7 @@ static DEVICE_ATTR_RO(clk_cur_freq_mhz);static struct attribute *hl_dev_clk_attrs[] = { &dev_attr_clk_max_freq_mhz.attr, &dev_attr_clk_cur_freq_mhz.attr, +NULL , };static ssize_t vrm_ver_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -93,6 +94,7 @@ static DEVICE_ATTR_RO(vrm_ver);static struct attribute *hl_dev_vrm_attrs[] = { &dev_attr_vrm_ver.attr, +NULL , }; static ssize_t uboot_ver_show(struct device *dev, struct device_attribute *attr,
drivers/misc/habanalabs/gaudi/gaudi.c +1 -0
@@ -9187,6 +9187,7 @@ static DEVICE_ATTR_RO(infineon_ver);static struct attribute *gaudi_vrm_dev_attrs[] = { &dev_attr_infineon_ver.attr, +NULL , }; static void gaudi_add_device_attr(struct hl_device *hdev, struct attribute_group *dev_clk_attr_grp,
drivers/misc/habanalabs/goya/goya_hwmgr.c +2 -0
@@ -359,6 +359,7 @@ static struct attribute *goya_clk_dev_attrs[] = { &dev_attr_pm_mng_profile.attr, &dev_attr_tpc_clk.attr, &dev_attr_tpc_clk_curr.attr, + NULL, };static ssize_t infineon_ver_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -375,6 +376,7 @@ static DEVICE_ATTR_RO(infineon_ver);static struct attribute *goya_vrm_dev_attrs[] = { &dev_attr_infineon_ver.attr, +NULL , }; void goya_add_device_attr(struct hl_device *hdev, struct attribute_group *dev_clk_attr_grp,
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 34/64 habanalabs/gaudi: invoke device reset from one code block
In reply to Sasha LevinFrom: Tal Cohen <[email protected]>
[ Upstream commit be572e67dafbf8004d46a2c9d97338c107efb60e ]
In order to prepare the driver code for device reset event notification, change the event handler function flow to call device reset from one code block.
In addition, the commit fixes an issue that reset was performed w/o checking the 'hard_reset_on_fw_event' state and w/o setting the HL_DRV_RESET_DELAY flag.
--- drivers/misc/habanalabs/gaudi/gaudi.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +16 -9
@@ -7717,10 +7717,10 @@ static void gaudi_handle_eqe(struct hl_device *hdev,struct gaudi_device *gaudi = hdev->asic_specific;u64 data =le64_to_cpu (eq_entry->data[0 ]);u32 ctl =le32_to_cpu (eq_entry->hdr.ctl); -u32 fw_fatal_err_flag =0 ; +u32 fw_fatal_err_flag =0 , flags =0 ;u16 event_type = ((ctl &EQ_CTL_EVENT_TYPE_MASK ) >>EQ_CTL_EVENT_TYPE_SHIFT ); -bool reset_required; +bool reset_required, reset_direct = false;u8 cause;int rc;
@@ -7808,7 +7808,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev,dev_err (hdev->dev,"reset required due to %s\n" , gaudi_irq_map_table[event_type].name); -hl_device_reset (hdev,0 ); + reset_direct = true; + goto reset_device; }else {hl_fw_unmask_irq (hdev, event_type); }
@@ -7830,7 +7831,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev,dev_err (hdev->dev,"reset required due to %s\n" , gaudi_irq_map_table[event_type].name); -hl_device_reset (hdev,0 ); + reset_direct = true; + goto reset_device; }else {hl_fw_unmask_irq (hdev, event_type); }
@@ -7981,12 +7983,17 @@ static void gaudi_handle_eqe(struct hl_device *hdev,return ; reset_device: -if (hdev->asic_prop.fw_security_enabled) -hl_device_reset (hdev,HL_DRV_RESET_HARD - |HL_DRV_RESET_BYPASS_REQ_TO_FW - | fw_fatal_err_flag); + reset_required = true; + +if (hdev->asic_prop.fw_security_enabled && !reset_direct) + flags =HL_DRV_RESET_HARD |HL_DRV_RESET_BYPASS_REQ_TO_FW | fw_fatal_err_flag;else if (hdev->hard_reset_on_fw_events) -hl_device_reset (hdev,HL_DRV_RESET_HARD |HL_DRV_RESET_DELAY | fw_fatal_err_flag); + flags =HL_DRV_RESET_HARD |HL_DRV_RESET_DELAY | fw_fatal_err_flag; +else + reset_required = false; + +if (reset_required) +hl_device_reset (hdev, flags);else hl_fw_unmask_irq (hdev, event_type); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 35/64 habanalabs/gaudi: fix shift out of bounds
In reply to Sasha LevinFrom: Ofir Bitton <[email protected]>
[ Upstream commit 01622098aeb05a5efbb727199bbc2a4653393255 ]
When validating NIC queues, queue offset calculation must be performed only for NIC queues.
--- drivers/misc/habanalabs/gaudi/gaudi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +9 -7
@@ -5654,15 +5654,17 @@ static int gaudi_parse_cb_no_ext_queue(struct hl_device *hdev, {struct asic_fixed_properties *asic_prop = &hdev->asic_prop;struct gaudi_device *gaudi = hdev->asic_specific; -u32 nic_mask_q_id =1 << (HW_CAP_NIC_SHIFT + - ((parser->hw_queue_id -GAUDI_QUEUE_ID_NIC_0_0 ) >>2 )); +u32 nic_queue_offset, nic_mask_q_id;if ((parser->hw_queue_id >=GAUDI_QUEUE_ID_NIC_0_0 ) && - (parser->hw_queue_id <=GAUDI_QUEUE_ID_NIC_9_3 ) && - (!(gaudi->hw_cap_initialized & nic_mask_q_id))) { -dev_err (hdev->dev,"h/w queue %d is disabled\n" , - parser->hw_queue_id); -return -EINVAL ; + (parser->hw_queue_id <=GAUDI_QUEUE_ID_NIC_9_3 )) { + nic_queue_offset = parser->hw_queue_id -GAUDI_QUEUE_ID_NIC_0_0 ; + nic_mask_q_id =1 << (HW_CAP_NIC_SHIFT + (nic_queue_offset >>2 )); + +if (!(gaudi->hw_cap_initialized & nic_mask_q_id)) { +dev_err (hdev->dev,"h/w queue %d is disabled\n" , parser->hw_queue_id); +return -EINVAL ; + } }/* For internal queue jobs just check if CB address is valid */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 36/64 habanalabs/gaudi: mask constant value before cast
In reply to Sasha LevinFrom: Oded Gabbay <[email protected]>
[ Upstream commit e3f49437a2e0221a387ecd192d742ae1434e1e3a ]
This fixes a sparse warning of
"cast truncates bits from constant value"
--- drivers/misc/habanalabs/gaudi/gaudi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/misc/habanalabs/gaudi/gaudi.c +4 -4
@@ -3339,19 +3339,19 @@ static void gaudi_init_nic_qman(struct hl_device *hdev, u32 nic_offset,u32 nic_qm_err_cfg, irq_handler_offset;u32 q_off; - mtr_base_en_lo =lower_32_bits (CFG_BASE + + mtr_base_en_lo =lower_32_bits ((CFG_BASE &U32_MAX ) + mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_PAY_ADDRL_0); mtr_base_en_hi =upper_32_bits (CFG_BASE + mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_PAY_ADDRL_0); - so_base_en_lo =lower_32_bits (CFG_BASE + + so_base_en_lo =lower_32_bits ((CFG_BASE &U32_MAX ) + mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_SOB_OBJ_0); so_base_en_hi =upper_32_bits (CFG_BASE + mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_SOB_OBJ_0); - mtr_base_ws_lo =lower_32_bits (CFG_BASE + + mtr_base_ws_lo =lower_32_bits ((CFG_BASE &U32_MAX ) + mmSYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_PAY_ADDRL_0); mtr_base_ws_hi =upper_32_bits (CFG_BASE + mmSYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_PAY_ADDRL_0); - so_base_ws_lo =lower_32_bits (CFG_BASE + + so_base_ws_lo =lower_32_bits ((CFG_BASE &U32_MAX ) + mmSYNC_MNGR_W_S_SYNC_MNGR_OBJS_SOB_OBJ_0); so_base_ws_hi =upper_32_bits (CFG_BASE + mmSYNC_MNGR_W_S_SYNC_MNGR_OBJS_SOB_OBJ_0);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 37/64 mmc: tmio: avoid glitches when resetting
In reply to Sasha LevinFrom: Wolfram Sang <[email protected]>
[ Upstream commit 2e586f8a5b0ed4a525014a692923ac96f6647816 ]
If we reset because of an error, we need to preserve values for the clock frequency. Otherwise, glitches may be seen on the bus.
To achieve that, we introduce a 'preserve' parameter to the reset function and the IP core specific reset callbacks to handle everything accordingly.
--- drivers/mmc/host/renesas_sdhi_core.c | 29 ++++++++++++++-------------- drivers/mmc/host/tmio_mmc.c | 2 +- drivers/mmc/host/tmio_mmc.h | 6 +++++- drivers/mmc/host/tmio_mmc_core.c | 28 +++++++++++++++++++++------ 4 files changed, 42 insertions(+), 23 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +14 -15
@@ -49,9 +49,6 @@#define HOST_MODE_GEN3_32BIT (HOST_MODE_GEN3_WMODE | HOST_MODE_GEN3_BUSWIDTH)#define HOST_MODE_GEN3_64BIT 0 -#define CTL_SDIF_MODE 0xe6 -#define SDIF_MODE_HS400 BIT(0) -#define SDHI_VER_GEN2_SDR50 0x490c#define SDHI_VER_RZ_A1 0x820b/* very old datasheets said 0x490c for SDR104, too. They are wrong! */
@@ -562,23 +559,25 @@ static void renesas_sdhi_scc_reset(struct tmio_mmc_host *host, struct renesas_sd }/* only populated for TMIO_MMC_MIN_RCAR2 */ -static void renesas_sdhi_reset (struct tmio_mmc_host *host) +static void renesas_sdhi_reset (struct tmio_mmc_host *host,bool preserve) {struct renesas_sdhi *priv =host_to_priv (host);int ret;u16 val; -if (priv->rstc) { -reset_control_reset (priv->rstc); -/* Unknown why but without polling reset status, it will hang */ -read_poll_timeout (reset_control_status, ret, ret ==0 ,1 ,100 , - false, priv->rstc); -/* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */ -sd_ctrl_write16 (host,CTL_RESET_SD ,0x0001 ); - priv->needs_adjust_hs400 = false; -renesas_sdhi_set_clock (host, host->clk_cache); - }else if (priv->scc_ctl) { -renesas_sdhi_scc_reset (host, priv); +if (!preserve) { +if (priv->rstc) { +reset_control_reset (priv->rstc); +/* Unknown why but without polling reset status, it will hang */ +read_poll_timeout (reset_control_status, ret, ret ==0 ,1 ,100 , + false, priv->rstc); +/* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */ +sd_ctrl_write16 (host,CTL_RESET_SD ,0x0001 ); + priv->needs_adjust_hs400 = false; +renesas_sdhi_set_clock (host, host->clk_cache); + }else if (priv->scc_ctl) { +renesas_sdhi_scc_reset (host, priv); + } }if (sd_ctrl_read16 (host,CTL_VERSION ) >=SDHI_VER_GEN3_SD ) {
drivers/mmc/host/tmio_mmc.c +1 -1
@@ -75,7 +75,7 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,tmio_mmc_clk_start (host); } -static void tmio_mmc_reset (struct tmio_mmc_host *host) +static void tmio_mmc_reset (struct tmio_mmc_host *host,bool preserve) {sd_ctrl_write16 (host,CTL_RESET_SDIO ,0x0000 );usleep_range (10000 ,11000 );
drivers/mmc/host/tmio_mmc.h +5 -1
@@ -42,6 +42,7 @@#define CTL_DMA_ENABLE 0xd8#define CTL_RESET_SD 0xe0#define CTL_VERSION 0xe2 +#define CTL_SDIF_MODE 0xe6/* only known on R-Car 2+ */ /* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */ #define TMIO_STOP_STP BIT(0)
@@ -98,6 +99,9 @@/* Definitions for values the CTL_DMA_ENABLE register can take */ #define DMA_ENABLE_DMASDRW BIT(1) +/* Definitions for values the CTL_SDIF_MODE register can take */ +#define SDIF_MODE_HS400 BIT(0)/* only known on R-Car 2+ */ +/* Define some IRQ masks */ /* This is the mask used at reset by the chip */ #define TMIO_MASK_ALL 0x837f031d
@@ -181,7 +185,7 @@ struct tmio_mmc_host {int (*multi_io_quirk)(struct mmc_card *card,unsigned int direction,int blk_size);int (*write16_hook)(struct tmio_mmc_host *host,int addr); -void (*reset)(struct tmio_mmc_host *host); +void (*reset)(struct tmio_mmc_host *host,bool preserve);bool (*check_retune)(struct tmio_mmc_host *host,struct mmc_request *mrq);void (*fixup_request)(struct tmio_mmc_host *host,struct mmc_request *mrq);unsigned int (*get_timeout_cycles)(struct tmio_mmc_host *host);
drivers/mmc/host/tmio_mmc_core.c +22 -6
@@ -179,8 +179,17 @@ static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,sd_ctrl_write16 (host,CTL_SD_MEM_CARD_OPT , reg); } -static void tmio_mmc_reset (struct tmio_mmc_host *host) +static void tmio_mmc_reset (struct tmio_mmc_host *host,bool preserve) { +u16 card_opt, clk_ctrl, sdif_mode; + +if (preserve) { + card_opt =sd_ctrl_read16 (host,CTL_SD_MEM_CARD_OPT ); + clk_ctrl =sd_ctrl_read16 (host,CTL_SD_CARD_CLK_CTL ); +if (host->pdata->flags &TMIO_MMC_MIN_RCAR2 ) + sdif_mode =sd_ctrl_read16 (host,CTL_SDIF_MODE ); + } +/* FIXME - should we set stop clock reg here */ sd_ctrl_write16 (host,CTL_RESET_SD ,0x0000 );usleep_range (10000 ,11000 );
@@ -190,7 +199,7 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)tmio_mmc_abort_dma (host);if (host->reset) - host->reset (host); + host->reset (host, preserve);sd_ctrl_write32_as_16_and_16 (host,CTL_IRQ_MASK , host->sdcard_irq_mask_all); host->sdcard_irq_mask = host->sdcard_irq_mask_all;
@@ -206,6 +215,13 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0001 ); } +if (preserve) { +sd_ctrl_write16 (host,CTL_SD_MEM_CARD_OPT , card_opt); +sd_ctrl_write16 (host,CTL_SD_CARD_CLK_CTL , clk_ctrl); +if (host->pdata->flags &TMIO_MMC_MIN_RCAR2 ) +sd_ctrl_write16 (host,CTL_SDIF_MODE , sdif_mode); + } +if (host->mmc->card)mmc_retune_needed (host->mmc); }
@@ -248,7 +264,7 @@ static void tmio_mmc_reset_work(struct work_struct *work)spin_unlock_irqrestore (&host->lock, flags); -tmio_mmc_reset (host); +tmio_mmc_reset (host, true);/* Ready for new calls */ host->mrq =NULL ;
@@ -961,7 +977,7 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)tmio_mmc_power_off (host);/* For R-Car Gen2+, we need to reset SDHI specific SCC */ if (host->pdata->flags &TMIO_MMC_MIN_RCAR2 ) -tmio_mmc_reset (host); +tmio_mmc_reset (host, false); host->set_clock (host,0 );break ;
@@ -1189,7 +1205,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) _host->sdcard_irq_mask_all =TMIO_MASK_ALL ; _host->set_clock (_host,0 ); -tmio_mmc_reset (_host); +tmio_mmc_reset (_host, false);spin_lock_init (&_host->lock);mutex_init (&_host->ios_lock);
@@ -1285,7 +1301,7 @@ int tmio_mmc_host_runtime_resume(struct device *dev)struct tmio_mmc_host *host =dev_get_drvdata (dev);tmio_mmc_clk_enable (host); -tmio_mmc_reset (host); +tmio_mmc_reset (host, false);if (host->clk_cache) host->set_clock (host, host->clk_cache);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 38/64 scsi: ufs: ufs-exynos: Change ufs phy control sequence
In reply to Sasha LevinFrom: Chanho Park <[email protected]>
[ Upstream commit 3d73b200f9893d8f5ba5d105e8b69c8d16744fa2 ]
Since commit 1599069a62c6 ("phy: core: Warn when phy_power_on is called before phy_init"), the following warning has been reported:
phy_power_on was called before phy_init
To address this, we need to remove phy_power_on from exynos_ufs_phy_init() and move it after phy_init. phy_power_off and phy_exit are also necessary in exynos_ufs_remove().
--- drivers/ufs/host/ufs-exynos.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/ufs/host/ufs-exynos.c +10 -7
@@ -910,9 +910,13 @@ static int exynos_ufs_phy_init(struct exynos_ufs *ufs)if (ret) {dev_err (hba->dev,"%s: phy init failed, ret = %d\n" , __func__, ret); - goto out_exit_phy; +return ret; } + ret =phy_power_on (generic_phy); +if (ret) + goto out_exit_phy; +return 0 ; out_exit_phy:
@@ -1174,10 +1178,6 @@ static int exynos_ufs_init(struct ufs_hba *hba) goto out; } - ret =phy_power_on (ufs->phy); -if (ret) - goto phy_off; -exynos_ufs_priv_init (hba, ufs);if (ufs->drv_data->drv_init) {
@@ -1195,8 +1195,6 @@ static int exynos_ufs_init(struct ufs_hba *hba)exynos_ufs_config_smu (ufs);return 0 ; -phy_off: -phy_power_off (ufs->phy); out: hba->priv =NULL ;return ret;
@@ -1514,9 +1512,14 @@ static int exynos_ufs_probe(struct platform_device *pdev)static int exynos_ufs_remove (struct platform_device *pdev) {struct ufs_hba *hba =platform_get_drvdata (pdev); +struct exynos_ufs *ufs =ufshcd_get_variant (hba);pm_runtime_get_sync (&(pdev)->dev);ufshcd_remove (hba); + +phy_power_off (ufs->phy); +phy_exit (ufs->phy); +return 0 ; }
Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 39/64 pinctrl: intel: Check against matching data instead of ACPI companion
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit c551bd81d198bf1dcd4398d5454acdc0309dbe77 ]
In some cases we may get a platform device that has ACPI companion which is different to the pin control described in the ACPI tables. This is primarily happens when device is instantiated by board file.
In order to allow this device being enumerated, refactor intel_pinctrl_get_soc_data() to check the matching data instead of ACPI companion.
--- drivers/pinctrl/intel/pinctrl-intel.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +6 -8
@@ -1641,16 +1641,14 @@ EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid);const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data (struct platform_device *pdev) { +const struct intel_pinctrl_soc_data *const *table;const struct intel_pinctrl_soc_data *data =NULL ; -const struct intel_pinctrl_soc_data **table; -struct acpi_device *adev; -unsigned int i; - adev =ACPI_COMPANION (&pdev->dev); -if (adev) { -const void *match =device_get_match_data (&pdev->dev); + table =device_get_match_data (&pdev->dev); +if (table) { +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev); +unsigned int i; - table = (const struct intel_pinctrl_soc_data **)match;for (i =0 ; table[i]; i++) {if (!strcmp (adev->pnp.unique_id, table[i]->uid)) { data = table[i];
@@ -1664,7 +1662,7 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_if (!id)return ERR_PTR (-ENODEV ); - table = (const struct intel_pinctrl_soc_data **)id->driver_data; + table = (const struct intel_pinctrl_soc_data *const *)id->driver_data; data = table[pdev->id]; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 40/64 cxl: Fix a memory leak in an error handling path
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 3a15b45b5454da862376b5d69a4967f5c6fa1368 ]
A bitmap_zalloc() must be balanced by a corresponding bitmap_free() in the error handling path of afu_allocate_irqs().
--- drivers/misc/cxl/irq.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/cxl/irq.c +1 -0
@@ -350,6 +350,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count) out: cxl_ops->release_irq_ranges (&ctx->irqs, ctx->afu->adapter); +bitmap_free (ctx->irq_bitmap);afu_irq_name_free (ctx);return -ENOMEM ; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 41/64 PCI/ACPI: Guard ARM64-specific mcfg_quirks
In reply to Sasha LevinFrom: Huacai Chen <[email protected]>
[ Upstream commit 40a6cc141b4b9580de140bcb3e893445708acc5d ]
Guard ARM64-specific quirks with CONFIG_ARM64 to avoid build errors, since mcfg_quirks will be shared by more than one architectures.
--- drivers/acpi/pci_mcfg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/pci_mcfg.c +3 -0
@@ -41,6 +41,8 @@ struct mcfg_fixup { static struct mcfg_fixup mcfg_quirks[] = {/* { OEM_ID, OEM_TABLE_ID, REV, SEGMENT, BUS_RANGE, ops, cfgres }, */ +#ifdef CONFIG_ARM64 +#define AL_ECAM (table_id, rev, seg, ops) \ { "AMAZON", table_id, rev, seg, MCFG_BUS_ANY, ops }
@@ -169,6 +171,7 @@ static struct mcfg_fixup mcfg_quirks[] = {ALTRA_ECAM_QUIRK (1 ,13 ),ALTRA_ECAM_QUIRK (1 ,14 ), ALTRA_ECAM_QUIRK(1, 15), +#endif /* ARM64 */ };static char mcfg_oem_id[ACPI_OEM_ID_SIZE ];
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 42/64 um: add "noreboot" command line option for PANIC_TIMEOUT=-1 setups
In reply to Sasha LevinFrom: "Jason A. Donenfeld" <[email protected]>
[ Upstream commit dda520d07b95072a0b63f6c52a8eb566d08ea897 ]
QEMU has a -no-reboot option, which halts instead of reboots when the guest asks to reboot. This is invaluable when used with CONFIG_PANIC_TIMEOUT=-1 (and panic_on_warn), because it allows panics and warnings to be caught immediately in CI. Implement this in UML too, by way of a basic setup param.
--- arch/um/os-Linux/skas/process.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/um/os-Linux/skas/process.c +16 -1
@@ -5,6 +5,7 @@*/ #include <stdlib.h> +#include <stdbool.h> #include <unistd.h> #include <sched.h> #include <errno.h>
@@ -707,10 +708,24 @@ void halt_skas(void)UML_LONGJMP (&initial_jmpbuf,INIT_JMP_HALT ); } +static bool noreboot; + +static int __init noreboot_cmd_param (char *str,int *add) +{ + noreboot = true; +return 0 ; +} + +__uml_setup ("noreboot" , noreboot_cmd_param, +"noreboot\n" +" Rather than rebooting, exit always, akin to QEMU's -no-reboot option.\n" +" This is useful if you're using CONFIG_PANIC_TIMEOUT in order to catch\n" +" crashes in CI\n" ); +void reboot_skas (void ) {block_signals_trace (); -UML_LONGJMP (&initial_jmpbuf,INIT_JMP_REBOOT ); +UML_LONGJMP (&initial_jmpbuf, noreboot ?INIT_JMP_HALT :INIT_JMP_REBOOT ); }void __switch_mm (struct mm_id *mm_idp)
Signature · 7 lines
2.35.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Sasha Levin
maintainerPATCH 43/64 of: overlay: Move devicetree_corrupt() check up
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit e385b0ba6a137f34953e746d70d543660c2de1a0 ]
There is no point in doing several preparatory steps in of_overlay_fdt_apply(), only to see of_overlay_apply() return early because of a corrupt device tree.
Move the check for a corrupt device tree from of_overlay_apply() to of_overlay_fdt_apply(), to check for this as early as possible.
--- drivers/of/overlay.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/of/overlay.c +5 -6
@@ -903,12 +903,6 @@ static int of_overlay_apply(struct overlay_changeset *ovcs) {int ret =0 , ret_revert, ret_tmp; -if (devicetree_corrupt ()) { -pr_err ("devicetree state suspect, refuse to apply overlay\n" ); - ret = -EBUSY ; - goto out; - } - ret =of_resolve_phandles (ovcs->overlay_root);if (ret) goto out;
@@ -983,6 +977,11 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, *ret_ovcs_id =0 ; +if (devicetree_corrupt ()) { +pr_err ("devicetree state suspect, refuse to apply overlay\n" ); +return -EBUSY ; + } +if (overlay_fdt_size <sizeof (struct fdt_header ) ||fdt_check_header (overlay_fdt)) {pr_err ("Invalid overlay_fdt header\n" );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 44/64 dmaengine: dw-axi-dmac: do not print NULL LLI during error
In reply to Sasha LevinFrom: Ben Dooks <[email protected]>
[ Upstream commit 86cb0defe0e275453bc39e856bb523eb425a6537 ]
During debugging we have seen an issue where axi_chan_dump_lli() is passed a NULL LLI pointer which ends up causing an OOPS due to trying to get fields from it. Simply print NULL LLI and exit to avoid this.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +5 -0
@@ -982,6 +982,11 @@ static int dw_axi_dma_chan_slave_config(struct dma_chan *dchan,static void axi_chan_dump_lli (struct axi_dma_chan *chan,struct axi_dma_hw_desc *desc) { +if (!desc->lli) { +dev_err (dchan2dev (&chan->vc.chan),"NULL LLI\n" ); +return ; + } + dev_err(dchan2dev(&chan->vc.chan), "SAR: 0x%llx DAR: 0x%llx LLP: 0x%llx BTS 0x%x CTL: 0x%x:%08x", le64_to_cpu(desc->lli->sar),
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 45/64 dmaengine: dw-axi-dmac: ignore interrupt if no descriptor
In reply to Sasha LevinFrom: Ben Dooks <[email protected]>
[ Upstream commit 820f5ce999d2f99961e88c16d65cd26764df0590 ]
If the channel has no descriptor and the interrupt is raised then the kernel will OOPS. Check the result of vchan_next_desc() in the handler axi_chan_block_xfer_complete() to avoid the error happening.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +6 -0
@@ -1054,6 +1054,11 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)/* The completed descriptor currently is in the head of vc list */ vd =vchan_next_desc (&chan->vc); +if (!vd) { +dev_err (chan2dev (chan),"BUG: %s, IRQ with no descriptors\n" , +axi_chan_name (chan)); + goto out; + }if (chan->cyclic) { desc =vd_to_axi_desc (vd);
@@ -1083,6 +1088,7 @@ static void axi_chan_block_xfer_complete(struct axi_dma_chan *chan)axi_chan_start_first_queued (chan); } +out:spin_unlock_irqrestore (&chan->vc.lock, flags); }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 46/64 mmc: renesas_sdhi: newer SoCs don't need manual tap correction
In reply to Sasha LevinFrom: Takeshi Saito <[email protected]>
[ Upstream commit 00e8c11c137b2e4b2bf54dc9881cf32e3441ddb4 ]
The newest Gen3 SoCs and Gen4 SoCs do not need manual tap correction with HS400 anymore. So, instead of checking the SDHI version, add a quirk flag and set manual tap correction only for affected SoCs.
--- drivers/mmc/host/renesas_sdhi.h | 1 + drivers/mmc/host/renesas_sdhi_core.c | 5 ++--- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/renesas_sdhi.h +1 -0
@@ -43,6 +43,7 @@ struct renesas_sdhi_quirks {bool hs400_4taps;bool fixed_addr_mode;bool dma_one_rx_only; +bool manual_tap_correction;u32 hs400_bad_taps;const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX ]; };
drivers/mmc/host/renesas_sdhi_core.c +2 -3
@@ -380,8 +380,7 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc)sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_DT2FF , priv->scc_tappos_hs400); -/* Gen3 can't do automatic tap correction with HS400, so disable it */ -if (sd_ctrl_read16 (host,CTL_VERSION ) ==SDHI_VER_GEN3_SDMMC ) +if (priv->quirks && priv->quirks->manual_tap_correction)sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_RVSCNTL , ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &sd_scc_read32 (host, priv,SH_MOBILE_SDHI_SCC_RVSCNTL ));
@@ -718,7 +717,7 @@ static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_RVSREQ ,0 );/* Change TAP position according to correction status */ -if (sd_ctrl_read16 (host,CTL_VERSION ) ==SDHI_VER_GEN3_SDMMC && +if (priv->quirks && priv->quirks->manual_tap_correction && host->mmc->ios.timing ==MMC_TIMING_MMC_HS400 ) {u32 bad_taps = priv->quirks ? priv->quirks->hs400_bad_taps :0 ;/*
drivers/mmc/host/renesas_sdhi_internal_dmac.c +6 -0
@@ -170,6 +170,7 @@ static const struct renesas_sdhi_quirks sdhi_quirks_4tap_nohs400_one_rx = {static const struct renesas_sdhi_quirks sdhi_quirks_4tap = { .hs400_4taps = true, .hs400_bad_taps =BIT (2 ) |BIT (3 ) |BIT (6 ) |BIT (7 ), + .manual_tap_correction = true, };static const struct renesas_sdhi_quirks sdhi_quirks_nohs400 = {
@@ -182,25 +183,30 @@ static const struct renesas_sdhi_quirks sdhi_quirks_fixed_addr = {static const struct renesas_sdhi_quirks sdhi_quirks_bad_taps1357 = { .hs400_bad_taps =BIT (1 ) |BIT (3 ) |BIT (5 ) |BIT (7 ), + .manual_tap_correction = true, };static const struct renesas_sdhi_quirks sdhi_quirks_bad_taps2367 = { .hs400_bad_taps =BIT (2 ) |BIT (3 ) |BIT (6 ) |BIT (7 ), + .manual_tap_correction = true, };static const struct renesas_sdhi_quirks sdhi_quirks_r8a7796_es13 = { .hs400_4taps = true, .hs400_bad_taps =BIT (2 ) |BIT (3 ) |BIT (6 ) |BIT (7 ), .hs400_calib_table = r8a7796_es13_calib_table, + .manual_tap_correction = true, };static const struct renesas_sdhi_quirks sdhi_quirks_r8a77965 = { .hs400_bad_taps =BIT (2 ) |BIT (3 ) |BIT (6 ) |BIT (7 ), .hs400_calib_table = r8a77965_calib_table, + .manual_tap_correction = true, };static const struct renesas_sdhi_quirks sdhi_quirks_r8a77990 = { .hs400_calib_table = r8a77990_calib_table, + .manual_tap_correction = true, };/*
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 47/64 ACPI: PPTT: Leave the table mapped for the runtime usage
In reply to Sasha LevinFrom: Sudeep Holla <[email protected]>
[ Upstream commit 0c80f9e165f8f9cca743d7b6cbdb54362da297e0 ]
Currently, everytime an information needs to be fetched from the PPTT, the table is mapped via acpi_get_table() and unmapped after the use via acpi_put_table() which is fine. However we do this at runtime especially when the CPU is hotplugged out and plugged in back since we re-populate the cache topology and other information.
However, with the support to fetch LLC information from the PPTT in the cpuhotplug path which is executed in the atomic context, it is preferred to avoid mapping and unmapping of the PPTT for every single use as the acpi_get_table() might sleep waiting for a mutex.
In order to avoid the same, the table is needs to just mapped once on the boot CPU and is never unmapped allowing it to be used at runtime with out the hassle of mapping and unmapping the table.
--
Hi Rafael,
Sorry to bother you again on this PPTT changes. Guenter reported an issue with lockdep enabled in -next that include my cacheinfo/arch_topology changes to utilise LLC from PPTT in the CPU hotplug path.
Please ack the change once you are happy so that I can get it merged with other fixes via Greg's tree.
Regards,
Sudeep
--- drivers/acpi/pptt.c | 102 ++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 55 deletions(-)
drivers/acpi/pptt.c +47 -55
@@ -532,21 +532,37 @@ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table,return -ENOENT ; } + +static struct acpi_table_header *acpi_get_pptt (void ) +{ +static struct acpi_table_header *pptt; +acpi_status status; + +/* +* PPTT will be used at runtime on every CPU hotplug in path, so we +* don't need to call acpi_put_table() to release the table mapping. +*/ +if (!pptt) { + status =acpi_get_table (ACPI_SIG_PPTT ,0 , &pptt); +if (ACPI_FAILURE (status)) +acpi_pptt_warn_missing (); + } + +return pptt; +} +static int find_acpi_cpu_topology_tag (unsigned int cpu,int level,int flag) {struct acpi_table_header *table; -acpi_status status;int retval; - status =acpi_get_table (ACPI_SIG_PPTT ,0 , &table); -if (ACPI_FAILURE (status)) { -acpi_pptt_warn_missing (); + table =acpi_get_pptt (); +if (!table)return -ENOENT ; - } + retval =topology_get_acpi_cpu_tag (table, cpu, level, flag);pr_debug ("Topology Setup ACPI CPU %d, level %d ret = %d\n" , cpu, level, retval); -acpi_put_table (table);return retval; }
@@ -567,16 +583,13 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)static int check_acpi_cpu_flag (unsigned int cpu,int rev,u32 flag) {struct acpi_table_header *table; -acpi_status status;u32 acpi_cpu_id =get_acpi_id_for_cpu (cpu);struct acpi_pptt_processor *cpu_node =NULL ;int ret = -ENOENT ; - status =acpi_get_table (ACPI_SIG_PPTT ,0 , &table); -if (ACPI_FAILURE (status)) { -acpi_pptt_warn_missing (); -return ret; - } + table =acpi_get_pptt (); +if (!table) +return -ENOENT ;if (table->revision >= rev) cpu_node =acpi_find_processor_node (table, acpi_cpu_id);
@@ -584,8 +597,6 @@ static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)if (cpu_node) ret = (cpu_node->flags & flag) !=0 ; -acpi_put_table (table); -return ret; }
@@ -604,18 +615,15 @@ int acpi_find_last_cache_level(unsigned int cpu)u32 acpi_cpu_id;struct acpi_table_header *table;int number_of_levels =0 ; -acpi_status status; + + table =acpi_get_pptt (); +if (!table) +return -ENOENT ;pr_debug ("Cache Setup find last level CPU=%d\n" , cpu); acpi_cpu_id =get_acpi_id_for_cpu (cpu); - status =acpi_get_table (ACPI_SIG_PPTT ,0 , &table); -if (ACPI_FAILURE (status)) { -acpi_pptt_warn_missing (); - }else { - number_of_levels =acpi_find_cache_levels (table, acpi_cpu_id); -acpi_put_table (table); - } + number_of_levels =acpi_find_cache_levels (table, acpi_cpu_id);pr_debug ("Cache Setup find last level level=%d\n" , number_of_levels);return number_of_levels;
@@ -637,20 +645,16 @@ int acpi_find_last_cache_level(unsigned int cpu)int cache_setup_acpi (unsigned int cpu) {struct acpi_table_header *table; -acpi_status status; -pr_debug ("Cache Setup ACPI CPU %d\n" , cpu); - - status =acpi_get_table (ACPI_SIG_PPTT ,0 , &table); -if (ACPI_FAILURE (status)) { -acpi_pptt_warn_missing (); + table =acpi_get_pptt (); +if (!table)return -ENOENT ; - } + +pr_debug ("Cache Setup ACPI CPU %d\n" , cpu);cache_setup_acpi_cpu (table, cpu); -acpi_put_table (table); -return status; +return 0 ; }/**
@@ -766,50 +770,38 @@ int find_acpi_cpu_topology_package(unsigned int cpu)int find_acpi_cpu_topology_cluster (unsigned int cpu) {struct acpi_table_header *table; -acpi_status status;struct acpi_pptt_processor *cpu_node, *cluster_node;u32 acpi_cpu_id;int retval;int is_thread; - status =acpi_get_table (ACPI_SIG_PPTT ,0 , &table); -if (ACPI_FAILURE (status)) { -acpi_pptt_warn_missing (); + table =acpi_get_pptt (); +if (!table)return -ENOENT ; - } acpi_cpu_id =get_acpi_id_for_cpu (cpu); cpu_node =acpi_find_processor_node (table, acpi_cpu_id); -if (cpu_node ==NULL || !cpu_node->parent) { - retval = -ENOENT ; - goto put_table; - } +if (!cpu_node || !cpu_node->parent) +return -ENOENT ; is_thread = cpu_node->flags &ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD ; cluster_node =fetch_pptt_node (table, cpu_node->parent); -if (cluster_node ==NULL ) { - retval = -ENOENT ; - goto put_table; - } +if (!cluster_node) +return -ENOENT ; +if (is_thread) { -if (!cluster_node->parent) { - retval = -ENOENT ; - goto put_table; - } +if (!cluster_node->parent) +return -ENOENT ; + cluster_node =fetch_pptt_node (table, cluster_node->parent); -if (cluster_node ==NULL ) { - retval = -ENOENT ; - goto put_table; - } +if (!cluster_node) +return -ENOENT ; }if (cluster_node->flags &ACPI_PPTT_ACPI_PROCESSOR_ID_VALID ) retval = cluster_node->acpi_processor_id;else retval =ACPI_PTR_DIFF (cluster_node, table); -put_table: -acpi_put_table (table); -return retval; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 48/64 RDMA/rxe: Limit the number of calls to each tasklet
In reply to Sasha LevinFrom: Bob Pearson <[email protected]>
[ Upstream commit eff6d998ca297cb0b2e53b032a56cf8e04dd8b17 ]
Limit the maximum number of calls to each tasklet from rxe_do_task() before yielding the cpu. When the limit is reached reschedule the tasklet and exit the calling loop. This patch prevents one tasklet from consuming 100% of a cpu core and causing a deadlock or soft lockup.
--- drivers/infiniband/sw/rxe/rxe_param.h | 6 ++++++ drivers/infiniband/sw/rxe/rxe_task.c | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/infiniband/sw/rxe/rxe_param.h +6 -0
@@ -105,6 +105,12 @@ enum rxe_device_param {RXE_INFLIGHT_SKBS_PER_QP_HIGH =64 ,RXE_INFLIGHT_SKBS_PER_QP_LOW =16 , +/* Max number of interations of each tasklet +* before yielding the cpu to let other +* work make progress +*/ +RXE_MAX_ITERATIONS =1024 , +/* Delay before calling arbiter timer */ RXE_NSEC_ARB_TIMER_DELAY = 200,
drivers/infiniband/sw/rxe/rxe_task.c +12 -4
@@ -8,7 +8,7 @@#include <linux/interrupt.h> #include <linux/hardirq.h> -#include "rxe_task.h" +#include "rxe.h" int __rxe_do_task (struct rxe_task *task)
@@ -33,6 +33,7 @@ void rxe_do_task(struct tasklet_struct *t)int cont;int ret;struct rxe_task *task =from_tasklet (task, t, tasklet); +unsigned int iterations =RXE_MAX_ITERATIONS ;spin_lock_bh (&task->state_lock);switch (task->state) {
@@ -61,13 +62,20 @@ void rxe_do_task(struct tasklet_struct *t)spin_lock_bh (&task->state_lock);switch (task->state) {case TASK_STATE_BUSY : -if (ret) +if (ret) { task->state =TASK_STATE_START ; -else + }else if (iterations--) { cont =1 ; + }else { +/* reschedule the tasklet and exit +* the loop to give up the cpu +*/ +tasklet_schedule (&task->tasklet); + task->state =TASK_STATE_START ; + }break ; -/* soneone tried to run the task since the last time we called +/* someone tried to run the task since the last time we called * func, so we will call one more time regardless of the * return value */
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 49/64 csky/kprobe: reclaim insn_slot on kprobe unregistration
In reply to Sasha LevinFrom: Liao Chang <[email protected]>
[ Upstream commit a2310c74d418deca0f1d749c45f1f43162510f51 ]
On kprobe registration kernel allocate one insn_slot for new kprobe, but it forget to reclaim the insn_slot on unregistration, leading to a potential leakage.
--- arch/csky/kernel/probes/kprobes.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/csky/kernel/probes/kprobes.c +4 -0
@@ -124,6 +124,10 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)void __kprobes arch_remove_kprobe (struct kprobe *p) { +if (p->ainsn.api.insn) { +free_insn_slot (p->ainsn.api.insn,0 ); + p->ainsn.api.insn =NULL ; + } }static void __kprobes save_previous_kprobe (struct kprobe_ctlblk *kcb)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 50/64 selftests/kprobe: Do not test for GRP/ without event failures
In reply to Sasha LevinFrom: "Steven Rostedt (Google)" <[email protected]>
[ Upstream commit f5eab65ff2b76449286d18efc7fee3e0b72f7d9b ]
A new feature is added where kprobes (and other probes) do not need to explicitly state the event name when creating a probe. The event name will come from what is being attached.
That is:
# echo 'p:foo/ vfs_read' > kprobe_events
Will no longer error, but instead create an event:
# cat kprobe_events p:foo/p_vfs_read_0 vfs_read
This should not be tested as an error case anymore. Remove it from the selftest as now this feature "breaks" the selftest as it no longer fails as expected.
--- .../selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +0 -1
@@ -21,7 +21,6 @@ check_error 'p:^/bar vfs_read' # NO_GROUP_NAME check_error 'p:^12345678901234567890123456789012345678901234567890123456789012345/bar vfs_read' # GROUP_TOO_LONG check_error 'p:^foo.1/bar vfs_read' # BAD_GROUP_NAME -check_error 'p:foo/^ vfs_read' # NO_EVENT_NAME check_error 'p:foo/^12345678901234567890123456789012345678901234567890123456789012345 vfs_read' # EVENT_TOO_LONG check_error 'p:foo/^bar.1 vfs_read' # BAD_EVENT_NAME
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 51/64 dmaengine: tegra: Add terminate() for Tegra234
In reply to Sasha LevinFrom: Akhil R <[email protected]>
[ Upstream commit 36834c67016794b8fa03d7672a5b7f2cc4529298 ]
In certain cases where the DMA client bus gets corrupted or if the end device ceases to send/receive data, DMA can wait indefinitely for the data to be received/sent. Attempting to terminate the transfer will put the DMA in pause flush mode and it remains there.
The channel is irrecoverable once this pause times out in Tegra194 and earlier chips. Whereas, from Tegra234, it can be recovered by disabling the channel and reprograming it.
Hence add a new terminate() function that ignores the outcome of dma_pause() so that terminate_all() can proceed to disable the channel.
--- drivers/dma/tegra186-gpc-dma.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/dma/tegra186-gpc-dma.c +24 -2
@@ -157,8 +157,8 @@* If any burst is in flight and DMA paused then this is the time to complete * on-flight burst and update DMA status register. */ -#define TEGRA_GPCDMA_BURST_COMPLETE_TIME 20 -#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT 100 +#define TEGRA_GPCDMA_BURST_COMPLETE_TIME 10 +#define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT 5000/* 5 msec */ /* Channel base address offset from GPCDMA base address */ #define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET 0x20000
@@ -432,6 +432,17 @@ static int tegra_dma_device_resume(struct dma_chan *dc)return 0 ; } +static inline int tegra_dma_pause_noerr (struct tegra_dma_channel *tdc) +{ +/* Return 0 irrespective of PAUSE status. +* This is useful to recover channels that can exit out of flush +* state when the channel is disabled. +*/ + +tegra_dma_pause (tdc); +return 0 ; +} +static void tegra_dma_disable (struct tegra_dma_channel *tdc) {u32 csr, status;
@@ -1292,6 +1303,14 @@ static const struct tegra_dma_chip_data tegra194_dma_chip_data = { .terminate = tegra_dma_pause, }; +static const struct tegra_dma_chip_data tegra234_dma_chip_data = { + .nr_channels =31 , + .channel_reg_size =SZ_64K , + .max_dma_count =SZ_1G , + .hw_support_pause = true, + .terminate = tegra_dma_pause_noerr, +}; +static const struct of_device_id tegra_dma_of_match[] = { { .compatible ="nvidia,tegra186-gpcdma" ,
@@ -1299,6 +1318,9 @@ static const struct of_device_id tegra_dma_of_match[] = { }, { .compatible = "nvidia,tegra194-gpcdma", .data = &tegra194_dma_chip_data, + }, { + .compatible = "nvidia,tegra234-gpcdma", + .data = &tegra234_dma_chip_data, }, { }, };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 52/64 dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
In reply to Sasha LevinFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 1e42f82cbec7b2cc4873751e7791e6611901c5fc ]
It's not allowed to quit remove early without cleaning up completely. Otherwise this results in resource leaks that probably yield graver problems later. Here for example some tasklets might survive the lifetime of the sprd-dma device and access sdev which is freed after .remove() returns.
As none of the device freeing requires an active device, just ignore the return value of pm_runtime_get_sync().
--- drivers/dma/sprd-dma.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/sprd-dma.c +1 -4
@@ -1237,11 +1237,8 @@ static int sprd_dma_remove(struct platform_device *pdev) {struct sprd_dma_dev *sdev =platform_get_drvdata (pdev);struct sprd_dma_chn *c, *cn; -int ret; - ret =pm_runtime_get_sync (&pdev->dev); -if (ret <0 ) -return ret; +pm_runtime_get_sync (&pdev->dev);/* explicitly free the irq */ if (sdev->irq >0 )
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 53/64 Revert "RDMA/rxe: Create duplicate mapping tables for FMRs"
In reply to Sasha LevinFrom: Li Zhijian <[email protected]>
[ Upstream commit 1e75550648da1fa1cd1969e7597355de8fe8caf6 ]
Below 2 commits will be reverted:
commit 8ff5f5d9d8cf ("RDMA/rxe: Prevent double freeing rxe_map_set()") commit 647bf13ce944 ("RDMA/rxe: Create duplicate mapping tables for FMRs")
The community has a few bug reports which pointed this commit at last. Some proposals are raised up in the meantime but all of them have no follow-up operation.
The previous commit led the map_set of FMR to be not available any more if the MR is registered again after invalidating. Although the mentioned patch try to fix a potential race in building/accessing the same table for fast memory regions, it broke rtrs etc ULPs. Since the latter could be worse, revert this patch.
With previous commit, it's observed that a same MR in rnbd server will trigger below code path:
-> rxe_mr_init_fast()
|-> alloc map_set() # map_set is uninitialized
|...-> rxe_map_mr_sg() # build the map_set
|-> rxe_mr_set_page()
|...-> rxe_reg_fast_mr() # mr->state change to VALID from FREE that means
# we can access host memory(such rxe_mr_copy)
|...-> rxe_invalidate_mr() # mr->state change to FREE from VALID
|...-> rxe_reg_fast_mr() # mr->state change to VALID from FREE,
# but map_set was not built again
|...-> rxe_mr_copy() # kernel crash due to access wild addresses
# that lookup from the map_setThe backtraces are not always identical.
[1st]----------
RIP: 0010:lookup_iova+0x66/0xa0 [rdma_rxe] Code: 00 00 00 48 d3 ee 89 32 c3 4c 8b 18 49 8b 3b 48 8b 47 08 48 39 c6 72 38 48 29 c6 45 31 d2 b8 01 00 00 00 48 63 c8 48 c1 e1 04 <48> 8b 4c 0f 08 48 39 f1 77 21 83 c0 01 48 29 ce 3d 00 01 00 00 75 RSP: 0018:ffffb7ff80063bf0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff9b9949d86800 RCX: 0000000000000000 RDX: ffffb7ff80063c00 RSI: 0000000049f6b378 RDI: 002818da00000004 RBP: 0000000000000120 R08: ffffb7ff80063c08 R09: ffffb7ff80063c04 R10: 0000000000000002 R11: ffff9b9916f7eef8 R12: ffff9b99488a0038 R13: ffff9b99488a0038 R14: ffff9b9914fb346a R15: ffff9b990ab27000 FS: 0000000000000000(0000) GS:ffff9b997dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007efc33a98ed0 CR3: 0000000014f32004 CR4: 00000000001706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> rxe_mr_copy.part.0+0x6f/0x140 [rdma_rxe] rxe_responder+0x12ee/0x1b60 [rdma_rxe] ? rxe_icrc_check+0x7e/0x100 [rdma_rxe] ? rxe_rcv+0x1d0/0x780 [rdma_rxe] ? rxe_icrc_hdr.isra.0+0xf6/0x160 [rdma_rxe] rxe_do_task+0x67/0xb0 [rdma_rxe] rxe_xmit_packet+0xc7/0x210 [rdma_rxe] rxe_requester+0x680/0xee0 [rdma_rxe] ? update_load_avg+0x5f/0x690 ? update_load_avg+0x5f/0x690 ? rtrs_clt_recv_done+0x1b/0x30 [rtrs_client]
[2nd]----------
RIP: 0010:rxe_mr_copy.part.0+0xa8/0x140 [rdma_rxe] Code: 00 00 49 c1 e7 04 48 8b 00 4c 8d 2c d0 48 8b 44 24 10 4d 03 7d 00 85 ed 7f 10 eb 6c 89 54 24 0c 49 83 c7 10 31 c0 85 ed 7e 5e <49> 8b 3f 8b 14 24 4c 89 f6 48 01 c7 85 d2 74 06 48 89 fe 4c 89 f7 RSP: 0018:ffffae3580063bf8 EFLAGS: 00010202 RAX: 0000000000018978 RBX: ffff9d7ef7a03600 RCX: 0000000000000008 RDX: 000000000000007c RSI: 000000000000007c RDI: ffff9d7ef7a03600 RBP: 0000000000000120 R08: ffffae3580063c08 R09: ffffae3580063c04 R10: ffff9d7efece0038 R11: ffff9d7ec4b1db00 R12: ffff9d7efece0038 R13: ffff9d7ef4098260 R14: ffff9d7f11e23c6a R15: 4c79500065708144 FS: 0000000000000000(0000) GS:ffff9d7f3dc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fce47276c60 CR3: 0000000003f66004 CR4: 00000000001706f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> rxe_responder+0x12ee/0x1b60 [rdma_rxe] ? rxe_icrc_check+0x7e/0x100 [rdma_rxe] ? rxe_rcv+0x1d0/0x780 [rdma_rxe] ? rxe_icrc_hdr.isra.0+0xf6/0x160 [rdma_rxe] rxe_do_task+0x67/0xb0 [rdma_rxe] rxe_xmit_packet+0xc7/0x210 [rdma_rxe] rxe_requester+0x680/0xee0 [rdma_rxe] ? update_load_avg+0x5f/0x690 ? update_load_avg+0x5f/0x690 ? rtrs_clt_recv_done+0x1b/0x30 [rtrs_client] rxe_do_task+0x67/0xb0 [rdma_rxe] tasklet_action_common.constprop.0+0x92/0xc0 __do_softirq+0xe1/0x2d8 run_ksoftirqd+0x21/0x30 smpboot_thread_fn+0x183/0x220 ? sort_range+0x20/0x20 kthread+0xe2/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30
--- drivers/infiniband/sw/rxe/rxe_loc.h | 1 - drivers/infiniband/sw/rxe/rxe_mr.c | 199 +++++++++----------------- drivers/infiniband/sw/rxe/rxe_mw.c | 6 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 39 +++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 21 ++- 5 files changed, 104 insertions(+), 162 deletions(-)
drivers/infiniband/sw/rxe/rxe_loc.h +0 -1
@@ -79,7 +79,6 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length);int advance_dma_data (struct rxe_dma_info *dma,unsigned int length);int rxe_invalidate_mr (struct rxe_qp *qp,u32 rkey);int rxe_reg_fast_mr (struct rxe_qp *qp,struct rxe_send_wqe *wqe); -int rxe_mr_set_page (struct ib_mr *ibmr,u64 addr);int rxe_dereg_mr (struct ib_mr *ibmr,struct ib_udata *udata);void rxe_mr_cleanup (struct rxe_pool_elem *elem);
drivers/infiniband/sw/rxe/rxe_mr.c +66 -133
364 lines not on this page · raw message
drivers/infiniband/sw/rxe/rxe_mw.c +3 -3
@@ -119,15 +119,15 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe,/* C10-75 */ if (mw->access &IB_ZERO_BASED ) { -if (unlikely (wqe->wr.wr.mw.length > mr->cur_map_set->length)) { +if (unlikely (wqe->wr.wr.mw.length > mr->length)) {pr_err_once ("attempt to bind a ZB MW outside of the MR\n" );return -EINVAL ; } }else { -if (unlikely ((wqe->wr.wr.mw.addr < mr->cur_map_set->iova) || +if (unlikely ((wqe->wr.wr.mw.addr < mr->iova) || ((wqe->wr.wr.mw.addr + wqe->wr.wr.mw.length) > - (mr->cur_map_set->iova + mr->cur_map_set->length)))) { + (mr->iova + mr->length)))) {pr_err_once ("attempt to bind a VA MW outside of the MR\n" );return -EINVAL ;
drivers/infiniband/sw/rxe/rxe_verbs.c +27 -12
@@ -967,26 +967,41 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,return ERR_PTR (err); } -/* build next_map_set from scatterlist -* The IB_WR_REG_MR WR will swap map_sets -*/ +static int rxe_set_page (struct ib_mr *ibmr,u64 addr) +{ +struct rxe_mr *mr =to_rmr (ibmr); +struct rxe_map *map; +struct rxe_phys_buf *buf; + +if (unlikely (mr->nbuf == mr->num_buf)) +return -ENOMEM ; + + map = mr->map[mr->nbuf /RXE_BUF_PER_MAP ]; + buf = &map->buf[mr->nbuf %RXE_BUF_PER_MAP ]; + + buf->addr = addr; + buf->size = ibmr->page_size; + mr->nbuf++; + +return 0 ; +} +static int rxe_map_mr_sg (struct ib_mr *ibmr,struct scatterlist *sg,int sg_nents,unsigned int *sg_offset) {struct rxe_mr *mr =to_rmr (ibmr); -struct rxe_map_set *set = mr->next_map_set;int n; - set->nbuf =0 ; + mr->nbuf =0 ; - n =ib_sg_to_pages (ibmr, sg, sg_nents, sg_offset, rxe_mr_set_page); + n =ib_sg_to_pages (ibmr, sg, sg_nents, sg_offset, rxe_set_page); - set->va = ibmr->iova; - set->iova = ibmr->iova; - set->length = ibmr->length; - set->page_shift =ilog2 (ibmr->page_size); - set->page_mask = ibmr->page_size -1 ; - set->offset = set->iova & set->page_mask; + mr->va = ibmr->iova; + mr->iova = ibmr->iova; + mr->length = ibmr->length; + mr->page_shift =ilog2 (ibmr->page_size); + mr->page_mask = ibmr->page_size -1 ; + mr->offset = mr->iova & mr->page_mask;return n; }
drivers/infiniband/sw/rxe/rxe_verbs.h +8 -13
@@ -288,17 +288,6 @@ struct rxe_map {struct rxe_phys_buf buf[RXE_BUF_PER_MAP ]; }; -struct rxe_map_set { -struct rxe_map **map; -u64 va; -u64 iova; -size_t length; -u32 offset; -u32 nbuf; -int page_shift; -int page_mask; -}; -static inline int rkey_is_mw (u32 rkey) {u32 index = rkey >>8 ;
@@ -316,20 +305,26 @@ struct rxe_mr {u32 rkey;enum rxe_mr_state state;enum ib_mr_type type; +u64 va; +u64 iova; +size_t length; +u32 offset;int access; +int page_shift; +int page_mask;int map_shift;int map_mask;u32 num_buf; +u32 nbuf;u32 max_buf;u32 num_map;atomic_t num_mw; -struct rxe_map_set *cur_map_set; -struct rxe_map_set *next_map_set; +struct rxe_map **map; };enum rxe_mw_state {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 54/64 ARM: 9202/1: kasan: support CONFIG_KASAN_VMALLOC
In reply to Sasha LevinFrom: Lecopzer Chen <[email protected]>
[ Upstream commit 565cbaad83d83e288927b96565211109bc984007 ]
Simply make shadow of vmalloc area mapped on demand.
Since the virtual address of vmalloc for Arm is also between MODULE_VADDR and 0x100000000 (ZONE_HIGHMEM), which means the shadow address has already included between KASAN_SHADOW_START and KASAN_SHADOW_END.
Thus we need to change nothing for memory map of Arm.
This can fix ARM_MODULE_PLTS with KASan, support KASan for higmem and support CONFIG_VMAP_STACK with KASan.
--- arch/arm/Kconfig | 1 + arch/arm/mm/kasan_init.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -0
@@ -75,6 +75,7 @@ config ARM select HAVE_ARCH_KFENCE if MMU && !XIP_KERNEL select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL + select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_PFN_VALID select HAVE_ARCH_SECCOMP
arch/arm/mm/kasan_init.c +5 -1
@@ -236,7 +236,11 @@ void __init kasan_init(void)clear_pgds (KASAN_SHADOW_START ,KASAN_SHADOW_END ); -kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_START ), +if (!IS_ENABLED (CONFIG_KASAN_VMALLOC )) +kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_START ), +kasan_mem_to_shadow ((void *)VMALLOC_END )); + +kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_END ),kasan_mem_to_shadow ((void *)-1UL ) +1 );for_each_mem_range (i, &pa_start, &pa_end) {
Signature · 1 line
2.35.1
Re: [PATCH AUTOSEL 5.19 54/64] ARM: 9202/1: kasan: support CONFIG_KASAN_VMALLOC
Quoted 13 lines · Sasha Levin
From: Lecopzer Chen <[email protected]>
[ Upstream commit
565cbaad83d83e288927b96565211109bc984007]Simply make shadow of vmalloc area mapped on demand.
Since the virtual address of vmalloc for Arm is also between
MODULE_VADDRand0x100000000(ZONE_HIGHMEM), which means the shadow address has already included betweenKASAN_SHADOW_STARTandKASAN_SHADOW_END.
Thus we need to change nothing for memory map of Arm.
Quoted 8 lines
This can fix
ARM_MODULE_PLTSwith KASan, support KASan for higmem and supportCONFIG_VMAP_STACKwith KASan.Signed-off-by Lecopzer Chen <[email protected]>Tested-by Linus Walleij <[email protected]>Reviewed-by Linus Walleij <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This patch does not belong in -stable. It has no fixes: or cc:stable tags, and the contents are completely inappropriate for backporting anywhere. In general, I think that no patch that touches arch/arm (with the exception of DTS updates, perhaps) should ever be backported unless proposed or acked by the maintainer.
I know I shouldn't ask, but how were these patches build/boot tested? KAsan is very tricky to get right, especially on 32-bit ARM ...
Quoted 37 lines
--- arch/arm/Kconfig | 1 + arch/arm/mm/kasan_init.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-)arch/arm/Kconfig +1
-0@@ -75,6 +75,7 @@ config ARM select HAVE_ARCH_KFENCE if MMU && !XIP_KERNEL select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL + select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_PFN_VALID select HAVE_ARCH_SECCOMParch/arm/mm/kasan_init.c +5
-2@@ -236,7 +236,11 @@ void __init kasan_init(void)clear_pgds (KASAN_SHADOW_START ,KASAN_SHADOW_END ); -kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_START ), +if (!IS_ENABLED (CONFIG_KASAN_VMALLOC )) +kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_START ), +kasan_mem_to_shadow ((void *)VMALLOC_END )); + +kasan_populate_early_shadow (kasan_mem_to_shadow ((void *)VMALLOC_END ),kasan_mem_to_shadow ((void *)-1UL ) +1 );for_each_mem_range (i, &pa_start, &pa_end) { --2.35.1
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.19 54/64] ARM: 9202/1: kasan: support CONFIG_KASAN_VMALLOC
Quoted 23 lines · Ard Biesheuvel
Quoted 13 lines · Sasha Levin
From: Lecopzer Chen <[email protected]>
[ Upstream commit
565cbaad83d83e288927b96565211109bc984007]Simply make shadow of vmalloc area mapped on demand.
Since the virtual address of vmalloc for Arm is also between
MODULE_VADDRand0x100000000(ZONE_HIGHMEM), which means the shadow address has already included betweenKASAN_SHADOW_STARTandKASAN_SHADOW_END.
Thus we need to change nothing for memory map of Arm.Quoted 8 lines
This can fix
ARM_MODULE_PLTSwith KASan, support KASan for higmem and supportCONFIG_VMAP_STACKwith KASan.Signed-off-by Lecopzer Chen <[email protected]>Tested-by Linus Walleij <[email protected]>Reviewed-by Linus Walleij <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 5 lines
This patch does not belong in -stable. It has no fixes: or cc:stable tags, and the contents are completely inappropriate for backporting anywhere. In general, I think that no patch that touches
arch/arm(with the exception of DTS updates, perhaps) should ever be backported unless proposed or acked by the maintainer.
I'll drop it.
Quoted 2 lines
I know I shouldn't ask, but how were these patches build/boot tested? KAsan is very tricky to get right, especially on 32-bit ARM ...
They were only build tested at this stage. They go through boot/functional test only after they are actually queued up for the various trees.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 55/64 ARM: 9203/1: kconfig: fix MODULE_PLTS for KASAN with KASAN_VMALLOC
In reply to Sasha LevinFrom: Lecopzer Chen <[email protected]>
[ Upstream commit 8fa7ea40bf56945c3ff5af00c0dca1fd9e26f129 ]
When we run out of module space address with ko insertion, and with MODULE_PLTS, module would turn to try to find memory from VMALLOC address space.
Unfortunately, with KASAN enabled, VMALLOC doesn't work without KASAN_VMALLOC, thus select KASAN_VMALLOC by default.
8<--- cut here ---
Unable to handle kernel paging request at virtual address bd300860 [bd300860] *pgd=41cf1811, *pte=41cf26df, *ppte=41cf265f Internal error: Oops: 80f [#1] PREEMPT SMP ARM Modules linked in: hello(O+) CPU: 0 PID: 89 Comm: insmod Tainted: G O 5.16.0-rc6+ #19 Hardware name: Generic DT based system PC is at mmioset+0x30/0xa8 LR is at 0x0 pc : [<c077ed30>] lr : [<00000000>] psr: 20000013 sp : c451fc18 ip : bd300860 fp : c451fc2c r10: f18042cc r9 : f18042d0 r8 : 00000000 r7 : 00000001 r6 : 00000003 r5 : 01312d00 r4 : f1804300 r3 : 00000000 r2 : 00262560 r1 : 00000000 r0 : bd300860 Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none Control: 10c5387d Table: 43e9406a DAC: 00000051 Register r0 information: non-paged memory Register r1 information: NULL pointer Register r2 information: non-paged memory Register r3 information: NULL pointer Register r4 information: 4887-page vmalloc region starting at 0xf1802000 allocated at load_module+0x14f4/0x32a8 Register r5 information: non-paged memory Register r6 information: non-paged memory Register r7 information: non-paged memory Register r8 information: NULL pointer Register r9 information: 4887-page vmalloc region starting at 0xf1802000 allocated at load_module+0x14f4/0x32a8 Register r10 information: 4887-page vmalloc region starting at 0xf1802000 allocated at load_module+0x14f4/0x32a8 Register r11 information: non-slab/vmalloc memory Register r12 information: non-paged memory Process insmod (pid: 89, stack limit = 0xc451c000) Stack: (0xc451fc18 to 0xc4520000) fc00: f18041f0 c04803a4 fc20: c451fc44 c451fc30 c048053c c0480358 f1804030 01312cff c451fc64 c451fc48 fc40: c047f330 c0480500 f18040c0 c1b52ccc 00000001 c5be7700 c451fc74 c451fc68 fc60: f1802098 c047f300 c451fcb4 c451fc78 c026106c f180208c c4880004 00000000 fc80: c451fcb4 bf001000 c044ff48 c451fec0 f18040c0 00000000 c1b54cc4 00000000 fca0: c451fdf0 f1804268 c451fe64 c451fcb8 c0264e88 c0260d48 ffff8000 00007fff fcc0: f18040c0 c025cd00 c451fd14 00000003 0157f008 f1804258 f180425c f1804174 fce0: f1804154 f180424c f18041f0 f180414c f1804178 f18041c0 bf0025d4 188a3fa8 fd00: 0000009e f1804170 f2b18000 c451ff10 c0d92e40 f180416c c451feec 00000001 fd20: 00000000 c451fec8 c451fe20 c451fed0 f18040cc 00000000 f17ea000 c451fdc0 fd40: 41b58ab3 c1387729 c0261c28 c047fb5c c451fe2c c451fd60 c0525308 c048033c fd60: 188a3fb4 c3ccb090 c451fe00 c3ccb080 00000000 00000000 00016920 00000000 fd80: c02d0388 c047f55c c02d0388 00000000 c451fddc c451fda0 c02d0388 00000000 fda0: 41b58ab3 c13a72d0 c0524ff0 c1705f48 c451fdfc c451fdc0 c02d0388 c047f55c fdc0: 00016920 00000000 00000003 c1bb2384 c451fdfc c3ccb080 c1bb2384 00000000 fde0: 00000000 00000000 00000000 00000000 c451fe1c c451fe00 c04e9d70 c1705f48 fe00: c1b54cc4 c1bbc71c c3ccb080 00000000 c3ccb080 00000000 00000003 c451fec0 fe20: c451fe64 c451fe30 c0525918 c0524ffc c451feb0 c1705f48 00000000 c1b54cc4 fe40: b78a3fd0 c451ff60 00000000 0157f008 00000003 c451fec0 c451ffa4 c451fe68 fe60: c0265480 c0261c34 c451feb0 7fffffff 00000000 00000002 00000000 c4880000 fe80: 41b58ab3 c138777b c02652cc c04803ec 000a0000 c451ff00 ffffff9c b6ac9f60 fea0: c451fed4 c1705f48 c04a4a90 b78a3fdc f17ea000 ffffff9c b6ac9f60 c0100244 fec0: f17ea21a f17ea300 f17ea000 00016920 f1800240 f18000ac f17fb7dc 01316000 fee0: 013161b0 00002590 01316250 00000000 00000000 00000000 00002580 00000029 ff00: 0000002a 00000013 00000000 0000000c 00000000 00000000 0157f004 c451ffb0 ff20: c1719be0 aed6f410 c451ff74 c451ff38 c0c4103c c0c407d0 c451ff84 c451ff48 ff40: 00000805 c02c8658 c1604230 c1719c30 00000805 0157f004 00000005 c451ffb0 ff60: c1719be0 aed6f410 c451ffac c451ff78 c0122130 c1705f48 c451ffac 0157f008 ff80: 00000006 0000005f 0000017b c0100244 c4880000 0000017b 00000000 c451ffa8 ffa0: c0100060 c02652d8 0157f008 00000006 00000003 0157f008 00000000 b6ac9f60 ffc0: 0157f008 00000006 0000005f 0000017b 00000000 00000000 aed85f74 00000000 ffe0: b6ac9cd8 b6ac9cc8 00030200 aecf2d60 a0000010 00000003 00000000 00000000 Backtrace: [<c048034c>] (kasan_poison) from [<c048053c>] (kasan_unpoison+0x48/0x5c) [<c04804f4>] (kasan_unpoison) from [<c047f330>] (__asan_register_globals+0x3c/0x64) r5:01312cff r4:f1804030 [<c047f2f4>] (__asan_register_globals) from [<f1802098>] (_sub_I_65535_1+0x18/0xf80 [hello]) r7:c5be7700 r6:00000001 r5:c1b52ccc r4:f18040c0 [<f1802080>] (_sub_I_65535_1 [hello]) from [<c026106c>] (do_init_module+0x330/0x72c) [<c0260d3c>] (do_init_module) from [<c0264e88>] (load_module+0x3260/0x32a8) r10:f1804268 r9:c451fdf0 r8:00000000 r7:c1b54cc4 r6:00000000 r5:f18040c0 r4:c451fec0 [<c0261c28>] (load_module) from [<c0265480>] (sys_finit_module+0x1b4/0x1e8) r10:c451fec0 r9:00000003 r8:0157f008 r7:00000000 r6:c451ff60 r5:b78a3fd0 r4:c1b54cc4 [<c02652cc>] (sys_finit_module) from [<c0100060>] (ret_fast_syscall+0x0/0x1c) Exception stack(0xc451ffa8 to 0xc451fff0) ffa0: 0157f008 00000006 00000003 0157f008 00000000 b6ac9f60 ffc0: 0157f008 00000006 0000005f 0000017b 00000000 00000000 aed85f74 00000000 ffe0: b6ac9cd8 b6ac9cc8 00030200 aecf2d60 r10:0000017b r9:c4880000 r8:c0100244 r7:0000017b r6:0000005f r5:00000006 r4:0157f008 Code: e92d4100 e1a08001 e1a0e003 e2522040 (a8ac410a) ---[ end trace df6e12843197b6f5 ]---
--- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/Kconfig +1 -0
@@ -1415,6 +1415,7 @@ config HW_PERF_EVENTS config ARM_MODULE_PLTS bool "Use PLTs to allow module memory to spill over into vmalloc area" depends on MODULES + select KASAN_VMALLOC if KASAN default y help Allocate PLTs when loading modules so that jumps and calls whose
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 56/64 openrisc: io: Define iounmap argument as volatile
In reply to Sasha LevinFrom: Stafford Horne <[email protected]>
[ Upstream commit 52e0ea900202d23843daee8f7089817e81dd3dd7 ]
When OpenRISC enables PCI it allows for more drivers to be compiled resulting in exposing the following with -Werror.
drivers/video/fbdev/riva/fbdev.c: In function 'rivafb_probe':
drivers/video/fbdev/riva/fbdev.c:2062:42: error:
passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type
drivers/video/fbdev/nvidia/nvidia.c: In function 'nvidiafb_probe':
drivers/video/fbdev/nvidia/nvidia.c:1414:20: error:
passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type
drivers/scsi/aic7xxx/aic7xxx_osm.c: In function 'ahc_platform_free':
drivers/scsi/aic7xxx/aic7xxx_osm.c:1231:41: error:
passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type
Most architectures define the iounmap argument to be volatile. To fix this issue we do the same for OpenRISC. This patch must go before PCI is enabled on OpenRISC to avoid any compile failures.
--- arch/openrisc/include/asm/io.h | 2 +- arch/openrisc/mm/ioremap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/openrisc/include/asm/io.h +1 -1
@@ -31,7 +31,7 @@void __iomem *ioremap (phys_addr_t offset,unsigned long size);#define iounmap iounmap -extern void iounmap (void __iomem *addr); +extern void iounmap (volatile void __iomem *addr);#include <asm-generic/io.h>
arch/openrisc/mm/ioremap.c +1 -1
@@ -77,7 +77,7 @@ void __iomem *__ref ioremap(phys_addr_t addr, unsigned long size) }EXPORT_SYMBOL (ioremap); -void iounmap (void __iomem *addr) +void iounmap (volatile void __iomem *addr) {/* If the page is from the fixmap pool then we just clear out * the fixmap mapping.
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 57/64 phy: samsung: phy-exynos-pcie: sanitize init/power_on callbacks
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit f2812227bb07e2eaee74253f11cea1576945df31 ]
The exynos-pcie driver called phy_power_on() before phy_init() for some historical reasons. However the generic PHY framework assumes that the proper sequence is to call phy_init() first, then phy_power_on(). The operations done by both functions should be considered as one action and as such they are called by the exynos-pcie driver (without doing anything between them). The initialization is just a sequence of register writes, which cannot be altered without breaking the hardware operation.
To match the generic PHY framework requirement, simply move all register writes to the phy_init()/phy_exit() and drop power_on()/power_off() callbacks. This way the driver will also work with the old (incorrect) PHY initialization call sequence.
--- drivers/phy/samsung/phy-exynos-pcie.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/phy/samsung/phy-exynos-pcie.c +9 -16
@@ -51,6 +51,13 @@ static int exynos5433_pcie_phy_init(struct phy *phy) {struct exynos_pcie_phy *ep =phy_get_drvdata (phy); +regmap_update_bits (ep->pmureg,EXYNOS5433_PMU_PCIE_PHY_OFFSET , +BIT (0 ),1 ); +regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_GLOBAL_RESET , +PCIE_APP_REQ_EXIT_L1_MODE ,0 ); +regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_L1SUB_CM_CON , +PCIE_REFCLK_GATING_EN ,0 ); +regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_COMMON_RESET ,PCIE_PHY_RESET ,1 ); regmap_update_bits(ep->fsysreg, PCIE_EXYNOS5433_PHY_MAC_RESET,
@@ -109,20 +116,7 @@ static int exynos5433_pcie_phy_init(struct phy *phy)return 0 ; } -static int exynos5433_pcie_phy_power_on (struct phy *phy) -{ -struct exynos_pcie_phy *ep =phy_get_drvdata (phy); - -regmap_update_bits (ep->pmureg,EXYNOS5433_PMU_PCIE_PHY_OFFSET , -BIT (0 ),1 ); -regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_GLOBAL_RESET , -PCIE_APP_REQ_EXIT_L1_MODE ,0 ); -regmap_update_bits (ep->fsysreg,PCIE_EXYNOS5433_PHY_L1SUB_CM_CON , -PCIE_REFCLK_GATING_EN ,0 ); -return 0 ; -} - -static int exynos5433_pcie_phy_power_off (struct phy *phy) +static int exynos5433_pcie_phy_exit (struct phy *phy) {struct exynos_pcie_phy *ep =phy_get_drvdata (phy);
@@ -135,8 +129,7 @@ static int exynos5433_pcie_phy_power_off(struct phy *phy)static const struct phy_ops exynos5433_phy_ops = { .init = exynos5433_pcie_phy_init, - .power_on = exynos5433_pcie_phy_power_on, - .power_off = exynos5433_pcie_phy_power_off, + .exit = exynos5433_pcie_phy_exit, .owner =THIS_MODULE , };
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Sasha Levin
maintainerPATCH 58/64 md: Notify sysfs sync_completed in md_reap_sync_thread()
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 9973f0fa7d20269fe6fefe6333997fb5914449c1 ]
The mdadm test 07layouts randomly produces a kernel hung task deadlock. The deadlock is caused by the suspend_lo/suspend_hi files being set by the mdadm background process during reshape and not being cleared because the process hangs. (Leaving aside the issue of the fragility of freezing kernel tasks by buggy userspace processes...)
When the background mdadm process hangs it, is waiting (without a timeout) on a change to the sync_completed file signalling that the reshape has completed. The process is woken up a couple times when the reshape finishes but it is woken up before MD_RECOVERY_RUNNING is cleared so sync_completed_show() reports 0 instead of "none".
To fix this, notify the sysfs file in md_reap_sync_thread() after MD_RECOVERY_RUNNING has been cleared. This wakes up mdadm and causes it to continue and write to suspend_lo/suspend_hi to allow IO to continue.
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/md.c +1 -0
@@ -9466,6 +9466,7 @@ void md_reap_sync_thread(struct mddev *mddev)wake_up (&resync_wait);/* flag recovery needed just to double check */ set_bit (MD_RECOVERY_NEEDED , &mddev->recovery); +sysfs_notify_dirent_safe (mddev->sysfs_completed);sysfs_notify_dirent_safe (mddev->sysfs_action);md_new_event ();if (mddev->event_work.func)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 59/64 md/raid5: Make logic blocking check consistent with logic that blocks
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 6e3f50d30af847bebce072182bd735e90a294c6a ]
The check in raid5_make_request differs very slightly from the logic that causes it to block lower down. This likely does not cause a bug as the check is fuzzy anyway (as reshape may move on between the first check and the subsequent check). However, make it consistent so it can be cleaned up in a subsequent patch.
The condition which causes the schedule is:
!(mddev->reshape_backwards ? logical_sector < conf->reshape_progress :
logical_sector >= conf->reshape_progress) &&
(mddev->reshape_backwards ? logical_sector < conf->reshape_safe :
logical_sector >= conf->reshape_safe)
The condition that causes the early bailout is made to match this.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -5841,7 +5841,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)if ((bi->bi_opf &REQ_NOWAIT ) && (conf->reshape_progress != MaxSector) && (mddev->reshape_backwards - ? (logical_sector > conf->reshape_progress && logical_sector <= conf->reshape_safe) + ? (logical_sector >= conf->reshape_progress && logical_sector < conf->reshape_safe) : (logical_sector >= conf->reshape_safe && logical_sector < conf->reshape_progress))) {bio_wouldblock_error (bi);if (rw ==WRITE )
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 60/64 nvmet-tcp: fix lockdep complaint on nvmet_tcp_wq flush during queue teardown
In reply to Sasha LevinFrom: Sagi Grimberg <[email protected]>
[ Upstream commit 533d2e8b4d5e4c89772a0adce913525fb86cbbee ]
We probably need nvmet_tcp_wq to have MEM_RECLAIM as we are sending/receiving for the socket from works on this workqueue. Also this eliminates lockdep complaints:
--
[ 6174.010200] workqueue: WQ_MEM_RECLAIM nvmet-wq:nvmet_tcp_release_queue_work [nvmet_tcp] is flushing !WQ_MEM_RECLAIM nvmet_tcp_wq:nvmet_tcp_io_work [nvmet_tcp] [ 6174.010216] WARNING: CPU: 20 PID: 14456 at kernel/workqueue.c:2628
check_flush_dependency+0x110/0x14c
--- drivers/nvme/target/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +2 -1
@@ -1839,7 +1839,8 @@ static int __init nvmet_tcp_init(void) {int ret; - nvmet_tcp_wq =alloc_workqueue ("nvmet_tcp_wq" ,WQ_HIGHPRI ,0 ); + nvmet_tcp_wq =alloc_workqueue ("nvmet_tcp_wq" , +WQ_MEM_RECLAIM |WQ_HIGHPRI ,0 );if (!nvmet_tcp_wq)return -ENOMEM ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 61/64 drivers:md:fix a potential use-after-free bug
In reply to Sasha LevinFrom: Wentao_Liang <[email protected]>
[ Upstream commit 104212471b1c1817b311771d817fb692af983173 ]
In line 2884, "raid5_release_stripe(sh);" drops the reference to sh and may cause sh to be released. However, sh is subsequently used in lines 2886 "if (sh->batch_head && sh != sh->batch_head)". This may result in an use-after-free bug.
It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of the function.
--- drivers/md/raid5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5.c +1 -1
@@ -2881,10 +2881,10 @@ static void raid5_end_write_request(struct bio *bi)if (!test_and_clear_bit (R5_DOUBLE_LOCKED , &sh->dev[i].flags))clear_bit (R5_LOCKED , &sh->dev[i].flags);set_bit (STRIPE_HANDLE , &sh->state); -raid5_release_stripe (sh);if (sh->batch_head && sh != sh->batch_head)raid5_release_stripe (sh->batch_head); +raid5_release_stripe (sh); }static void raid5_error (struct mddev *mddev,struct md_rdev *rdev)
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 62/64 ext4: avoid remove directory when directory is corrupted
In reply to Sasha LevinFrom: Ye Bin <[email protected]>
[ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ]
Now if check directoy entry is corrupted, ext4_empty_dir may return true then directory will be removed when file system mounted with "errors=continue". In order not to make things worse just return false when directory is corrupted.
--- fs/ext4/namei.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/ext4/namei.c +2 -5
@@ -3067,11 +3067,8 @@ bool ext4_empty_dir(struct inode *inode) de = (struct ext4_dir_entry_2 *) (bh->b_data + (offset & (sb->s_blocksize -1 )));if (ext4_check_dir_entry (inode,NULL , de, bh, - bh->b_data, bh->b_size, offset)) { - offset = (offset | (sb->s_blocksize -1 )) +1 ; -continue ; - } -if (le32_to_cpu (de->inode)) { + bh->b_data, bh->b_size, offset) || +le32_to_cpu (de->inode)) {brelse (bh);return false; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 63/64 ext4: block range must be validated before use in ext4_mb_clear_bb()
In reply to Sasha LevinFrom: Lukas Czerner <[email protected]>
[ Upstream commit 1e1c2b86ef86a8477fd9b9a4f48a6bfe235606f6 ]
Block range to free is validated in ext4_free_blocks() using ext4_inode_block_valid() and then it's passed to ext4_mb_clear_bb(). However in some situations on bigalloc file system the range might be adjusted after the validation in ext4_free_blocks() which can lead to troubles on corrupted file systems such as one found by syzkaller that resulted in the following BUG
kernel BUG at fs/ext4/ext4.h:3319!
PREEMPT SMP NOPTI
CPU: 28 PID: 4243 Comm: repro Kdump: loaded Not tainted 5.19.0-rc6+ #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1.fc35 04/01/2014 RIP: 0010:ext4_free_blocks+0x95e/0xa90 Call Trace: <TASK> ? lock_timer_base+0x61/0x80 ? __es_remove_extent+0x5a/0x760 ? __mod_timer+0x256/0x380 ? ext4_ind_truncate_ensure_credits+0x90/0x220 ext4_clear_blocks+0x107/0x1b0 ext4_free_data+0x15b/0x170 ext4_ind_truncate+0x214/0x2c0 ? _raw_spin_unlock+0x15/0x30 ? ext4_discard_preallocations+0x15a/0x410 ? ext4_journal_check_start+0xe/0x90 ? __ext4_journal_start_sb+0x2f/0x110 ext4_truncate+0x1b5/0x460 ? __ext4_journal_start_sb+0x2f/0x110 ext4_evict_inode+0x2b4/0x6f0 evict+0xd0/0x1d0 ext4_enable_quotas+0x11f/0x1f0 ext4_orphan_cleanup+0x3de/0x430 ? proc_create_seq_private+0x43/0x50 ext4_fill_super+0x295f/0x3ae0 ? snprintf+0x39/0x40 ? sget_fc+0x19c/0x330 ? ext4_reconfigure+0x850/0x850 get_tree_bdev+0x16d/0x260 vfs_get_tree+0x25/0xb0 path_mount+0x431/0xa70 __x64_sys_mount+0xe2/0x120 do_syscall_64+0x5b/0x80 ? do_user_addr_fault+0x1e2/0x670 ? exc_page_fault+0x70/0x170 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7fdf4e512ace
Fix it by making sure that the block range is properly validated before used every time it changes in ext4_free_blocks() or ext4_mb_clear_bb().
--- fs/ext4/mballoc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +20 -1
@@ -5928,6 +5928,15 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode, sbi =EXT4_SB (sb); +if (!(flags &EXT4_FREE_BLOCKS_VALIDATED ) && + !ext4_inode_block_valid (inode, block, count)) { +ext4_error (sb,"Freeing blocks in system zone - " +"Block = %llu, count = %lu" , block, count); +/* err = 0. ext4_std_error should be a no op */ + goto error_return; + } + flags |=EXT4_FREE_BLOCKS_VALIDATED ; + do_more: overflow =0 ;ext4_get_group_no_and_offset (sb, block, &block_group, &bit);
@@ -5944,6 +5953,8 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode, overflow =EXT4_C2B (sbi, bit) + count -EXT4_BLOCKS_PER_GROUP (sb); count -= overflow; +/* The range changed so it's no longer validated */ + flags &= ~EXT4_FREE_BLOCKS_VALIDATED ; } count_clusters =EXT4_NUM_B2C (sbi, count); bitmap_bh =ext4_read_block_bitmap (sb, block_group);
@@ -5958,7 +5969,8 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode, goto error_return; } -if (!ext4_inode_block_valid (inode, block, count)) { +if (!(flags &EXT4_FREE_BLOCKS_VALIDATED ) && + !ext4_inode_block_valid (inode, block, count)) {ext4_error (sb,"Freeing blocks in system zone - " "Block = %llu, count = %lu" , block, count);/* err = 0. ext4_std_error should be a no op */
@@ -6081,6 +6093,8 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode, block += count; count = overflow;put_bh (bitmap_bh); +/* The range changed so it's no longer validated */ + flags &= ~EXT4_FREE_BLOCKS_VALIDATED ; goto do_more; } error_return:
@@ -6127,6 +6141,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, "block = %llu, count = %lu", block, count);return ; } + flags |=EXT4_FREE_BLOCKS_VALIDATED ;ext4_debug ("freeing block %llu\n" , block);trace_ext4_free_blocks (inode, block, count, flags);
@@ -6158,6 +6173,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, block -= overflow; count += overflow; } +/* The range changed so it's no longer validated */ + flags &= ~EXT4_FREE_BLOCKS_VALIDATED ; } overflow =EXT4_LBLK_COFF (sbi, count);if (overflow) {
@@ -6168,6 +6185,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,return ; }else count += sbi->s_cluster_ratio - overflow; +/* The range changed so it's no longer validated */ + flags &= ~EXT4_FREE_BLOCKS_VALIDATED ; }if (!bh && (flags &EXT4_FREE_BLOCKS_FORGET )) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 64/64 ext4: avoid resizing to a partial cluster size
In reply to Sasha LevinFrom: "Kiselev, Oleg" <[email protected]>
[ Upstream commit 69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd ]
This patch avoids an attempt to resize the filesystem to an unaligned cluster boundary. An online resize to a size that is not integral to cluster size results in the last iteration attempting to grow the fs by a negative amount, which trips a BUG_ON and leaves the fs with a corrupted in-memory superblock.
--- fs/ext4/resize.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ext4/resize.c +10 -0
@@ -1988,6 +1988,16 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) }brelse (bh); +/* +* For bigalloc, trim the requested size to the nearest cluster +* boundary to avoid creating an unusable filesystem. We do this +* silently, instead of returning an error, to avoid breaking +* callers that blindly resize the filesystem to the full size of +* the underlying block device. +*/ +if (ext4_has_feature_bigalloc (sb)) + n_blocks_count &= ~((1 <<EXT4_CLUSTER_BITS (sb)) -1 ); + retry: o_blocks_count =ext4_blocks_count (es);
Signature · 1 line
2.35.1