issue with devcoredump.patch
With 4.10-rc1 the devcoredump.patch in patches/backport-adjustment no longer applies due to following commit:
commit f76d25275c314defb684fdd692239507001774bc
Author: Greg Kroah-Hartman <[email protected]> Date: Mon Nov 28 16:41:58 2016 +0100
driver core: devcoredump: convert to use class_groups
Convert devcoredump to use class_groups instead of class_attrs as that's the correct way to handle lists of class attribute files.
So I am reworking the patch file (attached). When I run gentree I get following:
Traceback (most recent call last):
File "./gentree.py", line 1091, in <module>
ret = _main()
File "./gentree.py", line 724, in _main
logwrite=logwrite)
File "./gentree.py", line 906, in process
apply_patches(args, "backport", source_dir, 'patches',
bpid.target_dir, logwrite)
File "./gentree.py", line 514, in apply_patches
raise Exception('No patch content found in %s' % print_name)
Exception: No patch content found in backport-adjustments/devcoredump.patch
However, go into the target dir and applying patch works fine:
$ patch -p1 < ~-/patches/backport-adjustments/devcoredump.patch patching file compat/drivers-base-devcoredump.c Hunk #7 succeeded at 181 with fuzz 1 (offset 2 lines). Hunk #8 succeeded at 248 (offset 2 lines). Hunk #9 succeeded at 339 (offset 2 lines). Hunk #10 succeeded at 386 (offset 2 lines). patching file include/linux/backport-devcoredump.h
So I am a bit puzzled as to what is going on so currently debugging lib/patch.py. If anyone has a good hint feel free to let me know.
Regards,
Arend
compat/drivers-base-devcoredump.c +16 -2
@@ -31,6 +31,7 @@#include <linux/slab.h> #include <linux/fs.h> #include <linux/workqueue.h> +#include "backports.h" static struct class devcd_class;
@@ -40,6 +41,10 @@ static bool devcd_disabled;/* if data isn't read by userspace after 5 minutes then delete it */ #define DEVCD_TIMEOUT (HZ * 60 * 5) +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,11 ,0 ) +static struct bin_attribute devcd_attr_data; +#endif +struct devcd_entry {struct device devcd_dev;void *data;
@@ -69,8 +74,7 @@ static void devcd_dev_release(struct device *dev)* a struct device to know when it goes away? */ if (devcd->failing_dev->kobj.sd) -sysfs_delete_link (&devcd->failing_dev->kobj, &dev->kobj, -"devcoredump" ); +sysfs_remove_link (&devcd->failing_dev->kobj,"devcoredump" );put_device (devcd->failing_dev);kfree (devcd);
@@ -82,6 +86,9 @@ static void devcd_del(struct work_struct *wk) devcd = container_of(wk, struct devcd_entry, del_wk.work); +#if LINUX_VERSION_CODE <KERNEL_VERSION (3 ,11 ,0 ) +device_remove_bin_file (&devcd->devcd_dev, &devcd_attr_data); +#endif device_del (&devcd->devcd_dev);put_device (&devcd->devcd_dev); }
@@ -115,6 +122,7 @@ static struct bin_attribute devcd_attr_data = { .write = devcd_data_write, }; +#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,11 ,0 )static struct bin_attribute *devcd_dev_bin_attrs[] = { &devcd_attr_data,NULL , };
@@ -126,6 +134,7 @@ static const struct attribute_group devcd_dev_group = {static const struct attribute_group *devcd_dev_groups[] = { &devcd_dev_group,NULL , }; +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) */ static int devcd_free (struct device *dev,void *data) {
@@ -170,7 +179,13 @@ static struct class devcd_class = { .name = "devcoredump", .owner = THIS_MODULE, .dev_release = devcd_dev_release, +#if LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,11 ,0 ) .dev_groups = devcd_dev_groups, +#endif +#if LINUX_VERSION_CODE <KERNEL_VERSION (4 ,10 ,0 ) + .class_attrs = devcd_class_attrs, +#else
.class_groups = devcd_class_groups,
+#endif
};
@@ -231,6 +242,14 @@ static void devcd_free_sgtable(void *data)
_devcd_free_sgtable(data);
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
+ void *buf, size_t buflen, off_t skip)
+{
+ return 0;
+}
+#endif
+
/**
* devcd_read_from_table - copy data from sg_table to a given buffer
* and return the number of bytes read
@@ -314,6 +333,11 @@ void dev_coredumpm(struct device *dev, struct module *owner,
if (device_add(&devcd->devcd_dev))
goto put_device;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+ if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
+ goto put_device;
+#endif
+
if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
"failing_device"))
/* nothing - symlink will be missing */;
@@ -356,15 +380,13 @@ void dev_coredumpsg(struct device *dev, struct scatterlist *table,
}
EXPORT_SYMBOL_GPL(dev_coredumpsg);
-static int __init devcoredump_init(void)
+int __init devcoredump_init(void)
{
return class_register(&devcd_class);
}
-__initcall(devcoredump_init);
-static void __exit devcoredump_exit(void)
+void __exit devcoredump_exit(void)
{
class_for_each_device(&devcd_class, NULL, NULL, devcd_free); class_unregister(&devcd_class);
}
-__exitcall(devcoredump_exit);
include/linux/backport-devcoredump.h +2 -2
@@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(struct scatterlist *table) } -#ifdef CONFIG_DEV_COREDUMP +#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP void dev_coredumpv (struct device *dev,void *data,size_t datalen,gfp_t gfp);
@@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct device *dev, struct scatterlist *table, {_devcd_free_sgtable (table); } -#endif /* CONFIG_DEV_COREDUMP */ +#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */ #endif /* __DEVCOREDUMP_H */
Quoted 40 lines · Arend Van Spriel
With 4.10-rc1 the devcoredump.patch in patches/backport-adjustment no longer applies due to following commit:
commit
f76d25275c314defb684fdd692239507001774bcAuthor: Greg Kroah-Hartman <[email protected]> Date: Mon Nov 28 16:41:58 2016 +0100driver core: devcoredump: convert to use
class_groupsConvert devcoredump to use
class_groupsinstead ofclass_attrsas that's the correct way to handle lists of class attribute files.Acked-by Johannes Berg <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>So I am reworking the patch file (attached). When I run gentree I get following:
Traceback (most recent call last):
File "./gentree.py", line 1091, in <module>ret = _main()File "./gentree.py", line 724, in
_main
logwrite=logwrite)
File "./gentree.py", line 906, in process
apply_patches(args, "backport",source_dir, 'patches',
bpid.target_dir, logwrite)
File "./gentree.py", line 514, inapply_patches
raiseException('No patch content found in %s' % print_name)
Exception: No patch content found inbackport-adjustments/devcoredump.patchHowever, go into the target dir and applying patch works fine:
$ patch -p1 < ~-/patches/backport-adjustments/devcoredump.patch patching file compat/drivers-base-devcoredump.c Hunk #7 succeeded at 181 with fuzz 1 (offset 2 lines). Hunk #8 succeeded at 248 (offset 2 lines). Hunk #9 succeeded at 339 (offset 2 lines). Hunk #10 succeeded at 386 (offset 2 lines). patching file include/linux/backport-devcoredump.h
Quoted 2 lines
So I am a bit puzzled as to what is going on so currently debugging
lib/patch.py. If anyone has a good hint feel free to let me know.
Turns out that at line 70 of the patch file there is no single space before the tab, which lib/patch.py marks as an error. With that fixed the fun really starts as I get following code:
static CLASS_ATTR_RW(disabled);
static struct attribute *devcd_class_attrs[] = {
&class_attr_disabled.attr,
NULL,
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)ATTRIBUTE_GROUPS(devcd_class);
#else
#define BP_ATTR_GRP_STRUCT device_attributeATTRIBUTE_GROUPS_BACKPORT(devcd_class);
#endif
static struct class devcd_class = {
.name = "devcoredump",
.owner = THIS_MODULE,
.dev_release = devcd_dev_release,#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
.dev_groups = devcd_dev_groups,
#else
.dev_attrs = devcd_class_dev_attrs,
#endif
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
.class_attrs = devcd_class_attrs,
#else
.class_groups = devcd_class_groups,
#endif
};
This is because the new devcoredump.c in 4.10-rc1 now triggers a Coccinelle script to kick in, ie. patches/collateral-evolutions/generic/0001-group-attr/0001-group_attr_class.cocci. It seems to kick in because of the ATTRIBUTE_GROUPS(devcd_class) macro.
Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Hey Arend,
Quoted 35 lines · Arend Van Spriel
Turns out that at line 70 of the patch file there is no single space before the tab, which
lib/patch.pymarks as an error. With that fixed the fun really starts as I get following code:static
CLASS_ATTR_RW(disabled);static struct attribute *devcd_class_attrs[] = {
&class_attr_disabled.attr,
NULL,
};
#ifLINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)ATTRIBUTE_GROUPS(devcd_class);
#else
#defineBP_ATTR_GRP_STRUCTdevice_attributeATTRIBUTE_GROUPS_BACKPORT(devcd_class);
#endifstatic struct class
devcd_class= {.name = "devcoredump", .owner = THIS_MODULE, .dev_release = devcd_dev_release,#if
LINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)
#ifLINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)
.dev_groups =devcd_dev_groups,
#else
.dev_attrs =devcd_class_dev_attrs,
#endif
#endif
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,10,0)
.class_attrs =devcd_class_attrs,
#else
.class_groups =devcd_class_groups,
#endif
};
Quoted 4 lines
This is because the new
devcoredump.cin 4.10-rc1 now triggers a Coccinelle script to kick in, ie.patches/collateral-evolutions/generic/0001-group-attr/0001-group_attr_class.cocci. It seems to kick in because of theATTRIBUTE_GROUPS(devcd_class)macro.
Did you ever get this to work? I'm getting this warnings:
home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:197:3: warning: initialization from incompatible pointer type [enabled by default]
.class_attrs = devcd_class_attrs,
^/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:197:3: warning: (near initialization for ‘devcd_class.class_attrs’) [enabled by default] In file included from /home/luca/iwlwifi/stack-dev/backport-include/linux/sysfs.h:3:0,
from include/linux/kobject.h:21,
from include/linux/module.h:17,
from /home/luca/iwlwifi/stack-dev/backport-include/linux/module.h:3,
from /home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:27:/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:179:18: warning: ‘devcd_class_groups’ defined but not used [-Wunused-variable]
ATTRIBUTE_GROUPS(devcd_class);
^
include/linux/sysfs.h:131:38: note: in definition of macro ‘__ATTRIBUTE_GROUPS’
static const struct attribute_group *_name##_groups[] = { \
^/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:179:1: note: in expansion of macro ‘ATTRIBUTE_GROUPS’
ATTRIBUTE_GROUPS(devcd_class);
^
Any idea how to fix it?
--
Cheers,
Luca.
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Quoted 60 lines · Luca Coelho
Hey Arend,
Quoted 35 lines · Arend Van Spriel
Turns out that at line 70 of the patch file there is no single space before the tab, which
lib/patch.pymarks as an error. With that fixed the fun really starts as I get following code:static
CLASS_ATTR_RW(disabled);static struct attribute *devcd_class_attrs[] = {
&class_attr_disabled.attr,
NULL,
};
#ifLINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)ATTRIBUTE_GROUPS(devcd_class);
#else
#defineBP_ATTR_GRP_STRUCTdevice_attributeATTRIBUTE_GROUPS_BACKPORT(devcd_class);
#endifstatic struct class
devcd_class= {.name = "devcoredump", .owner = THIS_MODULE, .dev_release = devcd_dev_release,#if
LINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)
#ifLINUX_VERSION_CODE>=KERNEL_VERSION(3,11,0)
.dev_groups =devcd_dev_groups,
#else
.dev_attrs =devcd_class_dev_attrs,
#endif
#endif
#ifLINUX_VERSION_CODE<KERNEL_VERSION(4,10,0)
.class_attrs =devcd_class_attrs,
#else
.class_groups =devcd_class_groups,
#endif
};Quoted 4 lines
This is because the new
devcoredump.cin 4.10-rc1 now triggers a Coccinelle script to kick in, ie.patches/collateral-evolutions/generic/0001-group-attr/0001-group_attr_class.cocci. It seems to kick in because of theATTRIBUTE_GROUPS(devcd_class)macro.Did you ever get this to work? I'm getting this warnings:
home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:197:3: warning: initialization from incompatible pointer type [enabled by default]
.class_attrs =devcd_class_attrs,
^/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:197:3: warning: (near initialization for ‘devcd_class.class_attrs’) [enabled by default] In file included from/home/luca/iwlwifi/stack-dev/backport-include/linux/sysfs.h:3:0,
frominclude/linux/kobject.h:21,
frominclude/linux/module.h:17,
from/home/luca/iwlwifi/stack-dev/backport-include/linux/module.h:3,
from/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:27:/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:179:18: warning: ‘devcd_class_groups’ defined but not used [-Wunused-variable]ATTRIBUTE_GROUPS(devcd_class); ^ include/linux/sysfs.h:131:38: note: in definition of macro ‘__ATTRIBUTE_GROUPS’ static const struct attribute_group *_name##_groups[] = { \ ^
Quoted 5 lines
/home/luca/iwlwifi/stack-dev/compat/drivers-base-devcoredump.c:179:1: note: in expansion of macro ‘ATTRIBUTE_GROUPS’
ATTRIBUTE_GROUPS(devcd_class);
^Any idea how to fix it?
Yeah. This is what I hit after fixing the devcoredump.patch. Because of the recent change in drivers/base/devcoredump.c I think 0001-group_attr_class.cocci needs to be quite a bit smarter. My SmPL knowledge is still somewhat limited so I did not get it working properly. Maybe posting the problem (in simplified form) on the Cocci mailing list will get us a solution.
Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe backports" in