Skip to content

Commit 0d4b78b

Browse files
committed
drm/i915/guc: Assert we have the doorbell before setting it up
As our early doorbell is split between early allocation and a late setup after we have a channel to the GuC, it may happen due to a lapse of programmer judgement that we try to setup an invalid doorbell. Make use of our has_doorbell() function to check the doorbell does exist for the client before we try and tell the guc about it. In doing so, we prevent the compiler from warning about the otherwise unused function in some configurations. Reported-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: Daniele Ceraolo Spurio <[email protected]> Cc: Michał Winiarski <[email protected]> Cc: Michal Wajdeczko <[email protected]> Cc: Michel Thierry <[email protected]> Reviewed-by: Michel Thierry <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 46e2068 commit 0d4b78b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

drivers/gpu/drm/i915/intel_guc_submission.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,17 @@ static int reserve_doorbell(struct intel_guc_client *client)
124124
return 0;
125125
}
126126

127+
static bool has_doorbell(struct intel_guc_client *client)
128+
{
129+
if (client->doorbell_id == GUC_DOORBELL_INVALID)
130+
return false;
131+
132+
return test_bit(client->doorbell_id, client->guc->doorbell_bitmap);
133+
}
134+
127135
static void unreserve_doorbell(struct intel_guc_client *client)
128136
{
129-
GEM_BUG_ON(client->doorbell_id == GUC_DOORBELL_INVALID);
137+
GEM_BUG_ON(!has_doorbell(client));
130138

131139
__clear_bit(client->doorbell_id, client->guc->doorbell_bitmap);
132140
client->doorbell_id = GUC_DOORBELL_INVALID;
@@ -184,14 +192,6 @@ static struct guc_doorbell_info *__get_doorbell(struct intel_guc_client *client)
184192
return client->vaddr + client->doorbell_offset;
185193
}
186194

187-
static bool has_doorbell(struct intel_guc_client *client)
188-
{
189-
if (client->doorbell_id == GUC_DOORBELL_INVALID)
190-
return false;
191-
192-
return test_bit(client->doorbell_id, client->guc->doorbell_bitmap);
193-
}
194-
195195
static void __create_doorbell(struct intel_guc_client *client)
196196
{
197197
struct guc_doorbell_info *doorbell;
@@ -207,7 +207,6 @@ static void __destroy_doorbell(struct intel_guc_client *client)
207207
struct guc_doorbell_info *doorbell;
208208
u16 db_id = client->doorbell_id;
209209

210-
211210
doorbell = __get_doorbell(client);
212211
doorbell->db_status = GUC_DOORBELL_DISABLED;
213212
doorbell->cookie = 0;
@@ -224,6 +223,9 @@ static int create_doorbell(struct intel_guc_client *client)
224223
{
225224
int ret;
226225

226+
if (WARN_ON(!has_doorbell(client)))
227+
return -ENODEV; /* internal setup error, should never happen */
228+
227229
__update_doorbell_desc(client, client->doorbell_id);
228230
__create_doorbell(client);
229231

0 commit comments

Comments
 (0)