-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
AMD mailbox driver support #7270
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the checkpatch issues.
This code is unused, do you plan to upstream code that uses the mailbox driver any time soon?
Add support for the AMD Mailbox Service for use on AMD platforms. The Mailbox Service requires the Local IPI ID as a mandatory input, provided via CFG_MAILBOX_LOCAL_ID. Mailbox initialization for CFG_MAILBOX_LOCAL_ID occurs as a late init service and will be utilized by various drivers to communicate with other firmware. The remote ID will be supplied by different drivers using the mailbox service. Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
bd5d9e9
to
9ab658e
Compare
core/drivers/amd/mailbox_driver.c
Outdated
{ | ||
TEE_Result res = TEE_ERROR_GENERIC; | ||
|
||
cache_operation(TEE_CACHEINVALIDATE, ipi_info.rsp, payload_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, cache_operation()
may return an error code. If never awaited, maybe asserting the return value is enough. That said, I see that almost all callers of that function do not check the return value :(
There are all in core/drivers/...
. Note that if ipi_info.rsp
is NULL, the function would have returned an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me revisit and modify accordingly.
um, isnt this driver just the same than could you comment please? |
Also, if this is an |
Also notice that given the nature of the firmware receiving the requests, mbox requests/responses usually consist of several buffers and the payload and each buffer had alignment requirements. as @jenswi-linaro mentioned, if would be nice to have an example of usage. |
@ldts This driver is meant for a newer AMD Versal Gen 2 family and later versions. This change is having the base infra, more will be added to it later. The use case is different from the the versal platform. |
What do you mean by "more will be added to it later"? Are you referring to additional changes to this mailbox driver under review? This driver is a simplified version of versal_mbox.c, and my concern is that you may eventually need to make it more complex, resulting in something similar to what already exists. |
Add AMD mailbox driver support for AMD Versal Gen 2 platform. Keeping the config CFG_MAILBOX_DRIVER disabled by default. Once a driver using the mailbox service is added and enabled for this platform the configuration to be updated. Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
Address upstream review comments Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
As I mentioned, AMD Versal Gen 2 is new family and the underlying workings are not exactly same as Versal and Versal NET.
Appreciate, will have a look in to those changes as well. |
thanks. but please, do take the time to ask my questions to avoid going in circles. This driver is a simplified version of what we currently have. |
Address error condition cases as per review comments. Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
9ab658e
to
c85d468
Compare
@etienne-lms @jenswi-linaro |
um you made me curious about the IPI Gen2 now, where can I find the PLM code? should it still be in the embeddedsw repo or is it now hosted somwhere else? |
Hi @ldts all PLM code is in the embedded software directory. This will be using the versal_aiegen2 specific code along with the common code. |
-s/id/ID -return values - brace removal - explicit header addition Signed-off-by: Akshay Belsare <akshay.belsare@amd.com>
@etienne-lms Addressed comments from you. |
thanks Nathan. Um so I fail to see how this is architecturally (software wise) different than Versal or Versal net: they share the same TF-A mailbox service and similar PLM services (multiple buffers on the payload). It seems to me it will ultimately need the versal_mbox features but will see. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with few comments.
Could you squash the fixup commits?
/* Reset struct ipi_info. | ||
* Not checking return, already in error case | ||
EMSG("Failed to open Mailbox for remote ID %"PRIu32, remote_id); | ||
/* Reset IPI information structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- /* Reset IPI information structure.
+ /*
+ * Reset IPI information structure.
* Not checking return value res, already in error case
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you address these coding convention issues?
/* Remove mapping for request buffer */ | ||
/* Remove mapping for request buffer. | ||
* Not checking return value res, since already in error case. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- /* Remove mapping for request buffer.
+ /*
+ * Remove mapping for request buffer.
* Not checking return value res, since already in error case.
*/
@etienne-lms could you comment my concerns before providing any form of ack? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few remaining comments.
Fell free to squash current and coming fixup commit in your next update.
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
for commit
"plat-versal2: enable AMD mailbox driver".
payload_size); | ||
if (res != TEE_SUCCESS) { | ||
EMSG("Failed to remove request mapping for remote ID %"PRIu32, | ||
remote_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto out;
for consistency?
/* Reset struct ipi_info. | ||
* Not checking return, already in error case | ||
EMSG("Failed to open Mailbox for remote ID %"PRIu32, remote_id); | ||
/* Reset IPI information structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you address these coding convention issues?
#define IPI_NON_BLOCK U(0x0) | ||
#define IPI_BLOCK U(0x1) | ||
|
||
TEE_Result mailbox_open(uint32_t remote_id, size_t payload_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an amd_
prefix for these functions.
@Akshay-Belsare, please address @ldts's concerns. He has been a long-term contributor to this area. OP-TEE is a community-driven project, so the community's view matters. |
@ldts |
You are simply copying current drivers—mbox, GPIO and others will follow—while stripping functionality and removing the original copyright. As I mentioned, over time, you will inevitably need to restore some of the features you're removing (even if you haven’t realized it yet). That said, as I requested regarding the GPIO driver you’re proposing, please retain the original copyrights from the code you’re copying. It’s a requirement of the license. |
Hi @ldts, sorry, I see I missed you comment #7270 (comment). I would hardly tell whether this driver is worth being factorized with the Versal drivers as I don't known the hardware and the firmwares ABI. I would rather rely on your view. |
Hi @etienne-lms, no worries—it happens to me all the time. I think the issue is best understood through a simple example that illustrates my point. Take a look at the PUF registration: PUF registration code. As it can be observed, this specific mailbox request to the PUF firmware service consists of five separate buffers, requiring alignment and cache management for both read and write operations: Mailbox request handling. If the AMD driver aims to one day support Versal, it will need to implement something similar to what we already have so both drivers will end up being the same on. Just partitioned a bit differently perhaps. In any case I do not oppose to the creation of new drivers as long as the license is respected (copying and splitting doesn't void the terms of the license WRT to copyright: https://opensource.org/license/bsd-2-clause ) |
Add support for the AMD Mailbox Service for use on AMD platforms.
The Mailbox Service requires the Local IPI ID as a mandatory input,
provided via CFG_MAILBOX_LOCAL_ID.
Mailbox initialization for CFG_MAILBOX_LOCAL_ID occurs as a late init
service and will be utilized by various drivers to communicate with other
firmware.
The remote ID will be supplied by different drivers using the mailbox
service.