From nobody Sun Nov 24 21:52:56 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21A684690 for ; Sat, 2 Nov 2024 00:47:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730508457; cv=none; b=ZD5rxmNQzwwDKsBdI/BSXoIz1T9F9ctHVJnUVj/LA5eIxD+/xOHuTGuFNVepvXNfM1XLq6UtszEd5lhgxqEmNkZmEmsSmCbedlNdJVoaKF2Ja6HXZ619rmIP+e7Ob/nscZM8a+2L2LMFh/xGj372fRlU2hdGHMylRCwx4K9Pino= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730508457; c=relaxed/simple; bh=cOjhF1DzZ0BKraxrpQ99UN+wj8KvzwPmVCYJbq7BfOM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=ZcapmC8P1FrlmGPptuSW8Ruqp0R/63RojJDIy/Ed3i96zOWWCpKPPvPfgq0skuZhWazMh/K0cRINXaQ844rRhSo/ACECNeQeEntJKZcynB8WypOkLcp8f4Ty7peHlrcKjdTPz1NlIpTZ1joOBnnlCuOfETO6CRfF3743V4MvP4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=adwOQ+ul; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="adwOQ+ul" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20cdbe608b3so27196745ad.1 for ; Fri, 01 Nov 2024 17:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730508455; x=1731113255; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rKbz4vSUus6EYp9VxKs8/XhL54cjrUbDh/ERsiQ6PtM=; b=adwOQ+ulptzh7mPTE1sZIXOUc40NjrHVMTMCLYVcB/TtsPuMF2rVlX/nmXokgx21Rx zwH8NXAyRg5aVYs3FIAiJhfOvLhf3OI5GiVhuvka89ZrJ7LpssyXFZ463EL8h0pFWs0/ bU2AZckCczT0pibs32SgbmpK23iNSnwLwGuyv4hxNY+gQNqUlrHaHO7bJGNa89RSTDsy l3hJAk7Aa3GAbn3cMbIuQq9B+4BWWy2aLaAjCzFJduXXCEUK1rZE2L/Hxm1NShgtXcYu onSYuO6WZ6FztkorvSUqTRMhCWGWuaOpUqBLIPAzfeCXrPs/CaovDa8ZomSAhOOaNwYi JOBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730508455; x=1731113255; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rKbz4vSUus6EYp9VxKs8/XhL54cjrUbDh/ERsiQ6PtM=; b=TauGgHfgTInkY6/74fC3GW4UVHW+C+9aY5FNa0rreGA6YRMsJn8xZnm3AqtqyTbK0E 5644n0/SW1CiKeBg2JPReKORslm7IMCyGZtS9/TITjwkN1ampDq5rdsCP92+KY/Ek7lT ui/wVgPcYMoYD31FHf0pZn+QBL8PVPD5pxjGFwQWDP6DPePCWpHaYLayAWcpm5IKLhB3 C1j1CUFOz3Dgi8eI8wSxdVx/aV3n2X6AIfKQBDaZyAHb9iDsVYt6l1b4Ssdhv1g6UOrS yzM+QG33ynbqfCUIIjCk0tVYxXjs4kID71BhaZCEph8izV+aUd2TyvoFhvtn9gjVRE4Z 5kcQ== X-Forwarded-Encrypted: i=1; AJvYcCVbRvja7UVqI4r3NRd7I3sZSCZQ1ENdIe0ikLnVLhIU3waMFneLmxb0i2wcRYXvT2J+lKHI09l2c2feRj8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/8gJYjAI1ygRcRH5WhqQhpcSTRnImcQpCXutn06Vc+IhjR93h cAk3+4YqjL0NT3kbaTg5BC1TGTlf37/FxXHajX+wW7nuRK/rb+Uo X-Google-Smtp-Source: AGHT+IGfT+QrJhbzaGTno6I8tz8KNSs8v9qGiYh0kUt05lcdKhZ8kcN06zRDkuNtCztnf0KF3rr1yw== X-Received: by 2002:a17:902:ce83:b0:20c:d578:d712 with SMTP id d9443c01a7336-210f770832bmr161707145ad.59.1730508455235; Fri, 01 Nov 2024 17:47:35 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([59.16.200.168]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e92fa0f6edsm5642971a91.1.2024.11.01.17.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 17:47:34 -0700 (PDT) From: Gyeyoung Baek To: Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Gyeyoung Baek , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] drm/xe: Fix build error for XE_IOCTL_DBG macro Date: Sat, 2 Nov 2024 09:47:22 +0900 Message-Id: <20241102004722.124772-1-gye976@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable if CONFIG_DRM_USE_DYNAMIC_DEBUG is set, 'drm_dbg' function is replaced with '__dynamic_func_call_cls', which is replaced with a do while statement. so in the previous code, there are the following build errors. include/linux/dynamic_debug.h:221:58: error: expected expression before =E2= =80=98do=E2=80=99 221 | #define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ | ^~ include/linux/dynamic_debug.h:248:9: note: in expansion of macro =E2=80=98_= _dynamic_func_call_cls=E2=80=99 248 | __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func= , ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~ include/drm/drm_print.h:425:9: note: in expansion of macro =E2=80=98_dynami= c_func_call_cls=E2=80=99 425 | _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ | ^~~~~~~~~~~~~~~~~~~~~~ include/drm/drm_print.h:504:9: note: in expansion of macro =E2=80=98drm_dev= _dbg=E2=80=99 504 | drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, = ##__VA_ARGS__) | ^~~~~~~~~~~ include/drm/drm_print.h:522:33: note: in expansion of macro =E2=80=98drm_db= g_driver=E2=80=99 522 | #define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARG= S__) | ^~~~~~~~~~~~~~ drivers/gpu/drm/xe/xe_macros.h:14:21: note: in expansion of macro =E2=80=98= drm_dbg=E2=80=99 14 | ((cond) && (drm_dbg(&(xe)->drm, \ | ^~~~~~~ drivers/gpu/drm/xe/xe_bo.c:2029:13: note: in expansion of macro =E2=80=98XE= _IOCTL_DBG=E2=80=99 2029 | if (XE_IOCTL_DBG(xe, !gem_obj)) the problem is that, XE_IOCTL_DBG uses this function for conditional expr. so I fix the expr to be compatible with the do while statement, by referring to "https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html". v2: I modified this to print when only cond is true. v3: Modify to evaluate cond only once. Signed-off-by: Gyeyoung Baek --- drivers/gpu/drm/xe/xe_macros.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_macros.h b/drivers/gpu/drm/xe/xe_macros.h index daf56c846d03..b956acbe4000 100644 --- a/drivers/gpu/drm/xe/xe_macros.h +++ b/drivers/gpu/drm/xe/xe_macros.h @@ -10,9 +10,11 @@ =20 #define XE_WARN_ON WARN_ON =20 -#define XE_IOCTL_DBG(xe, cond) \ - ((cond) && (drm_dbg(&(xe)->drm, \ - "Ioctl argument check failed at %s:%d: %s", \ - __FILE__, __LINE__, #cond), 1)) - -#endif +#define XE_IOCTL_DBG(xe, cond) ({ \ + int cond__ =3D !!(cond); \ + if (cond__) \ + drm_dbg(&(xe)->drm, \ + "Ioctl argument check failed at %s:%d: %s", \ + __FILE__, __LINE__, #cond); \ + cond__; \ +}) --=20 2.34.1