Lines Matching +full:total +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0
282 * tpm1_calc_ordinal_duration() - calculate the maximum command duration
304 duration = chip->duration[duration_idx]; in tpm1_calc_ordinal_duration()
315 * tpm1_startup() - turn on the TPM
329 dev_info(&chip->dev, "starting up the TPM manually\n"); in tpm1_startup()
350 sizeof(cap.timeout)); in tpm1_get_timeouts()
357 sizeof(cap.timeout)); in tpm1_get_timeouts()
361 dev_err(&chip->dev, "A TPM error (%zd) occurred attempting to determine the timeouts\n", in tpm1_get_timeouts()
366 timeout_old[0] = jiffies_to_usecs(chip->timeout_a); in tpm1_get_timeouts()
367 timeout_old[1] = jiffies_to_usecs(chip->timeout_b); in tpm1_get_timeouts()
368 timeout_old[2] = jiffies_to_usecs(chip->timeout_c); in tpm1_get_timeouts()
369 timeout_old[3] = jiffies_to_usecs(chip->timeout_d); in tpm1_get_timeouts()
370 timeout_chip[0] = be32_to_cpu(cap.timeout.a); in tpm1_get_timeouts()
371 timeout_chip[1] = be32_to_cpu(cap.timeout.b); in tpm1_get_timeouts()
372 timeout_chip[2] = be32_to_cpu(cap.timeout.c); in tpm1_get_timeouts()
373 timeout_chip[3] = be32_to_cpu(cap.timeout.d); in tpm1_get_timeouts()
377 * Provide ability for vendor overrides of timeout values in case in tpm1_get_timeouts()
380 if (chip->ops->update_timeouts) in tpm1_get_timeouts()
381 chip->ops->update_timeouts(chip, timeout_eff); in tpm1_get_timeouts()
383 if (!chip->timeout_adjusted) { in tpm1_get_timeouts()
392 chip->timeout_adjusted = true; in tpm1_get_timeouts()
399 chip->timeout_adjusted = true; in tpm1_get_timeouts()
404 if (chip->timeout_adjusted) { in tpm1_get_timeouts()
405 …dev_info(&chip->dev, HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D… in tpm1_get_timeouts()
412 chip->timeout_a = usecs_to_jiffies(timeout_eff[0]); in tpm1_get_timeouts()
413 chip->timeout_b = usecs_to_jiffies(timeout_eff[1]); in tpm1_get_timeouts()
414 chip->timeout_c = usecs_to_jiffies(timeout_eff[2]); in tpm1_get_timeouts()
415 chip->timeout_d = usecs_to_jiffies(timeout_eff[3]); in tpm1_get_timeouts()
423 chip->duration[TPM_SHORT] = in tpm1_get_timeouts()
425 chip->duration[TPM_MEDIUM] = in tpm1_get_timeouts()
427 chip->duration[TPM_LONG] = in tpm1_get_timeouts()
429 chip->duration[TPM_LONG_LONG] = 0; /* not used under 1.2 */ in tpm1_get_timeouts()
435 if (chip->ops->update_durations) in tpm1_get_timeouts()
436 chip->ops->update_durations(chip, durations); in tpm1_get_timeouts()
438 if (chip->duration_adjusted) { in tpm1_get_timeouts()
439 dev_info(&chip->dev, HW_ERR "Adjusting reported durations."); in tpm1_get_timeouts()
440 chip->duration[TPM_SHORT] = durations[0]; in tpm1_get_timeouts()
441 chip->duration[TPM_MEDIUM] = durations[1]; in tpm1_get_timeouts()
442 chip->duration[TPM_LONG] = durations[2]; in tpm1_get_timeouts()
447 * fix up the resulting too-small TPM_SHORT value to make things work. in tpm1_get_timeouts()
448 * We also scale the TPM_MEDIUM and -_LONG values by 1000. in tpm1_get_timeouts()
450 if (chip->duration[TPM_SHORT] < (HZ / 100)) { in tpm1_get_timeouts()
451 chip->duration[TPM_SHORT] = HZ; in tpm1_get_timeouts()
452 chip->duration[TPM_MEDIUM] *= 1000; in tpm1_get_timeouts()
453 chip->duration[TPM_LONG] *= 1000; in tpm1_get_timeouts()
454 chip->duration_adjusted = true; in tpm1_get_timeouts()
455 dev_info(&chip->dev, "Adjusting TPM timeout parameters."); in tpm1_get_timeouts()
458 chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; in tpm1_get_timeouts()
521 * tpm1_get_random() - get random bytes from the TPM's RNG
528 * * -errno (positive TPM return codes are masked to -EIO)
535 u32 total = 0; in tpm1_get_random() local
547 rc = tpm_transmit_cmd(chip, &buf, sizeof(out->rng_data_len), in tpm1_get_random()
551 rc = -EIO; in tpm1_get_random()
557 recd = be32_to_cpu(out->rng_data_len); in tpm1_get_random()
559 rc = -EFAULT; in tpm1_get_random()
564 sizeof(out->rng_data_len) + recd) { in tpm1_get_random()
565 rc = -EFAULT; in tpm1_get_random()
568 memcpy(dest, out->rng_data, recd); in tpm1_get_random()
571 total += recd; in tpm1_get_random()
572 num_bytes -= recd; in tpm1_get_random()
575 } while (retries-- && total < max); in tpm1_get_random()
577 rc = total ? (int)total : -EIO; in tpm1_get_random()
601 rc = -EFAULT; in tpm1_pcr_read()
614 * tpm1_continue_selftest() - run TPM's selftest
635 * tpm1_do_selftest - have the TPM continue its selftest and wait until it
656 chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED; in tpm1_do_selftest()
657 dev_info(&chip->dev, "TPM not ready (%d)\n", rc); in tpm1_do_selftest()
673 if (rc == -ETIME) { in tpm1_do_selftest()
674 dev_info(&chip->dev, HW_ERR "TPM command timed out during continue self test"); in tpm1_do_selftest()
680 dev_info(&chip->dev, "TPM is disabled/deactivated (0x%X)\n", in tpm1_do_selftest()
691 } while (--loops > 0); in tpm1_do_selftest()
698 * tpm1_auto_startup - Perform the standard automatic TPM initialization
713 dev_warn(&chip->dev, "TPM self test failed, switching to the firmware upgrade mode\n"); in tpm1_auto_startup()
715 chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE; in tpm1_auto_startup()
718 dev_err(&chip->dev, "TPM self test failed\n"); in tpm1_auto_startup()
725 rc = -ENODEV; in tpm1_auto_startup()
732 * tpm1_pm_suspend() - pm suspend handler
779 dev_err(&chip->dev, "Error (%d) sending savestate before suspend\n", in tpm1_pm_suspend()
782 dev_warn(&chip->dev, "TPM savestate took %dms\n", in tpm1_pm_suspend()
791 * tpm1_get_pcr_allocation() - initialize the allocated bank
802 chip->allocated_banks = kcalloc(1, sizeof(*chip->allocated_banks), in tpm1_get_pcr_allocation()
804 if (!chip->allocated_banks) in tpm1_get_pcr_allocation()
805 return -ENOMEM; in tpm1_get_pcr_allocation()
807 chip->allocated_banks[0].alg_id = TPM_ALG_SHA1; in tpm1_get_pcr_allocation()
808 chip->allocated_banks[0].digest_size = hash_digest_size[HASH_ALGO_SHA1]; in tpm1_get_pcr_allocation()
809 chip->allocated_banks[0].crypto_id = HASH_ALGO_SHA1; in tpm1_get_pcr_allocation()
810 chip->nr_allocated_banks = 1; in tpm1_get_pcr_allocation()