crypto: qat - fix and improve ring related debugfs functions
Subsystems (2)
Giovanni Cabiddu
maintainercover crypto: qat - fix and improve ring related debugfs functions
This small patchset addresses a bug in the seq_file implementation for ring-related debugfs functions in the QAT driver and introduces a simple refactor.
Giovanni Cabiddu (2):
crypto: qat - fix seq_file position update in adf_ring_next()
crypto: qat - refactor ring-related debug functions
.../qat/qat_common/adf_transport_debug.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
base-commit: 60a2ff0c7e1bc0615558a4f4c65f031bcd00200d
Signature · 1 line
2.50.0
Giovanni Cabiddu
maintainerPATCH 1/2 crypto: qat - fix seq_file position update in adf_ring_next()
The adf_ring_next() function in the QAT debug transport interface fails to correctly update the position index when reaching the end of the ring elements. This triggers the following kernel warning when reading ring files, such as /sys/kernel/debug/qat_c6xx_<D:B:D:F>/transport/bank_00/ring_00:
[27725.022965] seq_file: buggy .next function adf_ring_next [intel_qat] did not update position index
Ensure that the *pos index is incremented before returning NULL when after the last element in the ring is found, satisfying the seq_file API requirements and preventing the warning.
--- drivers/crypto/intel/qat/qat_common/adf_transport_debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_transport_debug.c +3 -1
@@ -31,8 +31,10 @@ static void *adf_ring_next(struct seq_file *sfile, void *v, loff_t *pos)struct adf_etr_ring_data *ring = sfile->private;if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES (ring->ring_size) / -ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) +ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) { + (*pos)++;return NULL ; + }return ring->base_addr + (ADF_MSG_SIZE_TO_BYTES (ring->msg_size) * (*pos)++);
Signature · 1 line
2.50.0
Giovanni Cabiddu
maintainerPATCH 2/2 crypto: qat - refactor ring-related debug functions
In reply to Giovanni CabidduRefactor the functions adf_ring_start() and adf_ring_next() to improve readability.
This does not introduce any functional change.
--- .../qat/qat_common/adf_transport_debug.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_transport_debug.c +14 -9
@@ -10,16 +10,21 @@static DEFINE_MUTEX (ring_read_lock);static DEFINE_MUTEX (bank_read_lock); +#define ADF_RING_NUM_MSGS (ring) \ + (ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size) / \ + ADF_MSG_SIZE_TO_BYTES(ring->msg_size)) +static void *adf_ring_start (struct seq_file *sfile,loff_t *pos) {struct adf_etr_ring_data *ring = sfile->private; +unsigned int num_msg =ADF_RING_NUM_MSGS (ring); +loff_t val = *pos;mutex_lock (&ring_read_lock); -if (*pos ==0 ) +if (val ==0 )return SEQ_START_TOKEN ; -if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES (ring->ring_size) / -ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) +if (val >= num_msg)return NULL ; return ring->base_addr +
@@ -29,15 +34,15 @@ static void *adf_ring_start(struct seq_file *sfile, loff_t *pos)static void *adf_ring_next (struct seq_file *sfile,void *v,loff_t *pos) {struct adf_etr_ring_data *ring = sfile->private; +unsigned int num_msg =ADF_RING_NUM_MSGS (ring); +loff_t val = *pos; + + (*pos)++; -if (*pos >= (ADF_SIZE_TO_RING_SIZE_IN_BYTES (ring->ring_size) / -ADF_MSG_SIZE_TO_BYTES (ring->msg_size))) { - (*pos)++; +if (val >= num_msg)return NULL ; - } -return ring->base_addr + - (ADF_MSG_SIZE_TO_BYTES (ring->msg_size) * (*pos)++); +return ring->base_addr + (ADF_MSG_SIZE_TO_BYTES (ring->msg_size) * val); }static int adf_ring_show (struct seq_file *sfile,void *v)
Signature · 1 line
2.50.0
Herbert Xu
maintainerQuoted 8 lines · Giovanni Cabiddu
This small patchset addresses a bug in the
seq_fileimplementation for ring-related debugfs functions in the QAT driver and introduces a simple refactor.Giovanni Cabiddu (2):
crypto: qat - fixseq_fileposition update inadf_ring_next()
crypto: qat - refactor ring-related debug functions
Quoted 7 lines
.../qat/qat_common/adf_transport_debug.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)base-commit:
60a2ff0c7e1bc0615558a4f4c65f031bcd00200dSignature · 1 line
2.50.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt