User Details
- User Since
- Jan 22 2024, 3:05 AM (41 w, 1 d)
Mar 8 2024
@bz Ok, so it turns out that the issue I had was not with the driver. So there was no issue with the reset function, and the current version of the Diff properly works for me with the ACPI version of the driver. Since the clk* functions are no longer called when sc->mutex is locked, I assume the issue regarding mutex ordering is also fixed for the FDT driver. So this means the driver should also be ready for you to test.
I will do additional tests. There have been quite a few moving parts this week on my end (with the I2C tool I have been working on in addition to the driver), so I could have rushed my tests a bit too much and have drawn the wrong conclusions. I will do systematic tests starting from working versions.
Mar 6 2024
Ok I think I know how this could be fixed. I should create a sc->initialized_freq flag which is set by the attach function once sc->freq has been set. The reset function should check the status of this flag after locking sc->mutex, and if it is not the case, it should cv_wait for a condition from attach. The attach function should cv_signal this condition after setting the flag. Does it look like the best strategy to you?
Is there a way to prevent the reset function from being called before the driver is done attaching?
The driver seems to be misbehaving with the latest changes. I think it is due to interference between the attach and the reset functions (the attach and reset functions are called in parallel, and i2c_get_div_val gets called by the reset function before sc->freq is set to UINT32_MAX). This issue combined with the lock restrictions for the clk* functions makes it tricky to get the driver properly initialized at boot time. I will have to take a look at it another day...
Merging changes from D44020
Moving back sc->mutex initialization into vf_i2c_attach_common as before, but now locking the mutex whenever it is needed to communicate with the controller. No longer locking it before calling ofw* and clk* functions in vf_i2c_fdt_attach
I think I will have to make additional changes...
Trying to fix the "lock order reversal: (sleepable after non-sleepable)" error in FDT by moving back to an i2g_get_div_val function that gets called outside the sc->mutex lock with a WRITE call of the divider register inside the lock, that gets only called when the divider register value has been set.
Merging changes from D44020
Please ignore this revision
Mar 5 2024
Based on the last couple of tests, it looks like the clk functions should not be called when a mutex is locked with mtx_lock?
Sorry the previous diff had been generated using an outdated version of the D44020 diff.
-The previous diff was not generated properly w.r.t. the last version of D44020
Feb 28 2024
Merging changes from D44020
Adding a couple of missing spaces
Merging changes from D44020
Modifying vf_i2c.c, vf_i2c_fdt.c and vf_i2c_acpi.c so sc->mutex is used for the attach and detach functions as well, in order to prevent race conditions, in particular with the reset function that is called in parallel with the attach function at boot time.
Feb 27 2024
Feb 26 2024
Merging updates from D44020
- Renaming driver's data structure
Feb 24 2024
- Merging readability change from D44020.
- Fixing a bug that was introduced in Diff 134928 (a pointer was not properly declared).
Yes it is equivalent. I updated the code.
Modifying the code to make it more readable
Also changing the references for the driver updates, based on recommendations in D44020.
- Merge changes that were done to D44020 into here
- Implementing all bz's recommendations
Implementing all but one of bz's recommendations, pending feedback from comment.
Feb 22 2024
Feb 21 2024
Feb 20 2024
Updating copyright notice to state copyright for each author and also removing the original vf_i2c author for vf_i2c_acpi
I looked through src and it looks like either form of quoting are used for the copyright notice...
I got it from https://www.freebsd.org/internal/software-license/
sys/modules/vf_i2c/Makefile: Removing header files that are not required
As far as I know, all requests have been addressed. Please let me know if I have missed anything. Thanks!
Feb 14 2024
sys/arm/freescale/vybrid/files.vybrid: Removing ACPI support for vf_i2c
I think the latest diff addresses everything that has been mentioned so far.
Merging vf_i2c_acpi and vf_i2c_fdt devices and modules
Feb 13 2024
Fixing last diff...
Adding more context as requested.
Implementing most of the recommended changes, pending clarification for the remaining requests.
Feb 12 2024
Feb 10 2024
Adjusting copyright
Updating copyright notice and credits.
Feb 9 2024
Renaming the directory for the driver's source files from qoriq to vybrid
Merging the code with the existing driver in D43811. This differential is now obsolete.
Feb 7 2024
The main issue I have for the FDT driver, is the following couple of lines in vf_i2c.c:
So I looked at the VFXXX controller reference manual (https://www.nxp.com/docs/en/reference-manual/VFXXXRM.pdf), and the specs for the I2C controller look almost identical to the ones for the LX2160A I2C controller, except mostly for the clock divider table. Based on this information, I do not see why the new implementation could not work for the VFXXX controller. I would have to reintroduce the code by @dgr_semihalf.com to do the clock divider calculations for the devices that differ from the LX2160A though.
Feb 6 2024
Fixing /sys/arm64/conf/std.nxp and sys/conf/files.arm64
Last diff is broken. Will investigate...
Adding devices to sys/arm64/conf/std.nxp . The driver should work for LX2160A, LX2120A, LX2080A, LS1046A and LS1026A based on their respective reference manuals. The ACPI driver could be included in GENERIC. However as previously mentioned, I think including the FDT version along with vf_i2c could be problematic due to them sharing the same ID, so I commented out the lx2160a_i2c_fdt device.
Fixing a few typos in debug print statements. Adding also one debug print statement.
Revised version with all requested changes
I think this is now ready for review.
Feb 5 2024
modules/Makefile: Moving _lx2160a_i2c_fdt inside the nested condition on OPT_FDT
modules/Makefile: The modules are now only enabled for arm64/aarch64
Removing the verification of IBSR_IBB in i2c_stop. It was most likely potentially problematic and should have not been used.
Adding blank line to copyright notice
Updating the copyright notice as recommended.
-The logic in wait_for_icf was not quite right. It is now fixed.
Removing unnecessary small delay in i2c_stop. It had been introduced earlier as an attempt to fix the issue which was resolved by using wait_for_nibb in i2c_start.
Removing an unused define in lx2160a_i2c.h