7.3.6-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 1222/2651 scsi: core: Rename sense field of struct scsi_failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 45cdf8164237277e52af5d8aa4218c3cb6199bf2 ]
Rename the sense field of struct scsi_failure to sense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in struct scsi_sense_hdr.
To be consistent with this change, the macro SCMD_FAILURE_SENSE_ANY is renamed SCMD_FAILURE_SENSE_KEY_ANY.
Of note is that the definition of the array any_sense_failure_defs in scsi_lib_test_any_sense() is modified to change the initialization of the result field to use SCMD_FAILURE_RESULT_ANY and add the .sense_key field initialization to SCMD_FAILURE_SENSE_KEY_ANY to match the test target case.
Stable-dep-of: 63cb3900be26 ("scsi: scsi_debug: Enforce physical block alignment of zoned writes")
--- drivers/scsi/ch.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 10 ++++----- drivers/scsi/scsi_lib.c | 6 ++--- drivers/scsi/scsi_lib_test.c | 25 +++++++++++---------- drivers/scsi/scsi_scan.c | 8 +++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 20 ++++++++--------- drivers/scsi/ses.c | 8 +++---- include/scsi/scsi_device.h | 12 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-)
drivers/scsi/ch.c +1 -1
@@ -190,7 +190,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =3 ,
drivers/scsi/device_handler/scsi_dh_hp_sw.c +2 -2
@@ -84,7 +84,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCMD_FAILURE_NO_LIMIT ,
@@ -138,7 +138,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)* * Switch-over in progress, retry. */ - .sense = NOT_READY, + .sense_key = NOT_READY, .asc = 0x04, .ascq = 0x03, .allowed = HP_SW_RETRIES,
drivers/scsi/device_handler/scsi_dh_rdac.c +5 -5
@@ -514,33 +514,33 @@ static void send_mode_select(struct work_struct *work)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =NO_SENSE , + .sense_key =NO_SENSE , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* LUN Not Ready and is in the Process of Becoming Ready */ { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x04 , .ascq =0x01 , .result =SAM_STAT_CHECK_CONDITION , },/* Command Lock contention */ { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCMD_FAILURE_NO_LIMIT ,
drivers/scsi/scsi_lib.c +3 -3
@@ -243,13 +243,13 @@ static int scsi_check_passthrough(struct scsi_cmnd *scmd,continue ;if (status_byte (failure->result) !=SAM_STAT_CHECK_CONDITION || - failure->sense ==SCMD_FAILURE_SENSE_ANY ) + failure->sense_key ==SCMD_FAILURE_SENSE_KEY_ANY ) goto maybe_retry;if (!scsi_command_normalize_sense (scmd, &sshdr))return 0 ; -if (failure->sense != sshdr.sense_key) +if (failure->sense_key != sshdr.sense_key)continue ;if (failure->asc ==SCMD_FAILURE_ASC_ANY )
@@ -2372,7 +2372,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,struct scsi_sense_hdr my_sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed = retries,
drivers/scsi/scsi_lib_test.c +13 -12
@@ -17,40 +17,40 @@ static void scsi_lib_test_multiple_sense(struct kunit *test) {struct scsi_failure multiple_sense_failure_defs[] = { { - .sense =DATA_PROTECT , + .sense_key =DATA_PROTECT , .asc =0x1 , .ascq =0x1 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x11 , .ascq =0x0 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x11 , .ascq =0x22 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =0x11 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =HARDWARE_ERROR , + .sense_key =HARDWARE_ERROR , .asc =SCMD_FAILURE_ASC_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED ,
@@ -116,8 +116,9 @@ static void scsi_lib_test_any_sense(struct kunit *test) {struct scsi_failure any_sense_failure_defs[] = { { - .result =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , + .result =SCMD_FAILURE_RESULT_ANY , }, {} };
@@ -129,7 +130,7 @@ static void scsi_lib_test_any_sense(struct kunit *test) .sense_buffer = sense, }; -/* Match using SCMD_FAILURE_SENSE_ANY */ +/* Match using SCMD_FAILURE_SENSE_KEY_ANY */ failures.failure_definitions = any_sense_failure_defs;scsi_build_sense (&sc,0 ,MEDIUM_ERROR ,0x11 ,0x22 );KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));
@@ -215,14 +216,14 @@ static void scsi_lib_test_total_allowed(struct kunit *test) {struct scsi_failure total_allowed_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
@@ -259,12 +260,12 @@ static void scsi_lib_test_mixed_total(struct kunit *test) {struct scsi_failure mixed_total_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x28 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .result =SAM_STAT_CHECK_CONDITION , },
drivers/scsi/scsi_scan.c +4 -4
@@ -658,12 +658,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,* so anyway. */ { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x28, .result = SAM_STAT_CHECK_CONDITION, }, { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x29, .result = SAM_STAT_CHECK_CONDITION, },
@@ -1457,14 +1457,14 @@ static int scsi_report_lun_scan(struct Scsi_Host *shost,struct scsi_device *sdev;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
drivers/scsi/scsi_transport_spi.c +1 -1
@@ -112,7 +112,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =DV_RETRIES ,
drivers/scsi/sd.c +10 -10
@@ -2033,7 +2033,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,u8 cmd[10 ] = {PERSISTENT_RESERVE_IN , sa };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2145,7 +2145,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2494,13 +2494,13 @@ sd_spinup_disk(struct scsi_disk *sdkp)struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION ,
@@ -2817,18 +2817,18 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , },/* Device reset might occur several times so retry a lot */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .allowed =READ_CAPACITY_RETRIES_ON_RESET , .result =SAM_STAT_CHECK_CONDITION ,
@@ -4159,21 +4159,21 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)struct scsi_failure failure_defs[] = { {/* Power on, reset, or bus device reset occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =0 , .result =SAM_STAT_CHECK_CONDITION , }, {/* Power on occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =1 , .result =SAM_STAT_CHECK_CONDITION , }, {/* SCSI bus reset */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =2 , .result =SAM_STAT_CHECK_CONDITION ,
drivers/scsi/ses.c +4 -4
@@ -88,14 +88,14 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,unsigned char recv_page_code;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
@@ -145,14 +145,14 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
include/scsi/scsi_device.h +6 -6
@@ -514,18 +514,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);*/ #define SCMD_FAILURE_STAT_ANY 0xff/* -* The following can be set to the scsi_failure sense, asc and ascq fields to -* match on any sense, ASC, or ASCQ value. +* The following can be set to the scsi_failure sense key, asc and ascq fields +* to match any sense key, ASC, and ASCQ value. */ -#define SCMD_FAILURE_SENSE_ANY 0xff -#define SCMD_FAILURE_ASC_ANY 0xff -#define SCMD_FAILURE_ASCQ_ANY 0xff +#define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_ASC_ANY 0xff +#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */ #define SCMD_FAILURE_NO_LIMIT -1struct scsi_failure {int result; -u8 sense; +u8 sense_key;u8 asc;u8 ascq;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1223/2651 scsi: core: Prepare for using combined sense codes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit ec5562d3ea803ec45831477129c626b2a22d2e2c ]
In preparation for handling sense codes and their qualifers as a single 16-bit sense code field, with the values defined as macros in include/scsi/scsi_sense.h, modify the definition of the structures scsi_failure and scsi_sense_hdr to introduce a 16-bit sense_code field as a union with the existing 8-bit asc and ascq fields.
This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bit sense_code field.
The helper functions scsi_sense_asc(), scsi_sense_ascq() are defined to allow accessing the 8-bit ASC and ASCQ values from the sense_code filed of struct scsi_sense_hdr. The helper functions scsi_failure_asc() and scsi_failure_ascq() provide the same for the sense code field of struct scsi_failure.
The helper functions scsi_set_sense_buffer() and scsi_set_sense() are also added to wrap calls to scsi_build_sense_buffer() and scsi_build_sense() using a 16-bit sense code argument instead of the 8-bit ASC and ASCQ arguments.
Stable-dep-of: 63cb3900be26 ("scsi: scsi_debug: Enforce physical block alignment of zoned writes")
--- include/scsi/scsi_cmnd.h | 7 +++++++ include/scsi/scsi_common.h | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_device.h | 25 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-)
include/scsi/scsi_cmnd.h +7 -0
@@ -394,6 +394,13 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq); +static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u16 code) +{ +scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);
include/scsi/scsi_common.h +29 -2
@@ -71,8 +71,18 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };u8 byte4;u8 byte5;u8 byte6;
@@ -87,10 +97,27 @@ static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)return (sshdr->response_code &0x70 ) ==0x70 ; } +static inline u8 scsi_sense_asc (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_asc (sshdr->sense_code); +} + +static inline u8 scsi_sense_ascq (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_ascq (sshdr->sense_code); +} +extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr);extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); + +static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) +{ +scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd); extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
include/scsi/scsi_device.h +23 -2
@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);* to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff#define SCMD_FAILURE_ASC_ANY 0xff#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
@@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);struct scsi_failure {int result;u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
@@ -537,6 +548,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc (const struct scsi_failure *failure) +{ +return scsi_sense_code_asc (failure->sense_code); +} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ +return scsi_sense_code_ascq (failure->sense_code); +} +struct scsi_failures {/* * If a scsi_failure does not have a retry limit setup this limit will
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1224/2651 scsi: scsi_debug: Use combined sense codes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 1b7ea7bb198e73a5237d3799187e46fe2b818ef5 ]
Refactor the scsi_debug driver to replace hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
The functions mk_sense_buffer() and mk_sense_info_tape() are modified to take a 16-bit sense code as argument.
No functional change intended.
Stable-dep-of: 63cb3900be26 ("scsi: scsi_debug: Enforce physical block alignment of zoned writes")
--- drivers/scsi/scsi_debug.c | 332 ++++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 161 deletions(-)
drivers/scsi/scsi_debug.c +171 -161
@@ -67,9 +67,6 @@ static const char *sdebug_version_date = "20210520";#define MY_NAME "scsi_debug" -/* Additional Sense Code Qualifier (ASCQ) */ -#define ACK_NAK_TO 0x3 -/* Default values for driver parameters */ #define DEF_NUM_HOST 1#define DEF_NUM_TGTS 1
@@ -1320,9 +1317,13 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp,sdev_printk (KERN_ERR , scp->device,"sense_buffer is NULL\n" );return ; } - asc = c_d ?INVALID_FIELD_IN_CDB :INVALID_FIELD_IN_PARAM_LIST ; +if (c_d) + asc =ASC_INVALID_FIELD_IN_CDB ; +else + asc =ASC_INVALID_FIELD_IN_PARAMETER_LIST ;memset (sbuff,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp, sdebug_dsense,ILLEGAL_REQUEST , asc,0 ); +scsi_set_sense (scp, sdebug_dsense,ILLEGAL_REQUEST , +scsi_sense_code (asc,0 ));memset (sks,0 ,sizeof (sks)); sks[0 ] =0x80 ;if (c_d)
@@ -1346,7 +1347,7 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, my_name, asc, c_d ? 'C' : 'D', in_byte, in_bit); } -static void mk_sense_buffer (struct scsi_cmnd *scp,int key,int asc,int asq) +static void mk_sense_buffer (struct scsi_cmnd *scp,u8 key,u16 code) {if (!scp->sense_buffer) {sdev_printk (KERN_ERR , scp->device,"sense_buffer is NULL\n" );
@@ -1354,16 +1355,16 @@ static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) }memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp, sdebug_dsense, key, asc, asq); +scsi_set_sense (scp, sdebug_dsense, key, code);if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device, -"%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n" , - my_name, key, asc, asq); +"%s: [sense_key,sense_code]: [0x%02x,0x%04x]\n" , + my_name, key, code); }/* Sense data that has information fields for tapes */ -static void mk_sense_info_tape (struct scsi_cmnd *scp,int key,int asc,int asq, +static void mk_sense_info_tape (struct scsi_cmnd *scp,u8 key,u16 code,unsigned int information,unsigned char tape_flags) {if (!scp->sense_buffer) {
@@ -1372,7 +1373,7 @@ static void mk_sense_info_tape(struct scsi_cmnd *scp, int key, int asc, int asq, }memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp,/* sdebug_dsense */ 0 , key, asc, asq); +scsi_set_sense (scp,/* sdebug_dsense */ 0 , key, code);/* only fixed format so far */ scp->sense_buffer[0 ] |=0x80 ;/* valid */
@@ -1381,13 +1382,13 @@ static void mk_sense_info_tape(struct scsi_cmnd *scp, int key, int asc, int asq,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device, -"%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n" , - my_name, key, asc, asq); +"%s: [sense_key,sense_code]: [0x%02x,0x%04x]\n" , + my_name, key, code); }static void mk_sense_invalid_opcode (struct scsi_cmnd *scp) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_OPCODE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_COMMAND_OP_CODE ); } static int scsi_debug_ioctl(struct scsi_device *dev, unsigned int cmd,
@@ -1484,46 +1485,43 @@ static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)switch (k) {case SDEBUG_UA_POR : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -POWER_ON_RESET_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED );if (sdebug_verbose) cp ="power on reset" ;break ;case SDEBUG_UA_POOCCUR : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -POWER_ON_OCCURRED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION ,POWER_ON_OCCURRED );if (sdebug_verbose) cp ="power on occurred" ;break ;case SDEBUG_UA_BUS_RESET : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -BUS_RESET_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +SCSI_BUS_RESET_OCCURRED );if (sdebug_verbose) cp ="bus reset" ;break ;case SDEBUG_UA_MODE_CHANGED : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_CHANGED_ASC , -MODE_CHANGED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +MODE_PARAMETERS_CHANGED );if (sdebug_verbose) cp ="mode parameters changed" ;break ;case SDEBUG_UA_CAPACITY_CHANGED : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_CHANGED_ASC , -CAPACITY_CHANGED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +CAPACITY_DATA_HAS_CHANGED );if (sdebug_verbose) cp ="capacity data changed" ;break ;case SDEBUG_UA_MICROCODE_CHANGED :mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -MICROCODE_CHANGED_ASCQ ); +MICROCODE_HAS_BEEN_CHANGED );if (sdebug_verbose) cp ="microcode has been changed" ;break ;case SDEBUG_UA_MICROCODE_CHANGED_WO_RESET :mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -MICROCODE_CHANGED_WO_RESET_ASCQ ); +MICROCODE_HAS_BEEN_CHANGED_WITHOUT_RESET );if (sdebug_verbose) cp ="microcode has been changed without reset" ;break ;
@@ -1539,14 +1537,13 @@ static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (sdebug_scsi_level >=6 )/* SPC-4 and above */ clear_luns_changed_on_target (devip);mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -LUNS_CHANGED_ASCQ ); +REPORTED_LUNS_DATA_HAS_CHANGED );if (sdebug_verbose) cp ="reported luns data has changed" ;break ;case SDEBUG_UA_NOT_READY_TO_READY : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_READY_ASC , -0 ); +mk_sense_buffer (scp,UNIT_ATTENTION , +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED );if (sdebug_verbose) cp ="not ready to ready transition/media change" ;break ;
@@ -2184,14 +2181,14 @@ static int resp_requests(struct scsi_cmnd *scp,if (dsense) { arr[0 ] =0x72 ; arr[1 ] =NOT_READY ; - arr[2 ] =LOGICAL_UNIT_NOT_READY ; + arr[2 ] =ASC_LU_NOT_READY ; arr[3 ] = (stopped_state ==2 ) ?0x1 :0x2 ; len =8 ; }else { arr[0 ] =0x70 ; arr[2 ] =NOT_READY ;/* NO_SENSE in sense_key */ arr[7 ] =0xa ;/* 18 byte sense buffer */ - arr[12 ] =LOGICAL_UNIT_NOT_READY ; + arr[12 ] =ASC_LU_NOT_READY ; arr[13 ] = (stopped_state ==2 ) ?0x1 :0x2 ; } }else if ((iec_m_pg[2 ] &0x4 ) && (6 == (iec_m_pg[3 ] &0xf ))) {
@@ -2199,14 +2196,14 @@ static int resp_requests(struct scsi_cmnd *scp,if (dsense) { arr[0 ] =0x72 ; arr[1 ] =0x0 ;/* NO_SENSE in sense_key */ - arr[2 ] =THRESHOLD_EXCEEDED ; + arr[2 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[3 ] =0xff ;/* Failure prediction(false) */ len =8 ; }else { arr[0 ] =0x70 ; arr[2 ] =0x0 ;/* NO_SENSE in sense_key */ arr[7 ] =0xa ;/* 18 byte sense buffer */ - arr[12 ] =THRESHOLD_EXCEEDED ; + arr[12 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[13 ] =0xff ;/* Failure prediction(false) */ } }else {/* nothing to report */
@@ -2457,8 +2454,7 @@ static int resp_rsup_opcodes(struct scsi_cmnd *scp, a_len = alloc_len; arr =kzalloc ((a_len <256 ) ?320 : a_len +64 ,GFP_ATOMIC );if (NULL == arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }switch (reporting_opts) {
@@ -2924,8 +2920,9 @@ static int resp_mode_sense(struct scsi_cmnd *scp,else bd_len =0 ; alloc_len = msense_6 ? cmd[4 ] :get_unaligned_be16 (cmd +7 ); -if (0x3 == pcontrol) {/* Saving values not supported */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,SAVING_PARAMS_UNSUP ,0 ); +if (0x3 == pcontrol) { +mk_sense_buffer (scp,ILLEGAL_REQUEST , +SAVING_PARAMETERS_NOT_SUPPORTED );return check_condition_result; } target_dev_id = ((devip->sdbg_host->shost->host_no + 1) * 2000) +
@@ -3174,7 +3171,7 @@ static int resp_mode_select(struct scsi_cmnd *scp, (arr[off +1 ] +2 );if ((pg_len + off) > param_len) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -PARAMETER_LIST_LENGTH_ERR ,0 ); +PARAMETER_LIST_LENGTH_ERROR );return check_condition_result; }switch (mpage) {
@@ -3256,7 +3253,7 @@ static int resp_ie_l_pg(unsigned char *arr)memcpy (arr, ie_l_pg,sizeof (ie_l_pg));if (iec_m_pg[2 ] &0x4 ) {/* TEST bit set */ - arr[4 ] =THRESHOLD_EXCEEDED ; + arr[4 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[5 ] =0xff ; }return sizeof (ie_l_pg);
@@ -3413,7 +3410,8 @@ static int resp_locate(struct scsi_cmnd *scp,break ;if (i < pos) { devip->tape_location[partition] = i; -mk_sense_buffer (scp,BLANK_CHECK ,0x05 ,0 ); +mk_sense_buffer (scp,BLANK_CHECK , +LU_DOES_NOT_RESPOND_TO_SELECTION );return check_condition_result; } devip->tape_location[partition] = pos;
@@ -3438,8 +3436,9 @@ static int resp_write_filemarks(struct scsi_cmnd *scp,for (i =0 , pos = devip->tape_location[partition]; i < count; i++, pos++) {if (pos >= devip->tape_eop[partition] -1 ) {/* don't overwrite EOD */ devip->tape_location[partition] = devip->tape_eop[partition] -1 ; -mk_sense_info_tape (scp,VOLUME_OVERFLOW ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , count,SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,VOLUME_OVERFLOW , +END_OF_PARTITION_MEDIUM_DETECTED , + count,SENSE_FLAG_EOM );return check_condition_result; } (devip->tape_blocks[partition] + pos)->fl_size = data;
@@ -3540,31 +3539,28 @@ static int resp_space(struct scsi_cmnd *scp, is_fm: devip->tape_location[partition] = pos; -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -FILEMARK_DETECTED_ASCQ , count - i, -SENSE_FLAG_FILEMARK ); +mk_sense_info_tape (scp,NO_SENSE ,FILEMARK_DETECTED , + count - i,SENSE_FLAG_FILEMARK );return check_condition_result; is_eod: devip->tape_location[partition] = pos; -mk_sense_info_tape (scp,BLANK_CHECK ,NO_ADDITIONAL_SENSE , -EOD_DETECTED_ASCQ , count - i, -0 ); +mk_sense_info_tape (scp,BLANK_CHECK ,END_OF_DATA_DETECTED , + count - i,0 );return check_condition_result; is_bop: devip->tape_location[partition] =0 ; -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -BEGINNING_OF_P_M_DETECTED_ASCQ , count - i, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,NO_SENSE , +BEGINNING_OF_PARTITION_MEDIUM_DETECTED , + count - i,SENSE_FLAG_EOM ); devip->tape_location[partition] =0 ;return check_condition_result; is_eop: devip->tape_location[partition] = devip->tape_eop[partition] -1 ; -mk_sense_info_tape (scp,MEDIUM_ERROR ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , (unsigned int )i, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,MEDIUM_ERROR ,END_OF_PARTITION_MEDIUM_DETECTED , + (unsigned int )i,SENSE_FLAG_EOM );return check_condition_result; }
@@ -3852,8 +3848,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* For host-managed, reads cannot cross zone types boundaries */ if (zsp->z_type != zsp_end->z_type) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -READ_INVDATA_ASCQ ); +ATTEMPT_TO_READ_INVALID_DATA );return check_condition_result; }return 0 ;
@@ -3861,8 +3856,8 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* Writing into a gap zone is not allowed */ if (zbc_zone_is_gap (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE , -ATTEMPT_ACCESS_GAP ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +ATTEMPT_TO_ACCESS_GAP_ZONE );return check_condition_result; }
@@ -3870,8 +3865,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,if (zbc_zone_is_conv (zsp)) {if (!zbc_zone_is_conv (zsp_end)) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -WRITE_BOUNDARY_ASCQ ); +WRITE_BOUNDARY_VIOLATION );return check_condition_result; }return 0 ;
@@ -3881,21 +3875,19 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* Writes cannot cross sequential zone boundaries */ if (zsp_end != zsp) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -WRITE_BOUNDARY_ASCQ ); +WRITE_BOUNDARY_VIOLATION );return check_condition_result; }/* Cannot write full zones */ if (zsp->z_cond ==ZC5_FULL ) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -INVALID_FIELD_IN_CDB ,0 ); +INVALID_FIELD_IN_CDB );return check_condition_result; }/* Writes must be aligned to the zone WP */ if (lba != zsp->z_wp) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -UNALIGNED_WRITE_ASCQ ); +UNALIGNED_WRITE_COMMAND );return check_condition_result; } }
@@ -3905,8 +3897,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,if (devip->max_open && devip->nr_exp_open >= devip->max_open) {mk_sense_buffer (scp,DATA_PROTECT , -INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +INSUFFICIENT_ZONE_RESOURCES );return check_condition_result; }zbc_open_zone (devip, zsp, false);
@@ -3923,17 +3914,18 @@ static inline int check_device_access_paramsstruct sdebug_dev_info *devip = (struct sdebug_dev_info *)sdp->hostdata;if (lba + num > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }/* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) {/* needs work to find which cdb byte 'num' comes from */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }if (write &&unlikely (sdebug_wp)) { -mk_sense_buffer (scp,DATA_PROTECT ,WRITE_PROTECTED ,0x2 ); +mk_sense_buffer (scp,DATA_PROTECT ,LU_SOFTWARE_WRITE_PROTECTED );return check_condition_result; }if (sdebug_dev_is_zoned (devip))
@@ -4442,17 +4434,17 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) i++, pos++, blp++) { devip->tape_location[partition] = pos +1 ;if (IS_TAPE_BLOCK_FM (blp->fl_size)) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -FILEMARK_DETECTED_ASCQ , fixed ? num - i : size, -SENSE_FLAG_FILEMARK ); +mk_sense_info_tape (scp,NO_SENSE ,FILEMARK_DETECTED , + fixed ? num - i : size, +SENSE_FLAG_FILEMARK );scsi_set_resid (scp, (num - i) * size);return check_condition_result; }/* Assume no REW */ if (IS_TAPE_BLOCK_EOD (blp->fl_size)) { -mk_sense_info_tape (scp,BLANK_CHECK ,NO_ADDITIONAL_SENSE , -EOD_DETECTED_ASCQ , fixed ? num - i : size, -0 ); +mk_sense_info_tape (scp,BLANK_CHECK , +END_OF_DATA_DETECTED , + fixed ? num - i : size,0 ); devip->tape_location[partition] = pos;scsi_set_resid (scp, (num - i) * size);return check_condition_result;
@@ -4464,9 +4456,9 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (fixed) {if (blp->fl_size != devip->tape_blksize) {scsi_set_resid (scp, (num - i) * size); -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -0 , num - i, -SENSE_FLAG_ILI ); +mk_sense_info_tape (scp,NO_SENSE , +NO_ADDITIONAL_SENSE_INFORMATION , + num - i,SENSE_FLAG_ILI );return check_condition_result; } }else {
@@ -4474,18 +4466,19 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (blp->fl_size < size)scsi_set_resid (scp, size - blp->fl_size);if (!sili) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -0 , size - blp->fl_size, -SENSE_FLAG_ILI ); +mk_sense_info_tape (scp,NO_SENSE , +NO_ADDITIONAL_SENSE_INFORMATION , + size - blp->fl_size, +SENSE_FLAG_ILI );return check_condition_result; } } } }if (pos >= devip->tape_eop[partition]) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , fixed ? num - i : size, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,NO_SENSE , +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : size,SENSE_FLAG_EOM ); devip->tape_location[partition] = pos -1 ;return check_condition_result; }
@@ -4572,8 +4565,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) && (lba <= (sdebug_medium_error_start + sdebug_medium_error_count -1 )) && ((lba + num) > sdebug_medium_error_start))) { -/* claim unrecoverable read error */ -mk_sense_buffer (scp,MEDIUM_ERROR ,UNRECOVERED_READ_ERR ,0 ); +mk_sense_buffer (scp,MEDIUM_ERROR ,UNRECOVERED_READ_ERROR );/* set info field and valid bit for fixed descriptor */ if (0x70 == (scp->sense_buffer[0 ] &0x7f )) { scp->sense_buffer[0 ] |=0x80 ;/* Valid bit */
@@ -4597,22 +4589,26 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)case 1 :/* Guard tag error */ if (cmd[1 ] >>5 !=3 ) {/* RDPROTECT != 3 */ sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return check_condition_result; }else if (scp->prot_flags &SCSI_PROT_GUARD_CHECK ) {sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return illegal_condition_result; }break ;case 3 :/* Reference tag error */ if (cmd[1 ] >>5 !=3 ) {/* RDPROTECT != 3 */ sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,3 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return check_condition_result; }else if (scp->prot_flags &SCSI_PROT_REF_CHECK ) {sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,3 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return illegal_condition_result; }break ;
@@ -4630,16 +4626,18 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 );return check_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }else if (SDEBUG_OPT_DIX_ERR & sdebug_opts) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }
@@ -4846,16 +4844,14 @@ static int resp_write_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) blp->fl_size =TAPE_BLOCK_EOD_FLAG ;if (pos >= devip->tape_eop[partition] -1 ) {mk_sense_info_tape (scp,VOLUME_OVERFLOW , -NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , - fixed ? num - i : transfer, -SENSE_FLAG_EOM ); +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : transfer,SENSE_FLAG_EOM );return check_condition_result; }if (ew) {/* early warning */ mk_sense_info_tape (scp,NO_SENSE , -NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , - fixed ? num - i : transfer, -SENSE_FLAG_EOM ); +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : transfer,SENSE_FLAG_EOM );return check_condition_result; }
@@ -4877,8 +4873,7 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely (sdebug_opts &SDEBUG_OPT_UNALIGNED_WRITE &&atomic_read (&sdeb_inject_pending))) {atomic_set (&sdeb_inject_pending,0 ); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE , -UNALIGNED_WRITE_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,UNALIGNED_WRITE_COMMAND );return check_condition_result; }
@@ -4959,22 +4954,26 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)case 1 :/* Guard tag error */ if (scp->prot_flags &SCSI_PROT_GUARD_CHECK ) {sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return illegal_condition_result; }else if (scp->cmnd[1 ] >>5 !=3 ) {/* WRPROTECT != 3 */ sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return check_condition_result; }break ;case 3 :/* Reference tag error */ if (scp->prot_flags &SCSI_PROT_REF_CHECK ) {sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,3 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return illegal_condition_result; }else if (scp->cmnd[1 ] >>5 !=3 ) {/* WRPROTECT != 3 */ sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,3 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return check_condition_result; }break ;
@@ -5002,16 +5001,18 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 );return check_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIX_ERR ) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }
@@ -5075,7 +5076,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device,"%s: LB Data Offset field bad\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return illegal_condition_result; } lbdof_blen = lbdof * lb_size;
@@ -5083,7 +5084,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device,"%s: LBA range descriptors don't fit\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return illegal_condition_result; } lrdp =kzalloc (lbdof_blen,GFP_ATOMIC | __GFP_NOWARN);
@@ -5124,8 +5125,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,sdev_printk (KERN_INFO , scp->device,"%s: sum of blocks > data provided\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,WRITE_ERROR_ASC , -0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,SSC_WRITE_ERROR ); ret = illegal_condition_result; goto err_out_unlock; }
@@ -5136,8 +5136,9 @@ static int resp_write_scat(struct scsi_cmnd *scp, ei_lba);if (prot_ret) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 , - prot_ret); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +scsi_sense_code (ASC_ID_CRC_OR_ECC_ERROR , + prot_ret)); ret = illegal_condition_result; goto err_out_unlock; }
@@ -5166,18 +5167,20 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 ); ret = check_condition_result; goto err_out_unlock; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 ); ret = illegal_condition_result; goto err_out_unlock; }else if (sdebug_opts &SDEBUG_OPT_DIX_ERR ) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 ); ret = illegal_condition_result; goto err_out_unlock;
@@ -5396,8 +5399,7 @@ static int resp_comp_write(struct scsi_cmnd *scp, dnum =2 * num; arr =kcalloc (lb_size, dnum,GFP_ATOMIC );if (NULL == arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5413,7 +5415,8 @@ static int resp_comp_write(struct scsi_cmnd *scp,sdeb_meta_write_lock (sip);sdeb_data_write_lock (sip);if (!comp_write_worker (sip, lba, num, arr, false)) { -mk_sense_buffer (scp,MISCOMPARE ,MISCOMPARE_VERIFY_ASC ,0 ); +mk_sense_buffer (scp,MISCOMPARE , +MISCOMPARE_DURING_VERIFY_OPERATION ); retval = check_condition_result; goto cleanup_unlock; }
@@ -5456,8 +5459,7 @@ static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) buf =kzalloc (scsi_bufflen (scp),GFP_ATOMIC );if (!buf) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5595,7 +5597,8 @@ static int resp_sync_cache(struct scsi_cmnd *scp, num_blocks =get_unaligned_be32 (cmd +10 ); }if (lba + num_blocks > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }if (!write_since_sync || (cmd[1 ] &0x2 ))
@@ -5633,7 +5636,8 @@ static int resp_pre_fetch(struct scsi_cmnd *scp, nblks =get_unaligned_be32 (cmd +10 ); }if (lba + nblks > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }if (!fsp)
@@ -5804,8 +5808,7 @@ static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) arr =kcalloc (lb_size, vnum,GFP_ATOMIC | __GFP_NOWARN);if (!arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }/* Not changing store, so only need read access */
@@ -5826,7 +5829,8 @@ static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) } ret =0 ;if (!comp_write_worker (sip, lba, vnum, arr, true)) { -mk_sense_buffer (scp,MISCOMPARE ,MISCOMPARE_VERIFY_ASC ,0 ); +mk_sense_buffer (scp,MISCOMPARE , +MISCOMPARE_DURING_VERIFY_OPERATION ); ret = check_condition_result; goto cleanup; }
@@ -5865,7 +5869,8 @@ static int resp_report_zones(struct scsi_cmnd *scp, partial = cmd[14 ] &0x80 ;if (zs_lba >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }
@@ -5876,8 +5881,8 @@ static int resp_report_zones(struct scsi_cmnd *scp, arr =kzalloc (arr_len,GFP_ATOMIC | __GFP_NOWARN);if (!arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5942,8 +5947,7 @@ static int resp_report_zones(struct scsi_cmnd *scp,continue ;break ;default : -mk_sense_buffer (scp,ILLEGAL_REQUEST , -INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); ret = check_condition_result; goto fini; }
@@ -6008,13 +6012,13 @@ static int resp_atomic_write(struct scsi_cmnd *scp,if (sdebug_atomic_wr_align &&do_div (lba_tmp, sdebug_atomic_wr_align)) {/* Does not meet alignment requirement */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }if (sdebug_atomic_wr_gran && len % sdebug_atomic_wr_gran) {/* Does not meet alignment requirement */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }
@@ -6075,8 +6079,8 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)/* Check if all closed zones can be open */ if (devip->max_open && devip->nr_exp_open + devip->nr_closed > devip->max_open) { -mk_sense_buffer (scp,DATA_PROTECT ,INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +mk_sense_buffer (scp,DATA_PROTECT , +INSUFFICIENT_ZONE_RESOURCES ); res = check_condition_result; goto fini; }
@@ -6088,19 +6092,20 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)/* Open the specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6110,8 +6115,7 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) goto fini;if (devip->max_open && devip->nr_exp_open >= devip->max_open) { -mk_sense_buffer (scp,DATA_PROTECT ,INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +mk_sense_buffer (scp,DATA_PROTECT ,INSUFFICIENT_ZONE_RESOURCES ); res = check_condition_result; goto fini; }
@@ -6155,19 +6159,20 @@ static int resp_close_zone(struct scsi_cmnd *scp,/* Close specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6227,19 +6232,20 @@ static int resp_finish_zone(struct scsi_cmnd *scp,/* Finish the specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6306,19 +6312,20 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -7189,7 +7196,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip, cmnd->result = scsi_result;if (cmnd->result ==0 &&unlikely (sdebug_opts &SDEBUG_OPT_TRANSPORT_ERR )) {if (atomic_read (&sdeb_inject_pending)) { -mk_sense_buffer (cmnd,ABORTED_COMMAND ,TRANSPORT_PROBLEM ,ACK_NAK_TO ); +mk_sense_buffer (cmnd,ABORTED_COMMAND ,ACK_NAK_TIMEOUT );atomic_set (&sdeb_inject_pending,0 ); cmnd->result = check_condition_result; }
@@ -8982,7 +8989,8 @@ static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)return 0 ; } } -mk_sense_buffer (scp,NOT_READY ,LOGICAL_UNIT_NOT_READY ,0x1 ); +mk_sense_buffer (scp,NOT_READY , +LU_IS_IN_PROCESS_OF_BECOMING_READY );if (sdebug_verbose)sdev_printk (KERN_INFO , sdp,"%s: Not ready: in process of becoming ready\n" , my_name);
@@ -9000,7 +9008,8 @@ static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)return check_condition_result; } } -mk_sense_buffer (scp,NOT_READY ,LOGICAL_UNIT_NOT_READY ,0x2 ); +mk_sense_buffer (scp,NOT_READY , +LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED );if (sdebug_verbose)sdev_printk (KERN_INFO , sdp,"%s: Not ready: initializing command required\n" , my_name);
@@ -9197,7 +9206,8 @@ static int sdebug_fail_cmd(struct scsi_cmnd *cmnd, int *retval, out_handle:if (err->cnt <0 ) err->cnt++; -mk_sense_buffer (cmnd, err->sense_key, err->asc, err->asq); +mk_sense_buffer (cmnd, err->sense_key, +scsi_sense_code (err->asc, err->asq)); result = err->status_byte | err->host_byte <<16 | err->driver_byte <<24 ; *info = *err; *retval =schedule_resp (cmnd, devip, result,NULL ,0 ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1225/2651 scsi: scsi_debug: Enforce physical block alignment of zoned writes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 63cb3900be261fccc05cadcf3402058418a5fada ]
ZBC-3 r06 (T10/BSR INCITS 579), 4.5.3.3.2, requires a write to a sequential write required zone to be terminated with ILLEGAL REQUEST / UNALIGNED WRITE COMMAND both when it does not start at the write pointer and when it does not end on a physical block boundary. That is why sd_zbc_read_zones() sets the zone_write_granularity queue limit to the physical block size of a host-managed device.
check_zbc_access_params() implements the first condition but not the second. So with zbc=managed sector_size=512 physblk_exp=3, a write of a single logical block at the write pointer is accepted and advances the write pointer by one logical block, leaving it off the granularity that was
advertised: nothing can write at it any more, and the zone can only be used again after being reset.
Check the ending LBA as well, with the same sense data, as the standard gives both conditions the same. An entire medium write same command, which the standard excludes, needs no special case: the preceding check already terminates it with WRITE BOUNDARY VIOLATION. Sequential write preferred zones are left alone, as writes to them need not be sequential, and with the default physblk_exp=0 the check is a no-op.
--- drivers/scsi/scsi_debug.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/scsi_debug.c +10 -0
@@ -3890,6 +3890,16 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, UNALIGNED_WRITE_COMMAND);return check_condition_result; } +/* +* Writes must end on a physical block boundary, that is, the +* transfer length must be a multiple of the physical block +* size. +*/ +if (!IS_ALIGNED (lba + num,1U << sdebug_physblk_exp)) { +mk_sense_buffer (scp,ILLEGAL_REQUEST , +UNALIGNED_WRITE_COMMAND ); +return check_condition_result; + } }/* Handle implicit open of closed and empty zones */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1226/2651 scsi: scsi_debug: Advance the write pointer over the data written
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit cb2d2a7c80c62d1e5e476609706f29dd9584d0e0 ]
resp_write_dt0() and resp_write_scat() advance the write pointer of a sequential write required zone by the transfer length of the command without looking at what do_device_access() returned, which is -1 when the data direction of the command does not match the operation, and a short byte count when the data-out buffer is smaller than the transfer length. An initiator can produce both with SG_IO.
The zone then describes more data than is on the medium, and a write at the position where the data really ends is terminated with UNALIGNED WRITE COMMAND, so the zone has to be reset before it can be written to again.
Advance the write pointer over the data that was written instead. As do_device_access() does not write a partial physical block to such a zone, that leaves the write pointer where a write can end.
--- drivers/scsi/scsi_debug.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/scsi/scsi_debug.c +7 -6
@@ -4994,9 +4994,9 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely (scsi_debug_lbp ()))map_region (sip, lba, num); -/* If ZBC zone then bump its write pointer */ -if (sdebug_dev_is_zoned (devip)) -zbc_inc_wp (devip, lba, num); +/* If ZBC zone then bump its write pointer over the data written */ +if (sdebug_dev_is_zoned (devip) && ret >0 ) +zbc_inc_wp (devip, lba, ret >>ilog2 (sdebug_sector_size));if (meta_data_locked)sdeb_meta_write_unlock (sip);
@@ -5161,9 +5161,10 @@ static int resp_write_scat(struct scsi_cmnd *scp, ret =do_device_access (sip, scp,min_t (u64, sg_off,scsi_bufflen (scp)), lba, num, group, true, true); -/* If ZBC zone then bump its write pointer */ -if (sdebug_dev_is_zoned (devip)) -zbc_inc_wp (devip, lba, num); +/* If ZBC zone then bump its write pointer over the data written */ +if (sdebug_dev_is_zoned (devip) && ret >0 ) +zbc_inc_wp (devip, lba, + ret >>ilog2 (sdebug_sector_size));if (unlikely (scsi_debug_lbp ()))map_region (sip, lba, num);if (unlikely (-1 == ret)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1227/2651 scsi: scsi_debug: Refuse a short WRITE ATOMIC (16) before writing it
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit b81608b17c5d04c797e6fc1cfb95182c842a4db9 ]
A write whose data-out buffer is shorter than its transfer length is short. An ordinary write transfers what the buffer holds and reports the rest as a residual, but an atomic write cannot be short: SBC-6 r02 (T10/BSR INCITS 587), 4.28.1, requires each atomic write operation to write either all of its data or none of it, and 4.28.2 requires one that cannot complete to leave the LBAs that it specifies unaltered.
resp_atomic_write() does fail a short WRITE ATOMIC (16) with DID_ERROR, but only after do_device_access() has returned, and do_device_access() copies one logical block at a time, so by then the blocks that the buffer did hold have been written. An eight block WRITE ATOMIC (16) with a buffer of four fails having overwritten the first four.
Check the length of the buffer before writing anything, and fail the command with the same DID_ERROR as before.
--- drivers/scsi/scsi_debug.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/scsi_debug.c +8 -0
@@ -6050,6 +6050,14 @@ static int resp_atomic_write(struct scsi_cmnd *scp, } } +/* +* Short atomic writes are not allowed: SBC-6 4.28.2 requires an +* atomic write that cannot complete to leave its LBAs unaltered, and +* do_device_access() would already have written part of it. +*/ +if (scsi_bufflen (scp) < len * sdebug_sector_size) +return DID_ERROR <<16 ; + ret =do_device_access (sip, scp,0 , lba, len,0 , true, true);if (unlikely (ret ==-1 ))return DID_ERROR <<16 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1228/2651 scsi: scsi_debug: Map the region written by WRITE ATOMIC (16)
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 491bd55c35cbb1ce059f22e7f3c6284551970fef ]
When logical block provisioning is enabled, every command that writes user data calls map_region() so that GET LBA STATUS reports the region as mapped. resp_atomic_write() does not, so GET LBA STATUS keeps reporting a region as deallocated after a WRITE ATOMIC (16) has written it.
Call map_region() the way resp_write_dt0() does, holding the zone metadata write lock across the access. That lock is what serialises the map against resp_unmap(), which does nothing unless logical block provisioning is enabled.
--- drivers/scsi/scsi_debug.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/scsi/scsi_debug.c +14 -0
@@ -4765,6 +4765,11 @@ static unsigned int map_state(struct sdeb_store_info *sip, sector_t lba,return mapped; } +/* +* Callers may map the whole range of a write without checking how much of +* it was written. SBC-6 4.7.4.6.2 allows a deallocated LBA to become mapped +* at any time, and only requires an LBA that was written to be mapped. +*/ static void map_region (struct sdeb_store_info *sip,sector_t lba,unsigned int len) {
@@ -6006,6 +6011,7 @@ static int resp_atomic_write(struct scsi_cmnd *scp,u8 *cmd = scp->cmnd;u16 boundary, len;u64 lba, lba_tmp; +bool lbp =scsi_debug_lbp ();int ret;if (!scsi_debug_atomic_write ()) {
@@ -6058,7 +6064,15 @@ static int resp_atomic_write(struct scsi_cmnd *scp,if (scsi_bufflen (scp) < len * sdebug_sector_size)return DID_ERROR <<16 ; +if (lbp) +sdeb_meta_write_lock (sip); + ret =do_device_access (sip, scp,0 , lba, len,0 , true, true); +if (lbp) { +map_region (sip, lba, len); +sdeb_meta_write_unlock (sip); + } +if (unlikely (ret ==-1 ))return DID_ERROR <<16 ;if (unlikely (ret != len * sdebug_sector_size))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1229/2651 scsi: scsi_debug: Validate the access parameters of WRITE ATOMIC (16)
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit a6c339feb830daa097ccc4c50c339c1733c12d42 ]
resp_atomic_write() validates the fields that are specific to an atomic write, but never the range that the command addresses. Every other command that writes user data calls check_device_access_params() first, which rejects a transfer that ends beyond the capacity of the device, one whose length exceeds the size of the store, and any write to a write protected device.
Call check_device_access_params(). The zone checks that it ends with are unreachable, as atomic writes and ZBC emulation are mutually exclusive.
--- drivers/scsi/scsi_debug.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/scsi_debug.c +4 -0
@@ -6056,6 +6056,10 @@ static int resp_atomic_write(struct scsi_cmnd *scp, } } + ret =check_device_access_params (scp, lba, len, true); +if (ret) +return ret; +/* * Short atomic writes are not allowed: SBC-6 4.28.2 requires an * atomic write that cannot complete to leave its LBAs unaltered, and
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1230/2651 scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 8d1cc285194dbcba88c136e1ff7c25cb10e38a5b ]
A device reset returns the drive's density and block size to their defaults. Commit 7081dc75df79 ("scsi: st: Restore some drive settings after reset") re-applies values changed by the user when the position is recovered with MTREW, MTSEEK or MTEOM. MTLOAD and MTRETEN are also allowed to clear the reset condition and also leave the same medium at BOT, but they restore nothing.
Because check_tape() reads the drive's block size with MODE SENSE on every open, the driver silently switches to the drive default after the reset. An application that set fixed-block mode with MTSETBLK and recovers with MTLOAD or MTRETEN keeps writing, but variable-length blocks, without any error.
Restore the changed density and block size for MTLOAD and MTRETEN as well. Both operations may make the drive report a new medium, and the new session started by check_tape() clears the "changed" flags and applies the mode defaults. So save the values before the operation, let check_tape() run first (do_load_unload() already calls it for MTLOAD; call it after MTRETEN), and then re-apply them. Retry the restore once in case a unit attention is still pending. Only restore when the drive is ready after the
operation: with an immediate-mode load and O_NONBLOCK, check_tape() does not wait and the drive may still be loading. In immediate mode (MT_ST_NOWAIT) MTRETEN may return before the retension has finished; do not wait for it there.
MTOFFL is not changed: the medium is unloaded and a different one may be loaded next, for which the mode defaults apply.
Reproduced with scsi_debug (which reports a new medium after MTRETEN and MTLOAD) and with IBM LTO drives on FC (which do not).
--- drivers/scsi/st.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/scsi/st.c +51 -0
@@ -3592,6 +3592,23 @@ static long st_common_ioctl(struct scsi_tape *STp, struct st_modedef *STm,return retval; } +/* +* Re-apply a density and block size that were changed by the user before a +* device reset (a negative value means "not changed"). A unit attention +* still pending after the operation (e.g. new medium after a load) fails the +* first MODE SELECT, so retry each once. As in the other post-reset restore +* path, errors are ignored and one setting failing does not prevent +* restoring the other. +*/ +static void st_restore_changed_settings (struct scsi_tape *STp,int density, +int blksize) +{ +if (density >=0 &&st_int_ioctl (STp,MTSETDENSITY , density)) +st_int_ioctl (STp,MTSETDENSITY , density); +if (blksize >=0 &&st_int_ioctl (STp,MTSETBLK , blksize)) +st_int_ioctl (STp,MTSETBLK , blksize); +} +/* The ioctl command */ static long st_ioctl (struct file *file,unsigned int cmd_in,unsigned long arg) {
@@ -3600,6 +3617,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)int retval =0 ;unsigned int blk;bool cmd_mtiocget; +int restore_density =-1 , restore_blksize =-1 ;struct scsi_tape *STp = file->private_data;struct st_modedef *STm;struct st_partstat *STps;
@@ -3746,6 +3764,17 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)st_int_ioctl (STp,MTSETDENSITY , STp->changed_density);if (STp->blksize_changed)st_int_ioctl (STp,MTSETBLK , STp->changed_blksize); + }else if (mtc.mt_op ==MTLOAD || mtc.mt_op ==MTRETEN ) { +/* +* The same medium ends up at BOT, so the settings +* apply as with MTREW. The operation may start a +* new session, which clears the "changed" flags: +* save the values and restore them afterwards. +*/ +if (STp->density_changed) + restore_density = STp->changed_density; +if (STp->blksize_changed) + restore_blksize = STp->changed_blksize; } }
@@ -3825,6 +3854,14 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)if (mtc.mt_op ==MTLOAD ) { retval =do_load_unload (STp, file,max (1 , mtc.mt_count)); +/* +* Restore only if the drive is ready: after an +* immediate-mode load with O_NONBLOCK, check_tape() +* does not wait and the drive may still be loading. +*/ +if (!retval && STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); goto out; }
@@ -3843,6 +3880,20 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) retval =st_compression (STp, (mtc.mt_count &1 )); else retval =st_int_ioctl (STp, mtc.mt_op, mtc.mt_count); +if (!retval && mtc.mt_op ==MTRETEN && !STp->immediate && + (restore_density >=0 || restore_blksize >=0 )) { +/* +* Retension reloads the medium and the drive may +* report a new medium. Let check_tape() start the new +* session (applying the mode defaults) now, as for +* MTLOAD; otherwise it happens at the next open and +* overrides the restored settings. +*/ +if (check_tape (STp, file) >=0 && + STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); + } goto out; }if (!STm->defined) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1231/2651 scsi: st: Record the tape position after a successful MTLOAD
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 54ee0ee9bdeb7e9d3b70cc5c2bdf7e58c4423e8d ]
Commit 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset") allows MTLOAD to clear the reset condition because the tape location is known after MTLOAD. But the driver does not record it:reset_state() sets the file and block numbers to -1, and do_load_unload() leaves them there. check_tape() sets them to 0 only for a new session, which requires a new-medium unit attention. Drives that do not report one when the medium was already loaded (seen with IBM LTO drives) keep reporting file/block -1 in MTIOCGET and no BOT, although the tape is at the beginning.
After a successful load, reset the partition and the state of all partitions, as the new-session path in check_tape() does: partition 0, position at BOT, EOF state cleared and no pending write. Otherwise the driver may still record the previous partition, so that a later MTSETPART to that partition is not performed; a read after loading at EOD fails with EIO; and a partition left in the ST_WRITING state by a partition switch in read() or write() makes st_flush() write a filemark at the beginning of partition 0 when the device is closed.
--- drivers/scsi/st.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/scsi/st.c +24 -0
@@ -2686,6 +2686,30 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_codelse { STp->rew_at_close = STp->autorew_dev; retval =check_tape (STp, filp); +/* +* LOAD leaves the medium at the beginning of partition +* 0. check_tape() records that only for a new session; +* without a new-medium unit attention (the medium was +* already loaded) the partition and the partition state +* would be left as before the load. Reset them as a +* new session does, for all partitions: a stale +* ST_WRITING state would make st_flush() write a +* filemark at the beginning of partition 0. +*/ +if (retval ==CHKRES_READY ) { +int i; + + STp->partition = STp->new_partition =0 ; +for (i =0 ; i <ST_NBR_PARTITIONS ; i++) { + STps = &(STp->ps[i]); + STps->rw =ST_IDLE ; + STps->eof =ST_NOEOF ; + STps->at_sm =0 ; + STps->last_block_valid =0 ; + STps->drv_block =0 ; + STps->drv_file =0 ; + } + }if (retval >0 ) retval =0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1232/2651 phy: rockchip-samsung-dcphy: Enable runtime PM at PHY core level
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Yang <[email protected]>
[ Upstream commit 261e84f9278f4373970471ad71479df20d82ed4c ]
phy_create() only enables runtime PM on the new PHY device if the parent already has it enabled, and this driver enables it afterwards. The PHY device therefore never gets runtime PM, and phy_pm_runtime_get_sync() returns -ENOTSUPP for every phy_init() and phy_power_on(). The block is still resumed today, but only through the supplier link fw_devlink builds from the phys phandle, which fw_devlink=off and =permissive do not.
Move devm_pm_runtime_enable() before devm_phy_create(), as done for the sibling HDPTX PHY in commit 10ba8479f460 ("phy:
phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level").
--- drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c +4 -4
@@ -1610,16 +1610,16 @@ static int samsung_mipi_dcphy_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (samsung->grf_apb_rst),"Failed to get system grf_apb_rst control\n" ); + ret =devm_pm_runtime_enable (dev); +if (ret) +return dev_err_probe (dev, ret,"Failed to enable runtime PM\n" ); + samsung->phy =devm_phy_create (dev,NULL , &samsung_mipi_dcphy_ops);if (IS_ERR (samsung->phy))return dev_err_probe (dev,PTR_ERR (samsung->phy),"Failed to create MIPI DC-PHY\n" );phy_set_drvdata (samsung->phy, samsung); - ret =devm_pm_runtime_enable (dev); -if (ret) -return dev_err_probe (dev, ret,"Failed to enable runtime PM\n" ); - phy_provider =devm_of_phy_provider_register (dev, samsung_mipi_dcphy_xlate);if (IS_ERR (phy_provider)) return dev_err_probe(dev, PTR_ERR(phy_provider),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1233/2651 phy: spacemit: fix K1 USB 2.0 PHY Kconfig dependencies
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bruno Banelli <[email protected]>
[ Upstream commit 882af55e42a4cd5bd61db0244c0b78941884518a ]
phy-k1-usb2.c maps its registers with devm_platform_ioremap_resource() and wraps them with devm_regmap_init_mmio(), but PHY_SPACEMIT_K1_USB2 neither depends on HAS_IOMEM nor selects REGMAP_MMIO.
REGMAP_MMIO has no prompt and can only be enabled by select, so a configuration that leaves it off fails to link. In practice the symbol is usually pulled in indirectly, which is why this has gone unnoticed.
PHY_SPACEMIT_K1_PCIE, directly above it in the same file, already has the HAS_IOMEM dependency; without it PHY_SPACEMIT_K1_USB2 can be built under COMPILE_TEST on architectures that provide no I/O memory.
--- drivers/phy/spacemit/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/spacemit/Kconfig +2 -0
@@ -18,8 +18,10 @@ config PHY_SPACEMIT_K1_USB2 tristate "SpacemiT K1 USB 2.0 PHY support" depends on (ARCH_SPACEMIT || COMPILE_TEST) && OF depends on COMMON_CLK + depends on HAS_IOMEM depends on USB_COMMON select GENERIC_PHY + select REGMAP_MMIO help Enable this to support K1 USB 2.0 PHY driver. This driver takes care of enabling and clock setup and will be used by K1 udc/ehci/otg/xhci driver.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1234/2651 phy: qcom: qmp-pcie: Select MFD_SYSCON for the multi-PHY driver
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit 77a0e6ae5dec54fb6049e3ab88288bc40c81f9fd ]
The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON the stub returning -ENOTSUPP is compiled in instead, so probe fails for every device and no PHY is ever registered.
Nothing in the build catches this: the driver still compiles, and arm64 defconfig happens to enable MFD_SYSCON through an unrelated select.
--- drivers/phy/qualcomm/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/Kconfig +1 -0
@@ -81,6 +81,7 @@ config PHY_QCOM_QMP_PCIE_MULTIPHY tristate "Qualcomm QMP PCIe Multi PHY Driver" depends on PCI || COMPILE_TEST select GENERIC_PHY + select MFD_SYSCON help Enable this to support the QMP PCIe PHY transceiver that is used with PCIe controllers on Qualcomm chips. This PHY is a single
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1235/2651 phy: qcom: qmp-pcie: Refactor common multiphy handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Chaitanya Chundru <[email protected]>
[ Upstream commit 6dd77bf6a10d0eb9ed17f5b6093b3511052084db ]
Reuse the existing port resource arrays for Glymur register regions, power domains, and NOCSR resets instead of maintaining duplicate Glymur-specific lists.
Attach each PHY instance's power domains to the device created for that PHY. This ensures that the associated GDSCs are managed with the lifetime of the individual PHY device rather than the parent multiphy platform device.
Validate the clock-output-names property before using its count for allocation, and use a generic module description.
Stable-dep-of: fb0f0e0e9e5d ("phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver")
--- .../phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 102 ++++++++---------- 1 file changed, 44 insertions(+), 58 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c +44 -58
@@ -113,31 +113,19 @@ static const char * const glymur_vreg_l[] = { "vdda-phy", "vdda-pll", "vdda-refgen0p9", "vdda-refgen1p2", }; -static const char *const glymur_pciephy_a_reg_l[] = { +static const char *const pciephy_port_a_reg_l[] = {"port_a" , }; -static const char *const glymur_pciephy_b_reg_l[] = { +static const char *const pciephy_port_b_reg_l[] = {"port_b" , }; -static const char *const glymur_pciephy_reg_l[] = { +static const char *const pciephy_port_ab_reg_l[] = {"port_a" ,"port_b" , }; -static const char *const glymur_pciephy_a_pd_l[] = { -"port_a" , -}; - -static const char *const glymur_pciephy_b_pd_l[] = { -"port_b" , -}; - -static const char *const glymur_pciephy_pd_l[] = { -"port_a" ,"port_b" , -}; - -static const char *const glymur_pciephy_a_nocsr_reset_l[] = { +static const char *const pciephy_port_a_nocsr_reset_l[] = {"port_a_nocsr" , };
@@ -145,7 +133,7 @@ static const char * const glymur_pciephy_nocsr_reset_l[] = { "port_a_nocsr", "port_b_nocsr", }; -static const char *const glymur_pciephy_b_nocsr_reset_l[] = { +static const char *const pciephy_port_b_nocsr_reset_l[] = {"port_b_nocsr" , };
@@ -155,12 +143,12 @@ static const struct qmp_pcie_offsets glymur_pcie_offsets_v8_50 = {static const struct qmp_phy_cfg glymur_qmp_gen5x4_pciephy_a_cfg = { .offsets = &glymur_pcie_offsets_v8_50, - .reg_names = glymur_pciephy_a_reg_l, - .num_regs =ARRAY_SIZE (glymur_pciephy_a_reg_l), - .pd_names = glymur_pciephy_a_pd_l, - .num_pds =ARRAY_SIZE (glymur_pciephy_a_pd_l), - .nocsr_reset_list = glymur_pciephy_a_nocsr_reset_l, - .num_nocsr_resets =ARRAY_SIZE (glymur_pciephy_a_nocsr_reset_l), + .reg_names = pciephy_port_a_reg_l, + .num_regs =ARRAY_SIZE (pciephy_port_a_reg_l), + .pd_names = pciephy_port_a_reg_l, + .num_pds =ARRAY_SIZE (pciephy_port_a_reg_l), + .nocsr_reset_list = pciephy_port_a_nocsr_reset_l, + .num_nocsr_resets =ARRAY_SIZE (pciephy_port_a_nocsr_reset_l), .vreg_list = glymur_vreg_l, .num_vregs =ARRAY_SIZE (glymur_vreg_l), .regs = pciephy_v8_50_regs_layout,
@@ -173,12 +161,12 @@ static const struct qmp_phy_cfg glymur_qmp_gen5x4_pciephy_a_cfg = {static const struct qmp_phy_cfg glymur_qmp_gen5x4_pciephy_b_cfg = { .offsets = &glymur_pcie_offsets_v8_50, - .reg_names = glymur_pciephy_b_reg_l, - .num_regs =ARRAY_SIZE (glymur_pciephy_b_reg_l), - .pd_names = glymur_pciephy_b_pd_l, - .num_pds =ARRAY_SIZE (glymur_pciephy_b_pd_l), - .nocsr_reset_list = glymur_pciephy_b_nocsr_reset_l, - .num_nocsr_resets =ARRAY_SIZE (glymur_pciephy_b_nocsr_reset_l), + .reg_names = pciephy_port_b_reg_l, + .num_regs =ARRAY_SIZE (pciephy_port_b_reg_l), + .pd_names = pciephy_port_b_reg_l, + .num_pds =ARRAY_SIZE (pciephy_port_b_reg_l), + .nocsr_reset_list = pciephy_port_b_nocsr_reset_l, + .num_nocsr_resets =ARRAY_SIZE (pciephy_port_b_nocsr_reset_l), .vreg_list = glymur_vreg_l, .num_vregs =ARRAY_SIZE (glymur_vreg_l), .regs = pciephy_v8_50_regs_layout,
@@ -191,10 +179,10 @@ static const struct qmp_phy_cfg glymur_qmp_gen5x4_pciephy_b_cfg = {static const struct qmp_phy_cfg glymur_qmp_gen5x8_pciephy_cfg = { .offsets = &glymur_pcie_offsets_v8_50, - .reg_names = glymur_pciephy_reg_l, - .num_regs =ARRAY_SIZE (glymur_pciephy_reg_l), - .pd_names = glymur_pciephy_pd_l, - .num_pds =ARRAY_SIZE (glymur_pciephy_pd_l), + .reg_names = pciephy_port_ab_reg_l, + .num_regs =ARRAY_SIZE (pciephy_port_ab_reg_l), + .pd_names = pciephy_port_ab_reg_l, + .num_pds =ARRAY_SIZE (pciephy_port_ab_reg_l), .nocsr_reset_list = glymur_pciephy_nocsr_reset_l, .num_nocsr_resets =ARRAY_SIZE (glymur_pciephy_nocsr_reset_l), .vreg_list = glymur_vreg_l,
@@ -398,45 +386,39 @@ static const struct phy_ops qmp_pcie_phy_ops = {static void qmp_pcie_pd_detach (void *data) {struct qmp_pcie *qmp = data; -const struct qmp_phy_cfg *cfg = qmp->cfg;int i; -for (i =0 ; i < cfg->num_pds; i++) { +for (i =0 ; i < qmp->cfg->num_pds; i++) {if (!IS_ERR_OR_NULL (qmp->pd_devs[i]))dev_pm_domain_detach (qmp->pd_devs[i], true); } } -static int qmp_pcie_pd_init (struct qmp_pcie *qmp) +static int qmp_pcie_pd_init (struct qmp_pcie *qmp,struct phy *phy) {const struct qmp_phy_cfg *cfg = qmp->cfg; -struct device *dev = qmp->dev; +struct device *pd_dev = &phy->dev;int i, ret;if (!cfg->num_pds)return 0 ; - qmp->pd_devs =devm_kcalloc (dev, cfg->num_pds,sizeof (*qmp->pd_devs), + qmp->pd_devs =devm_kcalloc (pd_dev, cfg->num_pds,sizeof (*qmp->pd_devs),GFP_KERNEL );if (!qmp->pd_devs)return -ENOMEM ; + ret =devm_add_action_or_reset (pd_dev, qmp_pcie_pd_detach, qmp); +if (ret) +return ret; +for (i =0 ; i < cfg->num_pds; i++) { - qmp->pd_devs[i] =dev_pm_domain_attach_by_name (dev, - cfg->pd_names[i]); -if (IS_ERR_OR_NULL (qmp->pd_devs[i])) { - ret =PTR_ERR (qmp->pd_devs[i]) ? : -ENODATA ; - goto err_detach; - } + qmp->pd_devs[i] =dev_pm_domain_attach_by_name (pd_dev, cfg->pd_names[i]); +if (IS_ERR_OR_NULL (qmp->pd_devs[i])) +return PTR_ERR_OR_ZERO (qmp->pd_devs[i]) ? : -ENODATA ; } -return devm_add_action_or_reset (dev, qmp_pcie_pd_detach, qmp); - -err_detach: -while (--i >=0 ) -dev_pm_domain_detach (qmp->pd_devs[i], false); - -return ret; +return 0 ; }static int qmp_pcie_vreg_init (struct qmp_pcie *qmp)
@@ -555,6 +537,8 @@ static int qmp_pcie_multiphy_register_clocks(struct device *dev,int i, ret; num_pipe_outputs =of_property_count_strings (np,"clock-output-names" ); +if (num_pipe_outputs <0 ) +return num_pipe_outputs; qmp_data->num_pipe_outputs = num_pipe_outputs; qmp_data->pipe_out_clks = devm_kcalloc(dev, num_pipe_outputs,
@@ -630,6 +614,7 @@ static struct phy *qmp_pcie_multiphy_xlate(struct device *dev,static int qmp_pcie_probe_phy (struct qmp_pcie *qmp,struct device_node *np,struct phy **out_phy) { +struct phy *phy;int ret; ret =qmp_pcie_get_mmio (qmp);
@@ -648,15 +633,16 @@ static int qmp_pcie_probe_phy(struct qmp_pcie *qmp, struct device_node *np,if (ret)return ret; - ret =qmp_pcie_pd_init (qmp); + phy =devm_phy_create (qmp->dev, np, &qmp_pcie_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); + + ret =qmp_pcie_pd_init (qmp, phy);if (ret)return ret; - *out_phy =devm_phy_create (qmp->dev, np, &qmp_pcie_phy_ops); -if (IS_ERR (*out_phy)) -return PTR_ERR (*out_phy); - -phy_set_drvdata (*out_phy, qmp); +phy_set_drvdata (phy, qmp); + *out_phy = phy;return 0 ; }
@@ -739,5 +725,5 @@ static struct platform_driver qmp_pcie_multiphy_driver = {module_platform_driver (qmp_pcie_multiphy_driver);MODULE_AUTHOR ("Qiang Yu <[email protected]>" ); -MODULE_DESCRIPTION ("Qualcomm QMP PCIe Multi-PHY driver for Glymur" ); +MODULE_DESCRIPTION ("Qualcomm QMP PCIe Multi-PHY driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1236/2651 phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
[ Upstream commit fb0f0e0e9e5dace7a6d9cde289537980ad35db3d ]
of_property_count_strings() returns a negative errno when the property is missing or malformed. The value was passed straight to devm_kcalloc(), whose overflow check rejected it, turning a device tree problem into a bogus -ENOMEM with no diagnostic.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c +2 -1
@@ -538,7 +538,8 @@ static int qmp_pcie_multiphy_register_clocks(struct device *dev, num_pipe_outputs =of_property_count_strings (np,"clock-output-names" );if (num_pipe_outputs <0 ) -return num_pipe_outputs; +return dev_err_probe (dev, num_pipe_outputs, +"failed to read clock-output-names\n" ); qmp_data->num_pipe_outputs = num_pipe_outputs; qmp_data->pipe_out_clks = devm_kcalloc(dev, num_pipe_outputs,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1237/2651 phy: rockchip: naneng-combphy: Fix TX detect RX termination errata
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <[email protected]>
[ Upstream commit d68e47a06c5cdc90cbd29ce2e74fa61eab5d47cc ]
Some PHY revisions may fail to detect the peer RX's termination resistor (RTERM) under certain critical temperature conditions. This causes TX detection failures on PCIe links.
Add a workaround to force the RTERM detection ready signal for affected PHY revisions. This ensures reliable TX-to-RX termination detection across all operating temperature ranges.
The fix applies to RK3562, RK3568, RK3576 and RK3588 SoCs which share the same PHY IP with this hardware errata.
--- .../rockchip/phy-rockchip-naneng-combphy.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +19 -0
@@ -106,6 +106,9 @@#define RK3568_PHYREG18 0x44#define RK3568_PHYREG18_PLL_LOOP 0x32 +#define RK3568_PHYREG26 0x64 +#define RK3568_PHYREG26_FORCE_RTERM_DET_RDY BIT(5) +#define RK3568_PHYREG30 0x74#define RK3568_PHYREG30_GATE_TX_PCK_SEL BIT(7)#define RK3568_PHYREG30_GATE_TX_PCK_DLY_PLL_OFF BIT(7)
@@ -194,6 +197,7 @@ struct rockchip_combphy_cfg {unsigned int num_phys;unsigned int phy_ids[3 ];const struct rockchip_combphy_grfcfg *grfcfg; +bool force_rxterm_det_rdy;int (*combphy_cfg)(struct rockchip_combphy_priv *priv); };
@@ -265,6 +269,17 @@ static int rockchip_combphy_init(struct phy *phy)switch (priv->type) {case PHY_TYPE_PCIE : +/* +* Hardware Errata: TX fails to detect peer RX termination. +* Some PHY revisions may fail to detect remote RX's RTERM +* (receiver termination resistor) under certain critical +* temperature conditions. Set force rterm detect ready to +* fix it. +*/ +if (priv->cfg->force_rxterm_det_rdy) +rockchip_combphy_updatel (priv,RK3568_PHYREG26_FORCE_RTERM_DET_RDY , +RK3568_PHYREG26_FORCE_RTERM_DET_RDY ,RK3568_PHYREG26 ); + fallthrough;case PHY_TYPE_USB3 :case PHY_TYPE_SATA :case PHY_TYPE_SGMII :
@@ -801,6 +816,7 @@ static const struct rockchip_combphy_cfg rk3562_combphy_cfgs = { }, .grfcfg = &rk3562_combphy_grfcfgs, .combphy_cfg = rk3562_combphy_cfg, + .force_rxterm_det_rdy = true, };static int rk3568_combphy_cfg (struct rockchip_combphy_priv *priv)
@@ -998,6 +1014,7 @@ static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = { }, .grfcfg = &rk3568_combphy_grfcfgs, .combphy_cfg = rk3568_combphy_cfg, + .force_rxterm_det_rdy = true, };static int rk3576_combphy_cfg (struct rockchip_combphy_priv *priv)
@@ -1219,6 +1236,7 @@ static const struct rockchip_combphy_cfg rk3576_combphy_cfgs = { }, .grfcfg = &rk3576_combphy_grfcfgs, .combphy_cfg = rk3576_combphy_cfg, + .force_rxterm_det_rdy = true, };static int rk3588_combphy_cfg (struct rockchip_combphy_priv *priv)
@@ -1391,6 +1409,7 @@ static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = { }, .grfcfg = &rk3588_combphy_grfcfgs, .combphy_cfg = rk3588_combphy_cfg, + .force_rxterm_det_rdy = true, };static const struct of_device_id rockchip_combphy_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1238/2651 phy: freescale: fsl-samsung-hdmi: initialize default rate
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristo Chen <[email protected]>
[ Upstream commit c01ccf91b257741e9edc374a465126bae9ae4711 ]
The HDMI PHY clock reports 74.25 MHz when cur_cfg is unset, but does not establish that rate in hardware. The common clock framework caches the reported rate when registering the clock and skips a first clk_set_rate(74250000) request because the rate appears unchanged.
Consequently, a display whose initial mode uses a 74.25 MHz pixel clock can leave the PHY with its bootloader register state and receive no TMDS signal. Requesting another rate first avoids the issue because the set_rate callback configures the PHY.
Program the 74.25 MHz table entry with the reference clock enabled before registering the clock provider. recalc_rate can then report the configured rate, and a skipped first rate change is safe. Also enable the reference clock when restoring that configuration on resume.
--- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 59 +++++++++++++++----- 1 file changed, 44 insertions(+), 15 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +44 -15
@@ -44,6 +44,8 @@#define MHZ (1000UL * 1000UL)#endif +#define PHY_DEFAULT_RATE 74250000 +#define PHY_PLL_DIV_REGS_NUM 7struct phy_config {
@@ -489,17 +491,6 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,return ret; } -static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) -{ -struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); - -if (!phy->cur_cfg) -return 74250000 ; - -return phy->cur_cfg->pixclk; -} -/* Helper function to lookup the available fractional-divider rate */ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate (unsigned long rate) {
@@ -520,6 +511,14 @@ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long r &phy_pll_cfg[i] : &phy_pll_cfg[i+1]); } +static unsigned long phy_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct fsl_samsung_hdmi_phy *phy =to_fsl_samsung_hdmi_phy (hw); + +return phy->cur_cfg->pixclk; +} +static void fsl_samsung_hdmi_calculate_phy (struct phy_config *cal_phy,unsigned long rate,u8 p,u16 m,u8 s) {
@@ -640,6 +639,7 @@ static int phy_clk_register(struct fsl_samsung_hdmi_phy *phy)static int fsl_samsung_hdmi_phy_probe (struct platform_device *pdev) { +const struct phy_config *default_cfg;struct fsl_samsung_hdmi_phy *phy;int ret;
@@ -664,6 +664,23 @@ static int fsl_samsung_hdmi_phy_probe(struct platform_device *pdev)return dev_err_probe (phy->dev,PTR_ERR (phy->refclk),"failed to get ref clk\n" ); +/* +* Establish the rate reported by recalc_rate() before registering the +* clock. Otherwise CCF may skip the first set_rate() when it requests +* the assumed default rate, leaving the PHY unconfigured. +*/ + ret =clk_prepare_enable (phy->refclk); +if (ret) +return dev_err_probe (phy->dev, ret, +"failed to enable ref clk\n" ); + + default_cfg =fsl_samsung_hdmi_phy_lookup_rate (PHY_DEFAULT_RATE ); + ret =fsl_samsung_hdmi_phy_configure (phy, default_cfg); +clk_disable_unprepare (phy->refclk); +if (ret) +return dev_err_probe (phy->dev, ret, +"failed to configure default rate\n" ); +pm_runtime_get_noresume (phy->dev);pm_runtime_set_active (phy->dev);pm_runtime_enable (phy->dev);
@@ -702,7 +719,7 @@ static int __maybe_unused fsl_samsung_hdmi_phy_suspend(struct device *dev)static int __maybe_unused fsl_samsung_hdmi_phy_resume (struct device *dev) {struct fsl_samsung_hdmi_phy *phy =dev_get_drvdata (dev); -int ret =0 ; +int ret; ret =clk_prepare_enable (phy->apbclk);if (ret) {
@@ -710,11 +727,23 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)return ret; } -if (phy->cur_cfg) - ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); +if (!phy->cur_cfg) +return 0 ; -return ret; + ret =clk_prepare_enable (phy->refclk); +if (ret) { +dev_err (phy->dev,"failed to enable ref clk\n" ); + goto disable_apbclk; + } + + ret =fsl_samsung_hdmi_phy_configure (phy, phy->cur_cfg); +clk_disable_unprepare (phy->refclk); +if (!ret) +return 0 ; +disable_apbclk: +clk_disable_unprepare (phy->apbclk); +return ret; } static DEFINE_RUNTIME_DEV_PM_OPS(fsl_samsung_hdmi_phy_pm_ops,
Signature · 1 line
2.53.0
Re: [PATCH 7.3 1238/2651] phy: freescale: fsl-samsung-hdmi: initialize default rate
Hello Greg,
Quoted 7 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristo Chen <[email protected]>
[ Upstream commit
c01ccf91b257741e9edc374a465126bae9ae4711]
This patch introduces regression in any RC release, 6.12, 6.18 and 7.3, please drop it.
Multiple people is affected, and I did send a revert 2 days ago, see
https://lore.kernel.org/all/[email protected]/
Francesco
Re: [PATCH 7.3 1238/2651] phy: freescale: fsl-samsung-hdmi: initialize default rate
Quoted 5 lines · Francesco Dolcini
Hello Greg,
Quoted 2 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
Quoted 8 lines
Quoted 5 lines
------------------
From: Aristo Chen <[email protected]>
[ Upstream commit
c01ccf91b257741e9edc374a465126bae9ae4711]This patch introduces regression in any RC release, 6.12, 6.18 and 7.3, please drop it.
Yes makes sense, lets drop it from stable
Quoted 3 lines
Multiple people is affected, and I did send a revert 2 days ago, see
https://lore.kernel.org/all/[email protected]/
Ack
Signature · 1 line
~Vinod
Sasha Levin
maintainerRe: [PATCH 7.3 1238/2651] phy: freescale: fsl-samsung-hdmi: initialize default rate
In reply to Francesco DolciniQuoted 2 lines · Francesco Dolcini
This patch introduces regression in any RC release, 6.12, 6.18 and 7.3, please drop it.
Dropped c01ccf91b257 ("phy: freescale: fsl-samsung-hdmi: initialize default rate") from the 7.3, 6.18 and 6.12 queues. On 6.12 the five patches that were queued only as its dependencies are dropped with it:
- 4a5a9e2577d6 ("phy: freescale: fsl-samsung-hdmi: Replace register defines with macro")
- 375ee44adb36 ("phy: freescale: fsl-samsung-hdmi: Simplify
REG21_PMS_S_MASK lookup")
- 1951dbb41d1d ("phy: freescale: fsl-samsung-hdmi: Support dynamic
integer")
- 279950205dde ("phy: freescale: fsl-samsung-hdmi: Use helper function
devm_clk_get_enabled()") - 739214dd1c20 ("phy: freescale: fsl-samsung-hdmi: Fix 64-by-32 division cocci warnings")
Dominique, the 6.12 NULL dereference you bisected is this same patch:
6.12 does not set cur_cfg before the clock is registered.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 7.3 1238/2651] phy: freescale: fsl-samsung-hdmi: initialize default rate
Sasha Levin wrote on Thu, Nov 19, 2026 at 09:08:58PM -0500:
Quoted 2 lines
Dominique, the 6.12 NULL dereference you bisected is this same patch:
6.12 does not setcur_cfgbefore the clock is registered.
Yes!
Adding commit 41db46233467 ("phy: freescale: fsl-samsung-hdmi: Refactor finding PHY settings") on top sets cur_cfg correctly and also fixes the NULL deref, but I definitely agree with dropping patches at this point (this cycle has been big enough!!), thank you for all the work!
Signature · 1 line
Dominique Martinet | Asmadeus
Greg Kroah-Hartman
maintainerPATCH 1239/2651 md: take reconfig_mutex when enabling PPL on an inactive array
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit 900bf42e0ff8009f66ffd4a679c56264957019dd ]
consistency_policy_store() sets MD_HAS_PPL for an external-metadata array that is not running yet, without holding reconfig_mutex. But ->pers is only assigned after pers->run() returns, so "not running" also covers an md_run() that is in progress under the lock.
If the write lands inside raid5_run() after log_init() has decided not to set up PPL, or after a failed ppl_init_log() has cleared the flag, the flag ends up set with conf->log_private still NULL. The next idle pass of raid5d() then does:
raid5d() -> handle_active_stripes() -> log_flush_stripe_to_raid()
-> ppl_write_stripe_run()
and dereferences the NULL ppl_conf:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002 KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:ppl_write_stripe_run+0x60/0x1320 drivers/md/raid5-ppl.c:538
Take reconfig_mutex around the update and refuse it with -EBUSY once the array is running, in which case ->change_consistency_policy() is the right interface.
--- drivers/md/md.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/md/md.c +9 -1
@@ -5887,7 +5887,15 @@ consistency_policy_store(struct mddev *mddev, const char *buf, size_t len)else err = -EBUSY ; }else if (mddev->external &&strncmp (buf,"ppl" ,3 ) ==0 ) { -set_bit (MD_HAS_PPL , &mddev->flags); +/* md_run() holds the lock until ->pers is set */ + err =mddev_lock (mddev); +if (err) +return err; +if (mddev->pers) + err = -EBUSY ; +else +set_bit (MD_HAS_PPL , &mddev->flags); +mddev_unlock (mddev); }else { err = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1240/2651 md/raid5: drain released_stripes before destroying the cache
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit af560e357a81964544be40c549e241b032ef7565 ]
grow_one_stripe() calls raid5_release_stripe() for each new stripe. When mddev->thread is already set, that queues the stripe on conf->released_stripes and wakes the thread. Only raid5d moves that list onto inactive_list.
Takeover calls setup_conf() while mddev->thread still belongs to the previous personality, so those stripes stay on released_stripes. If setup_conf() then fails, shrink_stripes() only frees inactive_list and kmem_cache_destroy() warns that objects remain.
Move stripes still queued on released_stripes onto inactive_list before shrink_stripes() frees them.
--- drivers/md/raid5.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/md/raid5.c +31 -0
@@ -2713,6 +2713,37 @@ static int drop_one_stripe(struct r5conf *conf)static void shrink_stripes (struct r5conf *conf) { +struct list_head temp[NR_STRIPE_HASH_LOCKS ]; +int i; + +/* +* grow_one_stripe() parks new stripes on released_stripes when +* mddev->thread is already set. Takeover leaves the previous +* personality's thread there, so raid5d never moves them to +* inactive_list. Drain them before the cache is destroyed. +* slab_cache is assigned only after device_lock and the hash +* lists exist; earlier abort paths have nothing to drain. +*/ +if (conf->slab_cache) { +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) +INIT_LIST_HEAD (&temp[i]); + +spin_lock_irq (&conf->device_lock); +release_stripe_list (conf, temp); +spin_unlock_irq (&conf->device_lock); + +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) { +if (list_empty (&temp[i])) +continue ; +spin_lock_irq (conf->hash_locks + i); +if (list_empty (conf->inactive_list + i)) +atomic_dec (&conf->empty_inactive_list_nr); +list_splice_tail_init (&temp[i], + conf->inactive_list + i); +spin_unlock_irq (conf->hash_locks + i); + } + } +while (conf->max_nr_stripes &&drop_one_stripe (conf)) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1241/2651 clk: imx: composite-93: return timeout from gate enable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 246d9fa6b83d2d3c524aad28de1ab5db5cecf048 ]
imx93_clk_composite_wait_ready() already reports a busy timeout, but imx93_clk_composite_gate_enable() ignores that and always returns 0. The clk framework then marks the clock enabled and lets consumers run while the CCM slice is still busy.
Propagate the timeout so enable fails instead of looking successful.
--- drivers/clk/imx/clk-composite-93.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-composite-93.c +6 -5
@@ -43,11 +43,12 @@ static int imx93_clk_composite_wait_ready(struct clk_hw *hw, void __iomem *reg)return ret; } -static void imx93_clk_composite_gate_endisable (struct clk_hw *hw,int enable) +static int imx93_clk_composite_gate_endisable (struct clk_hw *hw,int enable) {struct clk_gate *gate =to_clk_gate (hw);unsigned long flags;u32 reg; +int ret;if (gate->lock)spin_lock_irqsave (gate->lock, flags);
@@ -61,17 +62,17 @@ static void imx93_clk_composite_gate_endisable(struct clk_hw *hw, int enable)writel (reg, gate->reg); -imx93_clk_composite_wait_ready (hw, gate->reg); + ret =imx93_clk_composite_wait_ready (hw, gate->reg);if (gate->lock)spin_unlock_irqrestore (gate->lock, flags); + +return ret; }static int imx93_clk_composite_gate_enable (struct clk_hw *hw) { -imx93_clk_composite_gate_endisable (hw,1 ); - -return 0 ; +return imx93_clk_composite_gate_endisable (hw,1 ); }static void imx93_clk_composite_gate_disable (struct clk_hw *hw)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1242/2651 phy: rockchip: samsung-hdptx: Handle PHY config after module reload
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit a673b3d18e37e573d52bf41c47e75d46982f2fae ]
The pll_config_dirty mechanism introduced in commit aec3e4ce25da ("phy:
rockchip: samsung-hdptx: Handle uncommitted PHY config changes") invalidates the clock rate in determine_rate() by resetting req->rate to zero, ensuring CCF will invoke set_rate() to program pending PLL configuration changes into hardware.
However, after a module reload cycle the PHY PLL clock gets re-registered with CCF, which causes the framework's cached rate to also be zero. Setting req->rate to zero then has no effect, since CCF sees no difference between the requested and current rates and skips calling set_rate(), leaving the PLL unconfigured.
Address this by first computing the actual target rate from the HDMI link configuration, and only then invalidating it when it matches the CCF cached rate.
--- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +5 -3
@@ -2346,14 +2346,16 @@ static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw,* to ensure rk_hdptx_phy_clk_set_rate() will be always invoked. * Otherwise, restrict the rate according to the PHY link setup. */ -if (hdptx->pll_config_dirty) - req->rate =0 ; -else if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) + +if (hdptx->hdmi_cfg.mode ==PHY_HDMI_MODE_FRL ) req->rate = hdptx->hdmi_cfg.rate;else req->rate =DIV_ROUND_CLOSEST_ULL (hdptx->hdmi_cfg.rate *8 , hdptx->hdmi_cfg.bpc); +if (hdptx->pll_config_dirty && req->rate ==clk_hw_get_rate (hw)) + req->rate =0 ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1243/2651 md/raid5: protect big_stripe_tree lookup with RCU
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 73b0df929494522acf9ccc8dafea4f721166965b ]
big_stripe_tree is updated under tree_lock, and deleted radix-tree nodes are freed after an RCU grace period. r5c_big_stripe_cached() used to run under an RCU read-side critical section, but that protection was removed together with unrelated rdev lookup protection.
The lookup can now be preempted while walking the tree, allowing a concurrent deletion and grace period to complete before the walk resumes. Protect the lookup locally with rcu_read_lock(). Only the presence of the entry is used after unlocking.
--- drivers/md/raid5-cache.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/raid5-cache.c +2 -0
@@ -2970,7 +2970,9 @@ bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect)return false; tree_index =r5c_tree_index (conf, sect); +rcu_read_lock (); slot =radix_tree_lookup (&log->big_stripe_tree, tree_index); +rcu_read_unlock ();return slot !=NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1244/2651 dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit ca9a67831805dc788407a05f276abb6b86b1174d ]
On the H6 SoC, the Video Engine has two memory ports, thus two IOMMU connections. The secondary one that is missing is likely used for reading reference frames. The newer H616 is the same. On the other hand, the D1 only has one memory port.
Add the missing IOMMU connection for the Video Engine.
--- .../allwinner,sun4i-a10-video-engine.yaml | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +20 -1
@@ -55,7 +55,10 @@ properties: description: Phandle to the device SRAM iommus: - maxItems: 1 + minItems: 1 + items: + - description: VE port on IOMMU + - description: VE_R port on IOMMU memory-region: maxItems: 1
@@ -82,6 +85,22 @@ required: - resets - allwinner,sram +allOf: + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h6-video-engine + then: + properties: + iommus: + minItems: 2 + else: + properties: + iommus: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1245/2651 power: supply: bq24190_charger: dont reset registers across system suspend
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Brue <[email protected]>
[ Upstream commit e0844bd22a9f97885882bde3c4a441710e895240 ]
bq24190_pm_suspend() calls bq24190_register_reset(), which returns every register to its power-on default, and bq24190_pm_resume() does it again before re-applying the probe-time configuration. On any board that wires the charger's interrupt this makes system suspend unusable.
The reset re-arms the chip's 40 s i2c watchdog. bq24190_set_config() turns that watchdog off at probe, deliberately: as the comment there explains, the same write also takes the part out of default mode into host mode. Nothing pets it while the system is asleep, so it expires, resets the registers again and pulses INT. The charger interrupt is a system wake source -- armed unconditionally in probe since commit f385e6e2a153 ("power:bq24190_charger: Use PM runtime autosuspend"), and still enabled by default after the conversion to the wake irq API [1] -- so the pulse wakes the machine.
Measured on an MT8173 board (Amazon Fire HD 10 2017, BQ24297) by swapping only this driver between builds with and without this change, asking for a 150 s suspend each time:
on charger, with the reset: 41-43 s, 7 runs of 7 on charger, without the reset: 150 s, 3 runs of 3 on battery, with the reset: 40-41 s, 3 runs of 3 on battery, without the reset: 150 s, 3 runs of 3
It is not a charging-only problem. The watchdog runs from VBUS or from the battery, so an unplugged tablet loses suspend in the same way.
ftrace names the wake source. Across the resume, the first device interrupt after the machine comes back is the charger:
1270.760799: suspend_resume: machine_suspend[3] end 1270.775683: irq_handler_entry: irq=25 name=bq24190-charger 1270.776156: irq_handler_entry: irq=250 name=11010000.i2c
Everything between is IPI and arch_timer from bringing the secondary CPUs back up, and no RTC interrupt appears anywhere in the trace -- the 150 s wake alarm never fired. The cause leaves nothing behind for userspace to find, because WATCHDOG_FAULT is in the latch-on-read fault register and the driver's own interrupt handler has already consumed it.
The reset also discards host configuration that nothing restores. Resume calls bq24190_set_config(), which writes only the watchdog, SYS_MIN, IPRECHG, ITERM, ICHG and VREG, so:
- IINLIM returns to its power-on default. Boards without a charger-type detector set the input limit from userspace; measured here, one ordinary suspend/resume silently took input_current_limit from 1500 mA to 500 mA, and to 100 mA when running from the battery, where the default differs.
- EN_HIZ is cleared, so a charger the host put into high-impedance mode starts drawing from VBUS again the moment the system sleeps.
There is no way to have both. Default mode is what the reset is for, and on this part default mode and a disarmed watchdog are mutually exclusive: a write to any register moves the chip into host mode, and it only returns to default mode when the watchdog times out. Parking it in default mode for the sleep therefore always leaves a timer armed that will fire, and on any board that wires INT that firing is a wake. A per-board opt-out would not be choosing between two workable configurations, only between a working suspend and a broken one.
Resetting in suspend buys nothing worth this. The part is in host mode with its watchdog off; it charges on its own, switching from constant current to constant voltage and terminating when the battery is full, and nothing in it can expire or change while the host sleeps. Resetting on resume is weaker
still: the host is awake and about to reconfigure the chip, so the reset only guarantees the loss.
The one thing the reset does guard against is a host that never comes back:
a chip in host mode keeps whatever it was last told, where default mode would revert to the power-on values. But that is the state the driver leaves it in for all of normal runtime operation already, so sleep is not special, and the part still makes its own constant-current to constant-voltage transition and terminates when the battery is full.
So drop it in both directions. The suspend callback has nothing left to do and goes away. Resume re-applies the probe-time configuration, which is idempotent and also recovers a part that did somehow fall back to default mode, since bq24190_set_config() starts by turning the watchdog off.
This has been proposed before. Hans de Goede sent the same change in 2017
[2] and Sebastian Reichel agreed with the reasoning [3], but v6 kept the reset on by default and added the "disable-reset" device property instead [4]. That property cannot answer this: it is set only from x86 platform code -- i2c-cht-wc and x86-android-tablets -- and is not in bq24190.yaml, so no DT board can reach it. Every in-tree DT user of this driver (tegra124-xiaomi-mocha, qcom-msm8974-lge-nexus5-hammerhead, qcom-msm8974pro-oneplus-bacon, rk3188-bqedison2qc) wires the charger interrupt and so has the same wake armed, with no way to opt out. If some board does want the reset, it would be better expressed the other way round.
The vendor kernel for this board does not reset across suspend either: its driver, drivers/power/mt81xx/bq24297.c, only masks the charger interrupt on suspend and unmasks it on resume.
Reproduced on a BQ24297. The reasoning applies to the family, but the other parts were not available to test.
[1] https://lore.kernel.org/all/20260908-rbrue-suez-upstreaming-bq24190_charger-use-wake-irq-api-v1-1-c3f10ae2a34a@gmail.com/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/20170323112052.ukyazi4pnji7n6st@earth/
[4] https://lore.kernel.org/all/[email protected]/
--- drivers/power/supply/bq24190_charger.c | 30 ++++++++------------------ 1 file changed, 9 insertions(+), 21 deletions(-)
drivers/power/supply/bq24190_charger.c +9 -21
@@ -2249,25 +2249,6 @@ static __maybe_unused int bq24190_runtime_resume(struct device *dev)return 0 ; } -static __maybe_unused int bq24190_pm_suspend (struct device *dev) -{ -struct i2c_client *client =to_i2c_client (dev); -struct bq24190_dev_info *bdi =i2c_get_clientdata (client); -int error; - - error =pm_runtime_resume_and_get (bdi->dev); -if (error <0 ) -dev_warn (bdi->dev,"pm_runtime_get failed: %i\n" , error); - -bq24190_register_reset (bdi); - -if (error >=0 ) { -pm_runtime_put_autosuspend (bdi->dev); - } - -return 0 ; -} -static __maybe_unused int bq24190_pm_resume (struct device *dev) {struct i2c_client *client =to_i2c_client (dev);
@@ -2281,7 +2262,14 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)if (error <0 )dev_warn (bdi->dev,"pm_runtime_get failed: %i\n" , error); -bq24190_register_reset (bdi); +/* +* The chip kept its configuration through the sleep: it is in host +* mode with the i2c watchdog off, so nothing expired and nothing was +* reset. Do not reset it here either -- a userspace setting such as +* EN_HIZ or IINLIM would otherwise be silently lost on every resume. +* Re-applying the probe-time configuration is idempotent and cheap, +* and covers a part that did somehow fall back to default mode. +*/ bq24190_set_config (bdi);bq24190_read (bdi,BQ24190_REG_SS , &bdi->ss_reg);
@@ -2300,7 +2288,7 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)static const struct dev_pm_ops bq24190_pm_ops = { SET_RUNTIME_PM_OPS(bq24190_runtime_suspend, bq24190_runtime_resume, NULL) -SET_SYSTEM_SLEEP_PM_OPS (bq24190_pm_suspend, bq24190_pm_resume) +SET_SYSTEM_SLEEP_PM_OPS (NULL , bq24190_pm_resume) };static const struct i2c_device_id bq24190_i2c_ids[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1246/2651 md: Fix the null-ptr-deref of mddev->private while submitting IO
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 4c90b76e0198deb89376988daa8d96b48bea7fcf ]
Concurrent processes md_stop and IO submission can trigger a NULL pointer dereference of mddev->private:
BUG: kernel NULL pointer dereference, address: 0000000000000070 RIP: 0010:_wait_barrier+0x2f/0x250 Call Trace: raid1_make_request+0x150/0xf50 md_handle_request+0x104/0x530 md_submit_bio+0x76/0x130 submit_bio+0xdd/0x250 submit_bio_wait+0x1f/0x40 __blkdev_direct_IO_simple+0x1f6/0x370 blkdev_write_iter+0x3b2/0x520 ksys_write+0x7d/0x190
One process can submit I/O through an open file while a forked process uses the same file to issue STOP_ARRAY. The opener check permits this because md_open() was called only once. do_md_stop() can then clear mddev->private while the I/O is entering the personality make_request callback.
This affects raid0, raid1, raid10, and raid5. Suspend STOP_ARRAY while holding the reconfiguration lock so teardown waits for active_io references to drain. Fail I/O in md_handle_request() if mddev->pers is NULL after the array resumes.
The sysfs stopping paths are protected by mddev_set_closing_and_sync_blockdev(). Apply that protection to both clear and inactive transitions even when the array is read-only. dm-raid teardown is already invoked with the device suspended.
Fetch a reproducer in
https://bugzilla.kernel.org/show_bug.cgi?id=222020
--- drivers/md/md.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/md/md.c +17 -1
@@ -414,6 +414,20 @@ bool md_handle_request(struct mddev *mddev, struct bio *bio)if (!percpu_ref_tryget_live (&mddev->active_io)) goto check_suspended; } +if (!mddev->pers) { +/* +* The __md_stop() sets 'mddev->private' to NULL during +* the IO submitting, check 'mddev->pers' before the IO +* being processed by specific driver to avoid the +* null-ptr-deref of 'mddev-><member>'. The check is +* safe because the IO has got the 'mddev->active_io' +* reference, and all __md_stop() callers will wait for +* the reference to be zero. +*/ +bio_io_error (bio); +percpu_ref_put (&mddev->active_io); +return true; + }if (!mddev->pers->make_request (mddev, bio)) {percpu_ref_put (&mddev->active_io);if (mddev_is_dm (mddev) && mddev->pers->prepare_suspend)
@@ -4673,7 +4687,8 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)case readonly:case inactive:case read_auto: -if (!mddev->pers || !md_is_rdwr (mddev)) +if (!mddev->pers || + (st != clear && st != inactive && !md_is_rdwr (mddev)))break ;/* write sysfs will not open mddev and opener should be 0 */ err =mddev_set_closing_and_sync_blockdev (mddev,0 );
@@ -8319,6 +8334,7 @@ static bool md_ioctl_need_suspend(unsigned int cmd)case HOT_REMOVE_DISK :case SET_BITMAP_FILE :case SET_ARRAY_INFO : +case STOP_ARRAY :return true;default :return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1247/2651 dt-bindings: power: supply: ab8500: Add AB8505 charger
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 80d28539c1f9baab72210501729d67e3d9daa4b8 ]
AB8500 and AB8505 expose different charger interrupt sets. Add a unique AB8505 charger compatible with the AB8500 compatible as its fallback. Use the variant-specific string to require the fourteen main and USB charger interrupts on AB8500 and the nine USB charger interrupts on AB8505.
Also clarify that autopower_cfg describes the AB8500 facility, since the corresponding AB8505 register bit is reserved.
--- .../supply/stericsson,ab8500-charger.yaml | 76 ++++++++++++++----- 1 file changed, 56 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-charger.yaml +56 -20
@@ -10,12 +10,13 @@ title: AB8500 Charger maintainers: - Sebastian Reichel <[email protected]> -allOf: - - $ref: power-supply.yaml# - properties: compatible: - const: stericsson,ab8500-charger + oneOf: + - const: stericsson,ab8500-charger + - items: + - const: stericsson,ab8505-charger + - const: stericsson,ab8500-charger monitored-battery: true
@@ -28,27 +29,15 @@ properties: autopower_cfg: type: boolean - description: automatic poweron after powerloss + description: AB8500 automatic poweron after powerloss interrupts: + minItems: 9 maxItems: 14 interrupt-names: - items: - - const: MAIN_CH_UNPLUG_DET - - const: MAIN_CHARGE_PLUG_DET - - const: MAIN_EXT_CH_NOT_OK - - const: MAIN_CH_TH_PROT_R - - const: MAIN_CH_TH_PROT_F - - const: VBUS_DET_F - - const: VBUS_DET_R - - const: USB_LINK_STATUS - - const: USB_CH_TH_PROT_R - - const: USB_CH_TH_PROT_F - - const: USB_CHARGER_NOT_OKR - - const: VBUS_OVV - - const: CH_WD_EXP - - const: VBUS_CH_DROP_END + minItems: 9 + maxItems: 14 io-channels: minItems: 2
@@ -74,6 +63,53 @@ required: - io-channels - io-channel-names +allOf: + - $ref: power-supply.yaml# + - if: + properties: + compatible: + contains: + const: stericsson,ab8505-charger + then: + properties: + interrupts: + minItems: 9 + maxItems: 9 + + interrupt-names: + items: + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + else: + properties: + interrupts: + minItems: 14 + maxItems: 14 + + interrupt-names: + items: + - const: MAIN_CH_UNPLUG_DET + - const: MAIN_CHARGE_PLUG_DET + - const: MAIN_EXT_CH_NOT_OK + - const: MAIN_CH_TH_PROT_R + - const: MAIN_CH_TH_PROT_F + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1248/2651 iommu/arm-smmu-v3: Dont rb_erase() a never-inserted stream node
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit 2888520bdcbe0599cfc77b2fad8dc6c95505a3cb ]
arm_smmu_insert_master() skips inserting a stream whose StreamID duplicates one the same master already owns (bridged PCI devices can present duplicate IDs), leaving that master->streams[i].node zeroed and unlinked from the smmu->streams rb-tree.
Both the insert error-rollback loop and arm_smmu_remove_master() then call rb_erase() on every master->streams[i].node unconditionally. rb_erase() on a zeroed node sees a NULL parent, treats the node as the tree root and sets root->rb_node = NULL, silently emptying the whole SID tree and breaking SID lookups (and DMA) for every other master on the SMMU.
Mark each node with RB_CLEAR_NODE() after sort_nonatomic() reorders the array, since sorting relocates the entries and would leave the earlier self-referential RB_CLEAR_NODE() pointer stale. An un-inserted node then stays RB_EMPTY_NODE() and is skipped in both erase loops; inserted nodes are linked by rb_find_add() and erased as before.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +12 -2
@@ -4176,6 +4176,13 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,sizeof (master->streams[0 ]), arm_smmu_stream_id_cmp, NULL); +/* +* Clear after sorting: RB_CLEAR_NODE() records the node's own address, +* which sort_nonatomic() invalidates by relocating the entries. +*/ +for (i =0 ; i < fwspec->num_ids; i++) +RB_CLEAR_NODE (&master->streams[i].node); +mutex_lock (&smmu->streams_mutex);for (i =0 ; i < fwspec->num_ids; i++) {struct arm_smmu_stream *new_stream = &master->streams[i];
@@ -4208,7 +4215,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,if (ret) {for (i--; i >=0 ; i--) -rb_erase (&master->streams[i].node, &smmu->streams); +if (!RB_EMPTY_NODE (&master->streams[i].node)) +rb_erase (&master->streams[i].node, + &smmu->streams);kfree (master->streams);kfree (master->build_invs); }
@@ -4228,7 +4237,8 @@ static void arm_smmu_remove_master(struct arm_smmu_master *master)mutex_lock (&smmu->streams_mutex);for (i =0 ; i < fwspec->num_ids; i++) -rb_erase (&master->streams[i].node, &smmu->streams); +if (!RB_EMPTY_NODE (&master->streams[i].node)) +rb_erase (&master->streams[i].node, &smmu->streams);mutex_unlock (&smmu->streams_mutex);kfree (master->streams);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1249/2651 power: supply: qcom_battmgr: Report capacity on X1E80100
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liviu Nicoara <[email protected]>
[ Upstream commit f7c62ebfd9127b12a1e39f1cc7f3131cb3065886 ]
Commit 3f87baacea4d ("power: supply: qcom_battmgr: Report battery capacity") added POWER_SUPPLY_PROP_CAPACITY to the SC8280XP battery properties, computed from the firmware's charge and last-full values. When commit cc3e883a0625 ("power: supply: qcom_battmgr: Add charge control support") later gave X1E80100 a property table of its own, the table was copied without the capacity property, so X1E80100 machines expose energy_now and energy_full but no capacity.
The percentage is already computed for this variant in the shared SC8280XP callback; only the property list is missing it. Add it, in the same place it sits in the SC8280XP table.
Tested on a Dell XPS 13 9345: capacity reads 94 with energy_now 52640000 and energy_full 55540000.
--- drivers/power/supply/qcom_battmgr.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/supply/qcom_battmgr.c +1 -0
@@ -830,6 +830,7 @@ static const enum power_supply_property x1e80100_bat_props[] = {POWER_SUPPLY_PROP_STATUS ,POWER_SUPPLY_PROP_PRESENT ,POWER_SUPPLY_PROP_TECHNOLOGY , +POWER_SUPPLY_PROP_CAPACITY ,POWER_SUPPLY_PROP_CYCLE_COUNT ,POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN , POWER_SUPPLY_PROP_VOLTAGE_NOW,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1250/2651 .gitignore: drop Module.markers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit a7d32fa14bc74d1786a2f0513b6f0815bd4be311 ]
commit fc5377668c3d ("tracing: Remove markers") deleted the marker code and the modpost output. Follow-up commit 8723eaeff59a ("Kbuild: clean up marker") removed it from clean and mrproper targets. Both are from 2009, so the file is hopefully no longer in anyone's tree, drop it from .gitignore as well.
--- .gitignore | 1 - 1 file changed, 1 deletion(-)
.gitignore +0 -1
@@ -75,7 +75,6 @@ modules.order /vmlinux-gdb.py /vmlinuz /System.map -/Module.markers /modules.builtin /modules.builtin.modinfo /modules.builtin.ranges
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1251/2651 power: supply: bq257xx: Use psy directly instead of driver data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 1a64071bb30d97b75a1029943b6a3481098b254b ]
bq257xx_external_power_changed() is handed the power supply it is called for, but passes pdata->charger to power_supply_am_i_supplied(). Those are not equivalent during probe or teardown, and a supplier's changed_work can reach power_supply_external_power_changed() when pdata->charger doesn't point anywhere meaningful (e.g. freed memory during teardown).
Use the psy argument, which is valid whenever the callback runs.
--- drivers/power/supply/bq257xx_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq257xx_charger.c +1 -1
@@ -1055,7 +1055,7 @@ static void bq257xx_external_power_changed(struct power_supply *psy) pdata->chip->bq257xx_get_state (pdata); - pdata->supplied =power_supply_am_i_supplied (pdata->charger); + pdata->supplied =power_supply_am_i_supplied (psy);if (pdata->supplied <0 )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1252/2651 perf/cxl: Program the requested event group on configurable counters
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit b22dcc11429866e07dc54299255e8ca13c26d38a ]
cxl_pmu_get_event_idx() sets *counter_idx for a configurable counter but never *event_idx. hwc->event_base stays 0, so cxl_pmu_event_start() programs event group 0 no matter which group the user asked for.
Return the matched capability's event_idx.
--- drivers/perf/cxl_pmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/perf/cxl_pmu.c +6 -2
@@ -588,7 +588,10 @@ static const struct attribute_group *cxl_pmu_attr_groups[] = { NULL }; -/* If counter_idx == NULL, don't try to allocate a counter. */ +/* +* If counter_idx == NULL, don't try to allocate a counter. Callers that +* allocate pass both counter_idx and event_idx. +*/ static int cxl_pmu_get_event_idx (struct perf_event *event,int *counter_idx,int *event_idx) {
@@ -616,7 +619,7 @@ static int cxl_pmu_get_event_idx(struct perf_event *event, int *counter_idx, pmu_ev =cxl_pmu_find_config_counter_ev_cap (info, vid, gid, mask);if (!IS_ERR (pmu_ev)) { -if (!counter_idx) +if (!counter_idx || !event_idx)return 0 ; bitmap_andnot(configurable_and_free, info->conf_counter_bm,
@@ -627,6 +630,7 @@ static int cxl_pmu_get_event_idx(struct perf_event *event, int *counter_idx,return -EINVAL ; *counter_idx = i; + *event_idx = pmu_ev->event_idx;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1253/2651 perf/cxl: Clear stale event fields before reprogramming a counter
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 7406d6cf76b1dad53084f3988dc65ab967209344 ]
cxl_pmu_event_start() ORs the event group id, event mask, edge and invert selections into a configurable counter's config register without clearing them first, and cxl_pmu_event_stop() leaves them set. Reuse the counter for another event and the new selection lands on top of the old one, so the counter counts the wrong events with stale edge and invert behaviour.
Use FIELD_MODIFY() so each field is replaced rather than accumulated.
--- drivers/perf/cxl_pmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/perf/cxl_pmu.c +8 -8
@@ -759,17 +759,17 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags) cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_INT_ON_OVRFLW ,1 ); cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_FREEZE_ON_OVRFLW ,1 ); cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_ENABLE ,1 ); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EDGE , -cxl_pmu_config1_get_edge (event) ?1 :0 ); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_INVERT , -cxl_pmu_config1_get_invert (event) ?1 :0 ); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EDGE , &cfg, +cxl_pmu_config1_get_edge (event) ?1 :0 ); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_INVERT , &cfg, +cxl_pmu_config1_get_invert (event) ?1 :0 );/* Fixed purpose counters have next two fields RO */ if (test_bit (hwc->idx, info->conf_counter_bm)) { - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EVENT_GRP_ID_IDX_MSK , - hwc->event_base); - cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_EVENTS_MSK , -cxl_pmu_config_get_mask (event)); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EVENT_GRP_ID_IDX_MSK , &cfg, + hwc->event_base); +FIELD_MODIFY (CXL_PMU_COUNTER_CFG_EVENTS_MSK , &cfg, +cxl_pmu_config_get_mask (event)); } cfg &= ~CXL_PMU_COUNTER_CFG_THRESHOLD_MSK ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1254/2651 perf/cxl: Fix the counter overflow delta fixup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 0326269ed73529cdf821664b6176814cde9ca374 ]
The counter is masked to counter_width, so the subtraction in __cxl_pmu_read() throws away the bit that records the wrap. A delta of one whole period reads back as 0, the same as no events at all, and only the overflow status tells the two apart - which is why __cxl_pmu_read() takes an overflow argument.
The fixup keys off the delta rather than the operands:
delta = (new_cnt - prev_cnt) & GENMASK_ULL(counter_width - 1, 0); if (overflow && delta < GENMASK_ULL(counter_width - 1, 0)) delta += (1UL << counter_width);
so it cannot tell which of these it is looking at:
event_start polled read wrap ctr = 0 .......... ctr = P/2 ......... mask -> 0 (+r) prev = 0 prev = P/2 IRQ reads new = r
prev = 0 (no read yet): new >= prev, fell short -> add period prev = P/2 (polled): new < prev, spans wrap -> add nothing
Both rows are the same interrupt and the old guard adds a period in both, so a mid-period read makes the event over-count. 'perf stat -I' hits that.
Condition the fixup on new_cnt >= prev_cnt, the one case the subtraction cannot express. Dropping it outright would break the first row. It stays exact whatever the residual r is, which matters because some events increment by more than 1 per cycle (CXL r4.0 8.2.7.2.1, Threshold) and can step past 0 as they wrap.
Use mask + 1 for the period rather than a shift. It is 0 for a 64-bit counter, and avoids the old 1UL << counter_width - undefined for width 64, and for >= 32 on 32-bit kernels.
--- drivers/perf/cxl_pmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/perf/cxl_pmu.c +10 -6
@@ -802,7 +802,7 @@ static void __cxl_pmu_read(struct perf_event *event, bool overflow) {struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (event->pmu);struct hw_perf_event *hwc = &event->hw; -u64 new_cnt, prev_cnt, delta; +u64 new_cnt, prev_cnt, delta, mask; do { prev_cnt = local64_read(&hwc->prev_count);
@@ -810,12 +810,16 @@ static void __cxl_pmu_read(struct perf_event *event, bool overflow) }while (local64_cmpxchg (&hwc->prev_count, prev_cnt, new_cnt) != prev_cnt);/* -* If we know an overflow occur then take that into account. -* Note counter is not reset as that would lose events +* The mask discards the bit that says the counter wrapped, so a delta of +* one whole period reads back as 0 - the same as no events at all. Only +* the overflow status separates them, and new_cnt >= prev_cnt is that +* case, so add the period back. mask + 1 is 2^counter_width, which comes +* out as 0 for a 64-bit counter and avoids an undefined 1 << 64. */ - delta = (new_cnt - prev_cnt) &GENMASK_ULL (info->counter_width -1 ,0 ); -if (overflow && delta <GENMASK_ULL (info->counter_width -1 ,0 )) - delta += (1UL << info->counter_width); + mask =GENMASK_ULL (info->counter_width -1 ,0 ); + delta = (new_cnt - prev_cnt) & mask; +if (overflow && new_cnt >= prev_cnt) + delta += mask +1 ;local64_add (delta, &event->count); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1255/2651 perf/cxl: Accept an overflow interrupt on MSI message number 0
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit af06fba45746058ba8f983a0ac2f457a3404edba ]
cxl_pmu_probe() rejects the PMU when info->irq <= 0, but at that point the field still holds the MSI/MSI-X message number the device signals overflow on, not a Linux virq. That number is 0-based, and -1 means no interrupt support. Message number 0 is valid and pci_irq_vector() takes a 0-based index, so a compliant device signalling on the first vector fails to probe.
Reject only the no-interrupt case, matching how the CXL mailbox and event interrupts handle it.
--- drivers/perf/cxl_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +1 -1
@@ -986,7 +986,7 @@ static int cxl_pmu_probe(struct device *dev) .capabilities = PERF_PMU_CAP_NO_EXCLUDE, }; -if (info->irq <=0 ) +if (info->irq <0 )return -EINVAL ; rc =pci_irq_vector (pdev, info->irq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1256/2651 perf/cxl: Dont share the overflow interrupt, and keep it pinned
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit b899fd3487b0d4066d60ebcf5b73e77c9617de54 ]
The PMU pins its overflow interrupt to info->on_cpu in the hotplug callbacks, but requests it with only IRQF_SHARED | IRQF_NO_THREAD. Without IRQF_NOBALANCING, irqbalance or a userspace smp_affinity write can move it elsewhere, and cxl_pmu_irq() then runs local64_cmpxchg() and local64_add() on hwc->prev_count and event->count at the same time as the managing CPU. local64_t is only atomic against same-CPU access, so the counts corrupt.
The flag alone does not fix that while the line is shared. __setup_irq() only acts on it for the first action on a line, and a co-owner has no reason to want our affinity - it would keep taking the interrupt wherever its own points, running our handler on the wrong CPU.
Drop IRQF_SHARED and add IRQF_NOBALANCING. The spec only recommends a distinct Interrupt Message Number per CPMU instance (CXL r4.0 8.2.7.1.1), so a device may put several on one vector, or share with the mailbox or event log. Such a device now loses a PMU rather than silently miscounting - and only the PMU, since the preceding patch adds the CPMUs after the event configuration.
--- drivers/perf/cxl_pmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/perf/cxl_pmu.c +9 -2
@@ -895,7 +895,7 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data) overflowed =readq (base +CXL_PMU_OVERFLOW_REG ); -/* Interrupt may be shared, so maybe it isn't ours */ +/* Nothing overflowed, so the device did not raise this */ if (!overflowed)return IRQ_NONE ;
@@ -998,7 +998,14 @@ static int cxl_pmu_probe(struct device *dev)if (!irq_name)return -ENOMEM ; - rc =devm_request_irq (dev, irq, cxl_pmu_irq,IRQF_SHARED |IRQF_NO_THREAD , +/* +* The handler must run on info->on_cpu, so the interrupt cannot be +* shared - IRQF_NOBALANCING is only honoured for the first action on a +* line, and a co-owner would keep taking the interrupt wherever its own +* affinity points. +*/ + rc =devm_request_irq (dev, irq, cxl_pmu_irq, +IRQF_NO_THREAD |IRQF_NOBALANCING , irq_name, info);if (rc)return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1257/2651 perf/cxl: Unfreeze counters after handling an overflow interrupt
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 2e4fe234c72d65a09bbfd421240a0cfd7c8046a2 ]
The counters run with Freeze on Overflow set, so one overflow freezes every counter in the block (CXL r4.0 8.2.7.2.1), and a frozen counter "remains frozen until explicitly unfrozen by software" (8.2.7.1.3, Table 8-183). cxl_pmu_irq() reads the overflowed counters and clears the overflow status but never unfreezes, so everything stays frozen until the next pmu_enable() and events in that window are lost.
Unfreeze after clearing the status, unless the PMU has been disabled in the meantime - cxl_pmu_disable() freezes the block deliberately. Track the enabled state and leave it frozen in that case.
--- drivers/perf/cxl_pmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/perf/cxl_pmu.c +19 -0
@@ -112,6 +112,8 @@ struct cxl_pmu_info {bool filter_hdm;bool filter_crb;int irq; +/* Set between pmu_enable() and pmu_disable(), read by the IRQ handler */ +bool enabled; };#define pmu_to_cxl_pmu_info (_pmu) container_of(_pmu, struct cxl_pmu_info, pmu)
@@ -700,6 +702,7 @@ static void cxl_pmu_enable(struct pmu *pmu)void __iomem *base = info->base;/* Can assume frozen at this stage */ +WRITE_ONCE (info->enabled, true);writeq (0 , base +CXL_PMU_FREEZE_REG ); }
@@ -708,6 +711,7 @@ static void cxl_pmu_disable(struct pmu *pmu)struct cxl_pmu_info *info =pmu_to_cxl_pmu_info (pmu);void __iomem *base = info->base; +WRITE_ONCE (info->enabled, false);/* * Whilst bits above number of counters are RsvdZ * they are unlikely to be repurposed given
@@ -914,6 +918,21 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data)writeq (overflowed, base +CXL_PMU_OVERFLOW_REG ); +/* +* An overflow freezes every counter in the CPMU, so unfreeze once the +* overflowed ones have been read and their status cleared. Otherwise +* they stay frozen until the next pmu_enable() and events are lost. +* +* Not while the PMU is disabled, so as not to undo an intentional freeze. +* The check is advisory, not exclusive: pmu_disable() normally runs on +* info->on_cpu with interrupts off, where the pinned handler cannot +* preempt it. In the one window where it does not - the migration in +* cxl_pmu_offline_cpu() - the counters are legitimately running again, +* so unfreezing is correct there anyway. +*/ +if (READ_ONCE (info->enabled)) +writeq (0 , base +CXL_PMU_FREEZE_REG ); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1258/2651 perf/cxl: Validate the hardware-reported counter width
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 1c5499e67303a9393388197fb14b39ed06a3dc55 ]
cxl_pmu_parse_caps() takes the Counter Width straight from the CPMU Capability register without a bounds check. The Counter Data register is 64 bits wide, so a device reporting 0 or more than 64 is reporting nonsense, and GENMASK_ULL(width - 1, 0) in the read path then shifts out of range. That is undefined behaviour, and a UBSAN splat where it is enabled.
Reject a counter width outside 1..64 at probe.
--- drivers/perf/cxl_pmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/perf/cxl_pmu.c +9 -0
@@ -146,6 +146,15 @@ static int cxl_pmu_parse_caps(struct device *dev, struct cxl_pmu_info *info) info->num_counters =FIELD_GET (CXL_PMU_CAP_NUM_COUNTERS_MSK , val) +1 ; info->counter_width =FIELD_GET (CXL_PMU_CAP_COUNTER_WIDTH_MSK , val); +/* +* The Counter Data register is 64 bits wide, so a Counter Width of 0 or +* >64 is invalid. Reject it rather than let GENMASK_ULL(width - 1, 0) in +* the read path shift out of range. +*/ +if (info->counter_width ==0 || info->counter_width >64 ) { +dev_err (dev,"Invalid counter width %d\n" , info->counter_width); +return -ENODEV ; + } info->num_event_capabilities =FIELD_GET (CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK , val) +1 ; info->filter_hdm =FIELD_GET (CXL_PMU_CAP_FILTERS_SUP_MSK , val) &CXL_PMU_FILTER_HDM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1259/2651 perf/cxl: Dont log through pmu.dev in the overflow interrupt handler
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 984920c893f0e6832351bc03deeb5ef9a42fbdbb ]
perf_pmu_unregister() frees pmu->dev without clearing the pointer, and cxl_pmu_probe() orders its devm actions so that teardown runs it before free_irq(). Nothing in between masks the interrupt, and cxl_pmu_event_stop() leaves the overflow status bit set, so an overflow taken just before teardown is still delivered and still reaches the dev_dbg() in the !event branch - by which point info->pmu.dev is freed.
Log through info->pmu.parent instead, which is devm-managed and outlives every teardown action.
--- drivers/perf/cxl_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +1 -1
@@ -917,7 +917,7 @@ static irqreturn_t cxl_pmu_irq(int irq, void *data)struct perf_event *event = info->hw_events[i];if (!event) { -dev_dbg (info->pmu.dev, +dev_dbg (info->pmu.parent,"overflow but on non enabled counter %d\n" , i);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1260/2651 perf/cxl: Clear stale overflow status before using a counter
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 05d82cf377f706d0b566b572bc66e3a2057bd68e ]
cxl_pmu_event_stop() leaves the counter's bit set in the overflow status register and only cxl_pmu_irq() ever clears it, so a counter handed from one event to the next starts with the previous owner's overflow pending. The perf core stops and starts back to back with interrupts off, so an interrupt latched over the handover lands on the new event. prev_count is 0 by then, so the read path adds a full period: 2^counter_width phantom counts.
Clear the bit in cxl_pmu_event_start(), before the config write arms Interrupt on Overflow. Clear the whole register at probe too, for counters no event ever owns - the driver never touched it, so firmware or a previous kernel can leave a bit set there.
--- drivers/perf/cxl_pmu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/perf/cxl_pmu.c +17 -0
@@ -795,6 +795,15 @@ static void cxl_pmu_event_start(struct perf_event *event, int flags)*/ cfg |=FIELD_PREP (CXL_PMU_COUNTER_CFG_THRESHOLD_MSK ,cxl_pmu_config1_get_threshold (event)); + +/* +* Drop any overflow the previous owner of this counter left pending; +* cxl_pmu_event_stop() does not. Otherwise an interrupt latched over +* the handover gets charged to this event. Do it before arming Interrupt +* on Overflow below, and note RW1C leaves the other counters alone. +*/ +writeq (BIT_ULL (hwc->idx), base +CXL_PMU_OVERFLOW_REG ); +writeq (cfg, base +CXL_PMU_COUNTER_CFG_REG (hwc->idx));local64_set (&hwc->prev_count,0 );
@@ -1026,6 +1035,14 @@ static int cxl_pmu_probe(struct device *dev)if (!irq_name)return -ENOMEM ; +/* +* Same for counters no event owns yet: clear whatever firmware or a +* previous kernel left set before the handler goes live. Bits above the +* implemented counters are reserved, so only write those. +*/ +writeq (GENMASK_ULL (info->num_counters -1 ,0 ), + info->base +CXL_PMU_OVERFLOW_REG ); +/* * The handler must run on info->on_cpu, so the interrupt cannot be * shared - IRQF_NOBALANCING is only honoured for the first action on a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1261/2651 perf/dwc_pcie: Fix PCI device reference leak in probe
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 3a4067658363e34bf4e1d7039e5b52951fcb4012 ]
pci_get_domain_bus_and_slot() returns a referenced PCI device. When the subsequent RAS DES capability lookup fails, dwc_pcie_pmu_probe() returns -ENODEV without releasing that reference. Repeated failed probes can therefore keep the PCI device allocated after removal.
Declare the looked-up device with __free(pci_dev_put), so the temporary reference is released on every return path. Keeping the reference scoped to the whole probe also covers all later uses of the device during initialization.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/perf/dwc_pcie_pmu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/perf/dwc_pcie_pmu.c +5 -6
@@ -747,16 +747,16 @@ static struct notifier_block dwc_pcie_pmu_nb = {static int dwc_pcie_pmu_probe (struct platform_device *plat_dev) { -struct pci_dev *pdev; +u32 sbdf = plat_dev->id; + struct pci_dev *pdev __free(pci_dev_put) = +pci_get_domain_bus_and_slot (sbdf >>16 , +PCI_BUS_NUM (sbdf &0xffff ), + sbdf &0xff );struct dwc_pcie_pmu *pcie_pmu;char *name; -u32 sbdf;u16 vsec;int ret; - sbdf = plat_dev->id; - pdev =pci_get_domain_bus_and_slot (sbdf >>16 ,PCI_BUS_NUM (sbdf &0xffff ), - sbdf &0xff );if (!pdev) {pr_err ("No pdev found for the sbdf 0x%x\n" , sbdf);return -ENODEV ;
@@ -766,7 +766,6 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)if (!vsec)return -ENODEV ; -pci_dev_put (pdev); name =devm_kasprintf (&plat_dev->dev,GFP_KERNEL ,"dwc_rootport_%x" , sbdf);if (!name)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1262/2651 perf: marvell: avoid large stack variables
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 7e17084177aa6c76231c6ee8cdbbcd24f40c86cc ]
The probe function in this driver constructs multiple large structures on the stack, which ends up causing a size warning:
drivers/perf/marvell_cn10k_ddr_pmu.c:1168:12: error: stack frame size (1296) exceeds limit (1280) in 'cn10k_ddr_perf_probe' [-Werror,-Wframe-larger-than]
1168 | static int cn10k_ddr_perf_probe(struct platform_device *pdev)
| ^
Avoid this warning and simplify the code by turning these into static const structures and directly assigning them without the extra copy.
--- drivers/perf/marvell_cn10k_ddr_pmu.c | 85 +++++++++++++++------------- 1 file changed, 45 insertions(+), 40 deletions(-)
drivers/perf/marvell_cn10k_ddr_pmu.c +45 -40
@@ -1165,6 +1165,47 @@ static const struct ddr_pmu_platform_data odyssey_ddr_pmu_pdata = { };#endif +static const struct pmu cn10k_pmu = { + .module =THIS_MODULE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .task_ctx_nr = perf_invalid_context, + .attr_groups = cn10k_attr_groups, + .event_init = cn10k_ddr_perf_event_init, + .add = cn10k_ddr_perf_event_add, + .del = cn10k_ddr_perf_event_del, + .start = cn10k_ddr_perf_event_start, + .stop = cn10k_ddr_perf_event_stop, + .read = cn10k_ddr_perf_event_update, + .pmu_enable = cn10k_ddr_perf_pmu_enable, + .pmu_disable = cn10k_ddr_perf_pmu_disable, +}; + +static const struct pmu ody_pmu = { + .module =THIS_MODULE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .task_ctx_nr = perf_invalid_context, + .attr_groups = odyssey_attr_groups, + .event_init = cn10k_ddr_perf_event_init, + .add = cn10k_ddr_perf_event_add, + .del = cn10k_ddr_perf_event_del, + .start = cn10k_ddr_perf_event_start, + .stop = cn10k_ddr_perf_event_stop, + .read = cn10k_ddr_perf_event_update, +}; + +static const struct pmu cn20k_pmu = { + .module =THIS_MODULE , + .capabilities =PERF_PMU_CAP_NO_EXCLUDE , + .task_ctx_nr = perf_invalid_context, + .attr_groups = cn20k_attr_groups, + .event_init = cn10k_ddr_perf_event_init, + .add = cn10k_ddr_perf_event_add, + .del = cn10k_ddr_perf_event_del, + .start = cn10k_ddr_perf_event_start, + .stop = cn10k_ddr_perf_event_stop, + .read = cn10k_ddr_perf_event_update, +}; +static int cn10k_ddr_perf_probe (struct platform_device *pdev) {const struct ddr_pmu_platform_data *dev_data;
@@ -1202,56 +1243,20 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev)/* Setup the PMU counter to work in manual mode */ writeq_relaxed (OP_MODE_CTRL_VAL_MANUAL , ddr_pmu->base + ddr_pmu->p_data->cnt_op_mode_ctrl); + ddr_pmu->pmu = cn10k_pmu; - ddr_pmu->pmu = (struct pmu ) { - .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , - .task_ctx_nr = perf_invalid_context, - .attr_groups = cn10k_attr_groups, - .event_init = cn10k_ddr_perf_event_init, - .add = cn10k_ddr_perf_event_add, - .del = cn10k_ddr_perf_event_del, - .start = cn10k_ddr_perf_event_start, - .stop = cn10k_ddr_perf_event_stop, - .read = cn10k_ddr_perf_event_update, - .pmu_enable = cn10k_ddr_perf_pmu_enable, - .pmu_disable = cn10k_ddr_perf_pmu_disable, - }; }if (silicon_flags &IS_ODY ) { ddr_pmu->ops = &ddr_pmu_ody_ops; - - ddr_pmu->pmu = (struct pmu ) { - .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , - .task_ctx_nr = perf_invalid_context, - .attr_groups = odyssey_attr_groups, - .event_init = cn10k_ddr_perf_event_init, - .add = cn10k_ddr_perf_event_add, - .del = cn10k_ddr_perf_event_del, - .start = cn10k_ddr_perf_event_start, - .stop = cn10k_ddr_perf_event_stop, - .read = cn10k_ddr_perf_event_update, - }; + ddr_pmu->pmu = ody_pmu; }if (silicon_flags &IS_CN20K ) { ddr_pmu->ops = &ddr_pmu_ody_ops; - - ddr_pmu->pmu = (struct pmu ) { - .module =THIS_MODULE , - .capabilities =PERF_PMU_CAP_NO_EXCLUDE , - .task_ctx_nr = perf_invalid_context, - .attr_groups = cn20k_attr_groups, - .event_init = cn10k_ddr_perf_event_init, - .add = cn10k_ddr_perf_event_add, - .del = cn10k_ddr_perf_event_del, - .start = cn10k_ddr_perf_event_start, - .stop = cn10k_ddr_perf_event_stop, - .read = cn10k_ddr_perf_event_update, - }; + ddr_pmu->pmu = cn20k_pmu; } +/* Choose this cpu to collect perf data */ ddr_pmu->cpu =raw_smp_processor_id ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1263/2651 spi: fsl: unmap immr_spi_cs on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit af1d882d421de504a1e5fac92eb06947b6cbdd8f ]
of_fsl_spi_remove() does not unmap pinfo->immr_spi_cs after a successful probe when CONFIG_FSL_SOC is enabled and fsl,spisel_boot causes of_fsl_spi_probe() to map it with ioremap(). The probe error path already performs the matching iounmap().
Retrieve pinfo from the platform data and call iounmap() when pinfo->immr_spi_cs is present, pairing normal removal with the mapping established by of_fsl_spi_probe().
--- drivers/spi/spi-fsl-spi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/spi/spi-fsl-spi.c +8 -0
@@ -702,10 +702,18 @@ static void of_fsl_spi_remove(struct platform_device *ofdev) {struct spi_controller *host =platform_get_drvdata (ofdev);struct mpc8xxx_spi *mpc8xxx_spi =spi_controller_get_devdata (host); +#if IS_ENABLED (CONFIG_FSL_SOC ) +struct fsl_spi_platform_data *pdata =dev_get_platdata (&ofdev->dev); +struct mpc8xxx_spi_probe_info *pinfo =to_of_pinfo (pdata); +#endif spi_unregister_controller (host);fsl_spi_cpm_free (mpc8xxx_spi); +#if IS_ENABLED (CONFIG_FSL_SOC ) +if (pinfo->immr_spi_cs) +iounmap (pinfo->immr_spi_cs); +#endif }static struct platform_driver of_fsl_spi_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1264/2651 spi: bcm63xx-hsspi: Disable runtime PM on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 38232bd3cea74845c2064eb9f7eac77fa5a21d85 ]
bcm63xx_hsspi_probe() enables runtime PM before creating the sysfs
group, but bcm63xx_hsspi_remove() does not perform the matchingpm_runtime_disable() after a successful probe.
The probe error paths already disable runtime PM when sysfs group creation or controller registration fails.
Add pm_runtime_disable() to the remove path after removing the sysfs group to balance pm_runtime_enable() from bcm63xx_hsspi_probe().
--- drivers/spi/spi-bcm63xx-hsspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-bcm63xx-hsspi.c +1 -0
@@ -882,6 +882,7 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev)/* reset the hardware and block queue progress */ __raw_writel (0 , bs->regs +HSSPI_INT_MASK_REG );sysfs_remove_group (&pdev->dev.kobj, &bcm63xx_hsspi_group); +pm_runtime_disable (&pdev->dev); }static int bcm63xx_hsspi_suspend (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1265/2651 selftests/alsa: Do not take another controls event as our own
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c9b0768669976a1beb0a1537b4257bd6b76dfbac ]
The wait_for_event() skips an event for a different control with a continue inside its do-while loop. But continue goes straight to the loop condition, and that tests the mask of the event just skipped. So a value event for another control ends the wait as if it were ours.
A driver that notifies a second control from its put() queues that event first. The core only sends ours once put() returns. So the wait returns early and leaves ours in the queue. The next test then reports it as spurious. And event_missing passes for a control whose put() said nothing changed, as long as it notified a neighbour.
To fix this, clear the mask before skipping the event.
--- tools/testing/selftests/alsa/mixer-test.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/alsa/mixer-test.c +2 -0
@@ -261,6 +261,8 @@ static int wait_for_event(struct ctl_data *ctl, int timeout)if (ev_id !=snd_ctl_elem_info_get_numid (ctl->info)) {ksft_print_msg ("Event for unexpected ctl %s\n" ,snd_ctl_event_elem_get_name (event)); +/* The loop condition must not see the other control's mask */ + mask =0 ;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1266/2651 power: supply: ab8500_btemp: Fix event temperature reporting
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 95990cda8e42dda4bd3f1475d578323981bd8579 ]
The event-aware path initializes its local temperature to zero and compares that zero against the thermal thresholds. Consequently some events report the measured temperature after it crosses the event threshold, while others always report the threshold.
Start with the measured temperature, clamp it according to the active event, and convert to tenths of a degree only once. This path is used by AB8505 and later variants.
--- drivers/power/supply/ab8500_btemp.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/power/supply/ab8500_btemp.c +9 -19
@@ -468,39 +468,29 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,*/ static int ab8500_btemp_get_temp (struct ab8500_btemp *di) { -int temp =0 ; +int temp = di->bat_temp;/* * The BTEMP events are not reliabe on AB8500 cut3.3 * and prior versions */ -if (is_ab8500_3p3_or_earlier (di->parent)) { - temp = di->bat_temp *10 ; - }else { +if (!is_ab8500_3p3_or_earlier (di->parent)) {if (di->events.btemp_low) {if (temp > di->btemp_ranges.btemp_low_limit) - temp = di->btemp_ranges.btemp_low_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_low_limit; }else if (di->events.btemp_high) {if (temp < di->btemp_ranges.btemp_high_limit) - temp = di->btemp_ranges.btemp_high_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_high_limit; }else if (di->events.btemp_lowmed) {if (temp > di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; }else if (di->events.btemp_medhigh) {if (temp < di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; - }else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; + } } -return temp; + +return temp *10 ; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1267/2651 power: supply: ab8500: Preserve battery termination current
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3b33eda4067494658d51db0792377fef98787e3f ]
The battery-info parser uses a negative value for an unspecified termination current. Testing the value as a boolean instead replaces every valid positive current from the battery description with 200 mA.
Apply the default only when the property is unspecified so batteries retain their described charging termination current.
--- drivers/power/supply/ab8500_bmdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ab8500_bmdata.c +1 -1
@@ -174,7 +174,7 @@ int ab8500_bm_of_probe(struct power_supply *psy,if (bi->constant_charge_voltage_max_uv <0 ) bi->constant_charge_voltage_max_uv =4100000 ; -if (bi->charge_term_current_ua) +if (bi->charge_term_current_ua <0 )/* Charging stops when we drop below this current */ bi->charge_term_current_ua =200000 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1268/2651 power: supply: ab8500_charger: Fix AC charger re-enable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 3e1d2517347f6bb72f74e63ec77d1634385fbf21 ]
The AC check-enable callback passes the embedded USB charger object to ab8500_charger_ac_en(). That helper derives the parent with the AC charger offset, so the wrong object yields an invalid ab8500_charger pointer.
Pass the AC charger object when re-enabling AC charging.
--- drivers/power/supply/ab8500_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/ab8500_charger.c +2 -2
@@ -1778,7 +1778,7 @@ static int ab8500_charger_usb_check_enable(struct ux500_charger *charger, }/** -* ab8500_charger_ac_check_enable() - enable usb charging +* ab8500_charger_ac_check_enable() - enable AC charging * @charger: pointer to the ux500_charger structure * @vset_uv: charging voltage in microvolt * @iset_ua: charger output current in micrompere
@@ -1817,7 +1817,7 @@ static int ab8500_charger_ac_check_enable(struct ux500_charger *charger,return ret; } - ret =ab8500_charger_ac_en (&di->usb_chg, true, vset_uv, iset_ua); + ret =ab8500_charger_ac_en (&di->ac_chg, true, vset_uv, iset_ua);if (ret <0 ) {dev_err (di->dev,"failed to enable AC charger %d\n" , __LINE__);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1269/2651 power: supply: ab8500_charger: Decode AB8505 USB status
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 2b697df2b6394613a3bb168adfa8a845ad7c83d9 ]
AB8505 keeps USB link status in the same bit position as AB8500 but defines a different five-bit value table. Reusing the AB8500 enum treats several reserved AB8505 values as chargers and misidentifies the AB8505 charger-fault and DM-high states.
Add an AB8505 decoder, reject reserved and non-charging states, and retain conservative current limits for supported charger types. Restrict the invalid-link workaround to AB8500 and stop processing when the status register cannot be read.
--- drivers/power/supply/ab8500_charger.c | 170 +++++++++++++++++++++----- 1 file changed, 142 insertions(+), 28 deletions(-)
drivers/power/supply/ab8500_charger.c +142 -28
@@ -136,6 +136,33 @@ enum ab8500_charger_link_status { USB_STAT_ACA_DOCK_CHARGER, }; +/* UsbLink1Status register values used by AB8505 */ +enum ab8505_charger_link_status { +AB8505_USB_STAT_OFF , +AB8505_USB_STAT_SDP_NOT_CHARGING , +AB8505_USB_STAT_SDP_CHARGING , +AB8505_USB_STAT_SDP_SUSPENDED , +AB8505_USB_STAT_CDP , +AB8505_USB_STAT_RESERVED_5 , +AB8505_USB_STAT_RESERVED_6 , +AB8505_USB_STAT_DCP , +AB8505_USB_STAT_ACA_RID_A , +AB8505_USB_STAT_ACA_RID_B , +AB8505_USB_STAT_ACA_RID_C , +AB8505_USB_STAT_RESERVED_11 , +AB8505_USB_STAT_RESERVED_12 , +AB8505_USB_STAT_UPSTREAM_IDGND , +AB8505_USB_STAT_CHARGER_NOT_OK , +AB8505_USB_STAT_CHARGER_DM_HIGH , +AB8505_USB_STAT_PHY_ENABLED , +AB8505_USB_STAT_UPSTREAM_NO_IDGND , +AB8505_USB_STAT_UPSTREAM_IDGND_VBUS , +AB8505_USB_STAT_CHARGER_SE1 , +AB8505_USB_STAT_CARKIT_1 , +AB8505_USB_STAT_CARKIT_2 , +AB8505_USB_STAT_ACA_DOCK_CHARGER , +}; +enum ab8500_usb_state {AB8500_BM_USB_STATE_RESET_HS ,/* HighSpeed Reset */ AB8500_BM_USB_STATE_RESET_FS ,/* FullSpeed/LowSpeed Reset */
@@ -699,20 +726,102 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe) }/** -* ab8500_charger_max_usb_curr() - get the max curr for the USB type +* ab8505_charger_max_usb_curr() - get the max current for the USB type * @di: pointer to the ab8500_charger structure * @link_status: the identified USB type * -* Get the maximum current that is allowed to be drawn from the host -* based on the USB type. +* Decode AB8505-specific UsbLink1Status values and get the maximum current +* that is allowed to be drawn based on the USB type. * Returns error code in case of failure else 0 on success */ +static int ab8505_charger_max_usb_curr (struct ab8500_charger *di, +u8 link_status) +{ +int ret =0 ; + + di->is_aca_rid =0 ; + +switch (link_status) { +case AB8505_USB_STAT_SDP_NOT_CHARGING : +case AB8505_USB_STAT_SDP_CHARGING : +case AB8505_USB_STAT_SDP_SUSPENDED : +case AB8505_USB_STAT_CDP : +case AB8505_USB_STAT_CHARGER_DM_HIGH : +case AB8505_USB_STAT_UPSTREAM_NO_IDGND : +case AB8505_USB_STAT_UPSTREAM_IDGND_VBUS : +case AB8505_USB_STAT_CHARGER_SE1 : +case AB8505_USB_STAT_CARKIT_1 : +case AB8505_USB_STAT_CARKIT_2 : +case AB8505_USB_STAT_ACA_DOCK_CHARGER : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P5 ; +break ; +case AB8505_USB_STAT_DCP : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P5 ; +break ; +case AB8505_USB_STAT_ACA_RID_A : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P5 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_ACA_RID_B : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P3 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_ACA_RID_C : + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_1P5 ; + di->is_aca_rid =1 ; +break ; +case AB8505_USB_STAT_OFF : +if (di->vbus_detected) { + di->usb_device_is_unrecognised = true; + di->max_usb_in_curr.usb_type_max_ua = +USB_CH_IP_CUR_LVL_1P5 ; +break ; + } + fallthrough; +case AB8505_USB_STAT_UPSTREAM_IDGND : +case AB8505_USB_STAT_PHY_ENABLED : +dev_err (di->dev,"USB Type - Charging not allowed\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; +case AB8505_USB_STAT_CHARGER_NOT_OK : + di->flags.vbus_collapse = true; +dev_err (di->dev,"USB Type - VBUS has collapsed\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; +case AB8505_USB_STAT_RESERVED_5 : +case AB8505_USB_STAT_RESERVED_6 : +case AB8505_USB_STAT_RESERVED_11 : +case AB8505_USB_STAT_RESERVED_12 : +default : +dev_err (di->dev,"USB Type - Unknown\n" ); + di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; + ret = -ENXIO ; +break ; + } + +return ret; +} + +/** +* ab8500_charger_max_usb_curr() - get the max current for the USB type +* @di: pointer to the ab8500_charger structure +* @link_status: the identified USB type +* +* Get the maximum current that is allowed to be drawn based on the USB type. +* Returns error code in case of failure else 0 on success. +*/ static int ab8500_charger_max_usb_curr (struct ab8500_charger *di, -enum ab8500_charger_link_status link_status) +u8 link_status) {int ret =0 ; di->usb_device_is_unrecognised = false; +if (is_ab8505 (di->parent)) { + ret =ab8505_charger_max_usb_curr (di, link_status); + goto out; + }/* * Platform only supports USB 2.0.
@@ -721,7 +830,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,* should set USB_CH_IP_CUR_LVL_0P5. */ -switch (link_status) { +switch ((enum ab8500_charger_link_status )link_status) {case USB_STAT_STD_HOST_NC :case USB_STAT_STD_HOST_C_NS :case USB_STAT_STD_HOST_C_S :
@@ -825,6 +934,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,break ; } +out: di->max_usb_in_curr.set_max_ua = di->max_usb_in_curr.usb_type_max_ua;dev_dbg (di->dev,"USB Type - 0x%02x MaxCurr: %d" , link_status, di->max_usb_in_curr.set_max_ua);
@@ -866,8 +976,7 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di) val = (val &AB8500_USB_LINK_STATUS ) >>USB_LINK_STATUS_SHIFT ; else val = (val &AB8505_USB_LINK_STATUS ) >>USB_LINK_STATUS_SHIFT ; - ret =ab8500_charger_max_usb_curr (di, - (enum ab8500_charger_link_status ) val); + ret =ab8500_charger_max_usb_curr (di, val);return ret; }
@@ -929,8 +1038,7 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)if (val)break ; } - ret =ab8500_charger_max_usb_curr (di, - (enum ab8500_charger_link_status ) val); + ret =ab8500_charger_max_usb_curr (di, val);return ret; }
@@ -2277,6 +2385,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)int ret;u8 val;u8 link_status; +u8 link_status_mask;struct ab8500_charger *di =container_of (work, struct ab8500_charger, usb_link_status_work);
@@ -2303,20 +2412,22 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work) ret =abx500_get_register_interruptible (di->dev,AB8500_USB ,AB8500_USB_LINK1_STAT_REG , &val); -if (ret >=0 ) -dev_dbg (di->dev,"UsbLineStatus register = 0x%02x\n" , val); -else -dev_dbg (di->dev,"Error reading USB link status\n" ); +if (ret <0 ) { +dev_err (di->dev,"Error reading USB link status\n" ); +return ; + } +dev_dbg (di->dev,"UsbLineStatus register = 0x%02x\n" , val);if (is_ab8500 (di->parent)) - link_status =AB8500_USB_LINK_STATUS ; + link_status_mask =AB8500_USB_LINK_STATUS ;else - link_status =AB8505_USB_LINK_STATUS ; + link_status_mask =AB8505_USB_LINK_STATUS ; + link_status = (val & link_status_mask) >>USB_LINK_STATUS_SHIFT ;if (detected_chargers &USB_PW_CONN ) { -if (((val & link_status) >>USB_LINK_STATUS_SHIFT ) == -USB_STAT_NOT_VALID_LINK && - di->invalid_charger_detect_state ==0 ) { +if (is_ab8500 (di->parent) && + link_status ==USB_STAT_NOT_VALID_LINK && + di->invalid_charger_detect_state ==0 ) {dev_dbg (di->dev,"Invalid charger detected, state= 0\n" );/*Enable charger*/
@@ -2339,18 +2450,21 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)abx500_mask_and_set_register_interruptible (di->dev,AB8500_USB ,AB8500_USB_LINE_CTRL2_REG ,USB_CH_DET ,0x00 ); -/*Check link status*/ -if (is_ab8500 (di->parent)) - ret =abx500_get_register_interruptible (di->dev, -AB8500_USB ,AB8500_USB_LINE_STAT_REG , - &val); -else - ret =abx500_get_register_interruptible (di->dev, -AB8500_USB ,AB8500_USB_LINK1_STAT_REG , - &val); +/* Check link status */ + ret =abx500_get_register_interruptible (di->dev, +AB8500_USB , +AB8500_USB_LINE_STAT_REG , + &val); +if (ret <0 ) { +dev_err (di->dev, +"Error reading USB link status\n" ); +return ; + } + link_status = (val & link_status_mask) >> +USB_LINK_STATUS_SHIFT ;dev_dbg (di->dev,"USB link status= 0x%02x\n" , - (val & link_status) >>USB_LINK_STATUS_SHIFT ); + link_status); di->invalid_charger_detect_state =2 ; } }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1270/2651 power: supply: ab8500_charger: Respect AB8505 register layout
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dcecf527632297011153f088573689a1ad1de790 ]
Several AB8505 charger fields differ from AB8500. Its long VBUS falling debounce is 300 ms rather than 100 ms, and its VBUS overvoltage selector has a different encoding programmed through OTP. Writing the AB8500 6.3 V value selects 9 V on AB8505.
AB8505 revision 3 also defines SwControlFallback as reserved, correcting older documentation which led the driver to support autopower there. Preserve the AB8505 overvoltage setting, wait for its documented debounce, and reject the unsupported autopower setting.
--- drivers/power/supply/ab8500_charger.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/power/supply/ab8500_charger.c +19 -8
@@ -52,7 +52,7 @@#define MAIN_CH_DET 0x01#define MAIN_CH_CV_ON 0x04#define USB_CH_CV_ON 0x08 -#define VBUS_DET_DBNC100 0x02 +#define VBUS_DET_DBNC_LONG 0x02#define VBUS_DET_DBNC1 0x01#define OTP_ENABLE_WD 0x01#define DROP_COUNT_RESET 0x01
@@ -383,6 +383,10 @@ static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,u8 bit;int ret; +/* SwControlFallback is reserved and must remain clear on AB8505. */ +if (is_ab8505 (di->parent)) +return ; +dev_dbg (di->dev,"SW Fallback: %d\n" , fallback);if (is_ab8500 (di->parent)) {
@@ -703,12 +707,16 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)if (!probe) {/* -* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC100 +* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC_LONG * when disconnecting ACA even though no * charger was connected. Try waiting a little -* longer than the 100 ms of VBUS_DET_DBNC100... +* longer than its 100 ms debounce. AB8505 uses +* a 300 ms falling debounce for the same bit. */ -msleep (110 ); +if (is_ab8505 (di->parent)) +msleep (310 ); +else +msleep (110 ); } ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER ,AB8500_CH_USBCH_STAT1_REG , &val);
@@ -719,7 +727,7 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)dev_dbg (di->dev,"%s AB8500_CH_USBCH_STAT1_REG %x\n" , __func__, val); -if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC100 )) +if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC_LONG )) result |=USB_PW_CONN ;return result;
@@ -3185,7 +3193,7 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) } } -if (is_ab8505_2p0 (di->parent)) +if (is_ab8505 (di->parent)) ret = abx500_mask_and_set_register_interruptible(di->dev, AB8500_CHARGER, AB8500_USBCH_CTRL2_REG,
@@ -3534,11 +3542,14 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); -/* get parent data */ di->dev = dev; di->parent =dev_get_drvdata (pdev->dev.parent); + di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); +if (di->autopower_cfg &&is_ab8505 (di->parent)) { +dev_warn (dev,"autopower is not supported on AB8505\n" ); + di->autopower_cfg = false; + }/* Get ADC channels */ if (!is_ab8505 (di->parent)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1271/2651 power: supply: ab8500_charger: Handle detection errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1098c619ce7595a77a8c2e366a703e9fc5f29bf7 ]
ab8500_charger_detect_chargers() returns either a charger bitmask or a negative register-access error. The probe and component-bind paths use a negative return value as a bitmask, making failed reads appear as both AC and USB connections.
Propagate detection errors and release the bind-time workqueue on failure.
--- drivers/power/supply/ab8500_charger.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/power/supply/ab8500_charger.c +8 -0
@@ -3462,6 +3462,10 @@ static int ab8500_charger_bind(struct device *dev) } ch_stat =ab8500_charger_detect_chargers (di, false); +if (ch_stat <0 ) { +destroy_workqueue (di->charger_wq); +return ch_stat; + }if (ch_stat &AC_PW_CONN ) {if (is_ab8500 (di->parent))
@@ -3747,6 +3751,10 @@ static int ab8500_charger_probe(struct platform_device *pdev)/* Identify the connected charger types during startup */ charger_status =ab8500_charger_detect_chargers (di, true); +if (charger_status <0 ) { + ret = charger_status; + goto remove_ab8500_bm; + }if (charger_status &AC_PW_CONN ) { di->ac.charger_connected =1 ; di->ac_conn = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1272/2651 power: supply: ab8500_charger: Skip absent AB8505 main charger
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 52c8cdcc1146d86fae524a589d4512c8d59ea8b4 ]
AB8505 contains only the USB charger. It has no integrated main charger, main-charger status register, or main-charger interrupts.
Avoid reading the missing status register, requesting the five missing interrupts, or disabling an AC charger which was never enabled. This lets the driver bind using only the AB8505 USB charger resources.
--- drivers/power/supply/ab8500_charger.c | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/power/supply/ab8500_charger.c +21 -11
@@ -692,16 +692,19 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)int ret;u8 val; -/* Check for AC charger */ - ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , -AB8500_CH_STATUS1_REG , &val); -if (ret <0 ) { -dev_err (di->dev,"%s ab8500 read failed\n" , __func__); -return ret; - } +/* AB8505 has no integrated main charger. */ +if (!is_ab8505 (di->parent)) { + ret =abx500_get_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_CH_STATUS1_REG , &val); +if (ret <0 ) { +dev_err (di->dev,"%s ab8500 read failed\n" , __func__); +return ret; + } -if (val &MAIN_CH_DET ) - result =AC_PW_CONN ; +if (val &MAIN_CH_DET ) + result =AC_PW_CONN ; + }/* Check for USB charger */
@@ -3500,7 +3503,8 @@ static void ab8500_charger_unbind(struct device *dev)int ret;/* Disable AC charging */ -ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 ); +if (di->ac_chg.enabled) +ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 );/* Disable USB charging */ ab8500_charger_usb_en (&di->usb_chg, false,0 ,0 );
@@ -3724,7 +3728,13 @@ static int ab8500_charger_probe(struct platform_device *pdev) }/* Request interrupts */ -for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { +/* The first five interrupts belong to the AB8500 main charger. */ +if (is_ab8505 (di->parent)) + i =5 ; +else + i =0 ; + +for (; i <ARRAY_SIZE (ab8500_charger_irq); i++) { irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name);if (irq <0 )return irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1273/2651 power: supply: ab8500_charger: Retry AB8505 USB detection
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 95fba2e3055df99ed19e7d6399101bac42b3e7d5 ]
AB8505 reports UsbLink1Status state 14 when the USB charger port is not OK. The manual says that software can return the port detector to the detection state by setting the self-clearing ChargerCtrl.DropCountReset bit.
The Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle, and Samsung-SGH-T599-Codina-TMO product trees are reference points for a workaround that cycles the USB charger and retries detection three times before rejecting VBUS. Only the Kyle tree writes 1 to DropCountReset; the other two write 0 and therefore do not request the documented reset.
Add the same bounded recovery for AB8505, preserving the configured USB charger control bits across each cycle. Keep the charger connected while recovering, then report the fault and disconnect it if all three attempts fail. Leave AB8500 behavior unchanged.
--- drivers/power/supply/ab8500_charger.c | 114 ++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 5 deletions(-)
drivers/power/supply/ab8500_charger.c +109 -5
@@ -99,6 +99,8 @@#define CHARGER_STATUS_POLL 10/* in ms */ +#define AB8505_USB_CHARGER_NOT_OK_RETRIES 3 +#define CHG_WD_INTERVAL (60 * HZ)#define AB8500_SW_CONTROL_FALLBACK 0x03
@@ -261,6 +263,8 @@ struct ab8500_charger_max_usb_in_curr {* @is_aca_rid: Incicate if accessory is ACA type * @current_stepping_sessions: * Counter for current stepping sessions +* @usb_charger_not_ok_retries: +* Number of AB8505 USB charger recovery attempts * @parent: Pointer to the struct ab8500 * @adc_main_charger_v ADC channel for main charger voltage * @adc_main_charger_c ADC channel for main charger current
@@ -314,6 +318,7 @@ struct ab8500_charger {int invalid_charger_detect_state;int is_aca_rid;atomic_t current_stepping_sessions; +unsigned int usb_charger_not_ok_retries;struct ab8500 *parent;struct iio_channel *adc_main_charger_v;struct iio_channel *adc_main_charger_c;
@@ -473,6 +478,9 @@ static void ab8500_power_supply_changed(struct ab8500_charger *di,static void ab8500_charger_set_usb_connected (struct ab8500_charger *di,bool connected) { +if (!connected && !di->vbus_detected) + di->usb_charger_not_ok_retries =0 ; +if (connected != di->usb.charger_connected) {dev_dbg (di->dev,"USB connected:%i\n" , connected); di->usb.charger_connected = connected;
@@ -796,10 +804,19 @@ static int ab8505_charger_max_usb_curr(struct ab8500_charger *di, ret = -ENXIO ;break ;case AB8505_USB_STAT_CHARGER_NOT_OK : - di->flags.vbus_collapse = true; -dev_err (di->dev,"USB Type - VBUS has collapsed\n" ); di->max_usb_in_curr.usb_type_max_ua =USB_CH_IP_CUR_LVL_0P05 ; - ret = -ENXIO ; +if (di->usb_charger_not_ok_retries < +AB8505_USB_CHARGER_NOT_OK_RETRIES ) { +dev_warn (di->dev, +"USB Type - VBUS has collapsed, retrying\n" ); +queue_delayed_work (di->charger_wq, + &di->check_usbchgnotok_work,0 ); + ret = -EAGAIN ; + }else { +dev_err (di->dev, +"USB Type - VBUS recovery failed\n" ); + ret = -ENXIO ; + }break ;case AB8505_USB_STAT_RESERVED_5 :case AB8505_USB_STAT_RESERVED_6 :
@@ -2587,6 +2604,48 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work) } } +static int ab8505_charger_retry_usb_detection (struct ab8500_charger *di) +{ +u8 usbch_ctrl1; +bool usb_enabled; +int restore_ret; +int ret; + + ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , + &usbch_ctrl1); +if (ret <0 ) +return ret; + + usb_enabled = usbch_ctrl1 &USB_CH_ENA ; +if (usb_enabled) { + ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , +USB_CH_ENA ,0 ); +if (ret <0 ) +return ret; + } + + ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_CHARGER_CTRL , +DROP_COUNT_RESET , +DROP_COUNT_RESET ); + +if (usb_enabled) { + restore_ret =abx500_mask_and_set_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_USBCH_CTRL1_REG , +USB_CH_ENA , +USB_CH_ENA ); +if (restore_ret <0 ) +return restore_ret; + } + +return ret; +} +/** * ab8500_charger_check_usbchargernotok_work() - check USB chg not ok status * @work: pointer to the work_struct structure
@@ -2596,7 +2655,10 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work)static void ab8500_charger_check_usbchargernotok_work (struct work_struct *work) {int ret; +u8 link_status =0 ;u8 reg_value; +bool charger_not_ok; +bool prev_collapse;bool prev_status; struct ab8500_charger *di = container_of(work,
@@ -2609,19 +2671,61 @@ static void ab8500_charger_check_usbchargernotok_work(struct work_struct *work)dev_err (di->dev,"%s ab8500 read failed\n" , __func__);return ; } + charger_not_ok = reg_value &VBUS_CH_NOK ; +if (is_ab8505 (di->parent)) { + ret =abx500_get_register_interruptible (di->dev,AB8500_USB , +AB8500_USB_LINK1_STAT_REG , + &link_status); +if (ret <0 ) { +dev_err (di->dev,"%s USB link status read failed\n" , + __func__); +return ; + } + + link_status = (link_status &AB8505_USB_LINK_STATUS ) >> +USB_LINK_STATUS_SHIFT ; + charger_not_ok |= + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK ; + } + prev_status = di->flags.usbchargernotok; + prev_collapse = di->flags.vbus_collapse; + +if (is_ab8505 (di->parent) && + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK && + di->usb_charger_not_ok_retries < +AB8505_USB_CHARGER_NOT_OK_RETRIES ) { + di->usb_charger_not_ok_retries++; + di->flags.usbchargernotok = false; + di->flags.vbus_collapse = true; +dev_warn (di->dev,"Retrying USB charger detection (%u/%u)\n" , + di->usb_charger_not_ok_retries, +AB8505_USB_CHARGER_NOT_OK_RETRIES ); -if (reg_value &VBUS_CH_NOK ) { + ret =ab8505_charger_retry_usb_detection (di); +if (ret <0 ) +dev_err (di->dev,"USB charger retry failed: %d\n" , ret); + +queue_delayed_work (di->charger_wq, + &di->check_usbchgnotok_work,HZ ); + }else if (charger_not_ok) { di->flags.usbchargernotok = true; +if (is_ab8505 (di->parent) && + link_status ==AB8505_USB_STAT_CHARGER_NOT_OK ) { + di->flags.vbus_collapse = false; +ab8500_charger_set_usb_connected (di, false); + }/* Check again in 1sec */ queue_delayed_work (di->charger_wq, &di->check_usbchgnotok_work,HZ ); }else { di->flags.usbchargernotok = false; di->flags.vbus_collapse = false; + di->usb_charger_not_ok_retries =0 ; } -if (prev_status != di->flags.usbchargernotok) +if (prev_status != di->flags.usbchargernotok || + prev_collapse != di->flags.vbus_collapse)ab8500_power_supply_changed (di, di->usb_chg.psy); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1274/2651 power: supply: ab8500_charger: Recover inactive AB8505 charger
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 76bdf9d78245bb068207c23e9bf43d4b9bb201c3 ]
UsbChCtrl1.UsbChEna can remain set while UsbChStatus1.UsbChOn is clear. The existing recovery only checks the control bit, so it considers the charger enabled and leaves charging stopped.
The Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle, and Samsung-SGH-T599-Codina-TMO product trees are reference points for checking both bits and cycling the charger when they disagree.
Extend the USB charger check to detect this AB8505 state and enable the check in the charging algorithm for AB8505. Only cycle the charger when VBUS is debounced and no charger-not-OK, thermal, overvoltage, or watchdog fault accounts for the inactive hardware.
--- drivers/power/supply/ab8500_chargalg.c | 9 ++--- drivers/power/supply/ab8500_charger.c | 51 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-)
drivers/power/supply/ab8500_chargalg.c +3 -6
@@ -1241,12 +1241,9 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di) charger_status =ab8500_chargalg_check_charger_connection (di); -if (is_ab8500 (di->parent)) { - ret =ab8500_chargalg_check_charger_enable (di); -if (ret <0 ) -dev_err (di->dev,"Checking charger is enabled error" -": Returned Value %d\n" , ret); - } + ret =ab8500_chargalg_check_charger_enable (di); +if (ret <0 ) +dev_err (di->dev,"Checking charger enable failed: %d\n" , ret);/* * First check if we have a charger connected.
drivers/power/supply/ab8500_charger.c +50 -1
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1275/2651 power: supply: ab8500_fg: Finalize current measurements
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9a0461fb5e7cc64ed303bee3661452879ee139a1 ]
ab8500_fg_inst_curr_start() returns with cc_lock held and the CCEOC IRQ enabled. The bounded sampling loop in the load-compensated voltage path returns without calling ab8500_fg_inst_curr_finalize() when it expires, leaving both resources active. The next fuel-gauge work item then blocks on cc_lock and all cached power-supply values stop updating.
The Samsung-GT-I8530-Gavini, Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle and Samsung-SGH-T599-Codina-TMO product trees use a bounded sampling loop in drivers/battery/abb_fuelgauge.c but still call the finalizer. Follow that pattern so the normal completion timeout also performs the required cleanup.
Check the start result as well and return an uncompensated voltage if the instantaneous current transaction cannot be started or completed.
--- drivers/power/supply/ab8500_fg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/power/supply/ab8500_fg.c +9 -4
@@ -934,9 +934,15 @@ static int ab8500_load_comp_fg_bat_voltage(struct ab8500_fg *di, bool always)int i =0 ;int vbat_uv =0 ;int rcomp; +int ret;/* Average the instant current to get a stable current measurement */ -ab8500_fg_inst_curr_start (di); + ret =ab8500_fg_inst_curr_start (di); +if (ret) { +dev_err (di->dev,"failed to start instantaneous current measurement\n" ); + di->vbat_uv =ab8500_fg_bat_voltage (di); +return di->vbat_uv; + } do { vbat_uv += ab8500_fg_bat_voltage(di);
@@ -945,15 +951,14 @@ static int ab8500_load_comp_fg_bat_voltage(struct ab8500_fg *di, bool always) }while (!ab8500_fg_inst_curr_done (di) && i <=WAIT_FOR_INST_CURRENT_MAX ); -if (i >WAIT_FOR_INST_CURRENT_MAX ) { + ret =ab8500_fg_inst_curr_finalize (di, &di->inst_curr_ua); +if (ret) {dev_err (di->dev,"TIMEOUT: return uncompensated measurement of VBAT\n" ); di->vbat_uv = vbat_uv / i;return di->vbat_uv; } -ab8500_fg_inst_curr_finalize (di, &di->inst_curr_ua); -/* * If there is too high current dissipation, the compensation cannot be * trusted so return an error unless we must return something here, as
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1276/2651 power: supply: ab8500_fg: Avoid reserved AB8505 CCConf bit
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit edafb2e4642b72b0f86ce5990d5c29c116bb642b ]
AB8500 defines CCConf bit 1 as CCDeepSleepEna, but AB8505 reserves bits 7:1 and only defines bit 0, CCPwrUpEna. The fuel-gauge driver currently writes both bits whenever it starts the coulomb counter.
The Samsung-GT-S7710-Skomer and related Samsung product trees use the same unconditional value in their fuel-gauge drivers, so they provide no AB8505 workaround to carry over. Select the value from the detected PMIC variant instead, retaining the deep-sleep enable bit on all existing non-AB8505 paths and avoiding the reserved bit on AB8505.
--- drivers/power/supply/ab8500_fg.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/power/supply/ab8500_fg.c +12 -2
@@ -451,6 +451,16 @@ static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) avg->avg = sample; } +static u8 ab8500_fg_cc_config (struct ab8500_fg *di) +{ +u8 config =CC_PWR_UP_ENA ; + +if (!is_ab8505 (di->parent)) + config |=CC_DEEP_SLEEP_ENA ; + +return config; +} +/** * ab8500_fg_coulomb_counter() - enable coulomb counter * @di: pointer to the ab8500_fg structure
@@ -481,7 +491,7 @@ static int ab8500_fg_coulomb_counter(struct ab8500_fg *di, bool enable)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto cc_err;
@@ -555,7 +565,7 @@ int ab8500_fg_inst_curr_start(struct ab8500_fg *di)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto fail; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1277/2651 ASoC: aw88399: skip BSTS check when boost converter is bypassed
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Giunta <[email protected]>
[ Upstream commit 664824782df63013ba8686b649c625cac4793248 ]
The sysst check in aw_dev_check_sysst() requires BSTS (boost finished) to assert, but on hardware where the boost converter is bypassed via external power supply (BSTCTRL10 register 0x69, EN_HVBAT bit 2 set), BSTS (SYSST register 0x01, bit 9) will never assert.
The vendor's generic driver (aw883xx) handles this by reading EN_HVBAT and conditionally masking out BSTS from the sysst check. The in-tree driver missed this logic when the original code was ported upstream.
Add the same conditional check, matching the vendor driver's aw_dev_sysst_check() implementation.
--- include/sound/aw88399.h | 5 +++++ sound/soc/codecs/aw88399-lib.c | 13 +++++++++++++ 2 files changed, 18 insertions(+)
include/sound/aw88399.h +5 -0
@@ -449,6 +449,11 @@#define AW88399_NOISE_GATE_EN_MASK \ (~(((1<<AW88399_NOISE_GATE_EN_BITS_LEN)-1) << AW88399_NOISE_GATE_EN_START_BIT)) +#define AW88399_EPS_EN_START_BIT (2) +#define AW88399_EPS_EN_BITS_LEN (1) +#define AW88399_EPS_EN_MASK \ + (~(((1 << AW88399_EPS_EN_BITS_LEN) - 1) << AW88399_EPS_EN_START_BIT)) +#define AW88399_WDT_CNT_START_BIT (0)#define AW88399_WDT_CNT_BITS_LEN (8)#define AW88399_WDT_CNT_MASK \
sound/soc/codecs/aw88399-lib.c +13 -0
@@ -183,6 +183,19 @@ static int aw_dev_check_sysst(struct aw88399 *aw88399)else check_val =AW88399_BIT_SYSST_SWS_CHECK ; +/* +* When an external power supply (EPS) is used to feed the amplifier +* (EN_HVBAT bit in BSTCTRL10 set), the boost converter is bypassed, +* and BSTS (boost finished) will never assert. Skip the BSTS check in +* this case, matching the vendor driver's behavior. +*/ + ret =regmap_read (aw_dev->regmap,AW88399_BSTCTRL10_REG , ®_val); +if (ret) +return ret; + +if (reg_val & (~AW88399_EPS_EN_MASK )) + check_val &= ~AW88399_BSTS_FINISHED_VALUE ; +/* * On some hardware the BSTS (boost-finished) status bit does not * reliably assert even when audio output is working normally.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1278/2651 ASoC: rt5682-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9a98f7e955d35e0831fb179e88e98cf9bc0e001e ]
rt5682_sdw_remove() cancels jack_detect_work only when hw_init is true. rt5682_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack_detect_work may already have been queued by rt5682_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work object is initialized during probe, so cancel it unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt5682-sdw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/rt5682-sdw.c +1 -2
@@ -704,8 +704,7 @@ static void rt5682_sdw_remove(struct sdw_slave *slave) {struct rt5682_priv *rt5682 =dev_get_drvdata (&slave->dev); -if (rt5682->hw_init) -cancel_delayed_work_sync (&rt5682->jack_detect_work); +cancel_delayed_work_sync (&rt5682->jack_detect_work);pm_runtime_disable (&slave->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1279/2651 ASoC: rt711-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 4bf78e3d9e324f9f2e39feecedd4f70b05baeb16 ]
rt711_sdw_remove() cancels the jack and calibration work only when hw_init is true. rt711_update_status() clears hw_init when the SoundWire slave becomes unattached, but work may already have been queued by rt711_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdw.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/codecs/rt711-sdw.c +3 -5
@@ -461,11 +461,9 @@ static void rt711_sdw_remove(struct sdw_slave *slave) {struct rt711_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); -cancel_work_sync (&rt711->calibration_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work); +cancel_work_sync (&rt711->calibration_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1280/2651 ASoC: rt711-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit ecc2fca6decefe27d8cf40a4c9815798eec24d30 ]
rt711_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt711_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt711_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt711-sdca-sdw.c +2 -4
@@ -369,10 +369,8 @@ static void rt711_sdca_sdw_remove(struct sdw_slave *slave) {struct rt711_sdca_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1281/2651 ASoC: rt712-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit c7d07df95ee7ce7859e6c873a76d19ea9c64b6fd ]
rt712_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt712_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt712_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt712-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt712-sdca-sdw.c +2 -4
@@ -386,10 +386,8 @@ static void rt712_sdca_sdw_remove(struct sdw_slave *slave) {struct rt712_sdca_priv *rt712 =dev_get_drvdata (&slave->dev); -if (rt712->hw_init) { -cancel_delayed_work_sync (&rt712->jack_detect_work); -cancel_delayed_work_sync (&rt712->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt712->jack_detect_work); +cancel_delayed_work_sync (&rt712->jack_btn_check_work);pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1282/2651 ASoC: rt721-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 958d025d62352b81dbbd7e975442dd211176f4e1 ]
rt721_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt721_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt721_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt721-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt721-sdca-sdw.c +2 -4
@@ -422,10 +422,8 @@ static void rt721_sdca_sdw_remove(struct sdw_slave *slave) {struct rt721_sdca_priv *rt721 =dev_get_drvdata (&slave->dev); -if (rt721->hw_init) { -cancel_delayed_work_sync (&rt721->jack_detect_work); -cancel_delayed_work_sync (&rt721->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt721->jack_detect_work); +cancel_delayed_work_sync (&rt721->jack_btn_check_work);if (rt721->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1283/2651 ASoC: rt722-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9d29132d81a7f269177be676c3b81cc575899975 ]
rt722_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt722_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt722_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt722-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt722-sdca-sdw.c +2 -4
@@ -471,10 +471,8 @@ static void rt722_sdca_sdw_remove(struct sdw_slave *slave) {struct rt722_sdca_priv *rt722 =dev_get_drvdata (&slave->dev); -if (rt722->hw_init) { -cancel_delayed_work_sync (&rt722->jack_detect_work); -cancel_delayed_work_sync (&rt722->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt722->jack_detect_work); +cancel_delayed_work_sync (&rt722->jack_btn_check_work);if (rt722->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1284/2651 arm64: dts: rockchip: Rename rk3328 HDMI audio card
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit daa0db717771d43c25d98c2798fa6a7b0252deb7 ]
Rename the card from "HDMI" to "RK3328 HDMI" so it identifies the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3328.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +1 -1
@@ -207,7 +207,7 @@ hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <128>; - simple-audio-card,name = "HDMI"; + simple-audio-card,name = "RK3328 HDMI"; status = "disabled"; simple-audio-card,cpu {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1285/2651 ARM: dts: ux500: Use AB8505 charger compatible
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ff1501cbb825de117267124ecb8898112b4051c5 ]
Identify the AB8505 charger using its variant-specific compatible and retain the AB8500 compatible as a fallback for the existing driver. This selects the AB8505 interrupt constraints from the binding.
The AB8505 interrupt table explicitly omits the five interrupt sources belonging to the AB8500 main charger. Remove these nonexistent interrupts from the AB8505 charger node, leaving its nine USB charger interrupts.
--- arch/arm/boot/dts/st/ste-ab8505.dtsi | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
arch/arm/boot/dts/st/ste-ab8505.dtsi +4 -13
@@ -137,13 +137,9 @@ ab8500_btemp { }; ab8500_charger { - compatible = "stericsson,ab8500-charger"; - interrupts = <10 IRQ_TYPE_LEVEL_HIGH>, - <11 IRQ_TYPE_LEVEL_HIGH>, - <0 IRQ_TYPE_LEVEL_HIGH>, - <107 IRQ_TYPE_LEVEL_HIGH>, - <106 IRQ_TYPE_LEVEL_HIGH>, - <14 IRQ_TYPE_LEVEL_HIGH>, + compatible = "stericsson,ab8505-charger", + "stericsson,ab8500-charger"; + interrupts = <14 IRQ_TYPE_LEVEL_HIGH>, <15 IRQ_TYPE_LEVEL_HIGH>, <79 IRQ_TYPE_LEVEL_HIGH>, <105 IRQ_TYPE_LEVEL_HIGH>,
@@ -152,12 +148,7 @@ ab8500_charger { <22 IRQ_TYPE_LEVEL_HIGH>, <21 IRQ_TYPE_LEVEL_HIGH>, <16 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "MAIN_CH_UNPLUG_DET", - "MAIN_CHARGE_PLUG_DET", - "MAIN_EXT_CH_NOT_OK", - "MAIN_CH_TH_PROT_R", - "MAIN_CH_TH_PROT_F", - "VBUS_DET_F", + interrupt-names = "VBUS_DET_F", "VBUS_DET_R", "USB_LINK_STATUS", "USB_CH_TH_PROT_R",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1286/2651 arm64: dts: rockchip: Rename rk3566 and rk3568 HDMI audio cards
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit 8043ed0f40fe2b49df1c2c25409ab6bd3f88e806 ]
Move the HDMI audio card name for RK3566 and RK3568 to their corresponding dtsi files so the name can be set to match the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3566-base.dtsi | 4 ++++ arch/arm64/boot/dts/rockchip/rk3568.dtsi | 4 ++++ arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 1 - 3 files changed, 8 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3566-base.dtsi +4 -0
@@ -6,6 +6,10 @@ / { compatible = "rockchip,rk3566"; }; +&hdmi_sound { + simple-audio-card,name = "RK3566 HDMI"; +}; + &pipegrf { compatible = "rockchip,rk3566-pipe-grf", "syscon"; };
arch/arm64/boot/dts/rockchip/rk3568.dtsi +4 -0
@@ -382,6 +382,10 @@ &gpu { operating-points-v2 = <&gpu_opp_table>; }; +&hdmi_sound { + simple-audio-card,name = "RK3568 HDMI"; +}; + &pipegrf { compatible = "rockchip,rk3568-pipe-grf", "syscon"; };
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi +0 -1
@@ -150,7 +150,6 @@ scmi_clk: protocol@14 { hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; - simple-audio-card,name = "HDMI"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <256>; status = "disabled";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1287/2651 arm64: dts: rockchip: Rename rk3576 HDMI audio card
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit d3d3b67505fa5f10af587a6fc8e6d4640010d52e ]
Rename the card from "HDMI" to "RK3576 HDMI" so it identifies the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3576.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3576.dtsi +1 -1
@@ -410,7 +410,7 @@ scmi_clk: protocol@14 { hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; - simple-audio-card,name = "HDMI"; + simple-audio-card,name = "RK3576 HDMI"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <256>; status = "disabled";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1288/2651 arm64: dts: rockchip: Rename rk3588 HDMI audio cards
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit d1b7c3228041f4b3ad888abe6a31f6494279e979 ]
Rename the two cards from "hdmi0"/"hdmi1" to "RK3588 HDMI0"/"RK3588 HDMI1" so they identify the SoC in user-visible ALSA fields and match the naming scheme used across the rest of the Rockchip family.
--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 2 +- arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +1 -1
@@ -376,7 +376,7 @@ hdmi0_sound: hdmi0-sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <128>; - simple-audio-card,name = "hdmi0"; + simple-audio-card,name = "RK3588 HDMI0"; status = "disabled"; simple-audio-card,codec {
arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi +1 -1
@@ -11,7 +11,7 @@ hdmi1_sound: hdmi1-sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <128>; - simple-audio-card,name = "hdmi1"; + simple-audio-card,name = "RK3588 HDMI1"; status = "disabled"; simple-audio-card,codec {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1289/2651 arm64: dts: rockchip: fix missing sdmmc cd pinctrl on rk3588s-nanopi-r6
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joachim Eastwood <[email protected]>
[ Upstream commit 30fcc62cf5d27fe264145bb743407af62f8ff240 ]
The cd (card detect) pin is used, but not reserved through pinctrl.
--- arch/arm64/boot/dts/rockchip/rk3588s-nanopi-r6.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588s-nanopi-r6.dtsi +6 -0
@@ -421,6 +421,10 @@ rtc_int: rtc-int { }; sdmmc { + sdmmc_det_pin: sdmmc-det-pin { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>; + }; + sd_s0_pwr: sd-s0-pwr { rockchip,pins = <4 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>; };
@@ -496,6 +500,8 @@ &sdmmc { no-mmc; no-sdio; sd-uhs-sdr104; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc_bus4 &sdmmc_clk &sdmmc_cmd &sdmmc_det_pin>; vmmc-supply = <&vcc_3v3_sd_s0>; vqmmc-supply = <&vccio_sd_s0>; status = "okay";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1290/2651 arm64: dts: rockchip: fix missing pcie rst pinctrl on rk3588s-nanopi-r6
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joachim Eastwood <[email protected]>
[ Upstream commit 1d974afb0ea4e1ffc03535a2b2ae5a84d35738d7 ]
The pins are used as reset-gpios but not reserved through pinctrl.
--- .../arm64/boot/dts/rockchip/rk3588s-nanopi-r6.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588s-nanopi-r6.dtsi +14 -0
@@ -360,12 +360,16 @@ rgmii_phy1: ethernet-phy@1 { }; &pcie2x1l1 { + pinctrl-names = "default"; + pinctrl-0 = <&pcie20x1_1_perstn_m2>; reset-gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_HIGH>; vpcie3v3-supply = <&vcc_3v3_pcie20>; status = "okay"; }; &pcie2x1l2 { + pinctrl-names = "default"; + pinctrl-0 = <&pcie20x1_2_perstn_m0>; reset-gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_HIGH>; vpcie3v3-supply = <&vcc_3v3_pcie20>; status = "okay";
@@ -420,6 +424,16 @@ rtc_int: rtc-int { }; }; + pcie { + pcie20x1_1_perstn_m2: pcie20x1-1-perstn-m2 { + rockchip,pins = <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pcie20x1_2_perstn_m0: pcie20x1-2-perstn-m0 { + rockchip,pins = <3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + sdmmc { sdmmc_det_pin: sdmmc-det-pin { rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1291/2651 arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 23eab1a5e36099fd1269f8a18dc389e04dc19011 ]
The analog headphone jack on this board has never produced any sound with a mainline kernel.
GPIO4_C5 has to be high for audio to reach the jack. The board file muxes the pin to GPIO through the rt5640_hpcon pinctrl group and references that group from the codec node, but nothing ever requests or drives the line.
Describe it the way rk3399-roc-pc-plus.dts already does something similar, as a simple-audio-amplifier auxiliary component, so that DAPM asserts the GPIO while the headphone path is active.
Measured on a Firefly-RK3399 by toggling only this line while a 1 kHz tone kept playing, with the playback PCM in state: RUNNING throughout:
high -> audible, low -> silent, high -> audible
With this change the line is claimed and follows the audio path:
pin 149 (gpio4-21): headphones-amp gpio4:149
idle: gpio-21 (|enable) out lo
playing: gpio-21 (|enable) out hi
--- .../arm64/boot/dts/rockchip/rk3399-firefly.dts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +14 -4
@@ -96,6 +96,15 @@ key-power { }; }; + /* GPIO that enables the headphone output path */ + headphones_amp: headphones-amp { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio4 RK_PC5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&rt5640_hpcon>; + sound-name-prefix = "Headphone Amp"; + }; + ir-receiver { compatible = "gpio-ir-receiver"; gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
@@ -132,8 +141,11 @@ rt5640-sound { simple-audio-card,routing = "Mic Jack", "MICBIAS1", "IN1P", "Mic Jack", - "Headphone Jack", "HPOL", - "Headphone Jack", "HPOR"; + "Headphone Amp INL", "HPOL", + "Headphone Amp INR", "HPOR", + "Headphone Jack", "Headphone Amp OUTL", + "Headphone Jack", "Headphone Amp OUTR"; + simple-audio-card,aux-devs = <&headphones_amp>; simple-audio-card,cpu { sound-dai = <&i2s1>;
@@ -547,8 +559,6 @@ rt5640: rt5640@1c { clock-names = "mclk"; realtek,in1-differential; #sound-dai-cells = <0>; - pinctrl-names = "default"; - pinctrl-0 = <&rt5640_hpcon>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1292/2651 arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 9416a641cfe5b75dd9178c15960ee741c1091b45 ]
The board file enables i2s0, but no sound card references it: the on-board RT5640 is wired to i2s1 and the S/PDIF transmitter has its own controller. Keeping it enabled starves the other controllers, due to the pl330 instance that serves the audio block only having six channels.
The i2s0 pin groups also lists GPIO4_A0, which carries SCLK_I2S_8CH_OUT, providing the MCLK the codec runs on.
So add the pinmux for the MCLK signal to the i2s1 node.
The RT5640 and S/PDIF cards then register with no DMA errors, and a 1 kHz tone measured through the codec's internal HPOL/HPOR loopback is unchanged (L 2135 -> 2138, R 2202 -> 2203), confirming that MCLK still reaches the codec.
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +8 -6
@@ -628,13 +628,9 @@ accelerometer@68 { }; }; -&i2s0 { - rockchip,playback-channels = <8>; - rockchip,capture-channels = <8>; - status = "okay"; -}; - &i2s1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2s_8ch_mclk_pin>, <&i2s1_2ch_bus>; rockchip,playback-channels = <2>; rockchip,capture-channels = <2>; status = "okay";
@@ -689,6 +685,12 @@ ir_int: ir-int { }; }; + i2s1 { + i2s_8ch_mclk_pin: i2s-8ch-mclk-pin { + rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>; + }; + }; + lcd-panel { lcd_panel_reset: lcd-panel-reset { rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1293/2651 ASoC: mt6359-accdet: manage private workqueues with devres
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 9a773d9d21fa909e8babbe11e93c811cf1a6d22d ]
The threaded jack-detect interrupts queue work on two private workqueues. Neither queue is destroyed on device removal, so queued callbacks can retain pointers to devm-allocated state after it is released. Probe error paths also leak the queues.
Create and initialize both workqueues before requesting interrupts, then add a managed cleanup action. Since the managed IRQs are acquired afterwards, devres releases and synchronizes them before draining and destroying the workqueues on both removal and probe failure.
--- sound/soc/codecs/mt6359-accdet.c | 50 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-)
sound/soc/codecs/mt6359-accdet.c +28 -22
@@ -914,6 +914,14 @@ int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (mt6359_accdet_enable_jack_detect); +static void mt6359_accdet_destroy_workqueues (void *data) +{ +struct mt6359_accdet *priv = data; + +destroy_workqueue (priv->jd_workqueue); +destroy_workqueue (priv->accdet_workqueue); +} +static int mt6359_accdet_probe (struct platform_device *pdev) {struct mt6359_accdet *priv;
@@ -955,6 +963,26 @@ static int mt6359_accdet_probe(struct platform_device *pdev) }mutex_init (&priv->res_lock); + priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); +INIT_WORK (&priv->accdet_work, mt6359_accdet_work); +if (!priv->accdet_workqueue) { +dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); +return -ENOMEM ; + } + + priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); +INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); +if (!priv->jd_workqueue) { +dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); +destroy_workqueue (priv->accdet_workqueue); +return -ENOMEM ; + } + + ret =devm_add_action_or_reset (&pdev->dev, + mt6359_accdet_destroy_workqueues, priv); +if (ret) +return ret; + priv->accdet_irq =platform_get_irq (pdev,0 );if (priv->accdet_irq >=0 ) { ret = devm_request_threaded_irq(&pdev->dev, priv->accdet_irq,
@@ -1000,22 +1028,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev) } } - priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); -INIT_WORK (&priv->accdet_work, mt6359_accdet_work); -if (!priv->accdet_workqueue) { -dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); - ret =-1 ; - goto err_accdet_wq; - } - - priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); -INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); -if (!priv->jd_workqueue) { -dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); - ret =-1 ; - goto err_eint_wq; - } -platform_set_drvdata (pdev, priv); ret = devm_snd_soc_register_component(&pdev->dev, &mt6359_accdet_soc_driver,
@@ -1034,12 +1046,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev)mt6359_accdet_jack_report (priv);return 0 ; - -err_eint_wq: -destroy_workqueue (priv->accdet_workqueue); -err_accdet_wq: -dev_err (&pdev->dev,"%s error. now exit.!\n" , __func__); -return ret; }static struct platform_driver mt6359_accdet_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1294/2651 arm64: dts: rockchip: Use GPIO function for PCIe reset on Orange Pi 5 Pro
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dennis Gilmore <[email protected]>
[ Upstream commit e95e4fcdc4541e999888f297174e8f6f5f5f899a ]
The PERST# pins of pcie2x1l1 and pcie2x1l2 are used as reset-gpios, but the default pinctrl state muxes them to the controllers' dedicated PERST# function instead of GPIO.
Linux happens to work because the pin is switched to GPIO function when it is requested as a GPIO, but the devicetree should describe the pin function the board actually uses. Bootloaders such as U-Boot apply the pinctrl state as described and do not change the function when the GPIO is requested, and probing pcie2x1l2 then hangs.
Add GPIO pinctrl nodes for both reset pins and use them in place of the PERST# function, like other RK3588 boards do.
--- .../boot/dts/rockchip/rk3588s-orangepi-5-pro.dts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588s-orangepi-5-pro.dts +12 -2
@@ -188,7 +188,7 @@ package_fan1: package-fan1 { /* NVMe */ &pcie2x1l1 { pinctrl-names = "default"; - pinctrl-0 = <&pcie30x1m1_1_perstn>, <&pcie30x1m1_1_clkreqn>, + pinctrl-0 = <&pcie2_1_rst>, <&pcie30x1m1_1_clkreqn>, <&pcie30x1m1_1_waken>; reset-gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_HIGH>; supports-clkreq;
@@ -199,7 +199,7 @@ &pcie2x1l1 { /* NIC */ &pcie2x1l2 { pinctrl-names = "default"; - pinctrl-0 = <&pcie20x1m0_perstn>, <&pcie20x1m0_clkreqn>, + pinctrl-0 = <&pcie2_2_rst>, <&pcie20x1m0_clkreqn>, <&pcie20x1m0_waken>; reset-gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_HIGH>; vpcie3v3-supply = <&vcc3v3_eth>;
@@ -223,6 +223,16 @@ ethernet_en: ethernet-en { }; }; + pcie { + pcie2_1_rst: pcie2-1-rst { + rockchip,pins = <4 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pcie2_2_rst: pcie2-2-rst { + rockchip,pins = <3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + usb { vcc5v0_otg_en: vcc5v0-otg-en { rockchip,pins = <0 RK_PC4 RK_FUNC_GPIO &pcfg_pull_down>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1295/2651 perf/marvell: cn10k_tad: Publish the OF module alias
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit 848468c86f716e4552bd478d2f3c3f5d81bec7ac ]
The TAD PMU platform driver has ACPI and OF match tables, but only the ACPI table is published. A Device Tree platform device emits an OF modalias, so the ACPI alias does not select this module for it.
Publish the OF table inside CONFIG_OF and retain ACPI support.
--- drivers/perf/marvell_cn10k_tad_pmu.c | 1 + 1 file changed, 1 insertion(+)
drivers/perf/marvell_cn10k_tad_pmu.c +1 -0
@@ -424,6 +424,7 @@ static const struct of_device_id tad_pmu_of_match[] = { { .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data }, {}, }; +MODULE_DEVICE_TABLE (of, tad_pmu_of_match);#endif #ifdef CONFIG_ACPI
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1296/2651 svcrdma: Fix svc_rdma_recv_cid_init() kernel-doc
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit d1caedce2d015573b4c26b127c488059f25aabc4 ]
svc_rdma_recv_cid_init() initializes a Receive Queue completion ID, but its kernel-doc heading names svc_rdma_send_cid_init(). The latter is a separate helper immediately below it, so kernel-doc cannot match this comment to the receive helper.
Fix the copied function name.
--- include/linux/sunrpc/svc_rdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sunrpc/svc_rdma.h +1 -1
@@ -142,7 +142,7 @@ enum {#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD/** -* svc_rdma_send_cid_init - Initialize a Receive Queue completion ID +* svc_rdma_recv_cid_init - Initialize a Receive Queue completion ID * @rdma: controlling transport * @cid: completion ID to initialize */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1297/2651 cpufreq: sparc-us2e: fix frequency table index copy-paste error
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit e5b33fa47792375ca7fc49ccadee87d8e4b72929 ]
In us2e_freq_cpu_init(), the last two frequency writes both use index [2] instead of [3] and [4] respectively, and the terminator uses [3] instead of [5]. This is a copy-paste error where the index was not incremented, causing the divider-6 and divider-8 entries to overwrite the already-written divider-4 entry.
As a result, only three frequency steps (div 1, 2, and 4) are actually available to the cpufreq core, while the intended dividers 6 and 8 are silently lost. The struct us2e_freq_percpu_info::table[6] has room for 5 entries plus a terminator, matching the 5 hardware dividers.
Fix the indices so all five frequency steps are correctly populated:
table[0]=div1, table[1]=div2, table[2]=div4, table[3]=div6, table[4]=div8, table[5]=TABLE_END.
--- drivers/cpufreq/sparc-us2e-cpufreq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/cpufreq/sparc-us2e-cpufreq.c +5 -6
@@ -282,12 +282,11 @@ static int us2e_freq_cpu_init(struct cpufreq_policy *policy) table[1 ].frequency = clock_tick /2 ; table[2 ].driver_data =2 ; table[2 ].frequency = clock_tick /4 ; - table[2 ].driver_data =3 ; - table[2 ].frequency = clock_tick /6 ; - table[2 ].driver_data =4 ; - table[2 ].frequency = clock_tick /8 ; - table[2 ].driver_data =5 ; - table[3 ].frequency =CPUFREQ_TABLE_END ; + table[3 ].driver_data =3 ; + table[3 ].frequency = clock_tick /6 ; + table[4 ].driver_data =4 ; + table[4 ].frequency = clock_tick /8 ; + table[5 ].frequency =CPUFREQ_TABLE_END ; policy->cpuinfo.transition_latency =0 ; policy->cur = clock_tick;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1298/2651 cpufreq: tegra194: fix double-pointer error in get_cpu_ndiv
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit f0a750dad7da1c653e85f0698063235453b43831 ]
ndiv is already a u64 pointer, passing &ndiv to smp_call_function_single() results in a u64** being written to instead of the caller's u64 variable, so the caller always reads back an uninitialized ndiv. Drop the spurious '&'.
--- drivers/cpufreq/tegra194-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/tegra194-cpufreq.c +1 -1
@@ -367,7 +367,7 @@ static void tegra194_get_cpu_ndiv_sysreg(void *ndiv)static int tegra194_get_cpu_ndiv (u32 cpu,u32 cpuid,u32 clusterid,u64 *ndiv) { -return smp_call_function_single (cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true); +return smp_call_function_single (cpu, tegra194_get_cpu_ndiv_sysreg, ndiv, true); }static void tegra194_set_cpu_ndiv_sysreg (void *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1299/2651 cpufreq: sti: avoid NULL dereference in dev_err()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit fdbe4cae71c8196cd7681ad47254b5b0560d3c1e ]
ddata.cpu is NULL-checked, then immediately passed to dev_err(). Replace with pr_err() to avoid dereferencing NULL.
--- drivers/cpufreq/sti-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/sti-cpufreq.c +2 -2
@@ -263,7 +263,7 @@ static int __init sti_cpufreq_init(void) ddata.cpu =get_cpu_device (0 );if (!ddata.cpu) { -dev_err (ddata.cpu,"Failed to get device for CPU0\n" ); +pr_err ("Failed to get device for CPU0\n" ); goto skip_voltage_scaling; }
@@ -281,7 +281,7 @@ static int __init sti_cpufreq_init(void) goto register_cpufreq_dt; skip_voltage_scaling: -dev_err (ddata.cpu,"Not doing voltage scaling\n" ); +pr_err ("Not doing voltage scaling\n" ); register_cpufreq_dt:platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1300/2651 drm/msm/dpu: round up the compressed INTF width
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonhoe Kim <[email protected]>
[ Upstream commit 6b93e8b453fa27a1b6a1d472f3ff8663e6811fae ]
For DSI with DSC, drm_mode_to_intf_timing_params() scales the INTF active width by bpp / (3 * bits_per_component) and rounds down. The DSI host computes the same width with DIV_ROUND_UP, both for the pixel clock (dsi_adjust_pclk_for_compression()) and for the active width it programs (dsi_timing_setup(), from bytes per line). When the division is not exact the INTF line is one pclk shorter than the DSI line, and the DSI FIFO overflows.
Example: a bonded DSI video-mode panel, 952 pixels per link, DSC 8 bpp at 10 bpc: 952 * 8 / 30 = 253.87, so the INTF uses 253 and the DSI 254.
Round up, as the DSI host does. Qualcomm's downstream SDE driver also rounds this width up, and Pengyu Luo needed the same rounding on the Legion Y700 gen 4 [1].
Tested on a Lenovo Legion Tab Y700 gen 5 (SM8850) with that panel, with a module parameter selecting the rounding: rounding down, DPMS off/on gives no vblank and 14000-17000 DSI FIFO error interrupts per second (dsi_err_worker: status=4); rounding up, the picture comes back and there are no errors. Only tested on this device.
Patchwork: https://patchwork.freedesktop.org/patch/757958/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +2 -2
@@ -134,8 +134,8 @@ static void drm_mode_to_intf_timing_params(* TODO: replace drm_dsc_get_bpp_int with logic to handle * fractional part if there is fraction */ - timing->width = timing->width *drm_dsc_get_bpp_int (dsc) / - (dsc->bits_per_component *3 ); + timing->width =DIV_ROUND_UP (timing->width *drm_dsc_get_bpp_int (dsc), + dsc->bits_per_component *3 ); timing->xres = timing->width; timing->dce_bytes_per_line =msm_dsc_get_bytes_per_line (dsc); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1301/2651 firmware: qcom: tzmem: Use DO_ONCE_SLEEPABLE() in qcom_tzmem_enable()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 60d4a6edea9ec617725db6dd1e66d96a13bc8d0a ]
qcom_tzmem_enable() is called from qcom_scm_probe() in a sleepable process context. The helper it wraps, qcom_tzmem_init(), calls qcom_scm_shm_bridge_enable() -> qcom_scm_call(), which invokes might_sleep() and later acquires the qcom_scm_lock mutex via __scm_smc_do().
DO_ONCE() takes the once_lock spinlock with IRQs disabled, so invoking qcom_tzmem_init() from inside DO_ONCE() runs a sleepable call chain in atomic context. CONFIG_DEBUG_ATOMIC_SLEEP=y catches this on boot:
BUG: sleeping function called from invalid context at drivers/firmware/qcom/qcom_scm.c:334 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 49, name: kworker/u16:2 ... __might_resched+0x148/0x24c __might_sleep+0x48/0x7c qcom_scm_call+0x30/0xc0 __qcom_scm_is_call_available+0x98/0x100 qcom_scm_shm_bridge_enable+0x60/0xbc qcom_tzmem_enable+0xf8/0x118 qcom_scm_probe+0x2d0/0x680
[ BUG: Invalid wait context ]
...
kworker/u16:2/49 is trying to lock:
ffffa83e8a485e38 (qcom_scm_lock){....}-{4:4}, at: __scm_smc_do+0x70/0x488
Switch to DO_ONCE_SLEEPABLE(), which guards the one-shot init with a mutex-style path (__do_once_sleepable_start/done) that is safe to hold across sleeping callees. All callers of qcom_tzmem_enable() are in process context (driver probe), so this is safe.
--- drivers/firmware/qcom/qcom_tzmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/qcom/qcom_tzmem.c +1 -1
@@ -516,7 +516,7 @@ int qcom_tzmem_enable(struct device *dev)static int result; qcom_tzmem_dev = dev; -DO_ONCE (qcom_tzmem_do_init, &result); +DO_ONCE_SLEEPABLE (qcom_tzmem_do_init, &result);return result; }EXPORT_SYMBOL_GPL (qcom_tzmem_enable);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1302/2651 firmware: qcom_scm: handle empty PAS resource table
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 324103eb65ba26704c2293d9daaa15c0dc022930 ]
The PAS resource-table query may successfully return a zero-sized table. kmemdup() with a zero length returns ZERO_SIZE_PTR, which is stored in rproc->table_ptr. The remoteproc core then dereferences this invalid pointer while processing resources.
Treat a zero-sized result as an absent resource table and return NULL after releasing the TrustZone memory buffer. This allows the remoteproc core to skip resource-table processing.
--- drivers/firmware/qcom/qcom_scm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/firmware/qcom/qcom_scm.c +9 -1
@@ -865,6 +865,14 @@ static void *__qcom_scm_pas_get_rsc_table2(struct device *dev, goto free_input_rt; } + *output_rt_size = size; + +/* A zero-sized table means that TrustZone has no resource table. */ +if (!size) { + tbl_ptr =NULL ; + goto free_output_rt; + } + tbl_ptr =kmemdup (output_rt_tzm, size,GFP_KERNEL );if (!tbl_ptr) {qcom_tzmem_free (output_rt_tzm);
@@ -872,7 +880,7 @@ static void *__qcom_scm_pas_get_rsc_table2(struct device *dev, goto free_input_rt; } - *output_rt_size = size; +free_output_rt:qcom_tzmem_free (output_rt_tzm); free_input_rt:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1303/2651 firmware: qcom_scm: align PAS resource table retry
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 57e43df2e426ac5561ee3832d425e1071772e963 ]
The initial PAS resource-table buffer can be too small. TrustZone returns the required size and the wrapper retries the SCM call. Although qcom_tzmem_alloc() aligns the allocated buffer, the size passed to TrustZone remained unaligned.
Align the retry size to a page boundary so that both the buffer and its advertised size satisfy the PAS/TrustZone contract.
--- drivers/firmware/qcom/qcom_scm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/firmware/qcom/qcom_scm.c +4 -2
@@ -854,12 +854,14 @@ static void *__qcom_scm_pas_get_rsc_table2(struct device *dev, output_rt_tzm =__qcom_scm_pas_get_rsc_table (dev, ctx->pas_id, input_rt_tzm, input_rt_size, &size); -if (PTR_ERR (output_rt_tzm) == -EOVERFLOW ) -/* Try again with the size requested by the TZ */ +if (PTR_ERR (output_rt_tzm) == -EOVERFLOW ) { +/* Try again with a page-aligned size requested by the TZ. */ + size =PAGE_ALIGN (size); output_rt_tzm =__qcom_scm_pas_get_rsc_table (dev, ctx->pas_id, input_rt_tzm, input_rt_size, &size); + }if (IS_ERR (output_rt_tzm)) { ret =PTR_ERR (output_rt_tzm); goto free_input_rt;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1304/2651 soc: qcom: pmic_glink: Avoid losing early rpmsg probe
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 0c79a829af36a94143c747a0ab8f0a8563b17cfa ]
The PMIC GLINK rpmsg device can appear before the platform device has finished probing. In that case pmic_glink_rpmsg_probe() sees __pmic_glink as NULL and returns -ENODEV, which is treated as a fatal probe failure for the rpmsg endpoint.
If this race is hit, pg->ept is never installed and PMIC GLINK clients never receive the service-up notification. This may leave the system with no Type-C functionality and without battery/power supply management.
Return -EPROBE_DEFER when the rpmsg endpoint arrives before the platform device is ready.
--- drivers/soc/qcom/pmic_glink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soc/qcom/pmic_glink.c +2 -1
@@ -250,7 +250,8 @@ static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)guard (mutex)(&__pmic_glink_lock); pg = __pmic_glink;if (!pg) -return dev_err_probe (&rpdev->dev, -ENODEV ,"no pmic_glink device to attach to\n" ); +return dev_err_probe (&rpdev->dev, -EPROBE_DEFER , +"no pmic_glink device to attach to\n" );dev_set_drvdata (&rpdev->dev, pg); pg->pdr_available = rpdev->id.driver_data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1305/2651 soc: qcom: geni-se: provide PROG_RAM_DEPTH for I2C HUB Serial Engines
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Armstrong <[email protected]>
[ Upstream commit 803f9950a6c6e0b37ed7f24925feed823703467e ]
The I2C Hub serial elements lacks DMA, so the SE_HW_PARAM_2 register which is in the DMA register space doesn't exist for those instances.
Provide the ram depth in the compatible data to be used instead of the reading the missing SE_HW_PARAM_2 register.
--- drivers/soc/qcom/qcom-geni-se.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/soc/qcom/qcom-geni-se.c +12 -2
@@ -101,22 +101,26 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(geni_se_regs);* @base: Base address of this instance of QUP wrapper core * @clks: Handle to the primary & optional secondary AHB clocks * @num_clks: Count of clocks +* @prog_ram_depth: Available CFG RAM depth for instance without SE_HW_PARAM_2 */ struct geni_wrapper {struct device *dev;void __iomem *base;struct clk_bulk_data clks[MAX_CLKS ];unsigned int num_clks; +unsigned int prog_ram_depth; };/** * struct geni_se_desc - Data structure to represent the QUP Wrapper resources * @clks: Name of the primary & optional secondary AHB clocks * @num_clks: Count of clock names +* @prog_ram_depth: Available CFG RAM depth for instance without SE_HW_PARAM_2 */ struct geni_se_desc {unsigned int num_clks;const char *const *clks; +unsigned int prog_ram_depth; };static const char *const icc_path_names[] = {"qup-core" ,"qup-config" ,
@@ -1244,6 +1248,7 @@ static const struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const senum geni_se_protocol_type protocol, u32 *fw_size_out) { + struct geni_wrapper *wrapper = se->wrapper;struct device *dev = se->dev;const struct elf32_hdr *ehdr;const struct elf32_phdr *phdrs;
@@ -1308,8 +1313,11 @@ static const struct se_fw_hdr *geni_find_protocol_fw(struct geni_se *se, const s cfg_val_end =le16_to_cpu (sefw->cfg_val_offset) +le16_to_cpu (sefw->cfg_size_in_items) *sizeof (u32); - prog_ram_depth =FIELD_GET (PROG_RAM_DEPTH_MSK , -readl_relaxed (se->base +SE_HW_PARAM_2 )); +if (wrapper->prog_ram_depth) + prog_ram_depth = wrapper->prog_ram_depth; +else + prog_ram_depth =FIELD_GET (PROG_RAM_DEPTH_MSK , +readl_relaxed (se->base +SE_HW_PARAM_2 ));if (fw_size >= prog_ram_depth) {dev_err (dev,"Firmware size (%u) exceeds RAM size (%u)\n" , fw_size, prog_ram_depth);
@@ -1620,6 +1628,7 @@ static int geni_se_probe(struct platform_device *pdev)return PTR_ERR (wrapper->base); desc =device_get_match_data (&pdev->dev); + wrapper->prog_ram_depth = desc->prog_ram_depth;if (!has_acpi_companion (&pdev->dev) && desc->num_clks) {int i;
@@ -1672,6 +1681,7 @@ static const char * const i2c_master_hub_clks[] = {static const struct geni_se_desc i2c_master_hub_desc = { .clks = i2c_master_hub_clks, .num_clks =ARRAY_SIZE (i2c_master_hub_clks), + .prog_ram_depth =1020 , };static const struct of_device_id geni_se_dt_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1306/2651 soc: qcom: pmic_pdcharger_ulog: prevent work requeue during remove
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yibo Tan <[email protected]>
[ Upstream commit 66894a1c51366cc2d5c498178105dfe3bcccc1e4 ]
pmic_pdcharger_ulog_rpmsg_remove() cancels the delayed worker while the RPMsg endpoint can still deliver callbacks. The RPMsg core invokes the driver remove callback before destroying the endpoint, so a response callback can run after cancel_delayed_work_sync() returns and queue the worker again.
Device cleanup then frees the devm-allocated pmic_pdcharger_ulog while the requeued delayed work still embeds and dereferences that object. KASAN reports a slab-use-after-free in pmic_pdcharger_ulog_work().
Use disable_delayed_work_sync() to drain the worker and reject queue attempts that race with removal.
The issue was reproduced in four of four runs with the real target driver, RPMsg bus removal, endpoint teardown, workqueue code and devres cleanup. The test provider delivered a valid response in the window between the driver remove callback and endpoint destruction. With this change, the same late callback occurred in four of four runs without a KASAN report, warning, Oops or panic.
The reproducer uses a test RPMsg provider to control the teardown timing. No unprivileged trigger or physical Qualcomm-device result is claimed.
--- drivers/soc/qcom/pmic_pdcharger_ulog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pmic_pdcharger_ulog.c +1 -1
@@ -143,7 +143,7 @@ static void pmic_pdcharger_ulog_rpmsg_remove(struct rpmsg_device *rpdev) {struct pmic_pdcharger_ulog *pg =dev_get_drvdata (&rpdev->dev); -cancel_delayed_work_sync (&pg->ulog_work); +disable_delayed_work_sync (&pg->ulog_work); }static const struct rpmsg_device_id pmic_pdcharger_ulog_rpmsg_id_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1307/2651 ASoC: codecs: es8375: use devm_clk_get_optional() for mclk
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 58e7bca5cf264e910ad9199cfc40246e0a2834f4 ]
es8375_read_device_properities() gets "mclk" with devm_clk_get() and then tests the result for NULL to print "assuming static mclk". A missing clock makes devm_clk_get() return -ENOENT, so the probe fails before that test can match.
The binding does not require clocks, its example has none, and everest,mclk-src lets the codec run from SCLK instead of MCLK. Use devm_clk_get_optional(), as es8311, es8316, es8323, es8326 and es8389 do for the same clock.
Found with an experimental clang warning about NULL tests on functions that return error pointers. Tested only in QEMU with i2c-stub in place of the codec, not on real hardware.
--- sound/soc/codecs/es8375.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/es8375.c +1 -1
@@ -665,7 +665,7 @@ static int es8375_read_device_properities(struct device *dev, struct es8375_privreturn ret; } - es8375->mclk =devm_clk_get (dev,"mclk" ); + es8375->mclk =devm_clk_get_optional (dev,"mclk" );if (IS_ERR (es8375->mclk))return dev_err_probe (dev,PTR_ERR (es8375->mclk),"unable to get mclk\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1308/2651 wifi: cfg80211: allow zero HE OBSS PD offsets
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominic White <[email protected]>
[ Upstream commit d9ecaa0a31732014a128e3b03243de54bbbd8394 ]
IEEE Std 802.11 permits the OBSS PD offset fields in the Spatial Reuse Parameter Set element to have a value of zero. (IEEE Std 802.11-2024, 26.10.2.4)
The standard specifies the offsets as unsigned values added to -82 dBm, with field presence signalled independently. The valid offset range is therefore 0..20.
nl80211 currently rejects zero for all three HE OBSS PD offset attributes during nested netlink policy validation, before the values reach cfg80211 or the driver. Allow zero while retaining the upper bound and the existing minimum/maximum relationship validation.
--- net/wireless/nl80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/wireless/nl80211.c +3 -3
@@ -529,11 +529,11 @@ nl80211_pmsr_attr_policy[NL80211_PMSR_ATTR_MAX + 1] = {static const struct nla_policy he_obss_pd_policy[NL80211_HE_OBSS_PD_ATTR_MAX +1 ] = { [NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP ] =NLA_POLICY_EXACT_LEN (8 ), [NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP] =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1309/2651 wifi: b43: dont pass unterminated string to sscanf()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 9b6cb072f9249e2cdb7c32be2b8069774c7e01e6 ]
The "buf" buffer is a PAGE_SIZE and allocated with kzalloc(). We store a string from the user in it and then pass it to sscanf() in the write functions such as shm32write__write_file(). Only a few numbers are stored in the buffer so it never comes close to filling up the whole PAGE_SIZE. Reserve the last character of the page for a NUL terminator.
This is debugfs so it's root only.
--- drivers/net/wireless/broadcom/b43/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/debugfs.c +1 -1
@@ -557,7 +557,7 @@ static ssize_t b43_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; dev = file->private_data;if (!dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1310/2651 wifi: b43legacy: debugfs: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f94595252b318a9ae3c01d78b3bcd33b01b1c082 ]
The "buf" buffer is PAGE_SIZE and allocated with kzalloc(). We store a string from the user in it and then pass it to sscanf() in the write functions such as tsf_write_file(). The buffer is only used to store a number so we never come close to filling up the whole PAGE_SIZE. Reserve the last character of the page for a NUL terminator.
This is debugfs so it's root only.
--- drivers/net/wireless/broadcom/b43legacy/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43legacy/debugfs.c +1 -1
@@ -259,7 +259,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; dev = file->private_data;if (!dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1311/2651 wifi: carl9170: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit ece30e1daf6a9c95d6f9d0518534a0b9c8c7fd42 ]
The "buf" buffer comes from the user. We use it to store a number or two so it doesn't need to be large. It gets passed to sscanf() in the write functions such as carl9170_debugfs_erp_write(). Ensure that buffer is NUL terminated.
This is debugfs so it's root only.
--- drivers/net/wireless/ath/carl9170/debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/debug.c +3 -2
@@ -119,7 +119,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; ar = file->private_data;
@@ -131,7 +131,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,if (!dfops->write)return -ENOSYS ; - buf =vmalloc (count); + buf =vmalloc (count +1 );if (!buf)return -ENOMEM ;
@@ -139,6 +139,7 @@ static ssize_t carl9170_debugfs_write(struct file *file, err = -EFAULT ; goto out_free; } + buf[count] ='\0' ;if (mutex_trylock (&ar->mutex) ==0 ) { err = -EAGAIN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1312/2651 Revert "wifi: mac80211: do not use old MBSSID elements"
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit 56fb2334c86cef0b6d44099a6b21de4c8d80a7cb ]
Commit a519be2f5d95 ("wifi: mac80211: do not use old MBSSID elements") fixed the incorrect inclusion of stopped/removed non-transmitted profiles from the Beacon frames, but it caused a regression for channel switch (CSA) and BSS color change (CCA) operations initiated from hostapd.
Hostapd passes two Beacon templates to kernel for CSA and CCA -
(1) beacon_csa/beacon_color_change used during the countdown.
(2) beacon_after/beacon_next used after the countdown completes. Hostapd relies on the kernel to include the old MBSSID elements while sending beacon_csa/beacon_color_change templates to the driver.
This path is now broken and results in CSA/CCA failure.
Including existing MBSSID elements explicitly makes the netlink buffer larger than default 4 KB depending on the number of APs which would need unnecessary complication to pre-calculate the buffer length.
Revert the commit to fix the regression.
Regarding the original issue fixed by the reverted commit - Hostapd now has a new commit which always includes at least one MBSSID element when the feature is enabled, hence when all non-transmitted profiles are removed, this empty element ensures that stopped profiles are not advertised.
--- net/mac80211/cfg.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/mac80211/cfg.c +10 -0
@@ -1501,6 +1501,7 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, size =sizeof (*new) + new_head_len + new_tail_len; +/* new or old multiple BSSID elements? */ if (params->mbssid_ies) { mbssid = params->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt);
@@ -1510,6 +1511,15 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, } size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, mbssid->cnt); + }else if (old && old->mbssid_ies) { + mbssid = old->mbssid_ies; + size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); +if (old && old->rnr_ies) { + rnr = old->rnr_ies; + size +=struct_size (new->rnr_ies, elem, rnr->cnt); + } + size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, + mbssid->cnt); } new =kzalloc (size,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1313/2651 drm/msm/a5xx: dont read the GPMU registers on GPUs without a GPMU
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 77e3ffcf69065c4ce92c725540e0b4db14f43ad7 ]
Only a530/a540 have a GPMU. On the other a5xx parts, reading the 0xa800-0xac60 GPMU aperture during a crashdump resets the board -- on sda660 (a512) a GPU hang thus reboots the SoC instead of recovering.
Split the GPMU block into its own array and collect it only when a GPMU is present.
Patchwork: https://patchwork.freedesktop.org/patch/754867/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 49 +++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +46 -3
@@ -1337,9 +1337,14 @@ static const u32 a5xx_registers[] = {0xE800 ,0xE806 ,0xE810 ,0xE89A ,0xE8A0 ,0xE8A4 ,0xE8AA ,0xE8EB ,0xE900 ,0xE905 ,0xEB80 ,0xEB8F ,0xEBB0 ,0xEBB0 ,0xEC00 ,0xEC05 ,0xEC08 ,0xECE9 ,0xECF0 ,0xECF0 ,0xEA80 ,0xEA80 ,0xEA82 ,0xEAA3 , -0xEAA5 ,0xEAC2 ,0xA800 ,0xA800 ,0xA820 ,0xA828 ,0xA840 ,0xA87D , -0XA880 ,0xA88D ,0xA890 ,0xA8A3 ,0xA8D0 ,0xA8D8 ,0xA8E0 ,0xA8F5 , - 0xAC60, 0xAC60, ~0, + 0xEAA5, 0xEAC2, ~0, +}; + +/* GPMU registers, only valid on parts with a GPMU (a530/a540) */ +static const u32 a5xx_gpmu_registers[] = { +0xA800 ,0xA800 ,0xA820 ,0xA828 ,0xA840 ,0xA87D ,0xA880 ,0xA88D , +0xA890 ,0xA8A3 ,0xA8D0 ,0xA8D8 ,0xA8E0 ,0xA8F5 ,0xAC60 ,0xAC60 , + ~0 , };static void a5xx_dump (struct msm_gpu *gpu)
@@ -1448,6 +1453,7 @@ struct a5xx_crashdumper {struct a5xx_gpu_state {struct msm_gpu_state base;u32 *hlsqregs; +u32 *gpmuregs; }; static int a5xx_crashdumper_init(struct msm_gpu *gpu,
@@ -1565,8 +1571,30 @@ static void a5xx_gpu_state_get_hlsq_regs(struct msm_gpu *gpu,msm_gem_kernel_put (dumper.bo, gpu->vm); } +static void a5xx_gpu_state_get_gpmu_regs (struct msm_gpu *gpu, +struct a5xx_gpu_state *a5xx_state) +{ +u32 count =0 , pos =0 ; +int i; + +for (i =0 ; a5xx_gpmu_registers[i] != ~0 ; i +=2 ) + count += a5xx_gpmu_registers[i +1 ] - a5xx_gpmu_registers[i] +1 ; + + a5xx_state->gpmuregs =kcalloc (count,sizeof (u32),GFP_KERNEL ); +if (!a5xx_state->gpmuregs) +return ; + +for (i =0 ; a5xx_gpmu_registers[i] != ~0 ; i +=2 ) { +u32 addr; + +for (addr = a5xx_gpmu_registers[i]; addr <= a5xx_gpmu_registers[i +1 ]; addr++) + a5xx_state->gpmuregs[pos++] =gpu_read (gpu, addr); + } +} +static struct msm_gpu_state *a5xx_gpu_state_get (struct msm_gpu *gpu) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a5xx_gpu_state *a5xx_state =kzalloc_obj (*a5xx_state);bool stalled = !!(gpu_read (gpu,REG_A5XX_RBBM_STATUS3 ) &BIT (24 ));
@@ -1581,6 +1609,9 @@ static struct msm_gpu_state *a5xx_gpu_state_get(struct msm_gpu *gpu) a5xx_state->base.rbbm_status =gpu_read (gpu,REG_A5XX_RBBM_STATUS ); +if (adreno_is_a530 (adreno_gpu) ||adreno_is_a540 (adreno_gpu)) +a5xx_gpu_state_get_gpmu_regs (gpu, a5xx_state); +/* * Get the HLSQ regs with the help of the crashdumper, but only if * we are not stalled in an iommu fault (in which case the crashdumper
@@ -1602,6 +1633,7 @@ static void a5xx_gpu_state_destroy(struct kref *kref) struct a5xx_gpu_state, base);kfree (a5xx_state->hlsqregs); +kfree (a5xx_state->gpmuregs);adreno_gpu_state_destroy (state);kfree (a5xx_state);
@@ -1630,6 +1662,17 @@ static void a5xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state,adreno_show (gpu, state, p); +if (a5xx_state->gpmuregs) { +u32 o, pos =0 ; + +drm_printf (p,"registers-gpmu:\n" ); + +for (i =0 ; a5xx_gpmu_registers[i] != ~0 ; i +=2 ) +for (o = a5xx_gpmu_registers[i]; o <= a5xx_gpmu_registers[i +1 ]; o++) +drm_printf (p," - { offset: 0x%04x, value: 0x%08x }\n" , + o <<2 , a5xx_state->gpmuregs[pos++]); + } +/* Dump the additional a5xx HLSQ registers */ if (!a5xx_state->hlsqregs)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1314/2651 dmaengine: switchtec-dma: fix double-free in switchtec_dma_free_desc()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit bdfd76514bd11301f4e67d150485ab696c26d83d ]
switchtec_dma_free_desc() frees swdma_chan->hw_sq, hw_cq, and every desc_ring[] entry without clearing the pointers afterward. If switchtec_dma_alloc_chan_resources() fails partway through and calls it during unwind, then a later retry of alloc_chan_resources() fails in switchtec_dma_alloc_desc() before reallocating one of those pointers, its own failure path calls switchtec_dma_free_desc() again and frees the same, already-freed pointers a second time.
NULL out each pointer as it's freed so a subsequent call is a no-op for anything already released.
--- drivers/dma/switchtec_dma.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/dma/switchtec_dma.c +5 -1
@@ -886,14 +886,18 @@ static void switchtec_dma_free_desc(struct switchtec_dma_chan *swdma_chan)if (swdma_chan->hw_sq)dma_free_coherent (swdma_dev->dma_dev.dev, size, swdma_chan->hw_sq, swdma_chan->dma_addr_sq); + swdma_chan->hw_sq =NULL ; size =SWITCHTEC_DMA_CQ_SIZE *sizeof (*swdma_chan->hw_cq);if (swdma_chan->hw_cq)dma_free_coherent (swdma_dev->dma_dev.dev, size, swdma_chan->hw_cq, swdma_chan->dma_addr_cq); + swdma_chan->hw_cq =NULL ; -for (i =0 ; i <SWITCHTEC_DMA_RING_SIZE ; i++) +for (i =0 ; i <SWITCHTEC_DMA_RING_SIZE ; i++) {kfree (swdma_chan->desc_ring[i]); + swdma_chan->desc_ring[i] =NULL ; + } }static int switchtec_dma_alloc_desc (struct switchtec_dma_chan *swdma_chan)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1315/2651 dmaengine: switchtec-dma: fix resource leak in alloc_chan_resources
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit 1188942d6160b9f799af297bdb5d7812cd7fde6d ]
switchtec_dma_alloc_chan_resources() returns directly on any later failure, without ever freeing the descriptor rings and coherent DMA memory it just allocated. The dmaengine core does not call device_free_chan_resources() when device_alloc_chan_resources() fails, so the driver has to unwind its own partial state.
The device-removed check also runs after ring_active and comp_ring_active have already been set true, so a failure there left the channel marked active despite alloc_chan_resources() reporting failure.
Add an error-unwind path that disables the channel and frees the descriptor rings on every failure after allocation. ring_active and comp_ring_active are cleared under the same locks switchtec_dma_free_chan_resources() already uses, since the completion tasklet checks comp_ring_active under complete_lock before touching the completion ring, and a stale IRQ can still be in flight when this unwind path runs.
--- drivers/dma/switchtec_dma.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/dma/switchtec_dma.c +19 -4
@@ -988,15 +988,15 @@ static int switchtec_dma_alloc_chan_resources(struct dma_chan *chan) rc =enable_channel (swdma_chan);if (rc) -return rc; + goto err_free_desc; rc =reset_channel (swdma_chan);if (rc) -return rc; + goto err_disable_channel; rc =unhalt_channel (swdma_chan);if (rc) -return rc; + goto err_disable_channel; swdma_chan->ring_active = true; swdma_chan->comp_ring_active = true;
@@ -1007,7 +1007,8 @@ static int switchtec_dma_alloc_chan_resources(struct dma_chan *chan)rcu_read_lock ();if (!rcu_dereference (swdma_dev->pdev)) {rcu_read_unlock (); -return -ENODEV ; + rc = -ENODEV ; + goto err_ring_inactive; } perf_cfg =readl (&swdma_chan->mmio_chan_fw->perf_cfg);
@@ -1029,6 +1030,20 @@ static int switchtec_dma_alloc_chan_resources(struct dma_chan *chan) FIELD_GET(PERF_MRRS_MASK, perf_cfg));return SWITCHTEC_DMA_SQ_SIZE ; + +err_ring_inactive: +spin_lock_bh (&swdma_chan->submit_lock); + swdma_chan->ring_active = false; +spin_unlock_bh (&swdma_chan->submit_lock); + +spin_lock_bh (&swdma_chan->complete_lock); + swdma_chan->comp_ring_active = false; +spin_unlock_bh (&swdma_chan->complete_lock); +err_disable_channel: +disable_channel (swdma_chan); +err_free_desc: +switchtec_dma_free_desc (swdma_chan); +return rc; }static void switchtec_dma_free_chan_resources (struct dma_chan *chan)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1316/2651 dmaengine: switchtec-dma: fix channel leak on registration failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit fd39726ab7096840cc9c9dea6dfba23834fc81f0 ]
switchtec_dma_chans_release() is called in three places but the underlying memory is not freed in all of those places. In order to clean this up, introduce a switchtec_dma_chans_free() helper that will free the memory.
Ensure each call to switchtec_dma_chans_release() has a corresponding switchtec_dma_chans_free() call. (The release in switchtec_dma_remove() pairs with the free in switchtec_dma_release()).
swdma_dev->chan_cnt is now set to the number of channels that succeeded when one fails to initialise, so switchtec_dma_chans_free() can still be used if not all channels succeed in being allocated.
switchtec_dma_chans_free() also removes each channel from dma_dev->channels before freeing it, since the channel status ISR walks that list and would otherwise dereference freed memory.
--- drivers/dma/switchtec_dma.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/dma/switchtec_dma.c +17 -10
@@ -1175,6 +1175,18 @@ static int switchtec_dma_chans_release(struct pci_dev *pdev,return 0 ; } +static void switchtec_dma_chans_free (struct switchtec_dma_dev *swdma_dev) +{ +int i; + +for (i =0 ; i < swdma_dev->chan_cnt; i++) { +list_del (&swdma_dev->swdma_chans[i]->dma_chan.device_node); +kfree (swdma_dev->swdma_chans[i]); + } + +kfree (swdma_dev->swdma_chans); +} +static int switchtec_dma_chans_enumerate (struct switchtec_dma_dev *swdma_dev,struct pci_dev *pdev,int chan_cnt) {
@@ -1199,7 +1211,7 @@ static int switchtec_dma_chans_enumerate(struct switchtec_dma_dev *swdma_dev,if (rc) {dev_err (&pdev->dev,"Channel %d: init channel failed\n" , i); - chan_cnt = i; + swdma_dev->chan_cnt = i; goto err_exit; } }
@@ -1207,10 +1219,8 @@ static int switchtec_dma_chans_enumerate(struct switchtec_dma_dev *swdma_dev,return chan_cnt; err_exit: -for (i =0 ; i < chan_cnt; i++) -switchtec_dma_chan_free (pdev, swdma_dev->swdma_chans[i]); - -kfree (swdma_dev->swdma_chans); +switchtec_dma_chans_release (pdev, swdma_dev); +switchtec_dma_chans_free (swdma_dev);return rc; }
@@ -1219,12 +1229,8 @@ static void switchtec_dma_release(struct dma_device *dma_dev) {struct switchtec_dma_dev *swdma_dev = container_of(dma_dev, struct switchtec_dma_dev, dma_dev); -int i; -for (i =0 ; i < swdma_dev->chan_cnt; i++) -kfree (swdma_dev->swdma_chans[i]); - -kfree (swdma_dev->swdma_chans); +switchtec_dma_chans_free (swdma_dev);put_device (dma_dev->dev);kfree (swdma_dev);
@@ -1315,6 +1321,7 @@ static int switchtec_dma_create(struct pci_dev *pdev) err_chans_release_exit:switchtec_dma_chans_release (pdev, swdma_dev); +switchtec_dma_chans_free (swdma_dev); err_exit:if (swdma_dev->chan_status_irq)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1317/2651 dmaengine: ioat: disable relaxed ordering before registering the device
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit 10d34fbca6e09a6a18d64fa3ebaa3db9f27fc1a6 ]
ioat3_dma_probe() disabled PCIe relaxed ordering after calling dma_async_device_register(), so if an error occurs and the code jumps to err_disable_interrupts, the function returns with the device still registered in the core's dma_device_list while the caller frees the ioatdma_device struct, leaving a dangling registration that anything walking the device list can dereference after it's been freed.
Move the capability read/write ahead of dma_async_device_register() instead. Nothing after registration depends on relaxed ordering already being disabled, and nothing before it depends on the device being registered, so this is a plain reordering. It also means every remaining step after registration can't fail, so there's no need to ever have to unregister the device once registered.
--- drivers/dma/ioat/init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/dma/ioat/init.c +9 -9
@@ -1170,15 +1170,6 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); } - err =dma_async_device_register (&ioat_dma->dma_dev); -if (err) - goto err_disable_interrupts; - -ioat_kobject_add (ioat_dma, &ioat_ktype); - -if (dca) - ioat_dma->dca =ioat_dca_init (pdev, ioat_dma->reg_base); -/* disable relaxed ordering */ err =pcie_capability_read_word (pdev,PCI_EXP_DEVCTL , &val16);if (err) {
@@ -1194,6 +1185,15 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) goto err_disable_interrupts; } + err =dma_async_device_register (&ioat_dma->dma_dev); +if (err) + goto err_disable_interrupts; + +ioat_kobject_add (ioat_dma, &ioat_ktype); + +if (dca) + ioat_dma->dca =ioat_dca_init (pdev, ioat_dma->reg_base); +if (ioat_dma->cap &IOAT_CAP_DPS )writeb (ioat_pending_level +1 , ioat_dma->reg_base +IOAT_PREFETCH_LIMIT_OFFSET );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1318/2651 dmaengine: plx_dma: fix NULL pointer deref in plx_dma_isr()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit f3017892457d8bb664ea4b912910dc254e2dd825 ]
plx_dma_create() registered the interrupt handler with request_irq() before initializing plxdev->bar. If the device raised an interrupt in that window, plx_dma_isr() would dereference the still-NULL bar.
Move the bar assignment ahead of request_irq() so everything the handler can touch is initialized before it can run.
--- drivers/dma/plx_dma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/plx_dma.c +5 -5
@@ -504,17 +504,17 @@ static int plx_dma_create(struct pci_dev *pdev)if (!plxdev)return -ENOMEM ; - rc =request_irq (pci_irq_vector (pdev,0 ), plx_dma_isr,0 , -KBUILD_MODNAME , plxdev); -if (rc) - goto free_plx; -spin_lock_init (&plxdev->ring_lock);tasklet_setup (&plxdev->desc_task, plx_dma_desc_task);RCU_INIT_POINTER (plxdev->pdev, pdev); plxdev->bar =pcim_iomap_table (pdev)[0 ]; + rc =request_irq (pci_irq_vector (pdev,0 ), plx_dma_isr,0 , +KBUILD_MODNAME , plxdev); +if (rc) + goto free_plx; + dma = &plxdev->dma_dev;INIT_LIST_HEAD (&dma->channels);dma_cap_set (DMA_MEMCPY , dma->cap_mask);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1319/2651 SUNRPC: reject a client-side TLS alert record that is not two octets
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 1e87497aac8d2d4aee9b288ba43f58d1690b9a89 ]
tls_alert_recv() reads two octets from the kvec it is handed and does not check the length (net/handshake/alert.c). xs_sock_process_cmsg() calls it for any alert record, and the alert[] buffer that xs_sock_recv_cmsg() supplies carries no initializer. A one-octet alert body leaves the description read from uninitialized stack and reported through trace_tls_alert_recv().
The peer controls that length. Neither tls_rx_msg_size() nor tls_rx_one_record() enforces the two-octet Alert payload. A TLS 1.3 record carrying only the inner content-type octet decrypts to a zero-length payload. RFC 8446 Section 5.1 requires a record with an Alert type to carry exactly one message, so any other length is malformed. RFC 9289 Section 5 bars RPC-with-TLS from negotiating a version below TLS 1.3, so no other alert framing applies.
Require exactly two octets before parsing and return -EACCES otherwise. xs_stream_data_receive() already treats -EACCES as a fatal alert and reports it to the pending tasks. Gate the path on a control message rather than a positive count so that a zero-length record reaches the check.
--- net/sunrpc/xprtsock.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
net/sunrpc/xprtsock.c +18 -2
@@ -407,9 +407,25 @@ xs_sock_recv_cmsg(struct socket *sock, unsigned int *msg_flags, int flags)iov_iter_kvec (&msg.msg_iter,ITER_DEST , &alert_kvec,1 , alert_kvec.iov_len); ret =sock_recvmsg (sock, &msg, flags); -if (ret >0 ) { -if (tls_get_record_type (sock->sk, &u.cmsg) ==TLS_RECORD_TYPE_ALERT ) +/* put_cmsg() shrinks msg_controllen, so a short one means +* kTLS filled in u.cmsg. +*/ +if (ret >=0 && msg.msg_controllen <sizeof (u)) { +if (tls_get_record_type (sock->sk, &u.cmsg) == +TLS_RECORD_TYPE_ALERT ) { +/* RFC 8446 Section 5.1 requires a record with an +* Alert type to carry exactly one message. An alert +* is two octets. tls_alert_recv() reads both without +* checking the length. alert_kvec caps the count at +* two, so a longer record fills it as well. kTLS +* sets MSG_EOR only once the record has been +* drained. +*/ +if (ret !=sizeof (alert) || + !(msg.msg_flags &MSG_EOR )) +return -EACCES ;iov_iter_revert (&msg.msg_iter, ret); + } ret =xs_sock_process_cmsg (sock, &msg, msg_flags, &u.cmsg, -EAGAIN ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1320/2651 SUNRPC: treat every client-side TLS error alert as fatal
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 9b7b1f89b93a3ec1ed121e1ab28450acde815bff ]
xs_sock_process_cmsg() decides whether an alert ends the session by reading the alert's level octet. RFC 8446 Section 6 retired that field. The severity is implicit in the description, and a receiver treats every alert listed in Section 6.2 as an error alert "regardless of the AlertLevel in the message". A peer that aborts with unexpected_message but leaves the legacy octet set to warning makes the client return -EAGAIN. xs_stream_data_receive() wakes no pending task for that error, so RPC Calls queued on a dead TLS session wait for their timeouts to expire.
Decide from the alert description instead. close_notify and user_canceled are the closure alerts (RFC 8446 Section 6.1). Every other description ends the session, including one this kernel does not recognize.
--- net/sunrpc/xprtsock.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/sunrpc/xprtsock.c +12 -2
@@ -375,8 +375,18 @@ xs_sock_process_cmsg(struct socket *sock, struct msghdr *msg,break ;case TLS_RECORD_TYPE_ALERT :tls_alert_recv (sock->sk, msg, &level, &description); - ret = (level ==TLS_ALERT_LEVEL_FATAL ) ? - -EACCES : -EAGAIN ; +/* RFC 8446 Section 6: every alert but a closure alert is +* an error alert, whatever the legacy AlertLevel octet +* says. +*/ +switch (description) { +case TLS_ALERT_DESC_CLOSE_NOTIFY : +case TLS_ALERT_DESC_USER_CANCELED : + ret = -EAGAIN ; +break ; +default : + ret = -EACCES ; + }break ;default :/* discard this record type */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1321/2651 NFS: filelayout: calculate dense stripe width in 64 bits
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 9ba13ef0e3ad033d3ddbaeb740b12d135a88363d ]
filelayout_get_dense_offset() calculates the stripe width from the stripe unit and count, where both values are provided by the server. Their product is stored on 32 bits, and can wrap to zero despite passing individual checks. For example, a 1 GiB stripe unit (0x40000000) and four stripes (4) cause the following div_u64() to raise a divide error during the first read through the dense layout.
Update u32 to u64 and use div64_u64() instead of div_u64(). stripe_unit is a u32 and stripe_count is limited to 4096, so the product cannot overflow a u64.
--- fs/nfs/filelayout/filelayout.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/filelayout/filelayout.c +3 -2
@@ -55,12 +55,13 @@ static loff_t filelayout_get_dense_offset(struct nfs4_filelayout_segment *flseg, loff_t offset) { -u32 stripe_width = flseg->stripe_unit * flseg->dsaddr->stripe_count; +u64 stripe_width = (u64 )flseg->stripe_unit * + flseg->dsaddr->stripe_count;u64 stripe_no;u32 rem; offset -= flseg->pattern_offset; - stripe_no =div_u64 (offset, stripe_width); + stripe_no =div64_u64 (offset, stripe_width);div_u64_rem (offset, flseg->stripe_unit, &rem);return stripe_no * flseg->stripe_unit + rem;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1322/2651 wifi: nxpwifi: fix missing error codes in _nxpwifi_fw_dpc()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Chen <[email protected]>
[ Upstream commit df40d3645443e884897b5b95873f9871bb44b7e5 ]
When nxpwifi_register_cfg80211(), nxpwifi_init_channel_scan_gap(), or nxpwifi_add_virtual_intf() fail, the function jumped to an error label but left ret == 0, causing _nxpwifi_fw_dpc() to return success despite the failure.
Fix by propagating the return value of nxpwifi_register_cfg80211() and nxpwifi_init_channel_scan_gap() directly into ret, and by extracting the encoded error from the ERR_PTR wdev with PTR_ERR() before each goto err_add_intf. The P2P client interface path had the same IS_ERR/goto pattern and is fixed in the same way.
--- drivers/net/wireless/nxp/nxpwifi/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/nxp/nxpwifi/main.c +8 -2
@@ -603,14 +603,18 @@ static int _nxpwifi_fw_dpc(const struct firmware *firmware, void *context)maybe_quirk_fw_disable_ds (adapter);if (!adapter->wiphy) { -if (nxpwifi_register_cfg80211 (adapter)) { + ret =nxpwifi_register_cfg80211 (adapter); + +if (ret) {nxpwifi_dbg (adapter,ERROR ,"cannot register with cfg80211\n" ); goto err_init_fw; } } -if (nxpwifi_init_channel_scan_gap (adapter)) { + ret =nxpwifi_init_channel_scan_gap (adapter); + +if (ret) {nxpwifi_dbg (adapter,ERROR ,"could not init channel stats table\n" ); goto err_init_chan_scan;
@@ -623,6 +627,7 @@ static int _nxpwifi_fw_dpc(const struct firmware *firmware, void *context)if (IS_ERR (wdev)) {nxpwifi_dbg (adapter,ERROR ,"cannot create default STA interface\n" ); + ret =PTR_ERR (wdev);rtnl_unlock (); goto err_add_intf; }
@@ -632,6 +637,7 @@ static int _nxpwifi_fw_dpc(const struct firmware *firmware, void *context)if (IS_ERR (wdev)) {nxpwifi_dbg (adapter,ERROR ,"cannot create AP interface\n" ); + ret =PTR_ERR (wdev);rtnl_unlock (); goto err_add_intf; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1323/2651 wifi: nxpwifi: validate variable IE lengths in beacon parser
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit 52c9568fa2eda80d02842961e7ba01e07eb01883 ]
nxpwifi_update_bss_desc_with_ie() stores pointers to the HT, VHT and HE capability and operation elements, to the operating mode notification and to the 20/40 BSS coexistence element, taken from a beacon or probe response, without checking that each element is long enough for the structure the driver later dereferences it as.
bss_desc->beacon_buf is a tight kmemdup() of the on-air elements, so a truncated element leaves the stored pointer short of the structure and the consumers read past the end of that allocation at association time. Some of those bytes are copied into the association request, so a rogue access point in range can both trigger the read and receive the result.
Reject the frame with -EINVAL when any of these elements is shorter than the structure read from it, as the FH, DS and CF parameter set cases in the same parser already do.
The extended capabilities element has no structure size to check against, so nxpwifi_is_ap_11ax_twt_supported()'s read of bcn_ext_cap->data[9] is bounded at that consumer instead.
--- drivers/net/wireless/nxp/nxpwifi/11ax.c | 2 ++ drivers/net/wireless/nxp/nxpwifi/scan.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/wireless/nxp/nxpwifi/11ax.c +2 -0
@@ -402,6 +402,8 @@ static u8 nxpwifi_is_ap_11ax_twt_supported(struct nxpwifi_bssdescriptor *bss_desreturn false; ext_cap = (struct element *)bss_desc->bcn_ext_cap; +if (ext_cap->datalen <10 ) +return false;if (!(ext_cap->data[9 ] &WLAN_EXT_CAPA10_TWT_RESPONDER_SUPPORT ))return false;return true;
drivers/net/wireless/nxp/nxpwifi/scan.c +18 -0
@@ -1209,6 +1209,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, (u16)(current_ptr - bss_entry->beacon_buf);break ;case WLAN_EID_HT_CAPABILITY : +if (element_len <sizeof (*bss_entry->bcn_ht_cap)) +return -EINVAL ; bss_entry->bcn_ht_cap = (struct ieee80211_ht_cap *)(current_ptr + elem_size);
@@ -1217,6 +1219,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, bss_entry->beacon_buf);break ;case WLAN_EID_HT_OPERATION : +if (element_len <sizeof (*bss_entry->bcn_ht_oper)) +return -EINVAL ; bss_entry->bcn_ht_oper = (struct ieee80211_ht_operation *)(current_ptr + elem_size);
@@ -1225,6 +1229,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, bss_entry->beacon_buf);break ;case WLAN_EID_VHT_CAPABILITY : +if (element_len <sizeof (*bss_entry->bcn_vht_cap)) +return -EINVAL ; bss_entry->disable_11ac = false; bss_entry->bcn_vht_cap = (void *)(current_ptr + elem_size);
@@ -1233,6 +1239,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, bss_entry->beacon_buf);break ;case WLAN_EID_VHT_OPERATION : +if (element_len <sizeof (*bss_entry->bcn_vht_oper)) +return -EINVAL ; bss_entry->bcn_vht_oper = (void *)(current_ptr + elem_size); bss_entry->vht_info_offset =
@@ -1240,6 +1248,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, bss_entry->beacon_buf);break ;case WLAN_EID_BSS_COEX_2040 : +if (!element_len) +return -EINVAL ; bss_entry->bcn_bss_co_2040 = current_ptr; bss_entry->bss_co_2040_offset = (u16)(current_ptr - bss_entry->beacon_buf);
@@ -1250,6 +1260,8 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, (u16)(current_ptr - bss_entry->beacon_buf);break ;case WLAN_EID_OPMODE_NOTIF : +if (total_ie_len <sizeof (*bss_entry->oper_mode)) +return -EINVAL ; bss_entry->oper_mode = (void *)current_ptr; bss_entry->oper_mode_offset = (u16)(current_ptr - bss_entry->beacon_buf);
@@ -1262,6 +1274,9 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter,switch (elem->data[0 ]) {case WLAN_EID_EXT_HE_CAPABILITY : +if (element_len < +1 +sizeof (*bss_entry->bcn_he_cap)) +return -EINVAL ; bss_entry->disable_11ax = false; bss_entry->bcn_he_cap = (void *)(current_ptr + elem_size +1 );
@@ -1270,6 +1285,9 @@ int nxpwifi_update_bss_desc_with_ie(struct nxpwifi_adapter *adapter, bss_entry->beacon_buf);break ;case WLAN_EID_EXT_HE_OPERATION : +if (element_len < +1 +sizeof (*bss_entry->bcn_he_oper)) +return -EINVAL ; bss_entry->bcn_he_oper = (void *)(current_ptr + elem_size +1 ); bss_entry->he_info_offset =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1324/2651 floppy: flush pending work before releasing resources on init failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 74c2e2eeb7e51cdeb5e3eceaf324cfcf8dcd0d32 ]
do_floppy_init() probes each FDC with user_reset_fdc(), which queues a redo_fd_request() work item on floppy_wq that may still be pending when the probe finishes. When no controller is found, the error path calls floppy_release_irq_and_dma() to free the IRQ and DMA channel, and only later destroys the workqueue. destroy_workqueue() drains the queued work last, so it can run after the IRQ and DMA are already gone:
floppy0: no floppy controllers found
work still pending
The flush used to be here. Commit 070ad7e793dc ("floppy: convert to delayed work and single-thread wq") renamed the label out_flush_work to out_release_dma and dropped it. Restore it so the work drains before the IRQ and DMA are released, as floppy_module_exit() already does.
--- drivers/block/floppy.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/floppy.c +2 -0
@@ -4744,6 +4744,8 @@ static int __init do_floppy_init(void) } } out_release_dma: +/* Drain the queued redo_fd_request() before releasing IRQ and DMA. */ +flush_workqueue (floppy_wq);if (atomic_read (&usage_count))floppy_release_irq_and_dma (); out_unreg_driver:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1325/2651 dlm: validate node weights before building member array
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Ming <[email protected]>
[ Upstream commit 7f662eb1807ed732ac7d5e119753c8185f241bb8 ]
DLM node weights are parsed as signed integers and copied into the member list. make_member_array() uses their sum as the allocation count, but only positive weights contribute entries to the array. A negative weight can therefore reduce the allocation without reducing the number of writes.
The issue was found through static analysis of the configfs input and member array construction. With two recovery members weighted -31 and 32, the sum is 1, so recovery allocates one int and then writes the positive member's node ID 32 times. A reproducer using dlm_controld and dlm_tool triggered the same report on a KASAN kernel:
BUG: KASAN: slab-out-of-bounds in dlm_recover_members [dlm] Write of size 4 by task dlm_recoverd Call Trace: dlm_recover_members dlm_recoverd kthread ret_from_fork
Reject negative weights at the configfs input boundary. Also detect overflow when adding non-negative weights to the signed allocation count, and propagate array construction errors to the recovery path.
--- fs/dlm/config.c | 9 ++++++++- fs/dlm/member.c | 17 +++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-)
fs/dlm/config.c +8 -1
@@ -857,10 +857,17 @@ static ssize_t node_weight_show(struct config_item *item, char *buf)static ssize_t node_weight_store (struct config_item *item,const char *buf,size_t len) { -int rc =kstrtoint (buf,0 , &config_item_to_node (item)->weight); +struct dlm_node *node =config_item_to_node (item); +int weight; +int rc; + rc =kstrtoint (buf,0 , &weight);if (rc)return rc; +if (weight <0 ) +return -EINVAL ; + + node->weight = weight;return len; }
fs/dlm/member.c +11 -6
@@ -402,7 +402,7 @@ void dlm_clear_members_gone(struct dlm_ls *ls)clear_memb_list (&ls->ls_nodes_gone,NULL ); } -static void make_member_array (struct dlm_ls *ls) +static int make_member_array (struct dlm_ls *ls) {struct dlm_member *memb;int i, w, x =0 , total =0 , all_zero =0 , *array;
@@ -411,8 +411,8 @@ static void make_member_array(struct dlm_ls *ls) ls->ls_node_array =NULL ;list_for_each_entry (memb, &ls->ls_nodes, list) { -if (memb->weight) - total += memb->weight; +if (check_add_overflow (total, memb->weight, &total)) +return -EOVERFLOW ; }/* all nodes revert to weight of 1 if all have weight 0 */
@@ -422,10 +422,9 @@ static void make_member_array(struct dlm_ls *ls) all_zero =1 ; } - ls->ls_total_weight = total; array =kmalloc_objs (*array, total,GFP_NOFS );if (!array) -return ; +return -ENOMEM ;list_for_each_entry (memb, &ls->ls_nodes, list) {if (!all_zero && !memb->weight)
@@ -442,7 +441,10 @@ static void make_member_array(struct dlm_ls *ls) array[x++] = memb->nodeid; } + ls->ls_total_weight = total; ls->ls_node_array = array; + +return 0 ; }/* send a status request to all members just to establish comms connections */
@@ -617,7 +619,10 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out) } ls->ls_low_nodeid = low; -make_member_array (ls); + error =make_member_array (ls); +if (error) +return error; + *neg_out = neg; error =ping_members (ls, rv->seq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1326/2651 floppy: avoid NULL deref in reset_interrupt when cont is cleared
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit 7c82781039c03a3e47b70d3259f336adbb9d2692 ]
reset_fdc() arms do_floppy = reset_interrupt; the IRQ handler then queues that function via schedule_bh(). If unlock_fdc() or do_wakeup() clears cont before the work runs, reset_interrupt() dereferences a NULL cont and oopses.
Example crash excerpt:
[ 1070.468148] status=80 [ 1070.468152] fdc_busy=1 [ 1070.468158] cont= (null) [ 1070.468161] current_req= (null) [ 1070.468162] command_status=-1 [ 1070.468163] [ 1070.557051] floppy0: floppy timeout called [ 1070.557053] no cont in shutdown! [ 1070.557056] floppy0: floppy_shutdown: timeout handler died. [ 1074.419509] floppy0: FDC access conflict! [ 1074.419782] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 [ 1074.421969] PGD 0 P4D 0 [ 1074.422320] Oops: 0000 [#1] SMP NOPTI [ 1074.422648] CPU: 10 PID: 3269 Comm: kworker/u256:4 Kdump: loaded [ 1074.423830] Hardware name: inspur Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 [ 1074.424284] Workqueue: floppy floppy_work_workfn [floppy] [ 1074.424757] RIP: 0010:reset_interrupt+0x3a/0xa0 [floppy]
The same NULL deref has also been reported by syzbot on upstream.
Return early if cont is already NULL after result(). The hardware reset has completed; result() still drains the FDC. A later request can lock the FDC and reset again. This is a defensive fix for stale work, not a rewrite of the floppy continuation state machine.
--- drivers/block/floppy.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/block/floppy.c +3 -0
@@ -1784,6 +1784,9 @@ static void reset_interrupt(void) {debugt (__func__,"" );result (current_fdc);/* get the status ready for set_fdc */ +/* Stale work: unlock_fdc()/do_wakeup() may have cleared cont. */ +if (!cont) +return ;if (fdc_state[current_fdc].reset) {pr_info ("reset set in interrupt, calling %ps\n" , cont->error); cont->error ();/* a reset just after a reset. BAD! */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1327/2651 floppy: unregister platform device on add_disk failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit f1e72d80ad4ac5ff3573796d07bd1a1e74909f94 ]
The change referenced by the Fixes tag reverted a previous fix because that fix added incorrect cleanup for the platform_device_register() failure path.
However, reverting the whole change also removed the cleanup for a later failure path. If platform_device_register() succeeds but device_add_disk() fails, the current floppy platform device has already been registered and registered[drive] has been set.
The common out_remove_drives path uses while (drive--), so it starts from the previous drive and does not unregister the current one. As a result, the platform device registered for the failing drive is leaked.
Unregister the current platform device directly on the device_add_disk() failure path, where platform_device_register() is known to have succeeded. Leave the platform_device_register() failure path unchanged.
--- drivers/block/floppy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/block/floppy.c +4 -1
@@ -4732,8 +4732,11 @@ static int __init do_floppy_init(void) err =device_add_disk (&floppy_device[drive].dev, disks[drive][0 ],NULL ); -if (err) +if (err) { +platform_device_unregister (&floppy_device[drive]); + registered[drive] = false; goto out_remove_drives; + } }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1328/2651 wifi: ath11k: fix unbalanced IRQ enable/disable during suspend/resume
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit e56c9d429ba004d5416b03091fd7656187cdcaf1 ]
Commit f7a74e131d3f ("wifi: ath11k: disable interrupts during firmware crash recovery") added an unconditional ath11k_hif_irq_disable()/ ath11k_hif_ce_irq_disable() pair inside ath11k_core_reconfigure_on_crash(), guarded by "if (!ab->is_reset)", to stop the DP NAPI from touching rings that have just been torn down. That fixes AHB device recovery, but breaks PCI device suspend/resume. During suspend, IRQs are disabled once in ath11k_core_suspend_late(). Then during resume, ath11k_core_reconfigure_on_crash() sees ab->is_reset clear and disables them a second time. Those IRQs are enabled only once during the following reinitialization, leaving the IRQ lines masked. As a result, HTC control responses never arrive, and resume fails:
failed to receive control response completion, polling.. failed to connect to HTT: -110
failed to reconfigure driver on crash recovery failed to resume core: -110
Fix this by disabling the IRQs unconditionally at the top of ath11k_core_reconfigure_on_crash(), and instead drop the disable calls from the two places that already disable IRQs before this function can run: ath11k_core_suspend_late() and ath11k_core_reset(). This keeps a single disable per recovery/suspend cycle regardless of which path (recovery or suspend) triggers it, so the refcount on PCI parts stays balanced while AHB parts keep getting the disable that the original commit needed.
--- drivers/net/wireless/ath/ath11k/core.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +2 -16
@@ -1275,9 +1275,6 @@ int ath11k_core_suspend_late(struct ath11k_base *ab)if (ab->actual_pm_policy ==ATH11K_PM_WOW )return 0 ; -ath11k_hif_irq_disable (ab); -ath11k_hif_ce_irq_disable (ab); -ath11k_hif_power_down (ab, true);return 0 ;
@@ -2333,17 +2330,9 @@ static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)int ret;mutex_lock (&ab->core_lock); +ath11k_hif_irq_disable (ab); +ath11k_hif_ce_irq_disable (ab);ath11k_thermal_unregister (ab); - -/* -* ath11k_core_reset() already disabled the interrupts on the reset -* path; only the firmware crash path reaches here with them live. -*/ -if (!ab->is_reset) { -ath11k_hif_irq_disable (ab); -ath11k_hif_ce_irq_disable (ab); - } -ath11k_dp_pdev_free (ab);ath11k_cfr_deinit (ab);ath11k_spectral_deinit (ab);
@@ -2605,9 +2594,6 @@ static void ath11k_core_reset(struct work_struct *work) time_left =wait_for_completion_timeout (&ab->recovery_start,ATH11K_RECOVER_START_TIMEOUT_HZ ); -ath11k_hif_irq_disable (ab); -ath11k_hif_ce_irq_disable (ab); -ath11k_hif_power_down (ab, false);ath11k_hif_power_up (ab);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1329/2651 wifi: ath12k: Reserve space for a string terminator
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 13b15eabe2c541b80406166964cdc8ccb5e9c32a ]
ath12k_write_htt_stats_type() accepts count == size, which fills the zero-initialized buffer without a terminating NUL. sscanf() then reads beyond the buffer.
Reject input that leaves no room for the trailing NUL.
--- drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +1 -1
@@ -6190,7 +6190,7 @@ static ssize_t ath12k_write_htt_stats_type(struct file *file,const int size =32 ;int num_args; -if (count > size) +if (count >= size)return -EINVAL ; char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1330/2651 drm/msm/a6xx: fix use-after-free of OPP in a6xx_pm_resume
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Demidov <[email protected]>
[ Upstream commit 8128ae7af6b4dc95e486c5c0a80839a069df578e ]
The OPP reference obtained via dev_pm_opp_find_freq_ceil() is dropped with dev_pm_opp_put() before being passed to dev_pm_opp_set_opp(). If the reference count reaches zero, the OPP object may be freed, leading to a use-after-free when dev_pm_opp_set_opp() dereferences it.
Fix the order of calls: first use the OPP to set the required performance state, then release the reference.
Patchwork: https://patchwork.freedesktop.org/patch/757104/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -1
@@ -2183,10 +2183,10 @@ static int a6xx_pm_resume(struct msm_gpu *gpu) ret =PTR_ERR (opp); goto err_set_opp; } -dev_pm_opp_put (opp);/* Set the core clock and bus bw, having VDD scaling in mind */ dev_pm_opp_set_opp (&gpu->pdev->dev, opp); +dev_pm_opp_put (opp);pm_runtime_resume_and_get (gmu->dev);pm_runtime_resume_and_get (gmu->gxpd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1331/2651 drm/msm/a6xx: check pm_runtime_resume_and_get during resume
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Demidov <[email protected]>
[ Upstream commit e2f57c576f14f96449cfee840860cb9707501d23 ]
The return values of pm_runtime_resume_and_get() calls in a6xx_pm_resume() are not checked, which can lead to hardware access on suspended devices and PM reference underflows.
Fix this by checking the return value of each pm_runtime_resume_and_get() call and properly unwinding the previously acquired resources on failure.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Patchwork: https://patchwork.freedesktop.org/patch/757106/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +21 -17
@@ -2181,44 +2181,48 @@ static int a6xx_pm_resume(struct msm_gpu *gpu) opp =dev_pm_opp_find_freq_ceil (&gpu->pdev->dev, &freq);if (IS_ERR (opp)) { ret =PTR_ERR (opp); - goto err_set_opp; + goto err_unlock; }/* Set the core clock and bus bw, having VDD scaling in mind */ dev_pm_opp_set_opp (&gpu->pdev->dev, opp);dev_pm_opp_put (opp); -pm_runtime_resume_and_get (gmu->dev); -pm_runtime_resume_and_get (gmu->gxpd); + ret =pm_runtime_resume_and_get (gmu->dev); +if (ret <0 ) + goto err_opp_clear; + ret =pm_runtime_resume_and_get (gmu->gxpd); +if (ret <0 ) + goto err_put_dev; ret =clk_bulk_prepare_enable (gpu->nr_clocks, gpu->grp_clks);if (ret) - goto err_bulk_clk; + goto err_put_gxpd; ret =clk_bulk_prepare_enable (gmu->nr_clocks, gmu->clocks);if (ret) {clk_bulk_disable_unprepare (gpu->nr_clocks, gpu->grp_clks); - goto err_bulk_clk; + goto err_put_gxpd; }if (adreno_is_a619_holi (adreno_gpu))a6xx_sptprac_enable (gmu); -/* If anything goes south, tear the GPU down piece by piece.. */ -if (ret) { -err_bulk_clk: -pm_runtime_put (gmu->gxpd); -pm_runtime_put (gmu->dev); -dev_pm_opp_set_opp (&gpu->pdev->dev,NULL ); - } -err_set_opp:mutex_unlock (&a6xx_gpu->gmu.lock); +msm_devfreq_resume (gpu); +a6xx_llc_activate (a6xx_gpu); -if (!ret) { -msm_devfreq_resume (gpu); -a6xx_llc_activate (a6xx_gpu); - } +return 0 ; +/* If anything goes south, tear the GPU down piece by piece.. */ +err_put_gxpd: +pm_runtime_put (gmu->gxpd); +err_put_dev: +pm_runtime_put (gmu->dev); +err_opp_clear: +dev_pm_opp_set_opp (&gpu->pdev->dev,NULL ); +err_unlock: +mutex_unlock (&a6xx_gpu->gmu.lock);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1332/2651 dmaengine: ste_dma40: Fix physical cyclic capability
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 11101a8e3e42273a5910a149f6324040b88f4747 ]
d40_dmaengine_init() configures dma_both for physical channels that can handle both slave and memcpy transfers. Physical DMA40 channel setup has supported cyclic LLIs since cyclic transfer support was added, but the DMA_CYCLIC capability is set on dma_slave a second time instead of dma_both.
Set DMA_CYCLIC on dma_both so d40_ops_init() installs device_prep_dma_cyclic and physical channels advertise cyclic support.
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -2897,7 +2897,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,dma_cap_zero (base->dma_both.cap_mask);dma_cap_set (DMA_SLAVE , base->dma_both.cap_mask);dma_cap_set (DMA_MEMCPY , base->dma_both.cap_mask); -dma_cap_set (DMA_CYCLIC , base->dma_slave.cap_mask); +dma_cap_set (DMA_CYCLIC , base->dma_both.cap_mask);d40_ops_init (base, &base->dma_both); err =dmaenginem_async_device_register (&base->dma_both);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1333/2651 dmaengine: ste_dma40: Fix cyclic transfer residue
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c80edceff29ee212987c2d2c851b2cb2eb4b477a ]
DMA40 reads residue from the element count of the currently active LLI. For a cyclic transfer this reports at most one period, not the bytes remaining until the cyclic buffer wraps.
Once DMA40 advertises burst granularity, DMAengine PCM uses this residue directly. For a four-period PCM buffer it consequently reports the hardware pointer near three periods after every period interrupt. ALSA eventually stops playback with -EIO although DMA period callbacks continue.
Calculate cyclic residue from the current memory-side hardware pointer instead. Read the destination pointer for capture and the source pointer for playback. Sample the split logical channel pointer coherently and retain the last valid residue during relink transitions.
Make at most three residue sampling attempts: one initial read plus two retries. The retries let transient split-register updates or LLI relink windows settle, while the limit prevents unbounded polling if hardware does not yield a valid pointer.
This avoids counting terminal-count interrupts, which races with hardware advancing to the next LLI and cannot account for coalesced interrupt status. Also reject cyclic periods that expand into multiple LLIs because logical cyclic LLIs each request a terminal-count interrupt and would generate more than one callback per period.
Reject invalid cyclic geometries before dividing or constructing the scatterlist as well.
--- drivers/dma/ste_dma40.c | 106 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 5 deletions(-)
drivers/dma/ste_dma40.c +101 -5
@@ -65,6 +65,9 @@ struct stedma40_platform_data {/* Maximum iterations taken before giving up suspending a channel */ #define D40_SUSPEND_MAX_IT 500 +/* Maximum attempts to sample a stable cyclic residue position */ +#define D40_RESIDUE_MAX_ATTEMPTS 3 +/* Milliseconds */ #define DMA40_AUTOSUSPEND_DELAY 100
@@ -378,6 +381,9 @@ struct d40_lli_pool {* @lli_len: Number of llis of current descriptor. * @lli_current: Number of transferred llis. * @lcla_alloc: Number of LCLA entries allocated. +* @cyclic_dma_addr: Start address of the cyclic buffer. +* @cyclic_buf_len: Length of the cyclic buffer. +* @cyclic_residue: Last valid cyclic residue sample. * @txd: DMA engine struct. Used for among other things for communication * during a transfer. * @node: List entry.
@@ -396,6 +402,9 @@ struct d40_desc {int lli_len;int lli_current;int lcla_alloc; +dma_addr_t cyclic_dma_addr; +size_t cyclic_buf_len; +size_t cyclic_residue;struct dma_async_tx_descriptor txd;struct list_head node;
@@ -1420,6 +1429,64 @@ static u32 d40_residue(struct d40_chan *d40c)return num_elt * d40c->dma_cfg.dst_info.data_width; } +static bool d40_current_addr (struct d40_chan *d40c,dma_addr_t *addr) +{ +bool dst = d40c->dma_cfg.dir ==DMA_DEV_TO_MEM ; +void __iomem *high_reg; +void __iomem *low_reg; +u32 low; +u32 high; +u32 check; +int i; + +if (chan_is_physical (d40c)) { + *addr =readl (chan_base (d40c) + + (dst ?D40_CHAN_REG_SDPTR :D40_CHAN_REG_SSPTR )); +return true; + } + +if (dst) { + low_reg = &d40c->lcpa->lcsp2; + high_reg = &d40c->lcpa->lcsp3; + }else { + low_reg = &d40c->lcpa->lcsp0; + high_reg = &d40c->lcpa->lcsp1; + } + +for (i =0 ; i <D40_RESIDUE_MAX_ATTEMPTS ; i++) { + high =readl (high_reg) &D40_MEM_LCSP1_SPTR_MASK ; + low =readl (low_reg) &D40_MEM_LCSP0_SPTR_MASK ; + check =readl (high_reg) &D40_MEM_LCSP1_SPTR_MASK ; +if (high == check) { + *addr = low | high; +return true; + } + } + +return false; +} + +static bool d40_cyclic_offset (struct d40_chan *d40c,struct d40_desc *d40d, +size_t *offset) +{ +dma_addr_t current_addr; +dma_addr_t current_offset; +int i; + +for (i =0 ; i <D40_RESIDUE_MAX_ATTEMPTS ; i++) { +if (!d40_current_addr (d40c, ¤t_addr)) +continue ; + + current_offset = current_addr - d40d->cyclic_dma_addr; +if (current_offset <= d40d->cyclic_buf_len) { + *offset = current_offset; +return true; + } + } + +return false; +} +static bool d40_tx_is_linked (struct d40_chan *d40c) {bool is_link;
@@ -2108,15 +2175,26 @@ static bool d40_is_paused(struct d40_chan *d40c) } -static u32 stedma40_residue (struct dma_chan *chan) +static u32 stedma40_residue (struct dma_chan *chan,dma_cookie_t cookie) {struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); +struct d40_desc *d40d; +size_t offset;u32 bytes_left;unsigned long flags;spin_lock_irqsave (&d40c->lock, flags); - bytes_left =d40_residue (d40c); + d40d =d40_first_active_get (d40c); +if (d40d && d40d->txd.cookie == cookie && d40d->cyclic && + d40d->cyclic_buf_len) { +if (d40_cyclic_offset (d40c, d40d, &offset)) + d40d->cyclic_residue = d40d->cyclic_buf_len - offset; + bytes_left = d40d->cyclic_residue; + }else { + bytes_left =d40_residue (d40c); + } +spin_unlock_irqrestore (&d40c->lock, flags);return bytes_left;
@@ -2246,8 +2324,13 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,if (desc ==NULL ) goto unlock; -if (sg_next (&sg_src[sg_len -1 ]) == sg_src) +if (sg_next (&sg_src[sg_len -1 ]) == sg_src) { desc->cyclic = true; +if (desc->lli_len != sg_len) { +chan_err (chan,"Cyclic periods must fit in one LLI\n" ); + goto free_desc; + } + } src_dev_addr =0 ; dst_dev_addr =0 ;
@@ -2524,11 +2607,18 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len, size_t period_len, enum dma_transfer_direction direction, unsigned long flags) { - unsigned int periods = buf_len / period_len; + unsigned int periods;struct dma_async_tx_descriptor *txd; +struct d40_desc *desc;struct scatterlist *sg; +dma_addr_t buf_addr = dma_addr;int i; +if (!buf_len || !period_len || buf_len % period_len) +return NULL ; + + periods = buf_len / period_len; + sg = kzalloc_objs(struct scatterlist, periods + 1, GFP_NOWAIT);if (!sg)return NULL ;
@@ -2543,6 +2633,12 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, txd =d40_prep_sg (chan, sg, sg, periods, direction,DMA_PREP_INTERRUPT ); +if (txd) { + desc = container_of(txd, struct d40_desc, txd); + desc->cyclic_dma_addr = buf_addr; + desc->cyclic_buf_len = buf_len; + desc->cyclic_residue = buf_len; + }kfree (sg);
@@ -2563,7 +2659,7 @@ static enum dma_status d40_tx_status(struct dma_chan *chan, ret =dma_cookie_status (chan, cookie, txstate);if (ret !=DMA_COMPLETE && txstate) -dma_set_residue (txstate,stedma40_residue (chan)); +dma_set_residue (txstate,stedma40_residue (chan, cookie));if (d40_is_paused (d40c)) ret =DMA_PAUSED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1334/2651 dmaengine: ste_dma40: Recover coalesced cyclic callbacks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit db28400d92cd97005065dad230b8a5d72ab121cb ]
DMA40 has one terminal-count status bit per channel, so cyclic period interrupts can coalesce.
Use the memory-side pointer displacement to queue the minimum observable number of callbacks. If sampling fails, queue one callback and invalidate the saved position; the next successful sample resynchronizes without recounting it.
The pointer is modulo the cyclic buffer: a displacement of d periods can mean d plus n complete iterations of the buffer. Report d, so the driver could have missed n iterations of the buffer; DMA40 has no counter to recover them. For an unchanged pointer, report one callback rather than risk a spurious full-buffer burst.
This condition has not been seen in practice and is only a product of review comments that the buffer can miss interrupts.
The preceding cyclic-residue fix ensures that every cyclic period fits in one LLI, so each boundary corresponds to one client callback.
--- drivers/dma/ste_dma40.c | 69 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +68 -1
@@ -384,11 +384,14 @@ struct d40_lli_pool {* @cyclic_dma_addr: Start address of the cyclic buffer. * @cyclic_buf_len: Length of the cyclic buffer. * @cyclic_residue: Last valid cyclic residue sample. +* @cyclic_period_len: Length of one cyclic period. +* @cyclic_callback_pos: Position after the callbacks already queued. * @txd: DMA engine struct. Used for among other things for communication * during a transfer. * @node: List entry. * @is_in_client_list: true if the client owns this descriptor. * @cyclic: true if this is a cyclic job +* @cyclic_callback_pos_valid: Whether cyclic_callback_pos is reliable. * * This descriptor is used for both logical and physical transfers. */
@@ -405,12 +408,15 @@ struct d40_desc {dma_addr_t cyclic_dma_addr;size_t cyclic_buf_len;size_t cyclic_residue; +size_t cyclic_period_len; +size_t cyclic_callback_pos;struct dma_async_tx_descriptor txd;struct list_head node;bool is_in_client_list;bool cyclic; +bool cyclic_callback_pos_valid; };/**
@@ -1487,6 +1493,61 @@ static bool d40_cyclic_offset(struct d40_chan *d40c, struct d40_desc *d40d,return false; } +static unsigned int d40_cyclic_periods_elapsed (struct d40_chan *d40c, +struct d40_desc *d40d) +{ +size_t current_pos; +size_t delta; +size_t offset; +unsigned int periods; + +if (!d40d->cyclic_period_len) +return 1 ; + +if (!d40_cyclic_offset (d40c, d40d, &offset)) { + d40d->cyclic_callback_pos_valid = false; +return 1 ; + } + + current_pos =rounddown (offset, d40d->cyclic_period_len); +if (!d40_residue (d40c) && current_pos != offset) + current_pos += d40d->cyclic_period_len; +if (current_pos == d40d->cyclic_buf_len) + current_pos =0 ; + +if (!d40d->cyclic_callback_pos_valid) { +/* +* The previous interrupt was reported without a pointer +* sample. Resynchronize without using the stale position, +* which would count that callback again. +*/ + d40d->cyclic_callback_pos = current_pos; + d40d->cyclic_callback_pos_valid = true; +return 1 ; + } + +/* +* The pointer wraps with the cyclic buffer, so its displacement is +* only the minimum number of elapsed periods. Complete buffer laps +* are not observable. +*/ + delta = (current_pos + d40d->cyclic_buf_len - + d40d->cyclic_callback_pos) % d40d->cyclic_buf_len; + periods = delta / d40d->cyclic_period_len; +if (!periods) { +/* +* The TC status is a single latched bit. An unchanged pointer +* cannot distinguish a complete lap from a repeated interrupt, +* so do not amplify it into a buffer's worth of callbacks. +*/ + periods =1 ; + } + + d40d->cyclic_callback_pos = current_pos; + +return periods; +} +static bool d40_tx_is_linked (struct d40_chan *d40c) {bool is_link;
@@ -1609,6 +1670,7 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)static void dma_tc_handle (struct d40_chan *d40c) {struct d40_desc *d40d; +unsigned int callbacks =1 ;/* Get first active entry from list */ d40d =d40_first_active_get (d40c);
@@ -1633,6 +1695,8 @@ static void dma_tc_handle(struct d40_chan *d40c)if (d40d->lli_current == d40d->lli_len) d40d->lli_current =0 ; } + + callbacks =d40_cyclic_periods_elapsed (d40c, d40d); }else {d40_lcla_free_all (d40c, d40d);
@@ -1653,7 +1717,7 @@ static void dma_tc_handle(struct d40_chan *d40c)d40_desc_done (d40c, d40d); } - d40c->pending_tx++; + d40c->pending_tx += callbacks;tasklet_schedule (&d40c->tasklet); }
@@ -2638,6 +2702,9 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr, desc->cyclic_dma_addr = buf_addr; desc->cyclic_buf_len = buf_len; desc->cyclic_residue = buf_len; + desc->cyclic_period_len = period_len; + desc->cyclic_callback_pos =0 ; + desc->cyclic_callback_pos_valid = true; }kfree (sg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1335/2651 dmaengine: ste_dma40: Fix failed start cleanup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 8175ead5727173d4b96d1e830e696765d75ade71 ]
If d40_start() fails after a queued descriptor has been moved to the active list, d40_queue_start() currently returns NULL without unwinding the transfer state or clearing the channel busy flag.
Fix this pre-existing error path by completing the descriptor through the normal tasklet path, clearing the busy flag, balancing the runtime PM reference and returning an error pointer to distinguish the failure from the no-work case. Do not free the descriptor directly, since it has already been submitted and has a DMA cookie.
When starting the next queued transfer from the completion handler, put the completed descriptor on the done list first. This preserves FIFO completion order if the new transfer fails to start and prevents the completed cookie from moving backwards.
Use done-list membership rather than the cyclic flag to identify terminal descriptors in the tasklet. A cyclic descriptor that failed to start is then completed and removed instead of remaining permanently at the head of the done list.
--- drivers/dma/ste_dma40.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/dma/ste_dma40.c +17 -8
@@ -1659,8 +1659,15 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)/* Start dma job */ err =d40_start (d40c); -if (err) -return NULL ; +if (err) { +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); + d40c->pending_tx++; + d40c->busy = false; +pm_runtime_put_autosuspend (d40c->base->dev); +tasklet_schedule (&d40c->tasklet); +return ERR_PTR (err); + } }return d40d;
@@ -1707,14 +1714,14 @@ static void dma_tc_handle(struct d40_chan *d40c)return ; } +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); +if (d40_queue_start (d40c) ==NULL ) { d40c->busy = false;pm_runtime_put_autosuspend (d40c->base->dev); } - -d40_desc_remove (d40d); -d40_desc_done (d40c, d40d); } d40c->pending_tx += callbacks;
@@ -1728,20 +1735,22 @@ static void dma_tasklet(struct tasklet_struct *t)struct d40_desc *d40d;unsigned long flags;bool callback_active; +bool from_done;struct dmaengine_desc_callback cb;spin_lock_irqsave (&d40c->lock, flags);/* Get first entry from the done list */ d40d =d40_first_done (d40c); -if (d40d ==NULL ) { + from_done = !!d40d; +if (!from_done) {/* Check if we have reached here for cyclic job */ d40d =d40_first_active_get (d40c);if (d40d ==NULL || !d40d->cyclic) goto check_pending_tx; } -if (!d40d->cyclic) +if (from_done)dma_cookie_complete (&d40d->txd);/*
@@ -1757,7 +1766,7 @@ static void dma_tasklet(struct tasklet_struct *t) callback_active = !!(d40d->txd.flags &DMA_PREP_INTERRUPT );dmaengine_desc_get_callback (&d40d->txd, &cb); -if (!d40d->cyclic) { +if (from_done) {if (async_tx_test_ack (&d40d->txd)) {d40_desc_remove (d40d);d40_desc_free (d40c, d40d);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1336/2651 dmaengine: ste_dma40: Fix probe runtime PM disable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c6809b381e34f8966cc3d9e5d7d658775a408f83 ]
Some d40_probe() error paths jump to destroy_cache before runtime PM has been enabled for the DMA controller device. The label unconditionally calls pm_runtime_disable(), which increments disable_depth even though this probe attempt never enabled runtime PM.
Use devm_pm_runtime_set_active_enabled() to mark the controller active, enable runtime PM and register balanced cleanup for probe failure. This avoids both the disable-depth imbalance and ad-hoc probe state tracking.
The interrupt handler uses pm_runtime_get_if_active() and cannot acknowledge a pending interrupt while runtime PM is disabled. Request the IRQ only after enabling runtime PM so the handler cannot enter an unacknowledged interrupt loop during probe.
--- drivers/dma/ste_dma40.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/dma/ste_dma40.c +13 -10
@@ -3757,12 +3757,6 @@ static int __init d40_probe(struct platform_device *pdev) goto destroy_cache; } - ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base); -if (ret) { -d40_err (dev,"No IRQ defined\n" ); - goto destroy_cache; - } -if (base->plat_data->use_esram_lcla) { base->lcpa_regulator =regulator_get (base->dev,"lcla_esram" );
@@ -3787,10 +3781,20 @@ static int __init d40_probe(struct platform_device *pdev)pm_runtime_irq_safe (base->dev);pm_runtime_set_autosuspend_delay (base->dev,DMA40_AUTOSUSPEND_DELAY ); -pm_runtime_use_autosuspend (base->dev);pm_runtime_mark_last_busy (base->dev); -pm_runtime_set_active (base->dev); -pm_runtime_enable (base->dev); + + ret =devm_pm_runtime_set_active_enabled (base->dev); +if (ret) { +d40_err (dev,"Failed to enable runtime PM: %d\n" , ret); + goto destroy_cache; + } +pm_runtime_use_autosuspend (base->dev); + + ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base); +if (ret) { +d40_err (dev,"No IRQ defined\n" ); + goto destroy_cache; + } ret =d40_dmaengine_init (base, num_reserved_chans);if (ret)
@@ -3826,7 +3830,6 @@ static int __init d40_probe(struct platform_device *pdev)regulator_disable (base->lcpa_regulator);regulator_put (base->lcpa_regulator); } -pm_runtime_disable (base->dev); report_failure:d40_err (dev,"probe failed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1337/2651 dmaengine: ste_dma40: Check runtime PM in IRQ
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 12787e3f2f93f3af59769b08ee4fcb044531120b ]
d40_handle_interrupt() reads DMA40 interrupt registers unconditionally. A spurious interrupt can arrive while the device is runtime suspended, after dma40_runtime_suspend() has disabled the GCC clock.
Avoid touching the registers unless the device is runtime active by taking a conditional runtime PM reference. Return IRQ_NONE when the device is suspended, and drop the reference after handling an active interrupt.
When CONFIG_PM is disabled, pm_runtime_get_if_active() returns -EINVAL even though the registers remain accessible. Keep handling interrupts in that configuration and only drop the runtime PM reference when one was acquired.
--- drivers/dma/ste_dma40.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dma/ste_dma40.c +8 -0
@@ -1807,6 +1807,11 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)u32 *regs = base->regs_interrupt;struct d40_interrupt_lookup *il = base->gen_dmac.il;u32 il_size = base->gen_dmac.il_size; +int ret; + + ret =pm_runtime_get_if_active (base->dev); +if (IS_ENABLED (CONFIG_PM ) && ret <=0 ) +return IRQ_NONE ;spin_lock (&base->interrupt_lock);
@@ -1855,6 +1860,9 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)spin_unlock (&base->interrupt_lock); +if (ret >0 ) +pm_runtime_put_autosuspend (base->dev); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1338/2651 dmaengine: ste_dma40: Handle runtime PM resume errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 55a35231b8ced2250a7743ec350a9566d553780e ]
Several channel operations use pm_runtime_get_sync() and access DMA40 registers without checking whether runtime resume succeeded. If resume fails, the registers may be inaccessible. pm_runtime_get_sync() also increments the usage counter on failure, making error unwinding easy to unbalance.
Use pm_runtime_resume_and_get() and avoid register access when resume fails. Acquire the runtime PM reference before allocating a channel so failure needs no channel-allocation rollback.
If a queued transfer cannot be started because resume failed, retire all issued descriptors through the normal tasklet path. Since dma_async_issue_pending() cannot return an error, leaving them queued would make clients wait indefinitely for callbacks.
Termination and channel release must also clean up software state when the controller cannot resume. d40_term_all() only releases descriptor state and does not access DMA40 registers, so it remains unconditional.
Balance each transient runtime PM reference in its successful acquisition block, without bookkeeping flags. Release the outstanding busy reference and channel allocation state when freeing a channel. Skip only the hardware stop that requires register access.
--- drivers/dma/ste_dma40.c | 74 +++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 22 deletions(-)
drivers/dma/ste_dma40.c +52 -22
@@ -1576,11 +1576,14 @@ static int d40_pause(struct dma_chan *chan)return 0 ;spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res <0 ) + goto unlock; res =d40_channel_execute_command (d40c,D40_DMA_SUSPEND_REQ );pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return res; }
@@ -1600,13 +1603,16 @@ static int d40_resume(struct dma_chan *chan)return 0 ;spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res <0 ) + goto unlock;/* If bytes left to transfer or linked tx resume job */ if (d40_residue (d40c) ||d40_tx_is_linked (d40c)) res =d40_channel_execute_command (d40c,D40_DMA_RUN );pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return res; }
@@ -1643,8 +1649,20 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)if (d40d !=NULL ) {if (!d40c->busy) { + err =pm_runtime_resume_and_get (d40c->base->dev); +if (err <0 ) { +chan_err (d40c,"Failed to resume DMA: %d\n" , + err); +do { +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); + d40c->pending_tx++; + d40d =d40_first_queued (d40c); + }while (d40d); +tasklet_schedule (&d40c->tasklet); +return ERR_PTR (err); + } d40c->busy = true; -pm_runtime_get_sync (d40c->base->dev); }/* Remove from queue */
@@ -2161,9 +2179,6 @@ static int d40_free_dma(struct d40_chan *d40c)struct d40_phy_res *phy = d40c->phy_chan;bool is_src; -/* Terminate all queued and active transfers */ -d40_term_all (d40c); -if (phy ==NULL ) {chan_err (d40c,"phy == null\n" );return -EINVAL ;
@@ -2185,11 +2200,18 @@ static int d40_free_dma(struct d40_chan *d40c)return -EINVAL ; } -pm_runtime_get_sync (d40c->base->dev); - res =d40_channel_execute_command (d40c,D40_DMA_STOP ); -if (res) { -chan_err (d40c,"stop failed\n" ); - goto mark_last_busy; +/* Release descriptor state; this does not access DMA40 registers. */ +d40_term_all (d40c); + + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res >=0 ) { + res =d40_channel_execute_command (d40c,D40_DMA_STOP ); +if (res) +chan_err (d40c,"stop failed\n" ); + +pm_runtime_put_autosuspend (d40c->base->dev); +if (res) +return res; }d40_alloc_mask_free (phy, is_src,chan_is_logical (d40c) ? event :0 );
@@ -2205,8 +2227,6 @@ static int d40_free_dma(struct d40_chan *d40c) d40c->busy = false; d40c->phy_chan =NULL ; d40c->configured = false; - mark_last_busy: -pm_runtime_put_autosuspend (d40c->base->dev);return res; }
@@ -2581,10 +2601,14 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) err =d40_config_memcpy (d40c);if (err) {chan_err (d40c,"Failed to configure memcpy channel\n" ); - goto mark_last_busy; + goto unlock; } } + err =pm_runtime_resume_and_get (d40c->base->dev); +if (err <0 ) + goto unlock; + err =d40_allocate_channel (d40c, &is_free_phy);if (err) {chan_err (d40c,"Failed to allocate channel\n" );
@@ -2592,8 +2616,6 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) goto mark_last_busy; } -pm_runtime_get_sync (d40c->base->dev); -d40_set_prio_realtime (d40c);if (chan_is_logical (d40c)) {
@@ -2625,6 +2647,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)d40_config_write (d40c); mark_last_busy:pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return err; }
@@ -2785,19 +2808,26 @@ static int d40_terminate_all(struct dma_chan *chan)spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); - ret =d40_channel_execute_command (d40c,D40_DMA_STOP ); -if (ret) -chan_err (d40c,"Failed to stop channel\n" ); + ret =pm_runtime_resume_and_get (d40c->base->dev); +if (ret >=0 ) { + ret =d40_channel_execute_command (d40c,D40_DMA_STOP ); +if (ret) +chan_err (d40c,"Failed to stop channel\n" ); + +pm_runtime_put_autosuspend (d40c->base->dev); + } +/* +* Always release software state, even when the controller cannot +* resume. d40_term_all() does not access DMA40 registers. +*/ d40_term_all (d40c); -pm_runtime_put_autosuspend (d40c->base->dev);if (d40c->busy)pm_runtime_put_autosuspend (d40c->base->dev); d40c->busy = false;spin_unlock_irqrestore (&d40c->lock, flags); -return 0 ; +return ret; } static int
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1339/2651 dmaengine: ste_dma40: Return IRQ_NONE when no interrupt is pending
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b96967644c524d34b2fdd2e58c31e7b36e3469e6 ]
d40_handle_interrupt() returns IRQ_HANDLED even when no terminal-count or error status bit is pending.
IRQ_NONE is not only used to identify a device on a shared interrupt. The generic IRQ core also counts it as unhandled for spurious IRQ detection. DMA40 does not request this IRQ with IRQF_SHARED, so interrupt sharing is not the purpose of this change.
If the line remains asserted without matching DMA40 status, returning IRQ_HANDLED hides the stuck interrupt and can leave the CPU servicing it indefinitely. Track whether any DMA40 status is pending and return IRQ_NONE when none is present, allowing the generic IRQ core to diagnose and eventually disable the faulty line.
DMA40 channels can be owned by other SoC cores. Their status means that the interrupt is real, but Linux must not acknowledge it. Treat foreign status as handled and leave its acknowledgment to the owning core, while acknowledging and dispatching only registered Linux channels.
--- drivers/dma/ste_dma40.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +8 -1
@@ -1816,6 +1816,7 @@ static void dma_tasklet(struct tasklet_struct *t)static irqreturn_t d40_handle_interrupt (int irq,void *data) { +irqreturn_t handled =IRQ_NONE ;int i;u32 idx;u32 row;
@@ -1849,6 +1850,12 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data) row = chan /BITS_PER_LONG ; idx = chan & (BITS_PER_LONG -1 ); +/* +* Status for a channel owned by another core still explains +* the interrupt, but only ACK Linux-owned channels below. +*/ + handled =IRQ_HANDLED ; +if (il[row].offset ==D40_PHY_CHAN ) d40c = base->lookup_phy_chans[idx];else
@@ -1881,7 +1888,7 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)if (ret >0 )pm_runtime_put_autosuspend (base->dev); -return IRQ_HANDLED ; +return handled; } static int d40_validate_conf(struct d40_chan *d40c,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1340/2651 dmaengine: ste_dma40: Init hardware before registration
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ffd583a734dc4bdafb9e18d9aa48b6efafd1a628 ]
d40_probe() enables the interrupt handler and registers DMAengine devices before calling d40_hw_init(). An interrupt pending from the bootloader can therefore reach the handler while the hardware interrupt state is not initialized and channel lookup entries are empty. The handler deliberately does not acknowledge an interrupt for an unknown channel, so a level IRQ can retrigger continuously.
Initialize the hardware and set the DMA segment limit before requesting the IRQ or registering DMAengine devices. d40_hw_init() clears pending logical and physical interrupt status, so request_irq() can enable the line normally after the hardware state is initialized.
This ensures that the handler and clients only observe initialized hardware.
--- drivers/dma/ste_dma40.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/dma/ste_dma40.c +4 -5
@@ -3835,20 +3835,19 @@ static int __init d40_probe(struct platform_device *pdev) }pm_runtime_use_autosuspend (base->dev); +dma_set_max_seg_size (base->dev,STEDMA40_MAX_SEG_SIZE ); + +d40_hw_init (base); + ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base);if (ret) {d40_err (dev,"No IRQ defined\n" ); goto destroy_cache; } - ret =d40_dmaengine_init (base, num_reserved_chans);if (ret) goto destroy_cache; -dma_set_max_seg_size (base->dev,STEDMA40_MAX_SEG_SIZE ); - -d40_hw_init (base); - ret =of_dma_controller_register (np, d40_xlate,NULL );if (ret) { dev_err(dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1341/2651 dmaengine: ste_dma40: Fix probe IRQ leak
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 7ca608cf6b842685bbbe131d4f7d638f7cdc2b5d ]
d40_probe() registers the hardware interrupt before several later probe steps that can fail. Those error paths jump to destroy_cache without freeing the IRQ, leaving the handler registered after probe resources have been released.
Route failures after a successful IRQ request through a dedicated cleanup label. Keep the request before DMAengine registration because that registration publishes channels to clients.
--- drivers/dma/ste_dma40.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +4 -2
@@ -3846,18 +3846,20 @@ static int __init d40_probe(struct platform_device *pdev) } ret =d40_dmaengine_init (base, num_reserved_chans);if (ret) - goto destroy_cache; + goto release_irq; ret =of_dma_controller_register (np, d40_xlate,NULL );if (ret) {dev_err (dev,"could not register of_dma_controller\n" ); - goto destroy_cache; + goto release_irq; }dev_info (base->dev,"initialized\n" );return 0 ; + release_irq: +free_irq (base->irq, base); destroy_cache:if (base->lcla_pool.dma_addr) dma_unmap_single(base->dev, base->lcla_pool.dma_addr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1342/2651 dmaengine: ste_dma40: Fix DMA registration unwind
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit f71ef686f913c8e9771a54466a76d653b83cd3dd ]
d40_dmaengine_init() registers DMAengine devices using devres-managed unregister actions. If probe fails after one of those registrations, the DMAengine devices stay visible until devres unwinds after d40_probe() returns.
The channel tasklets are also initialized before each DMAengine device is registered. An interrupt can therefore have queued a tasklet by the time a later registration step fails, but unregistering the DMAengine devices does not drain that tasklet before probe-owned storage is released.
Add tasklet cleanup actions to the DMAengine registration devres group. Install each action before publishing its DMAengine device. If action registration fails, those tasklets have never been exposed and cannot have been scheduled, so use devm_add_action() without immediate reset cleanup.
On later failure, free the IRQ before releasing the group so no new tasklets can be scheduled, then unregister the DMAengine devices and drain their tasklets before freeing the remaining probe resources. Keep the managed registrations and cleanup actions in place on successful probe by removing only the temporary group markers.
--- drivers/dma/ste_dma40.c | 45 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +43 -2
@@ -3039,6 +3039,18 @@ static void __init d40_chan_init(struct d40_base *base, struct dma_device *dma, } } +static void d40_kill_tasklets (void *data) +{ +struct dma_device *dma = data; +struct d40_chan *d40c; +struct dma_chan *chan; + +list_for_each_entry (chan, &dma->channels, device_node) { + d40c = container_of(chan, struct d40_chan, chan); +tasklet_kill (&d40c->tasklet); + } +} +static void d40_ops_init (struct d40_base *base,struct dma_device *dev) {if (dma_has_cap (DMA_SLAVE , dev->cap_mask)) {
@@ -3085,6 +3097,11 @@ static int __init d40_dmaengine_init(struct d40_base *base,d40_ops_init (base, &base->dma_slave); + err =devm_add_action (base->dev, d40_kill_tasklets, + &base->dma_slave); +if (err) + goto exit; + err =dmaenginem_async_device_register (&base->dma_slave);if (err) {
@@ -3100,6 +3117,11 @@ static int __init d40_dmaengine_init(struct d40_base *base,d40_ops_init (base, &base->dma_memcpy); + err =devm_add_action (base->dev, d40_kill_tasklets, + &base->dma_memcpy); +if (err) + goto exit; + err =dmaenginem_async_device_register (&base->dma_memcpy);if (err) {
@@ -3117,6 +3139,12 @@ static int __init d40_dmaengine_init(struct d40_base *base,dma_cap_set (DMA_CYCLIC , base->dma_both.cap_mask);d40_ops_init (base, &base->dma_both); + + err =devm_add_action (base->dev, d40_kill_tasklets, + &base->dma_both); +if (err) + goto exit; + err =dmaenginem_async_device_register (&base->dma_both);if (err) {
@@ -3714,6 +3742,7 @@ static int __init d40_probe(struct platform_device *pdev)struct d40_base *base;struct resource *res;struct resource res_lcpa; +void *dmaenginem_reg_group;int num_reserved_chans;u32 val;int ret;
@@ -3844,20 +3873,32 @@ static int __init d40_probe(struct platform_device *pdev)d40_err (dev,"No IRQ defined\n" ); goto destroy_cache; } + + dmaenginem_reg_group =devres_open_group (dev,NULL ,GFP_KERNEL ); +if (!dmaenginem_reg_group) { + ret = -ENOMEM ; + goto release_irq; + } + ret =d40_dmaengine_init (base, num_reserved_chans);if (ret) - goto release_irq; + goto release_dmaenginem; ret =of_dma_controller_register (np, d40_xlate,NULL );if (ret) {dev_err (dev,"could not register of_dma_controller\n" ); - goto release_irq; + goto release_dmaenginem; } +devres_remove_group (dev, dmaenginem_reg_group);dev_info (base->dev,"initialized\n" );return 0 ; + release_dmaenginem: +free_irq (base->irq, base); +devres_release_group (dev, dmaenginem_reg_group); + goto destroy_cache; release_irq:free_irq (base->irq, base); destroy_cache:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1343/2651 dmaengine: ste_dma40: Fix LCLA allocation order
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 7d4dc355c574d414d2402ac481a2fc4ee51e2771 ]
d40_lcla_allocate() calculates the number of pages needed for LCLA, but passes that raw page count as the allocation order to __get_free_pages(). The same value is later passed to free_pages().
Store the allocation order with get_order() instead, and use a separate byte size for allocation diagnostics, fallback kmalloc() sizing and DMA mapping.
--- drivers/dma/ste_dma40.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/dma/ste_dma40.c +16 -17
@@ -426,8 +426,8 @@ struct d40_desc {* @dma_addr: DMA address, if mapped * @base_unaligned: The original kmalloc pointer, if kmalloc is used. * This pointer is only there for clean-up on error. -* @pages: The number of pages needed for all physical channels. -* Only used later for clean-up on error +* @alloc_order: Order used for the LCLA page allocation. +* Only used later for clean-up on error. * @lock: Lock to protect the content in this struct. * @alloc_map: big map over which LCLA entry is own by which job. */
@@ -435,7 +435,7 @@ struct d40_lcla_pool {void *base;dma_addr_t dma_addr;void *base_unaligned; -int pages; +unsigned int alloc_order;spinlock_t lock;struct d40_desc **alloc_map; };
@@ -3603,6 +3603,7 @@ static void __init d40_hw_init(struct d40_base *base)static int __init d40_lcla_allocate (struct d40_base *base) {struct d40_lcla_pool *pool = &base->lcla_pool; +size_t lcla_size =SZ_1K * base->num_phy_chans;unsigned long *page_list;int i, j;int ret;
@@ -3618,20 +3619,20 @@ static int __init d40_lcla_allocate(struct d40_base *base)if (!page_list)return -ENOMEM ; -/* Calculating how many pages that are required */ - base->lcla_pool.pages =SZ_1K * base->num_phy_chans /PAGE_SIZE ; + base->lcla_pool.alloc_order =get_order (lcla_size);for (i =0 ; i <MAX_LCLA_ALLOC_ATTEMPTS ; i++) { page_list[i] =__get_free_pages (GFP_KERNEL , - base->lcla_pool.pages); + base->lcla_pool.alloc_order);if (!page_list[i]) { -d40_err (base->dev,"Failed to allocate %d pages.\n" , - base->lcla_pool.pages); +d40_err (base->dev,"Failed to allocate %zu bytes.\n" , + lcla_size); ret = -ENOMEM ;for (j =0 ; j < i; j++) -free_pages (page_list[j], base->lcla_pool.pages); +free_pages (page_list[j], + base->lcla_pool.alloc_order); goto free_page_list; }
@@ -3641,7 +3642,7 @@ static int __init d40_lcla_allocate(struct d40_base *base) }for (j =0 ; j < i; j++) -free_pages (page_list[j], base->lcla_pool.pages); +free_pages (page_list[j], base->lcla_pool.alloc_order);if (i <MAX_LCLA_ALLOC_ATTEMPTS ) { base->lcla_pool.base = (void *)page_list[i];
@@ -3651,10 +3652,9 @@ static int __init d40_lcla_allocate(struct d40_base *base)* alignment, try with allocating a big buffer. */ dev_warn (base->dev, -"[%s] Failed to get %d pages @ 18 bit align.\n" , - __func__, base->lcla_pool.pages); - base->lcla_pool.base_unaligned =kmalloc (SZ_1K * - base->num_phy_chans + +"[%s] Failed to get %zu bytes @ 18 bit align.\n" , + __func__, lcla_size); + base->lcla_pool.base_unaligned =kmalloc (lcla_size +LCLA_ALIGNMENT ,GFP_KERNEL );if (!base->lcla_pool.base_unaligned) {
@@ -3666,8 +3666,7 @@ static int __init d40_lcla_allocate(struct d40_base *base) LCLA_ALIGNMENT); } - pool->dma_addr =dma_map_single (base->dev, pool->base, -SZ_1K * base->num_phy_chans, + pool->dma_addr =dma_map_single (base->dev, pool->base, lcla_size,DMA_TO_DEVICE );if (dma_mapping_error (base->dev, pool->dma_addr)) { pool->dma_addr =0 ;
@@ -3909,7 +3908,7 @@ static int __init d40_probe(struct platform_device *pdev)if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)free_pages ((unsigned long )base->lcla_pool.base, - base->lcla_pool.pages); + base->lcla_pool.alloc_order);kfree (base->lcla_pool.base_unaligned);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1344/2651 dmaengine: ste_dma40: Fix probe LCLA free
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 750dfcdb7a406bdd52d604099a631bbe96ddda91 ]
When LCLA is placed in ESRAM, d40_probe() stores a devm_ioremap() address in lcla_pool.base and leaves base_unaligned unset. The destroy_cache error path can then pass the ioremap address to free_pages().
Only free lcla_pool.base with free_pages() when the driver allocated the LCLA pool from normal memory. The ESRAM mapping is devm-managed.
--- drivers/dma/ste_dma40.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +2 -1
@@ -3906,7 +3906,8 @@ static int __init d40_probe(struct platform_device *pdev)SZ_1K * base->num_phy_chans, DMA_TO_DEVICE); -if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) +if (!base->plat_data->use_esram_lcla && + !base->lcla_pool.base_unaligned && base->lcla_pool.base)free_pages ((unsigned long )base->lcla_pool.base, base->lcla_pool.alloc_order);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1345/2651 dmaengine: ste_dma40: Put the LCPA SRAM node
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9a3762b470421658214baeb6cce3eed7344bb435 ]
of_parse_phandle() takes a reference to the LCPA SRAM node, but d40_probe() does not release it after translating the node into a resource. This leaks the node reference for the lifetime of the system.
Put the node immediately after of_address_to_resource() so both the success and error paths release the reference.
--- drivers/dma/ste_dma40.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/ste_dma40.c +1 -0
@@ -3771,6 +3771,7 @@ static int __init d40_probe(struct platform_device *pdev) }/* This is no device so read the address directly from the node */ ret =of_address_to_resource (np_lcpa,0 , &res_lcpa); +of_node_put (np_lcpa);if (ret) {dev_err (dev,"no LCPA SRAM resource\n" ); goto report_failure;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1346/2651 dmaengine: ste_dma40: Fix memcpy channel parsing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit f2baf04a695de4f952513cb00ccf0338c6db2e00 ]
d40_of_probe() validates the memcpy-channels property against D40_MEMCPY_MAX_CHANS, but reads the property directly into a smaller global array. A long property can therefore overwrite adjacent data. The mutable global also lets a later DMA40 instance replace the memcpy channel mapping used for future allocations on an earlier instance.
Store the mapping in the per-device platform data, validate the property against that storage, and check the property read result. The property is required and d40_probe() always populates the platform data, so remove the obsolete global mapping and fallback.
--- drivers/dma/ste_dma40.c | 45 +++++++++++++---------------------------- 1 file changed, 14 insertions(+), 31 deletions(-)
drivers/dma/ste_dma40.c +14 -31
@@ -28,6 +28,8 @@#include "ste_dma40.h" #include "ste_dma40_ll.h" +#define D40_MEMCPY_MAX_CHANS 8 +/** * struct stedma40_platform_data - Configuration struct for the dma device. *
@@ -41,6 +43,7 @@* to use SoftLLI. * @use_esram_lcla: flag for mapping the lcla into esram region * @num_of_memcpy_chans: The number of channels reserved for memcpy. +* @memcpy_channels: The event lines used for memcpy. * @num_of_phy_chans: The number of physical channels implemented in HW. * 0 means reading the number of channels from DMA HW but this is only valid * for 'multiple of 4' channels, like 8.
@@ -51,6 +54,7 @@ struct stedma40_platform_data {int num_of_soft_lli_chans;bool use_esram_lcla;int num_of_memcpy_chans; +u32 memcpy_channels[D40_MEMCPY_MAX_CHANS ];int num_of_phy_chans; };
@@ -89,25 +93,6 @@ struct stedma40_platform_data {#define D40_ALLOC_PHY BIT(30)#define D40_ALLOC_LOG_FREE 0 -#define D40_MEMCPY_MAX_CHANS 8 - -/* Reserved event lines for memcpy only. */ -#define DB8500_DMA_MEMCPY_EV_0 51 -#define DB8500_DMA_MEMCPY_EV_1 56 -#define DB8500_DMA_MEMCPY_EV_2 57 -#define DB8500_DMA_MEMCPY_EV_3 58 -#define DB8500_DMA_MEMCPY_EV_4 59 -#define DB8500_DMA_MEMCPY_EV_5 60 - -static int dma40_memcpy_channels[] = { -DB8500_DMA_MEMCPY_EV_0 , -DB8500_DMA_MEMCPY_EV_1 , -DB8500_DMA_MEMCPY_EV_2 , -DB8500_DMA_MEMCPY_EV_3 , -DB8500_DMA_MEMCPY_EV_4 , -DB8500_DMA_MEMCPY_EV_5 , -}; -/* Default configuration for physical memcpy */ static const struct stedma40_chan_cfg dma40_memcpy_conf_phy = { .mode =STEDMA40_MODE_PHYSICAL ,
@@ -2154,7 +2139,8 @@ static int d40_config_memcpy(struct d40_chan *d40c)if (dma_has_cap (DMA_MEMCPY , cap) && !dma_has_cap (DMA_SLAVE , cap)) { d40c->dma_cfg = dma40_memcpy_conf_log; - d40c->dma_cfg.dev_type = dma40_memcpy_channels[d40c->chan.chan_id]; + d40c->dma_cfg.dev_type = + d40c->base->plat_data->memcpy_channels[d40c->chan.chan_id];d40_log_cfg (&d40c->dma_cfg, &d40c->log_def.lcsp1, &d40c->log_def.lcsp3);
@@ -3434,12 +3420,7 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS );/* The number of channels used for memcpy */ -if (plat_data->num_of_memcpy_chans) - num_memcpy_chans = plat_data->num_of_memcpy_chans; -else - num_memcpy_chans =ARRAY_SIZE (dma40_memcpy_channels); - - num_memcpy_chans =min (num_memcpy_chans,D40_MEMCPY_MAX_CHANS ); + num_memcpy_chans = plat_data->num_of_memcpy_chans; num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ; dev_info(dev,
@@ -3688,6 +3669,7 @@ static int __init d40_of_probe(struct device *dev,struct stedma40_platform_data *pdata;int num_phy =0 , num_memcpy =0 , num_disabled =0 ;const __be32 *list; +int ret; pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)
@@ -3701,18 +3683,19 @@ static int __init d40_of_probe(struct device *dev, list =of_get_property (np,"memcpy-channels" , &num_memcpy); num_memcpy /=sizeof (*list); -if (num_memcpy >D40_MEMCPY_MAX_CHANS || num_memcpy <=0 ) { +if (num_memcpy >ARRAY_SIZE (pdata->memcpy_channels) || + num_memcpy <=0 ) {d40_err (dev,"Invalid number of memcpy channels specified (%d)\n" , num_memcpy);return -EINVAL ; } + ret =of_property_read_u32_array (np,"memcpy-channels" , + pdata->memcpy_channels, num_memcpy); +if (ret) +return ret; pdata->num_of_memcpy_chans = num_memcpy; -of_property_read_u32_array (np,"memcpy-channels" , - dma40_memcpy_channels, - num_memcpy); - list =of_get_property (np,"disabled-channels" , &num_disabled); num_disabled /=sizeof (*list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1347/2651 dmaengine: ste_dma40: Validate disabled channel indexes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c96e9f056095825b5f8d4a11f4107fc174892f92 ]
d40_of_probe() checks how many entries disabled-channels contains, but not the channel numbers themselves. d40_phy_res_init() later uses every value as an index into base->phy_res, whose size is the number of channels found in this DMA40 instance. An out-of-range value can therefore write beyond the allocation.
Validate each disabled channel against the detected hardware channel count before allocating and initializing the channel resources.
--- drivers/dma/ste_dma40.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/ste_dma40.c +9 -0
@@ -3419,6 +3419,15 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS ); +for (i =0 ; plat_data->disabled_channels[i] !=-1 ; i++) { +int chan = plat_data->disabled_channels[i]; + +if (chan <0 || chan >= num_phy_chans) { +dev_err (dev,"Invalid disabled channel %d\n" , chan); +return -EINVAL ; + } + } +/* The number of channels used for memcpy */ num_memcpy_chans = plat_data->num_of_memcpy_chans; num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1348/2651 dmaengine: ste_dma40: Validate DMA specifier length
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9f1064ebe17cf3ab65ac6eb166398e02678aea33 ]
The DMA40 binding requires three cells, but d40_xlate() reads args[0], args[1], and args[2] without checking args_count. A malformed provider node can specify fewer cells, leaving some of these values uninitialized when the OF DMA core invokes the translation callback.
Reject specifiers that do not contain exactly three cells before reading the argument array.
--- drivers/dma/ste_dma40.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/ste_dma40.c +3 -0
@@ -2542,6 +2542,9 @@ static struct dma_chan *d40_xlate(struct of_phandle_args *dma_spec,dma_cap_mask_t cap;u32 flags; +if (dma_spec->args_count !=3 ) +return NULL ; +memset (&cfg,0 ,sizeof (struct stedma40_chan_cfg ));dma_cap_zero (cap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1349/2651 dmaengine: ste_dma40: Reject direction changes after allocation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 77ebc64f40717b8501793b5f5ee717a141e62e8e ]
Logical channel allocation uses the configured direction to select the source or destination allocation mask, derive the logical channel number, and choose the LCPA location.
d40_set_runtime_config_write() nevertheless overwrites the configured direction when a transfer is prepared for the opposite direction. d40_free_dma() then clears the wrong allocation mask, leaking the original resource and potentially releasing one used by another client.
Reject directions that differ from the direction used during allocation and propagate runtime configuration errors to callers. Skip slave runtime configuration for memcpy transfers, which also use d40_prep_sg() but do not require it.
--- drivers/dma/ste_dma40.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/dma/ste_dma40.c +14 -15
@@ -2410,7 +2410,13 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,return NULL ; } -d40_set_runtime_config_write (dchan, &chan->slave_config, direction); +if (direction !=DMA_MEM_TO_MEM ) { + ret =d40_set_runtime_config_write (dchan, + &chan->slave_config, + direction); +if (ret) +return NULL ; + }spin_lock_irqsave (&chan->lock, flags);
@@ -2886,6 +2892,13 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,return -EINVAL ; } +if (direction != cfg->dir) { +chan_err (d40c, +"transfer direction %d differs from allocated direction %d\n" , + direction, cfg->dir); +return -EINVAL ; + } + src_addr_width = config->src_addr_width; src_maxburst = config->src_maxburst; dst_addr_width = config->dst_addr_width;
@@ -2894,13 +2907,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,if (direction ==DMA_DEV_TO_MEM ) { config_addr = config->src_addr; -if (cfg->dir !=DMA_DEV_TO_MEM ) -dev_dbg (d40c->base->dev, -"channel was not configured for peripheral " -"to memory transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_DEV_TO_MEM ; -/* Configure the memory side */ if (dst_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) dst_addr_width = src_addr_width;
@@ -2910,13 +2916,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan, }else if (direction ==DMA_MEM_TO_DEV ) { config_addr = config->dst_addr; -if (cfg->dir !=DMA_MEM_TO_DEV ) -dev_dbg (d40c->base->dev, -"channel was not configured for memory " -"to peripheral transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_MEM_TO_DEV ; -/* Configure the memory side */ if (src_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) src_addr_width = dst_addr_width;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1350/2651 dmaengine: ste_dma40: Fix logical channel bounds check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 57938e0c2a24f9f792fe9f611391ef6b58d1aa21 ]
d40_validate_conf() checks the raw dev_type against num_log_chans, but d40_allocate_channel() derives the lookup_log_chans index as either 2 * dev_type or 2 * dev_type + 1.
Validate the dev_type against the derived logical channel index limit so channel allocation cannot write past lookup_log_chans.
--- drivers/dma/ste_dma40.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/dma/ste_dma40.c +14 -3
@@ -1881,15 +1881,26 @@ static int d40_validate_conf(struct d40_chan *d40c, {int res =0 ;bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ; +bool invalid_dev_type = conf->dev_type <0 ;if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ; } -if ((is_log && conf->dev_type > d40c->base->num_log_chans) || - (!is_log && conf->dev_type > d40c->base->num_phy_chans) || - (conf->dev_type <0 )) { +if (!invalid_dev_type && is_log) { +int max_dev_type; + +if (conf->dir ==DMA_DEV_TO_MEM ) + max_dev_type =DIV_ROUND_UP (d40c->base->num_log_chans,2 ); +else + max_dev_type = d40c->base->num_log_chans /2 ; + + invalid_dev_type = conf->dev_type >= max_dev_type; + } + +if (invalid_dev_type || + (!is_log && conf->dev_type > d40c->base->num_phy_chans)) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1351/2651 dmaengine: ste_dma40: Fix event group bounds
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit e66a9dbe04c71249cfb2a544c9c25d1b3b761fba ]
The dev_type validation can allow values whose derived event group has no matching physical channel pair. d40_allocate_channel() then indexes phy_res with j + event_group * 2, and __d40_set_prio_rt() uses the same group to select priority and realtime registers.
The physical-mode validation also compares dev_type with the number of physical channels. However, dev_type identifies an event line: DB8500 has eight physical channels but 64 source and 64 destination event lines. The event group determines which physical channel pair can serve an event, so the physical channel count is not a valid dev_type limit.
Reject dev_type values outside the hardware event-group range, remove the incorrect physical channel count limit, and stop the physical-channel search before a partial final channel group can index past phy_res.
--- drivers/dma/ste_dma40.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/dma/ste_dma40.c +22 -4
@@ -82,6 +82,10 @@ struct stedma40_platform_data {#define D40_LCLA_LINK_PER_EVENT_GRP 128#define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP +/* Number of event groups per hardware register layout */ +#define D40_EVENT_GROUPS_V4A 4 +#define D40_EVENT_GROUPS_V4B 5 +/* Max number of logical channels per physical channel */ #define D40_MAX_LOG_CHAN_PER_PHY 32
@@ -522,6 +526,7 @@ struct d40_chan {* @high_prio_clear: the high priority clear register * @interrupt_en: the interrupt enable register * @interrupt_clear: the interrupt clear register +* @num_event_groups: number of supported event groups * @il: the pointer to struct d40_interrupt_lookup * @il_size: the size of d40_interrupt_lookup array * @init_reg: the pointer to the struct d40_reg_val
@@ -536,6 +541,7 @@ struct d40_gen_dmac {u32 high_prio_clear;u32 interrupt_en;u32 interrupt_clear; +u32 num_event_groups;struct d40_interrupt_lookup *il;u32 il_size;struct d40_reg_val *init_reg;
@@ -1883,6 +1889,11 @@ static int d40_validate_conf(struct d40_chan *d40c,bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ;bool invalid_dev_type = conf->dev_type <0 ; +if (!invalid_dev_type && +D40_TYPE_TO_GROUP (conf->dev_type) >= + d40c->base->gen_dmac.num_event_groups) + invalid_dev_type = true; +if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ;
@@ -1899,8 +1910,7 @@ static int d40_validate_conf(struct d40_chan *d40c, invalid_dev_type = conf->dev_type >= max_dev_type; } -if (invalid_dev_type || - (!is_log && conf->dev_type > d40c->base->num_phy_chans)) { +if (invalid_dev_type) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
@@ -2065,8 +2075,12 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) } } }else -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; + j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ; +for (i = phy_num; i < phy_num +2 ; i++) { if (d40_alloc_mask_set(&phys[i], is_src,
@@ -2086,8 +2100,10 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)return -EINVAL ;/* Find logical channel */ -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ;if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel;
@@ -3467,6 +3483,7 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, base->log_chans = &base->phy_chans[num_phy_chans];if (base->plat_data->num_of_phy_chans ==14 ) { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4B ; base->gen_dmac.backup = d40_backup_regs_v4b; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4B ; base->gen_dmac.interrupt_en =D40_DREG_CPCMIS ;
@@ -3480,6 +3497,7 @@ static int __init d40_hw_detect_init(struct platform_device *pdev, base->gen_dmac.init_reg = dma_init_reg_v4b; base->gen_dmac.init_reg_size =ARRAY_SIZE (dma_init_reg_v4b); }else { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4A ;if (base->rev >=3 ) { base->gen_dmac.backup = d40_backup_regs_v4a; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4A ;
Signature · 1 line
2.53.0