Skip to content

Commit f5527be

Browse files
committed
Merge: [RHEL9.5] DMA Engine Updates
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3948 # Merge Request Required Information JIRA: https://issues.redhat.com/browse/RHEL-28792 JIRA: https://issues.redhat.com/browse/RHEL-28869 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git CVE: CVE-2023-52492 Tested: dsa_user_test_runner, iaa_user_test_runner for idxd driver. dmatest for idxd legacy support, ioat, ptdma ## Summary of Changes This rebases the supported dma engine subsystem drivers to 6.9-rc1. It contains various fixes, and updating some drivers to use new platform remove callback. It also completes the driver core change to constify the bus_type struct in the device and device_driver structs, which required a commit to modify rhel-only code in the vfio driver. ## Approved Development Ticket All submissions to CentOS Stream must reference an approved ticket in [Red Hat Jira](https://issues.redhat.com/). Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved. Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: John W. Linville <linville@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Andrew Halaney <ahalaney@redhat.com> Approved-by: Jocelyn Falempe <jfalempe@redhat.com> Approved-by: Myron Stowe <mstowe@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents d35f664 + bf9cb57 commit f5527be

File tree

33 files changed

+120
-134
lines changed

33 files changed

+120
-134
lines changed

drivers/base/bus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
10301030
list_move_tail(&a->p->knode_bus.n_node, list);
10311031
}
10321032

