Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dkms: add module load parameters #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions drivers/gpu/drm/i915/i915_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static bool intel_mmio_bar_valid(struct pci_dev *pdev, struct intel_device_info
return i915_pci_resource_valid(pdev, intel_mmio_bar(intel_info->__runtime.graphics.ip.ver));
}

extern int gfx_load_module(void *buf, int len);
extern int gfx_load_module(void *buf, int len, const char *kargs);

static void gfx_out_of_tree_load(struct device *dev)
{
Expand All @@ -1039,7 +1039,7 @@ static void gfx_out_of_tree_load(struct device *dev)
}
buf = __vmalloc((unsigned long)fw->size, GFP_KERNEL | __GFP_NOWARN);
memcpy(buf, fw->data, fw->size);
gfx_load_module(buf, fw->size);
gfx_load_module(buf, fw->size, NULL);
DRM_INFO("compat loaded\n");

err = firmware_request_nowarn(&fw, "i915/intel_vsec.ko", dev);
Expand All @@ -1049,7 +1049,7 @@ static void gfx_out_of_tree_load(struct device *dev)
}
buf = __vmalloc((unsigned long)fw->size, GFP_KERNEL | __GFP_NOWARN);
memcpy(buf, fw->data, fw->size);
gfx_load_module(buf, fw->size);
gfx_load_module(buf, fw->size, NULL);
DRM_INFO("intel_vsec loaded\n");

err = firmware_request_nowarn(&fw, "i915/i915_ag.ko", dev);
Expand All @@ -1059,7 +1059,7 @@ static void gfx_out_of_tree_load(struct device *dev)
}
buf = __vmalloc((unsigned long)fw->size, GFP_KERNEL | __GFP_NOWARN);
memcpy(buf, fw->data, fw->size);
gfx_load_module(buf, fw->size);
gfx_load_module(buf, fw->size, "nuclear_pageflip=1 enable_guc=0x7 max_vfs=7 modeset=1 fastboot=1");
DRM_INFO("i915_ag loaded\n");
}

Expand Down
20 changes: 12 additions & 8 deletions kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,7 +2739,7 @@ static int unknown_module_param_cb(char *param, char *val, const char *modname,
* zero, and we rely on this for optional sections.
*/
static int load_module(struct load_info *info, const char __user *uargs,
int flags, bool no_args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As load_moudle is a common API in kernel/module/main.c, if update the parameter format, will it impact other load module process?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no,
it's only extending for dGPU driver,
legacy working no changes.

const char *kargs, int flags, bool no_uargs)
{
struct module *mod;
long err = 0;
Expand Down Expand Up @@ -2866,7 +2866,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
flush_module_icache(mod);

/* Now copy in args */
if (!no_args) {
if (!no_uargs) {
mod->args = strndup_user(uargs, ~0UL >> 1);
if (IS_ERR(mod->args)) {
pr_debug("%s mod->args error\n", __func__);
Expand All @@ -2875,8 +2875,12 @@ static int load_module(struct load_info *info, const char __user *uargs,
}
pr_debug("%s mod->args: %llx \n", __func__, (u64)mod->args);
} else {
char *arg = "";
mod->args = kmemdup(arg, strlen(arg) + 1, GFP_KERNEL);
if (kargs)
mod->args = kmemdup(kargs, strlen(kargs) + 1, GFP_KERNEL);
else {
char *arg = "";
mod->args = kmemdup(arg, strlen(arg) + 1, GFP_KERNEL);
}
}

init_build_id(mod, info);
Expand Down Expand Up @@ -2989,7 +2993,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
if (err)
return err;

return load_module(&info, uargs, 0, false);
return load_module(&info, uargs, NULL, 0, false);
}

SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
Expand Down Expand Up @@ -3025,15 +3029,15 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
info.len = len;
}

return load_module(&info, uargs, flags, false);
return load_module(&info, uargs, NULL, flags, false);
}

int gfx_load_module(void *buf, int len)
int gfx_load_module(void *buf, int len, const char *kargs)
{
struct load_info info = { };
info.hdr = buf;
info.len = len;
return load_module(&info, NULL, 0, true);
return load_module(&info, NULL, kargs, 0, true);
}

static inline int within(unsigned long addr, void *start, unsigned long size)
Expand Down