All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] iommu/arm-smmu-v3: Parse out event records
@ 2024-11-12  8:30 Pranjal Shrivastava
  2024-11-12  8:30 ` [PATCH v5 1/3] iommu/arm-smmu-v3: Introduce struct arm_smmu_event Pranjal Shrivastava
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Pranjal Shrivastava @ 2024-11-12  8:30 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Robin Murphy
  Cc: Mostafa Saleh, Nicolin Chen, iommu, Jason Gunthorpe, Daniel Mentz,
	Pranjal Shrivastava

Enhance the arm-smmu-v3 driver to parse out useful information from
event records into a structure for better event handling & logging.

Some sample events, powered by QEMU:

1. Bad StreamID:

[    7.521940] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x02 received:
[    7.522485] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000002
[    7.523335] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.523814] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.524281] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.524759] arm-smmu-v3 arm-smmu-v3.0.auto: Event 0x2 received: C_BAD_STREAMID
[    7.524759]  client: 0000:00:01.0 sid: 0x8 ssid: 0x0

2. STE Fetch Fault:

[    7.531332] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x03 received:
[    7.531890] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000003
[    7.532371] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.533189] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.533674] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000000001e0
[    7.534136] arm-smmu-v3 arm-smmu-v3.0.auto: Event 0x3 received: F_STE_FETCH
[    7.534136]  client: 0000:00:01.0 sid: 0x8 ssid: 0x0
[    7.534136]  Fetch Address: 0x1e0

3. Permission Fault:

[    7.547455] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x13 received:
[    7.547997] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000013
[    7.548476] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000020000000000
[    7.548949] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000fffff040
[    7.549418] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.550168] arm-smmu-v3 arm-smmu-v3.0.auto: Event 0x13 received: F_PERMISSION
[    7.550168]  client: 0000:00:01.0 sid: 0x8 ssid: 0x0
[    7.550168]  iova 0xfffff040 ipa 0x0
[    7.550168]  Unpriv | Data | Write | S1 | Input address caused fault
[    7.550168]  STAG: 0x0

4. Translation Fault:

[    7.586428] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x10 received:
[    7.587012] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000800000010
[    7.587504] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000020000000000
[    7.587986] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000fffff040
[    7.588745] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.589219] arm-smmu-v3 arm-smmu-v3.0.auto: Event 0x10 received: F_TRANSLATION
[    7.589219]  client: 0000:00:01.0 sid: 0x8 ssid: 0x0
[    7.589219]  iova 0xfffff040 ipa 0x0
[    7.589219]  Unpriv | Data | Write | S1 | Input address caused fault
[    7.589219]  STAG: 0x0

5. Unknown / Implementation-defined Fault:

[    7.152599] arm-smmu-v3 arm-smmu-v3.0.auto: event 0x0b received:
[    7.153064] arm-smmu-v3 arm-smmu-v3.0.auto:  0x000000080000000b
[    7.153755] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000010000000000
[    7.154239] arm-smmu-v3 arm-smmu-v3.0.auto:  0x00000000fffff040
[    7.154702] arm-smmu-v3 arm-smmu-v3.0.auto:  0x0000000000000000
[    7.155169] arm-smmu-v3 arm-smmu-v3.0.auto: Event 0xb received: UNKNOWN
[    7.155169]  client: 0000:00:01.0 sid: 0x8 ssid: 0x0

v5
 * Replaced strings with used macros to conserve stack space
 * Fixed IPA log truncation,(e.g. logged 0xfffff instead of 0xfffff040)
 * Bounded evt->id by ARRAY_SIZE to avoid inflating event_str
 * Restored the original raw dump format
 * Decoupled "raw" event from `struct arm_smmu_event`
 * Moved the raw event log before the decoded/pretty log
 * Improved the sid.ssid format to be more readable
 * Zero-initialized the `arm_smmu_event` var in `arm_smmu_handle_evt`
 * Refactored struct arm_smmu_events to use bitfields instead of bools
 * Removed `struct arm_smmu_device` field from `struct arm_smmu_event`
 * Removed `master_name` field to use `dev_name(event->dev)` instead
 * Pahole reports a total of 3-byte holes & struct size = 40 bytes
 * Moved most constant parts of the log to the fmt string
 * Moved the event decoding within `arm_smmu_handle_evt`
 * Renamed `arm_smmu_get_event_from_raw` => `arm_smmu_decode_event`
 * Renamed a few EVT_IDs for consistency as per Daniel's suggestions
 * Renamed "master" to "client" in the logs as suggested in reviews
 * Corrected "F_VMS_FAULT" => "F_VMS_FETCH"
 * Re-ordered event strings in event_str as they appear in the spec
 * Removed less useful comments

v4
 https://lore.kernel.org/all/20241018180022.807928-1-praan@google.com/
 * Re-arranged the series to first introduce struct arm_smmu_event
 * Improved the complex ternary expression that prints TTRnW info
 * Added consistent spacing to the logs & resized log strings
 * Moved ratelimiting within `arm_smmu_dump_event`
 * Refactored master_name printing by getting a ref to the device
 * Refactored `arm_smmu_handle_evt` to avoid redundant master lookup

v3
 https://lore.kernel.org/all/20240928005143.2378938-1-praan@google.com/
 * Fixed a potential race and null pointer deref for arm_smmu_master
 * Improved the logging approach by using multiple strings
 * Added logs for STAG & STALL fields for relevant events
 * Invoked the log function within `arm_smmu_handle_evt` routine
 * Rebased the changes

v2
 https://lore.kernel.org/linux-iommu/20240827193026.3993039-1-praan@google.com/
 * Addressed review comments
 * Introduced `struct arm_smmu_event` to hold relevant event fields
 * Broke out helper functions to populate & dump event info
 * Modified the event handler routines to use `struct arm_smmu_event`

v1
 https://lore.kernel.org/linux-iommu/20240816211722.1404070-1-praan@google.com/


Pranjal Shrivastava (3):
  iommu/arm-smmu-v3: Introduce struct arm_smmu_event
  iommu/arm-smmu-v3: Log better event records
  iommu/arm-smmu-v3: Avoid redundant master lookup in events

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 173 ++++++++++++++++----
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h |  28 ++++
 2 files changed, 165 insertions(+), 36 deletions(-)

-- 
2.47.0.277.g8800431eea-goog


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2024-11-29 12:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12  8:30 [PATCH v5 0/3] iommu/arm-smmu-v3: Parse out event records Pranjal Shrivastava
2024-11-12  8:30 ` [PATCH v5 1/3] iommu/arm-smmu-v3: Introduce struct arm_smmu_event Pranjal Shrivastava
2024-11-12 23:30   ` Nicolin Chen
2024-11-15 13:13     ` Pranjal Shrivastava
2024-11-15 21:34       ` Nicolin Chen
2024-11-18 16:24         ` Jason Gunthorpe
2024-11-19  9:03           ` Will Deacon
2024-11-19  9:27             ` Pranjal Shrivastava
2024-11-20  9:56               ` Will Deacon
2024-11-20 11:46                 ` Pranjal Shrivastava
2024-11-27  3:25   ` Daniel Mentz
2024-11-27  9:25     ` Pranjal Shrivastava
2024-11-27 19:42       ` Daniel Mentz
2024-11-27 20:53         ` Pranjal Shrivastava
2024-11-28 23:40           ` Daniel Mentz
2024-11-29 12:56             ` Pranjal Shrivastava
2024-11-12  8:30 ` [PATCH v5 2/3] iommu/arm-smmu-v3: Log better event records Pranjal Shrivastava
2024-11-12  8:30 ` [PATCH v5 3/3] iommu/arm-smmu-v3: Avoid redundant master lookup in events Pranjal Shrivastava
2024-11-12 23:52   ` Nicolin Chen
2024-11-15 13:26     ` Pranjal Shrivastava
2024-11-15 21:46       ` Nicolin Chen
2024-11-20  4:45 ` [PATCH v5 0/3] iommu/arm-smmu-v3: Parse out event records Daniel Mentz
2024-11-20  6:54   ` Pranjal Shrivastava
2024-11-20  7:12     ` Pranjal Shrivastava
2024-11-20 11:43     ` Pranjal Shrivastava
2024-11-22 23:33       ` Daniel Mentz
2024-11-26  9:30         ` Pranjal Shrivastava

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.