1033-
void bus_sort_breadthfirst(struct bus_type *bus,
1033+
void bus_sort_breadthfirst(const struct bus_type *bus,
10341034
int (*compare)(const struct device *a,
10351035
const struct device *b))
10361036
{
@@ -1194,7 +1194,7 @@ static void system_root_device_release(struct device *dev)
11941194
kfree(dev);
11951195
}
11961196

1197-
static int subsys_register(struct bus_type *subsys,
1197+
static int subsys_register(const struct bus_type *subsys,
11981198
const struct attribute_group **groups,
11991199
struct kobject *parent_of_root)
12001200
{
@@ -1264,7 +1264,7 @@ static int subsys_register(struct bus_type *subsys,
12641264
* directory itself and not some create fake root-device placed in
12651265
* /sys/devices/system/<name>.
12661266
*/
1267-
int subsys_system_register(struct bus_type *subsys,
1267+
int subsys_system_register(const struct bus_type *subsys,
12681268
const struct attribute_group **groups)
12691269
{
12701270
return subsys_register(subsys, groups, &system_kset->kobj);
@@ -1282,7 +1282,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register);
12821282
* There's no restriction on device naming. This is for kernel software
12831283
* constructs which need sysfs interface.
12841284
*/
1285-
int subsys_virtual_register(struct bus_type *subsys,
1285+
int subsys_virtual_register(const struct bus_type *subsys,
12861286
const struct attribute_group **groups)
12871287
{
12881288
struct kobject *virtual_dir;

drivers/base/power/clock_ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int pm_clk_notify(struct notifier_block *nb,
793793
* the remaining members of @clknb should be populated prior to calling this
794794
* routine.
795795
*/
796-
void pm_clk_add_notifier(struct bus_type *bus,
796+
void pm_clk_add_notifier(const struct bus_type *bus,
797797
struct pm_clk_notifier_block *clknb)
798798
{
799799
if (!bus || !clknb)

drivers/dma/dmaengine.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,9 @@ EXPORT_SYMBOL_GPL(dma_async_device_channel_register);
11031103
static void __dma_async_device_channel_unregister(struct dma_device *device,
11041104
struct dma_chan *chan)
11051105
{
1106+
if (chan->local == NULL)
1107+
return;
1108+
11061109
WARN_ONCE(!device->device_release && chan->client_count,
11071110
"%s called while %d clients hold a reference\n",
11081111
__func__, chan->client_count);

drivers/dma/dmatest.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include <linux/slab.h>
2222
#include <linux/wait.h>
2323

24+
static bool nobounce;
25+
module_param(nobounce, bool, 0644);
26+
MODULE_PARM_DESC(nobounce, "Prevent using swiotlb buffer (default: use swiotlb buffer)");
27+
2428
static unsigned int test_buf_size = 16384;
2529
module_param(test_buf_size, uint, 0644);
2630
MODULE_PARM_DESC(test_buf_size, "Size of the memcpy test buffer");
@@ -90,6 +94,7 @@ MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts");
9094

9195
/**
9296
* struct dmatest_params - test parameters.
97+
* @nobounce: prevent using swiotlb buffer
9398
* @buf_size: size of the memcpy test buffer
9499
* @channel: bus ID of the channel to test
95100
* @device: bus ID of the DMA Engine to test
@@ -106,6 +111,7 @@ MODULE_PARM_DESC(polled, "Use polling for completion instead of interrupts");
106111
* @polled: use polling for completion instead of interrupts
107112
*/
108113
struct dmatest_params {
114+
bool nobounce;
109115
unsigned int buf_size;
110116
char channel[20];
111117
char device[32];
@@ -215,6 +221,7 @@ struct dmatest_done {
215221
struct dmatest_data {
216222
u8 **raw;
217223
u8 **aligned;
224+
gfp_t gfp_flags;
218225
unsigned int cnt;
219226
unsigned int off;
220227
};
@@ -533,7 +540,7 @@ static int dmatest_alloc_test_data(struct dmatest_data *d,
533540
goto err;
534541

535542
for (i = 0; i < d->cnt; i++) {
536-
d->raw[i] = kmalloc(buf_size + align, GFP_KERNEL);
543+
d->raw[i] = kmalloc(buf_size + align, d->gfp_flags);
537544
if (!d->raw[i])
538545
goto err;
539546

@@ -655,6 +662,13 @@ static int dmatest_func(void *data)
655662
goto err_free_coefs;
656663
}
657664

665+
src->gfp_flags = GFP_KERNEL;
666+
dst->gfp_flags = GFP_KERNEL;
667+
if (params->nobounce) {
668+
src->gfp_flags = GFP_DMA;
669+
dst->gfp_flags = GFP_DMA;
670+
}
671+
658672
if (dmatest_alloc_test_data(src, buf_size, align) < 0)
659673
goto err_free_coefs;
660674

@@ -1093,6 +1107,7 @@ static void add_threaded_test(struct dmatest_info *info)
10931107
struct dmatest_params *params = &info->params;
10941108

10951109
/* Copy test parameters */
1110+
params->nobounce = nobounce;
10961111
params->buf_size = test_buf_size;
10971112
strscpy(params->channel, strim(test_channel), sizeof(params->channel));
10981113
strscpy(params->device, strim(test_device), sizeof(params->device));

drivers/dma/dw/platform.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int dw_probe(struct platform_device *pdev)
9393
return err;
9494
}
9595

96-
static int dw_remove(struct platform_device *pdev)
96+
static void dw_remove(struct platform_device *pdev)
9797
{
9898
struct dw_dma_chip_pdata *data = platform_get_drvdata(pdev);
9999
struct dw_dma_chip *chip = data->chip;
@@ -109,8 +109,6 @@ static int dw_remove(struct platform_device *pdev)
109109

110110
pm_runtime_disable(&pdev->dev);
111111
clk_disable_unprepare(chip->clk);
112-
113-
return 0;
114112
}
115113

116114
static void dw_shutdown(struct platform_device *pdev)
@@ -192,7 +190,7 @@ static const struct dev_pm_ops dw_dev_pm_ops = {
192190

193191
static struct platform_driver dw_driver = {
194192
.probe = dw_probe,
195-
.remove = dw_remove,
193+
.remove_new = dw_remove,
196194
.shutdown = dw_shutdown,
197195
.driver = {
198196
.name = DRV_NAME,

drivers/dma/idma64.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,11 @@ static int idma64_platform_probe(struct platform_device *pdev)
660660
return 0;
661661
}
662662

663-
static int idma64_platform_remove(struct platform_device *pdev)
663+
static void idma64_platform_remove(struct platform_device *pdev)
664664
{
665665
struct idma64_chip *chip = platform_get_drvdata(pdev);
666666

667667
idma64_remove(chip);
668-
669-
return 0;
670668
}
671669

672670
static int __maybe_unused idma64_pm_suspend(struct device *dev)
@@ -691,7 +689,7 @@ static const struct dev_pm_ops idma64_dev_pm_ops = {
691689

692690
static struct platform_driver idma64_platform_driver = {
693691
.probe = idma64_platform_probe,
694-
.remove = idma64_platform_remove,
692+
.remove_new = idma64_platform_remove,
695693
.driver = {
696694
.name = LPSS_IDMA64_DRIVER_NAME,
697695
.pm = &idma64_dev_pm_ops,

drivers/dma/idxd/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE=IDXD
22

3+
obj-$(CONFIG_INTEL_IDXD_BUS) += idxd_bus.o
4+
idxd_bus-y := bus.o
5+
36
obj-$(CONFIG_INTEL_IDXD) += idxd.o
47
idxd-y := init.o irq.o device.o sysfs.o submit.o dma.o cdev.o debugfs.o defaults.o
58

69
idxd-$(CONFIG_INTEL_IDXD_PERFMON) += perfmon.o
710

8-
obj-$(CONFIG_INTEL_IDXD_BUS) += idxd_bus.o
9-
idxd_bus-y := bus.o
10-
1111
obj-$(CONFIG_INTEL_IDXD_COMPAT) += idxd_compat.o
1212
idxd_compat-y := compat.o

drivers/dma/idxd/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int idxd_bus_uevent(const struct device *dev, struct kobj_uevent_env *env
7272
return add_uevent_var(env, "MODALIAS=" IDXD_DEVICES_MODALIAS_FMT, 0);
7373
}
7474

75-
struct bus_type dsa_bus_type = {
75+
const struct bus_type dsa_bus_type = {
7676
.name = "dsa",
7777
.match = idxd_config_bus_match,
7878
.probe = idxd_config_bus_probe,

drivers/dma/idxd/cdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void idxd_file_dev_release(struct device *dev)
152152
mutex_unlock(&wq->wq_lock);
153153
}
154154

155-
static struct device_type idxd_cdev_file_type = {
155+
static const struct device_type idxd_cdev_file_type = {
156156
.name = "idxd_file",
157157
.release = idxd_file_dev_release,
158158
.groups = cdev_file_attribute_groups,
@@ -165,11 +165,11 @@ static void idxd_cdev_dev_release(struct device *dev)
165165
struct idxd_wq *wq = idxd_cdev->wq;
166166

167167
cdev_ctx = &ictx[wq->idxd->data->type];
168-
ida_simple_remove(&cdev_ctx->minor_ida, idxd_cdev->minor);
168+
ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor);
169169
kfree(idxd_cdev);
170170
}
171171

172-
static struct device_type idxd_cdev_device_type = {
172+
static const struct device_type idxd_cdev_device_type = {
173173
.name = "idxd_cdev",
174174
.release = idxd_cdev_dev_release,
175175
};
@@ -463,7 +463,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
463463
cdev = &idxd_cdev->cdev;
464464
dev = cdev_dev(idxd_cdev);
465465
cdev_ctx = &ictx[wq->idxd->data->type];
466-
minor = ida_simple_get(&cdev_ctx->minor_ida, 0, MINORMASK, GFP_KERNEL);
466+
minor = ida_alloc_max(&cdev_ctx->minor_ida, MINORMASK, GFP_KERNEL);
467467
if (minor < 0) {
468468
kfree(idxd_cdev);
469469
return minor;

drivers/dma/idxd/idxd.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ typedef int (*load_device_defaults_fn_t) (struct idxd_device *idxd);
282282
struct idxd_driver_data {
283283
const char *name_prefix;
284284
enum idxd_type type;
285-
struct device_type *dev_type;
285+
const struct device_type *dev_type;
286286
int compl_size;
287287
int align;
288288
int evl_cr_off;
@@ -515,15 +515,15 @@ static inline void idxd_set_user_intr(struct idxd_device *idxd, bool enable)
515515
iowrite32(reg.bits, idxd->reg_base + IDXD_GENCFG_OFFSET);
516516
}
517517

518-
extern struct bus_type dsa_bus_type;
518+
extern const struct bus_type dsa_bus_type;
519519

520520
extern bool support_enqcmd;
521521
extern struct ida idxd_ida;
522-
extern struct device_type dsa_device_type;
523-
extern struct device_type iax_device_type;
524-
extern struct device_type idxd_wq_device_type;
525-
extern struct device_type idxd_engine_device_type;
526-
extern struct device_type idxd_group_device_type;
522+
extern const struct device_type dsa_device_type;
523+
extern const struct device_type iax_device_type;
524+
extern const struct device_type idxd_wq_device_type;
525+
extern const struct device_type idxd_engine_device_type;
526+
extern const struct device_type idxd_group_device_type;
527527

528528
static inline bool is_dsa_dev(struct idxd_dev *idxd_dev)
529529
{

0 commit comments

Comments
 (0)