* [PATCH v4 0/7] wrappers for fpga_manager_ops
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
As followup from
https://lore.kernel.org/linux-fpga/06301910-10a1-0e62-45a0-d28ab5a787ed@redhat.com/
Boards should not be required to have noop functions.
So improve or create fpga-mgr wrappers for the fpga_manager_ops.
Remove the noop functions.
Refactor fpga-mgr to use the wrappers.
Changes from
v1:
commit subject,log
v2:
rebase to next-20210623
v3:
remove mops check
add write_sg wrapper
drop 'fpga-mgr: collect wappers and change to inline'
Tom Rix (7):
fpga-mgr: wrap the write_init() op
fpga-mgr: make write_complete() op optional
fpga-mgr: wrap the write() op
fpga-mgr: wrap the status() op
fpga-mgr: wrap the state() op
fpga-mgr: wrap the fpga_remove() op
fpga-mgr: wrap the write_sg() op
drivers/fpga/dfl-fme-mgr.c | 6 --
drivers/fpga/fpga-mgr.c | 111 +++++++++++++++++++++++------------
drivers/fpga/stratix10-soc.c | 6 --
drivers/fpga/ts73xx-fpga.c | 6 --
drivers/fpga/zynqmp-fpga.c | 7 ---
5 files changed, 75 insertions(+), 61 deletions(-)
--
2.26.3
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 0/7] wrappers for fpga_manager_ops
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
As followup from
https://lore.kernel.org/linux-fpga/06301910-10a1-0e62-45a0-d28ab5a787ed@redhat.com/
Boards should not be required to have noop functions.
So improve or create fpga-mgr wrappers for the fpga_manager_ops.
Remove the noop functions.
Refactor fpga-mgr to use the wrappers.
Changes from
v1:
commit subject,log
v2:
rebase to next-20210623
v3:
remove mops check
add write_sg wrapper
drop 'fpga-mgr: collect wappers and change to inline'
Tom Rix (7):
fpga-mgr: wrap the write_init() op
fpga-mgr: make write_complete() op optional
fpga-mgr: wrap the write() op
fpga-mgr: wrap the status() op
fpga-mgr: wrap the state() op
fpga-mgr: wrap the fpga_remove() op
fpga-mgr: wrap the write_sg() op
drivers/fpga/dfl-fme-mgr.c | 6 --
drivers/fpga/fpga-mgr.c | 111 +++++++++++++++++++++++------------
drivers/fpga/stratix10-soc.c | 6 --
drivers/fpga/ts73xx-fpga.c | 6 --
drivers/fpga/zynqmp-fpga.c | 7 ---
5 files changed, 75 insertions(+), 61 deletions(-)
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_init() op if there is nothing for it do.
So add a wrapper and move the op checking.
Default to success.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index ecb4c3c795fa5..c047de8a059b7 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,15 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
+ struct fpga_image_info *info,
+ const char *buf, size_t count)
+{
+ if (mgr->mops->write_init)
+ return mgr->mops->write_init(mgr, info, buf, count);
+ return 0;
+}
+
/**
* fpga_image_info_alloc - Allocate an FPGA image info struct
* @dev: owning device
@@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
mgr->state = FPGA_MGR_STATE_WRITE_INIT;
if (!mgr->mops->initial_header_size)
- ret = mgr->mops->write_init(mgr, info, NULL, 0);
+ ret = fpga_mgr_write_init(mgr, info, NULL, 0);
else
- ret = mgr->mops->write_init(
+ ret = fpga_mgr_write_init(
mgr, info, buf, min(mgr->mops->initial_header_size, count));
if (ret) {
@@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
int id, ret;
if (!mops || !mops->write_complete || !mops->state ||
- !mops->write_init || (!mops->write && !mops->write_sg) ||
+ (!mops->write && !mops->write_sg) ||
(mops->write && mops->write_sg)) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_init() op if there is nothing for it do.
So add a wrapper and move the op checking.
Default to success.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index ecb4c3c795fa5..c047de8a059b7 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,15 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
+ struct fpga_image_info *info,
+ const char *buf, size_t count)
+{
+ if (mgr->mops->write_init)
+ return mgr->mops->write_init(mgr, info, buf, count);
+ return 0;
+}
+
/**
* fpga_image_info_alloc - Allocate an FPGA image info struct
* @dev: owning device
@@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
mgr->state = FPGA_MGR_STATE_WRITE_INIT;
if (!mgr->mops->initial_header_size)
- ret = mgr->mops->write_init(mgr, info, NULL, 0);
+ ret = fpga_mgr_write_init(mgr, info, NULL, 0);
else
- ret = mgr->mops->write_init(
+ ret = fpga_mgr_write_init(
mgr, info, buf, min(mgr->mops->initial_header_size, count));
if (ret) {
@@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
int id, ret;
if (!mops || !mops->write_complete || !mops->state ||
- !mops->write_init || (!mops->write && !mops->write_sg) ||
+ (!mops->write && !mops->write_sg) ||
(mops->write && mops->write_sg)) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 2/7] fpga-mgr: make write_complete() op optional
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_complete function if there is nothing. Move
the op check to the existing wrapper.
Default to success.
Remove noop function.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 45 +++++++++++++++++++-------------------
drivers/fpga/zynqmp-fpga.c | 7 ------
2 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index c047de8a059b7..05a69ab3ecb9e 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,28 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+/*
+ * After all the FPGA image has been written, do the device specific steps to
+ * finish and set the FPGA into operating mode.
+ */
+static inline int fpga_mgr_write_complete(struct fpga_manager *mgr,
+ struct fpga_image_info *info)
+{
+ int ret = 0;
+
+ mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE;
+ if (mgr->mops->write_complete)
+ ret = mgr->mops->write_complete(mgr, info);
+ if (ret) {
+ dev_err(&mgr->dev, "Error after writing image data to FPGA\n");
+ mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR;
+ return ret;
+ }
+ mgr->state = FPGA_MGR_STATE_OPERATING;
+
+ return 0;
+}
+
static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
@@ -146,27 +168,6 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr,
return ret;
}
-/*
- * After all the FPGA image has been written, do the device specific steps to
- * finish and set the FPGA into operating mode.
- */
-static int fpga_mgr_write_complete(struct fpga_manager *mgr,
- struct fpga_image_info *info)
-{
- int ret;
-
- mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE;
- ret = mgr->mops->write_complete(mgr, info);
- if (ret) {
- dev_err(&mgr->dev, "Error after writing image data to FPGA\n");
- mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR;
- return ret;
- }
- mgr->state = FPGA_MGR_STATE_OPERATING;
-
- return 0;
-}
-
/**
* fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list
* @mgr: fpga manager
@@ -577,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->write_complete || !mops->state ||
+ if (!mops || !mops->state ||
(!mops->write && !mops->write_sg) ||
(mops->write && mops->write_sg)) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index 125743c9797ff..9efbd70aa6864 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -66,12 +66,6 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
return ret;
}
-static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr,
- struct fpga_image_info *info)
-{
- return 0;
-}
-
static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
{
u32 status = 0;
@@ -87,7 +81,6 @@ static const struct fpga_manager_ops zynqmp_fpga_ops = {
.state = zynqmp_fpga_ops_state,
.write_init = zynqmp_fpga_ops_write_init,
.write = zynqmp_fpga_ops_write,
- .write_complete = zynqmp_fpga_ops_write_complete,
};
static int zynqmp_fpga_probe(struct platform_device *pdev)
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 2/7] fpga-mgr: make write_complete() op optional
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_complete function if there is nothing. Move
the op check to the existing wrapper.
Default to success.
Remove noop function.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 45 +++++++++++++++++++-------------------
drivers/fpga/zynqmp-fpga.c | 7 ------
2 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index c047de8a059b7..05a69ab3ecb9e 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,28 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+/*
+ * After all the FPGA image has been written, do the device specific steps to
+ * finish and set the FPGA into operating mode.
+ */
+static inline int fpga_mgr_write_complete(struct fpga_manager *mgr,
+ struct fpga_image_info *info)
+{
+ int ret = 0;
+
+ mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE;
+ if (mgr->mops->write_complete)
+ ret = mgr->mops->write_complete(mgr, info);
+ if (ret) {
+ dev_err(&mgr->dev, "Error after writing image data to FPGA\n");
+ mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR;
+ return ret;
+ }
+ mgr->state = FPGA_MGR_STATE_OPERATING;
+
+ return 0;
+}
+
static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
@@ -146,27 +168,6 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr,
return ret;
}
-/*
- * After all the FPGA image has been written, do the device specific steps to
- * finish and set the FPGA into operating mode.
- */
-static int fpga_mgr_write_complete(struct fpga_manager *mgr,
- struct fpga_image_info *info)
-{
- int ret;
-
- mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE;
- ret = mgr->mops->write_complete(mgr, info);
- if (ret) {
- dev_err(&mgr->dev, "Error after writing image data to FPGA\n");
- mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR;
- return ret;
- }
- mgr->state = FPGA_MGR_STATE_OPERATING;
-
- return 0;
-}
-
/**
* fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list
* @mgr: fpga manager
@@ -577,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->write_complete || !mops->state ||
+ if (!mops || !mops->state ||
(!mops->write && !mops->write_sg) ||
(mops->write && mops->write_sg)) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index 125743c9797ff..9efbd70aa6864 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -66,12 +66,6 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
return ret;
}
-static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr,
- struct fpga_image_info *info)
-{
- return 0;
-}
-
static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr)
{
u32 status = 0;
@@ -87,7 +81,6 @@ static const struct fpga_manager_ops zynqmp_fpga_ops = {
.state = zynqmp_fpga_ops_state,
.write_init = zynqmp_fpga_ops_write_init,
.write = zynqmp_fpga_ops_write,
- .write_complete = zynqmp_fpga_ops_write_complete,
};
static int zynqmp_fpga_probe(struct platform_device *pdev)
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 3/7] fpga-mgr: wrap the write() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write function. Move the op check to the wrapper.
Default to -EOPNOTSUP so its users will fail
gracefully.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 05a69ab3ecb9e..8d5536d748081 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count)
+{
+ if (mgr->mops->write)
+ return mgr->mops->write(mgr, buf, count);
+ return -EOPNOTSUPP;
+}
+
/*
* After all the FPGA image has been written, do the device specific steps to
* finish and set the FPGA into operating mode.
@@ -204,7 +211,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG);
while (sg_miter_next(&miter)) {
- ret = mgr->mops->write(mgr, miter.addr, miter.length);
+ ret = fpga_mgr_write(mgr, miter.addr, miter.length);
if (ret)
break;
}
@@ -234,7 +241,7 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr,
* Write the FPGA image to the FPGA.
*/
mgr->state = FPGA_MGR_STATE_WRITE;
- ret = mgr->mops->write(mgr, buf, count);
+ ret = fpga_mgr_write(mgr, buf, count);
if (ret) {
dev_err(&mgr->dev, "Error while writing image data to FPGA\n");
mgr->state = FPGA_MGR_STATE_WRITE_ERR;
@@ -578,9 +585,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->state ||
- (!mops->write && !mops->write_sg) ||
- (mops->write && mops->write_sg)) {
+ if (!mops || !mops->state) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
}
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 3/7] fpga-mgr: wrap the write() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write function. Move the op check to the wrapper.
Default to -EOPNOTSUP so its users will fail
gracefully.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 05a69ab3ecb9e..8d5536d748081 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count)
+{
+ if (mgr->mops->write)
+ return mgr->mops->write(mgr, buf, count);
+ return -EOPNOTSUPP;
+}
+
/*
* After all the FPGA image has been written, do the device specific steps to
* finish and set the FPGA into operating mode.
@@ -204,7 +211,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG);
while (sg_miter_next(&miter)) {
- ret = mgr->mops->write(mgr, miter.addr, miter.length);
+ ret = fpga_mgr_write(mgr, miter.addr, miter.length);
if (ret)
break;
}
@@ -234,7 +241,7 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr,
* Write the FPGA image to the FPGA.
*/
mgr->state = FPGA_MGR_STATE_WRITE;
- ret = mgr->mops->write(mgr, buf, count);
+ ret = fpga_mgr_write(mgr, buf, count);
if (ret) {
dev_err(&mgr->dev, "Error while writing image data to FPGA\n");
mgr->state = FPGA_MGR_STATE_WRITE_ERR;
@@ -578,9 +585,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->state ||
- (!mops->write && !mops->write_sg) ||
- (mops->write && mops->write_sg)) {
+ if (!mops || !mops->state) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
}
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 4/7] fpga-mgr: wrap the status() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager is not required to provide a status() op.
Add a wrapper consistent with the other op wrappers.
Move the op check to the wrapper.
Default to 0, no errors to report.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 8d5536d748081..43518b6eed21e 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline u64 fpga_mgr_status(struct fpga_manager *mgr)
+{
+ if (mgr->mops->status)
+ return mgr->mops->status(mgr);
+ return 0;
+}
+
static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count)
{
if (mgr->mops->write)
@@ -434,10 +441,7 @@ static ssize_t status_show(struct device *dev,
u64 status;
int len = 0;
- if (!mgr->mops->status)
- return -ENOENT;
-
- status = mgr->mops->status(mgr);
+ status = fpga_mgr_status(mgr);
if (status & FPGA_MGR_STATUS_OPERATION_ERR)
len += sprintf(buf + len, "reconfig operation error\n");
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 4/7] fpga-mgr: wrap the status() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager is not required to provide a status() op.
Add a wrapper consistent with the other op wrappers.
Move the op check to the wrapper.
Default to 0, no errors to report.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 8d5536d748081..43518b6eed21e 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline u64 fpga_mgr_status(struct fpga_manager *mgr)
+{
+ if (mgr->mops->status)
+ return mgr->mops->status(mgr);
+ return 0;
+}
+
static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count)
{
if (mgr->mops->write)
@@ -434,10 +441,7 @@ static ssize_t status_show(struct device *dev,
u64 status;
int len = 0;
- if (!mgr->mops->status)
- return -ENOENT;
-
- status = mgr->mops->status(mgr);
+ status = fpga_mgr_status(mgr);
if (status & FPGA_MGR_STATUS_OPERATION_ERR)
len += sprintf(buf + len, "reconfig operation error\n");
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 5/7] fpga-mgr: wrap the state() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a state() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.
Default to FPGA_MGR_STATE_UNKNOWN, what noop state() ops use.
Remove unneeded noop state() ops
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/dfl-fme-mgr.c | 6 ------
drivers/fpga/fpga-mgr.c | 11 +++++++++--
drivers/fpga/stratix10-soc.c | 6 ------
drivers/fpga/ts73xx-fpga.c | 6 ------
4 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index d5861d13b3069..313420405d5e8 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -252,11 +252,6 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr,
return 0;
}
-static enum fpga_mgr_states fme_mgr_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static u64 fme_mgr_status(struct fpga_manager *mgr)
{
struct fme_mgr_priv *priv = mgr->priv;
@@ -268,7 +263,6 @@ static const struct fpga_manager_ops fme_mgr_ops = {
.write_init = fme_mgr_write_init,
.write = fme_mgr_write,
.write_complete = fme_mgr_write_complete,
- .state = fme_mgr_state,
.status = fme_mgr_status,
};
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 43518b6eed21e..b3380ad341d22 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr)
+{
+ if (mgr->mops->state)
+ return mgr->mops->state(mgr);
+ return FPGA_MGR_STATE_UNKNOWN;
+}
+
static inline u64 fpga_mgr_status(struct fpga_manager *mgr)
{
if (mgr->mops->status)
@@ -589,7 +596,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->state) {
+ if (!mops) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
}
@@ -707,7 +714,7 @@ int fpga_mgr_register(struct fpga_manager *mgr)
* from device. FPGA may be in reset mode or may have been programmed
* by bootloader or EEPROM.
*/
- mgr->state = mgr->mops->state(mgr);
+ mgr->state = fpga_mgr_state(mgr);
ret = device_add(&mgr->dev);
if (ret)
diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
index a2cea500f7cc6..047fd7f237069 100644
--- a/drivers/fpga/stratix10-soc.c
+++ b/drivers/fpga/stratix10-soc.c
@@ -388,13 +388,7 @@ static int s10_ops_write_complete(struct fpga_manager *mgr,
return ret;
}
-static enum fpga_mgr_states s10_ops_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static const struct fpga_manager_ops s10_ops = {
- .state = s10_ops_state,
.write_init = s10_ops_write_init,
.write = s10_ops_write,
.write_complete = s10_ops_write_complete,
diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
index 101f016c6ed8c..167abb0b08d40 100644
--- a/drivers/fpga/ts73xx-fpga.c
+++ b/drivers/fpga/ts73xx-fpga.c
@@ -32,11 +32,6 @@ struct ts73xx_fpga_priv {
struct device *dev;
};
-static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static int ts73xx_fpga_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
@@ -98,7 +93,6 @@ static int ts73xx_fpga_write_complete(struct fpga_manager *mgr,
}
static const struct fpga_manager_ops ts73xx_fpga_ops = {
- .state = ts73xx_fpga_state,
.write_init = ts73xx_fpga_write_init,
.write = ts73xx_fpga_write,
.write_complete = ts73xx_fpga_write_complete,
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 5/7] fpga-mgr: wrap the state() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a state() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.
Default to FPGA_MGR_STATE_UNKNOWN, what noop state() ops use.
Remove unneeded noop state() ops
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/dfl-fme-mgr.c | 6 ------
drivers/fpga/fpga-mgr.c | 11 +++++++++--
drivers/fpga/stratix10-soc.c | 6 ------
drivers/fpga/ts73xx-fpga.c | 6 ------
4 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c
index d5861d13b3069..313420405d5e8 100644
--- a/drivers/fpga/dfl-fme-mgr.c
+++ b/drivers/fpga/dfl-fme-mgr.c
@@ -252,11 +252,6 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr,
return 0;
}
-static enum fpga_mgr_states fme_mgr_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static u64 fme_mgr_status(struct fpga_manager *mgr)
{
struct fme_mgr_priv *priv = mgr->priv;
@@ -268,7 +263,6 @@ static const struct fpga_manager_ops fme_mgr_ops = {
.write_init = fme_mgr_write_init,
.write = fme_mgr_write,
.write_complete = fme_mgr_write_complete,
- .state = fme_mgr_state,
.status = fme_mgr_status,
};
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 43518b6eed21e..b3380ad341d22 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,13 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr)
+{
+ if (mgr->mops->state)
+ return mgr->mops->state(mgr);
+ return FPGA_MGR_STATE_UNKNOWN;
+}
+
static inline u64 fpga_mgr_status(struct fpga_manager *mgr)
{
if (mgr->mops->status)
@@ -589,7 +596,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
struct fpga_manager *mgr;
int id, ret;
- if (!mops || !mops->state) {
+ if (!mops) {
dev_err(parent, "Attempt to register without fpga_manager_ops\n");
return NULL;
}
@@ -707,7 +714,7 @@ int fpga_mgr_register(struct fpga_manager *mgr)
* from device. FPGA may be in reset mode or may have been programmed
* by bootloader or EEPROM.
*/
- mgr->state = mgr->mops->state(mgr);
+ mgr->state = fpga_mgr_state(mgr);
ret = device_add(&mgr->dev);
if (ret)
diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
index a2cea500f7cc6..047fd7f237069 100644
--- a/drivers/fpga/stratix10-soc.c
+++ b/drivers/fpga/stratix10-soc.c
@@ -388,13 +388,7 @@ static int s10_ops_write_complete(struct fpga_manager *mgr,
return ret;
}
-static enum fpga_mgr_states s10_ops_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static const struct fpga_manager_ops s10_ops = {
- .state = s10_ops_state,
.write_init = s10_ops_write_init,
.write = s10_ops_write,
.write_complete = s10_ops_write_complete,
diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c
index 101f016c6ed8c..167abb0b08d40 100644
--- a/drivers/fpga/ts73xx-fpga.c
+++ b/drivers/fpga/ts73xx-fpga.c
@@ -32,11 +32,6 @@ struct ts73xx_fpga_priv {
struct device *dev;
};
-static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr)
-{
- return FPGA_MGR_STATE_UNKNOWN;
-}
-
static int ts73xx_fpga_write_init(struct fpga_manager *mgr,
struct fpga_image_info *info,
const char *buf, size_t count)
@@ -98,7 +93,6 @@ static int ts73xx_fpga_write_complete(struct fpga_manager *mgr,
}
static const struct fpga_manager_ops ts73xx_fpga_ops = {
- .state = ts73xx_fpga_state,
.write_init = ts73xx_fpga_write_init,
.write = ts73xx_fpga_write,
.write_complete = ts73xx_fpga_write_complete,
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 6/7] fpga-mgr: wrap the fpga_remove() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager is not required to provide a fpga_remove() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index b3380ad341d22..077c0f9edbe4c 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,12 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr)
+{
+ if (mgr->mops->fpga_remove)
+ mgr->mops->fpga_remove(mgr);
+}
+
static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr)
{
if (mgr->mops->state)
@@ -745,8 +751,7 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
* If the low level driver provides a method for putting fpga into
* a desired state upon unregister, do it.
*/
- if (mgr->mops->fpga_remove)
- mgr->mops->fpga_remove(mgr);
+ fpga_mgr_fpga_remove(mgr);
device_unregister(&mgr->dev);
}
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 6/7] fpga-mgr: wrap the fpga_remove() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager is not required to provide a fpga_remove() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index b3380ad341d22..077c0f9edbe4c 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -25,6 +25,12 @@ struct fpga_mgr_devres {
struct fpga_manager *mgr;
};
+static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr)
+{
+ if (mgr->mops->fpga_remove)
+ mgr->mops->fpga_remove(mgr);
+}
+
static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr)
{
if (mgr->mops->state)
@@ -745,8 +751,7 @@ void fpga_mgr_unregister(struct fpga_manager *mgr)
* If the low level driver provides a method for putting fpga into
* a desired state upon unregister, do it.
*/
- if (mgr->mops->fpga_remove)
- mgr->mops->fpga_remove(mgr);
+ fpga_mgr_fpga_remove(mgr);
device_unregister(&mgr->dev);
}
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 7/7] fpga-mgr: wrap the write_sg() op
2021-06-25 19:51 ` trix
@ 2021-06-25 19:51 ` trix
-1 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_sg function. Move the op check to the wrapper.
Default to -EOPNOTSUP so its users will fail
gracefully.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 077c0f9edbe4c..aa30889e23208 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -83,6 +83,14 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
return 0;
}
+static inline int fpga_mgr_write_sg(struct fpga_manager *mgr,
+ struct sg_table *sgt)
+{
+ if (mgr->mops->write_sg)
+ return mgr->mops->write_sg(mgr, sgt);
+ return -EOPNOTSUPP;
+}
+
/**
* fpga_image_info_alloc - Allocate an FPGA image info struct
* @dev: owning device
@@ -225,7 +233,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
/* Write the FPGA image to the FPGA. */
mgr->state = FPGA_MGR_STATE_WRITE;
if (mgr->mops->write_sg) {
- ret = mgr->mops->write_sg(mgr, sgt);
+ ret = fpga_mgr_write_sg(mgr, sgt);
} else {
struct sg_mapping_iter miter;
--
2.26.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v4 7/7] fpga-mgr: wrap the write_sg() op
@ 2021-06-25 19:51 ` trix
0 siblings, 0 replies; 22+ messages in thread
From: trix @ 2021-06-25 19:51 UTC (permalink / raw
To: hao.wu, mdf, michal.simek
Cc: linux-fpga, linux-kernel, linux-arm-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
An FPGA manager should not be required to provide a
write_sg function. Move the op check to the wrapper.
Default to -EOPNOTSUP so its users will fail
gracefully.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/fpga/fpga-mgr.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 077c0f9edbe4c..aa30889e23208 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -83,6 +83,14 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
return 0;
}
+static inline int fpga_mgr_write_sg(struct fpga_manager *mgr,
+ struct sg_table *sgt)
+{
+ if (mgr->mops->write_sg)
+ return mgr->mops->write_sg(mgr, sgt);
+ return -EOPNOTSUPP;
+}
+
/**
* fpga_image_info_alloc - Allocate an FPGA image info struct
* @dev: owning device
@@ -225,7 +233,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
/* Write the FPGA image to the FPGA. */
mgr->state = FPGA_MGR_STATE_WRITE;
if (mgr->mops->write_sg) {
- ret = mgr->mops->write_sg(mgr, sgt);
+ ret = fpga_mgr_write_sg(mgr, sgt);
} else {
struct sg_mapping_iter miter;
--
2.26.3
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
2021-06-25 19:51 ` trix
@ 2021-06-28 18:53 ` Moritz Fischer
-1 siblings, 0 replies; 22+ messages in thread
From: Moritz Fischer @ 2021-06-28 18:53 UTC (permalink / raw
To: trix; +Cc: hao.wu, mdf, michal.simek, linux-fpga, linux-kernel,
linux-arm-kernel
On Fri, Jun 25, 2021 at 12:51:42PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> An FPGA manager should not be required to provide a
> write_init() op if there is nothing for it do.
> So add a wrapper and move the op checking.
> Default to success.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index ecb4c3c795fa5..c047de8a059b7 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -25,6 +25,15 @@ struct fpga_mgr_devres {
> struct fpga_manager *mgr;
> };
>
> +static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
> + struct fpga_image_info *info,
> + const char *buf, size_t count)
> +{
> + if (mgr->mops->write_init)
Will you need a if (mgr->mops && mgr->mops->write_init) here later?
> + return mgr->mops->write_init(mgr, info, buf, count);
> + return 0;
> +}
> +
> /**
> * fpga_image_info_alloc - Allocate an FPGA image info struct
> * @dev: owning device
> @@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
>
> mgr->state = FPGA_MGR_STATE_WRITE_INIT;
> if (!mgr->mops->initial_header_size)
> - ret = mgr->mops->write_init(mgr, info, NULL, 0);
> + ret = fpga_mgr_write_init(mgr, info, NULL, 0);
> else
> - ret = mgr->mops->write_init(
> + ret = fpga_mgr_write_init(
> mgr, info, buf, min(mgr->mops->initial_header_size, count));
>
> if (ret) {
> @@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
> int id, ret;
>
> if (!mops || !mops->write_complete || !mops->state ||
> - !mops->write_init || (!mops->write && !mops->write_sg) ||
> + (!mops->write && !mops->write_sg) ||
> (mops->write && mops->write_sg)) {
> dev_err(parent, "Attempt to register without fpga_manager_ops\n");
> return NULL;
> --
> 2.26.3
>
Looks good to me, I might reword the commit message some when applying.
- Moritz
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
@ 2021-06-28 18:53 ` Moritz Fischer
0 siblings, 0 replies; 22+ messages in thread
From: Moritz Fischer @ 2021-06-28 18:53 UTC (permalink / raw
To: trix; +Cc: hao.wu, mdf, michal.simek, linux-fpga, linux-kernel,
linux-arm-kernel
On Fri, Jun 25, 2021 at 12:51:42PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> An FPGA manager should not be required to provide a
> write_init() op if there is nothing for it do.
> So add a wrapper and move the op checking.
> Default to success.
>
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index ecb4c3c795fa5..c047de8a059b7 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -25,6 +25,15 @@ struct fpga_mgr_devres {
> struct fpga_manager *mgr;
> };
>
> +static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
> + struct fpga_image_info *info,
> + const char *buf, size_t count)
> +{
> + if (mgr->mops->write_init)
Will you need a if (mgr->mops && mgr->mops->write_init) here later?
> + return mgr->mops->write_init(mgr, info, buf, count);
> + return 0;
> +}
> +
> /**
> * fpga_image_info_alloc - Allocate an FPGA image info struct
> * @dev: owning device
> @@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
>
> mgr->state = FPGA_MGR_STATE_WRITE_INIT;
> if (!mgr->mops->initial_header_size)
> - ret = mgr->mops->write_init(mgr, info, NULL, 0);
> + ret = fpga_mgr_write_init(mgr, info, NULL, 0);
> else
> - ret = mgr->mops->write_init(
> + ret = fpga_mgr_write_init(
> mgr, info, buf, min(mgr->mops->initial_header_size, count));
>
> if (ret) {
> @@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
> int id, ret;
>
> if (!mops || !mops->write_complete || !mops->state ||
> - !mops->write_init || (!mops->write && !mops->write_sg) ||
> + (!mops->write && !mops->write_sg) ||
> (mops->write && mops->write_sg)) {
> dev_err(parent, "Attempt to register without fpga_manager_ops\n");
> return NULL;
> --
> 2.26.3
>
Looks good to me, I might reword the commit message some when applying.
- Moritz
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
2021-06-28 18:53 ` Moritz Fischer
@ 2021-06-28 21:03 ` Tom Rix
-1 siblings, 0 replies; 22+ messages in thread
From: Tom Rix @ 2021-06-28 21:03 UTC (permalink / raw
To: Moritz Fischer, Xu, Yilun
Cc: hao.wu, michal.simek, linux-fpga, linux-kernel, linux-arm-kernel
On 6/28/21 11:53 AM, Moritz Fischer wrote:
> On Fri, Jun 25, 2021 at 12:51:42PM -0700, trix@redhat.com wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> An FPGA manager should not be required to provide a
>> write_init() op if there is nothing for it do.
>> So add a wrapper and move the op checking.
>> Default to success.
>>
>> Signed-off-by: Tom Rix <trix@redhat.com>
>> ---
>> drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
>> index ecb4c3c795fa5..c047de8a059b7 100644
>> --- a/drivers/fpga/fpga-mgr.c
>> +++ b/drivers/fpga/fpga-mgr.c
>> @@ -25,6 +25,15 @@ struct fpga_mgr_devres {
>> struct fpga_manager *mgr;
>> };
>>
>> +static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
>> + struct fpga_image_info *info,
>> + const char *buf, size_t count)
>> +{
>> + if (mgr->mops->write_init)
> Will you need a if (mgr->mops && mgr->mops->write_init) here later?
This was changed from v3 based on Yilun's comment
https://lore.kernel.org/linux-fpga/20210624075414.GA44700@yilunxu-OptiPlex-7050/
This is checked on creation
>> + return mgr->mops->write_init(mgr, info, buf, count);
>> + return 0;
>> +}
>> +
>> /**
>> * fpga_image_info_alloc - Allocate an FPGA image info struct
>> * @dev: owning device
>> @@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
>>
>> mgr->state = FPGA_MGR_STATE_WRITE_INIT;
>> if (!mgr->mops->initial_header_size)
>> - ret = mgr->mops->write_init(mgr, info, NULL, 0);
>> + ret = fpga_mgr_write_init(mgr, info, NULL, 0);
>> else
>> - ret = mgr->mops->write_init(
>> + ret = fpga_mgr_write_init(
>> mgr, info, buf, min(mgr->mops->initial_header_size, count));
>>
>> if (ret) {
>> @@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
>> int id, ret;
>>
>> if (!mops || !mops->write_complete || !mops->state ||
>> - !mops->write_init || (!mops->write && !mops->write_sg) ||
>> + (!mops->write && !mops->write_sg) ||
>> (mops->write && mops->write_sg)) {
>> dev_err(parent, "Attempt to register without fpga_manager_ops\n");
>> return NULL;
>> --
>> 2.26.3
>>
> Looks good to me, I might reword the commit message some when applying.
That is fine.
Thanks
Tom
> - Moritz
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 1/7] fpga-mgr: wrap the write_init() op
@ 2021-06-28 21:03 ` Tom Rix
0 siblings, 0 replies; 22+ messages in thread
From: Tom Rix @ 2021-06-28 21:03 UTC (permalink / raw
To: Moritz Fischer, Xu, Yilun
Cc: hao.wu, michal.simek, linux-fpga, linux-kernel, linux-arm-kernel
On 6/28/21 11:53 AM, Moritz Fischer wrote:
> On Fri, Jun 25, 2021 at 12:51:42PM -0700, trix@redhat.com wrote:
>> From: Tom Rix <trix@redhat.com>
>>
>> An FPGA manager should not be required to provide a
>> write_init() op if there is nothing for it do.
>> So add a wrapper and move the op checking.
>> Default to success.
>>
>> Signed-off-by: Tom Rix <trix@redhat.com>
>> ---
>> drivers/fpga/fpga-mgr.c | 15 ++++++++++++---
>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
>> index ecb4c3c795fa5..c047de8a059b7 100644
>> --- a/drivers/fpga/fpga-mgr.c
>> +++ b/drivers/fpga/fpga-mgr.c
>> @@ -25,6 +25,15 @@ struct fpga_mgr_devres {
>> struct fpga_manager *mgr;
>> };
>>
>> +static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
>> + struct fpga_image_info *info,
>> + const char *buf, size_t count)
>> +{
>> + if (mgr->mops->write_init)
> Will you need a if (mgr->mops && mgr->mops->write_init) here later?
This was changed from v3 based on Yilun's comment
https://lore.kernel.org/linux-fpga/20210624075414.GA44700@yilunxu-OptiPlex-7050/
This is checked on creation
>> + return mgr->mops->write_init(mgr, info, buf, count);
>> + return 0;
>> +}
>> +
>> /**
>> * fpga_image_info_alloc - Allocate an FPGA image info struct
>> * @dev: owning device
>> @@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr,
>>
>> mgr->state = FPGA_MGR_STATE_WRITE_INIT;
>> if (!mgr->mops->initial_header_size)
>> - ret = mgr->mops->write_init(mgr, info, NULL, 0);
>> + ret = fpga_mgr_write_init(mgr, info, NULL, 0);
>> else
>> - ret = mgr->mops->write_init(
>> + ret = fpga_mgr_write_init(
>> mgr, info, buf, min(mgr->mops->initial_header_size, count));
>>
>> if (ret) {
>> @@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name,
>> int id, ret;
>>
>> if (!mops || !mops->write_complete || !mops->state ||
>> - !mops->write_init || (!mops->write && !mops->write_sg) ||
>> + (!mops->write && !mops->write_sg) ||
>> (mops->write && mops->write_sg)) {
>> dev_err(parent, "Attempt to register without fpga_manager_ops\n");
>> return NULL;
>> --
>> 2.26.3
>>
> Looks good to me, I might reword the commit message some when applying.
That is fine.
Thanks
Tom
> - Moritz
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 0/7] wrappers for fpga_manager_ops
2021-06-25 19:51 ` trix
@ 2021-07-18 15:08 ` Moritz Fischer
-1 siblings, 0 replies; 22+ messages in thread
From: Moritz Fischer @ 2021-07-18 15:08 UTC (permalink / raw
To: trix; +Cc: hao.wu, mdf, michal.simek, linux-fpga, linux-kernel,
linux-arm-kernel
On Fri, Jun 25, 2021 at 12:51:40PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> As followup from
> https://lore.kernel.org/linux-fpga/06301910-10a1-0e62-45a0-d28ab5a787ed@redhat.com/
>
> Boards should not be required to have noop functions.
> So improve or create fpga-mgr wrappers for the fpga_manager_ops.
> Remove the noop functions.
> Refactor fpga-mgr to use the wrappers.
>
> Changes from
>
> v1:
> commit subject,log
>
> v2:
> rebase to next-20210623
>
> v3:
> remove mops check
> add write_sg wrapper
> drop 'fpga-mgr: collect wappers and change to inline'
>
> Tom Rix (7):
> fpga-mgr: wrap the write_init() op
> fpga-mgr: make write_complete() op optional
> fpga-mgr: wrap the write() op
> fpga-mgr: wrap the status() op
> fpga-mgr: wrap the state() op
> fpga-mgr: wrap the fpga_remove() op
> fpga-mgr: wrap the write_sg() op
>
> drivers/fpga/dfl-fme-mgr.c | 6 --
> drivers/fpga/fpga-mgr.c | 111 +++++++++++++++++++++++------------
> drivers/fpga/stratix10-soc.c | 6 --
> drivers/fpga/ts73xx-fpga.c | 6 --
> drivers/fpga/zynqmp-fpga.c | 7 ---
> 5 files changed, 75 insertions(+), 61 deletions(-)
>
> --
> 2.26.3
>
Appled to for-next,
Thanks
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v4 0/7] wrappers for fpga_manager_ops
@ 2021-07-18 15:08 ` Moritz Fischer
0 siblings, 0 replies; 22+ messages in thread
From: Moritz Fischer @ 2021-07-18 15:08 UTC (permalink / raw
To: trix; +Cc: hao.wu, mdf, michal.simek, linux-fpga, linux-kernel,
linux-arm-kernel
On Fri, Jun 25, 2021 at 12:51:40PM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> As followup from
> https://lore.kernel.org/linux-fpga/06301910-10a1-0e62-45a0-d28ab5a787ed@redhat.com/
>
> Boards should not be required to have noop functions.
> So improve or create fpga-mgr wrappers for the fpga_manager_ops.
> Remove the noop functions.
> Refactor fpga-mgr to use the wrappers.
>
> Changes from
>
> v1:
> commit subject,log
>
> v2:
> rebase to next-20210623
>
> v3:
> remove mops check
> add write_sg wrapper
> drop 'fpga-mgr: collect wappers and change to inline'
>
> Tom Rix (7):
> fpga-mgr: wrap the write_init() op
> fpga-mgr: make write_complete() op optional
> fpga-mgr: wrap the write() op
> fpga-mgr: wrap the status() op
> fpga-mgr: wrap the state() op
> fpga-mgr: wrap the fpga_remove() op
> fpga-mgr: wrap the write_sg() op
>
> drivers/fpga/dfl-fme-mgr.c | 6 --
> drivers/fpga/fpga-mgr.c | 111 +++++++++++++++++++++++------------
> drivers/fpga/stratix10-soc.c | 6 --
> drivers/fpga/ts73xx-fpga.c | 6 --
> drivers/fpga/zynqmp-fpga.c | 7 ---
> 5 files changed, 75 insertions(+), 61 deletions(-)
>
> --
> 2.26.3
>
Appled to for-next,
Thanks
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2021-07-18 15:10 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-25 19:51 [PATCH v4 0/7] wrappers for fpga_manager_ops trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 1/7] fpga-mgr: wrap the write_init() op trix
2021-06-25 19:51 ` trix
2021-06-28 18:53 ` Moritz Fischer
2021-06-28 18:53 ` Moritz Fischer
2021-06-28 21:03 ` Tom Rix
2021-06-28 21:03 ` Tom Rix
2021-06-25 19:51 ` [PATCH v4 2/7] fpga-mgr: make write_complete() op optional trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 3/7] fpga-mgr: wrap the write() op trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 4/7] fpga-mgr: wrap the status() op trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 5/7] fpga-mgr: wrap the state() op trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 6/7] fpga-mgr: wrap the fpga_remove() op trix
2021-06-25 19:51 ` trix
2021-06-25 19:51 ` [PATCH v4 7/7] fpga-mgr: wrap the write_sg() op trix
2021-06-25 19:51 ` trix
2021-07-18 15:08 ` [PATCH v4 0/7] wrappers for fpga_manager_ops Moritz Fischer
2021-07-18 15:08 ` Moritz Fischer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.