Skip to content

Commit f28b0a1

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amd/pm: Add smu feature bits data struct
Add a bitmap struct to represent smu feature bits and functions to set/clear features. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Asad Kamal <asad.kamal@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 82a9ab3 commit f28b0a1

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ struct smu_power_context {
472472
};
473473

474474
#define SMU_FEATURE_MAX (64)
475+
476+
struct smu_feature_bits {
477+
DECLARE_BITMAP(bits, SMU_FEATURE_MAX);
478+
};
479+
475480
struct smu_feature {
476481
uint32_t feature_num;
477482
DECLARE_BITMAP(supported, SMU_FEATURE_MAX);
@@ -1974,4 +1979,80 @@ int amdgpu_smu_ras_send_msg(struct amdgpu_device *adev, enum smu_message_type ms
19741979

19751980
void smu_feature_cap_set(struct smu_context *smu, enum smu_feature_cap_id fea_id);
19761981
bool smu_feature_cap_test(struct smu_context *smu, enum smu_feature_cap_id fea_id);
1982+
1983+
static inline bool smu_feature_bits_is_set(const struct smu_feature_bits *bits,
1984+
unsigned int bit)
1985+
{
1986+
if (bit >= SMU_FEATURE_MAX)
1987+
return false;
1988+
1989+
return test_bit(bit, bits->bits);
1990+
}
1991+
1992+
static inline void smu_feature_bits_set_bit(struct smu_feature_bits *bits,
1993+
unsigned int bit)
1994+
{
1995+
if (bit < SMU_FEATURE_MAX)
1996+
__set_bit(bit, bits->bits);
1997+
}
1998+
1999+
static inline void smu_feature_bits_clear_bit(struct smu_feature_bits *bits,
2000+
unsigned int bit)
2001+
{
2002+
if (bit < SMU_FEATURE_MAX)
2003+
__clear_bit(bit, bits->bits);
2004+
}
2005+
2006+
static inline void smu_feature_bits_clearall(struct smu_feature_bits *bits)
2007+
{
2008+
bitmap_zero(bits->bits, SMU_FEATURE_MAX);
2009+
}
2010+
2011+
static inline void smu_feature_bits_fill(struct smu_feature_bits *bits)
2012+
{
2013+
bitmap_fill(bits->bits, SMU_FEATURE_MAX);
2014+
}
2015+
2016+
static inline bool
2017+
smu_feature_bits_test_mask(const struct smu_feature_bits *bits,
2018+
const unsigned long *mask)
2019+
{
2020+
return bitmap_intersects(bits->bits, mask, SMU_FEATURE_MAX);
2021+
}
2022+
2023+
static inline void smu_feature_bits_from_arr32(struct smu_feature_bits *bits,
2024+
const uint32_t *arr,
2025+
unsigned int nbits)
2026+
{
2027+
bitmap_from_arr32(bits->bits, arr, nbits);
2028+
}
2029+
2030+
static inline void
2031+
smu_feature_bits_to_arr32(const struct smu_feature_bits *bits, uint32_t *arr,
2032+
unsigned int nbits)
2033+
{
2034+
bitmap_to_arr32(arr, bits->bits, nbits);
2035+
}
2036+
2037+
static inline bool smu_feature_bits_empty(const struct smu_feature_bits *bits,
2038+
unsigned int nbits)
2039+
{
2040+
return bitmap_empty(bits->bits, nbits);
2041+
}
2042+
2043+
static inline void smu_feature_bits_copy(struct smu_feature_bits *dst,
2044+
const unsigned long *src,
2045+
unsigned int nbits)
2046+
{
2047+
bitmap_copy(dst->bits, src, nbits);
2048+
}
2049+
2050+
static inline void smu_feature_bits_or(struct smu_feature_bits *dst,
2051+
const struct smu_feature_bits *src1,
2052+
const unsigned long *src2,
2053+
unsigned int nbits)
2054+
{
2055+
bitmap_or(dst->bits, src1->bits, src2, nbits);
2056+
}
2057+
19772058
#endif

0 commit comments

Comments
 (0)