Commit 86f40bb6 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Match bitmask size to types in intel_fb_initial_config()

smatch complains of:
	drivers/gpu/drm/i915/intel_fbdev.c:403
	intel_fb_initial_config() warn: should '1 << i' be a 64 bit type?
	drivers/gpu/drm/i915/intel_fbdev.c:422 intel_fb_initial_config() warn:
	should '1 << i' be a 64 bit type?
	drivers/gpu/drm/i915/intel_fbdev.c:501 intel_fb_initial_config() warn:
	should '1 << i' be a 64 bit type?

We are prepared to iterate over a u64 but don't limit the number of
connectors we try to configure to a maximum of 64.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1467470166-31717-5-git-send-email-chris@chris-wilson.co.ukReviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
parent a98b7e58
...@@ -362,23 +362,24 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -362,23 +362,24 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
bool *enabled, int width, int height) bool *enabled, int width, int height)
{ {
struct drm_device *dev = fb_helper->dev; struct drm_device *dev = fb_helper->dev;
unsigned long conn_configured, mask;
unsigned int count = min(fb_helper->connector_count, BITS_PER_LONG);
int i, j; int i, j;
bool *save_enabled; bool *save_enabled;
bool fallback = true; bool fallback = true;
int num_connectors_enabled = 0; int num_connectors_enabled = 0;
int num_connectors_detected = 0; int num_connectors_detected = 0;
uint64_t conn_configured = 0, mask;
int pass = 0; int pass = 0;
save_enabled = kcalloc(fb_helper->connector_count, sizeof(bool), save_enabled = kcalloc(count, sizeof(bool), GFP_KERNEL);
GFP_KERNEL);
if (!save_enabled) if (!save_enabled)
return false; return false;
memcpy(save_enabled, enabled, fb_helper->connector_count); memcpy(save_enabled, enabled, count);
mask = (1 << fb_helper->connector_count) - 1; mask = BIT(count) - 1;
conn_configured = 0;
retry: retry:
for (i = 0; i < fb_helper->connector_count; i++) { for (i = 0; i < count; i++) {
struct drm_fb_helper_connector *fb_conn; struct drm_fb_helper_connector *fb_conn;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
...@@ -388,7 +389,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -388,7 +389,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
fb_conn = fb_helper->connector_info[i]; fb_conn = fb_helper->connector_info[i];
connector = fb_conn->connector; connector = fb_conn->connector;
if (conn_configured & (1 << i)) if (conn_configured & BIT(i))
continue; continue;
if (pass == 0 && !connector->has_tile) if (pass == 0 && !connector->has_tile)
...@@ -400,7 +401,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -400,7 +401,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
if (!enabled[i]) { if (!enabled[i]) {
DRM_DEBUG_KMS("connector %s not enabled, skipping\n", DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
connector->name); connector->name);
conn_configured |= (1 << i); conn_configured |= BIT(i);
continue; continue;
} }
...@@ -419,7 +420,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -419,7 +420,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n", DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n",
connector->name); connector->name);
enabled[i] = false; enabled[i] = false;
conn_configured |= (1 << i); conn_configured |= BIT(i);
continue; continue;
} }
...@@ -432,14 +433,15 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -432,14 +433,15 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
intel_crtc->lut_b[j] = j; intel_crtc->lut_b[j] = j;
} }
new_crtc = intel_fb_helper_crtc(fb_helper, connector->state->crtc); new_crtc = intel_fb_helper_crtc(fb_helper,
connector->state->crtc);
/* /*
* Make sure we're not trying to drive multiple connectors * Make sure we're not trying to drive multiple connectors
* with a single CRTC, since our cloning support may not * with a single CRTC, since our cloning support may not
* match the BIOS. * match the BIOS.
*/ */
for (j = 0; j < fb_helper->connector_count; j++) { for (j = 0; j < count; j++) {
if (crtcs[j] == new_crtc) { if (crtcs[j] == new_crtc) {
DRM_DEBUG_KMS("fallback: cloned configuration\n"); DRM_DEBUG_KMS("fallback: cloned configuration\n");
goto bail; goto bail;
...@@ -498,7 +500,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -498,7 +500,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :""); modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :"");
fallback = false; fallback = false;
conn_configured |= (1 << i); conn_configured |= BIT(i);
} }
if ((conn_configured & mask) != mask) { if ((conn_configured & mask) != mask) {
...@@ -522,7 +524,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, ...@@ -522,7 +524,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
if (fallback) { if (fallback) {
bail: bail:
DRM_DEBUG_KMS("Not using firmware configuration\n"); DRM_DEBUG_KMS("Not using firmware configuration\n");
memcpy(enabled, save_enabled, fb_helper->connector_count); memcpy(enabled, save_enabled, count);
kfree(save_enabled); kfree(save_enabled);
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment