diff --git a/drivers/char/svm.c b/drivers/char/svm.c index 83e575705cf024de014303b9f08211c2577f96cf..fce9f99572ef227b34ef2ae7e2e268dae5c0138a 100644 --- a/drivers/char/svm.c +++ b/drivers/char/svm.c @@ -1012,6 +1012,30 @@ static const struct file_operations svm_fops = { .open = svm_open, .unlocked_ioctl = svm_ioctl, }; + +#ifndef CONFIG_ACPI +static int svm_setup_l2buff(struct svm_device *sdev, struct device_node *np) +{ + struct device_node *l2buff = of_parse_phandle(np, "memory-region", 0); + + if (l2buff) { + struct resource r; + int err = of_address_to_resource(l2buff, 0, &r); + + if (err) { + of_node_put(l2buff); + return err; + } + + sdev->l2buff = r.start; + sdev->l2size = resource_size(&r); + } + + of_node_put(l2buff); + return 0; +} +#endif + /*svm device probe this is init the svm device*/ static int svm_device_probe(struct platform_device *pdev) { @@ -1066,6 +1090,14 @@ static int svm_device_probe(struct platform_device *pdev) #ifdef CONFIG_ACPI err = svm_init_core(sdev); #else + /* + * Get the l2buff phys address and size, if it do not exist + * just warn and continue, and runtime can not use L2BUFF. + */ + err = svm_setup_l2buff(sdev, np); + if (err) + dev_warn(dev, "Cannot get l2buff\n"); + err = svm_init_core(sdev, np); #endif