Repository navigation
Add SMI driver - #1105
Add SMI driver#1105Wren6991 wants to merge 2 commits into
Conversation
|
It appears that this PR is still your development branch - the last commit has things in that are clearly still debug. Usually the flow for adding a new feature has a sequence of commits that
Also, please follow the kernel style guide (mainly for comments, but there's a few other places that are outside the coding style) https://www.kernel.org/doc/Documentation/CodingStyle and run the commits through checkpatch.pl. I recommend creating a separate branch for commits that end up in a PR - avoids polluting the log with stuff that's still being worked on. |
|
Thanks, that sounds like very sound advice. One question - when I checkout changes from my dev branch and push them to this PR, should I just squash the previous PR commits with new ones? I was intending to squash the PR when @popcornmix is happy to merge and leave history on here for now so people can talk about commits, but is it better to keep the PR clean? Thanks, |
|
You've added a few Obviously |
|
I'd say keep the commits separate until they are approved - the user always has the option to view the changed files instead of the commits, which gives the same appearance as squashing, and this way you get to choose. |
|
Without SMI: (SMI, MTD, JFFS2 = n) With SMI (SMI, MTD, JFFS2 = y): Adds about 100k to the kernel so pretty heavy when you include things like JFFS2. |
|
That's the size of the compressed image. A more useful comparison would be the reported memory map on boot from dmesg: |
|
Dom asked for the size of kernel.img, here's the layout from the top of dmesg: |
|
Luke, It would be better to split this up into two commits, the first would be the SMI driver alone with nothing else. The second would be the flash + MTD interface implementation but without it enabled in the kernel by default. This would avoid increasing the size of the kernel with jffs / MTD but would enable someone to add the functionality themselves if required (an app note for how to get this working would be good) Gordon |
|
Hi Gordon, |
|
Is SMI really a 8080/6800 compatible bus interface? Maximum 18-bit databus and 5-bit address bus? If this driver is heading for mainline, you can't have a global variable to hold the smi instance. I also suggest to split out the userpace interface into a module of it's own, like spidev and i2c-dev for the spi/i2c busses. Also avoid making your own log functions like log_error(). Try and use dev_{err,info}() where possible. If you need pr_error() somewhere and want to prepend a string, you can use pr_fmt(). |
|
SMI is 8080/6800 compatible. There are 18 data lines (bits 16 and 17 can be repurposed as DREQ/DACK for paced DMA) and 6 address lines. |
|
I just realised that drivers/firmware/raspberrypi.c is not a good example as it is currently, because it was hacked to work without Device Tree and that was done with a global variable. So look at the original version. |
|
Hi @notro, thanks very much for the input, that all sounds like good advice. I'll make those changes. |
|
@notro is this what you meant? Each client has a phandle for the SMI node in its own node, and calls |
|
How do people feel about this now? There are still some things to clean up but it seems to be in a working state, I've done a certain amount of testing and someone else is using this internally for another driver. |
There was a problem hiding this comment.
The cm_reg macro looks very convoluted.
This is a common pattern:
static inline void smi_write_reg(struct bcm2835_smi_instance *inst, unsigned reg, u32 val)
{
writel(val, inst->smi_regs + reg);
}
static inline u32 smi_read_reg(struct bcm2835_smi_instance *inst, unsigned reg)
{
return readl(inst->smi_regs + reg);
}And similar for the cm_smi_regs.
|
Thanks for that, @notro. I will change those, I think all of your points were good ones. |
|
For now, I'd just go with a big transaction mutex. This can be made more granular (direct vs FIFO/DMA transfers) as the SMI peripheral supports interleaving these two types but requires a bit of work to ensure that you can't end up with deadlocks. |
|
Okay, that sounds like the pragmatic thing to do. |
|
Had to use a lock rather than a mutex because some clients (JFFS2 + MTD) call into SMI from an atomic context. |
|
This seems to be working for me on Pi 1 and Pi 2. I'll ask Edd to start using this version of the driver and see if he runs into any problems. @pelwell @popcornmix any thoughts on the current state? |
There was a problem hiding this comment.
I can't recall having seen status mentioned in a binding document before (and it is optional). You can remove it.
There was a problem hiding this comment.
I think I was just following the example of another binding document, maybe something Atmel related. I've removed that from the bindings.
|
The kernel doesn't have a subsystem for 8080 like busses, so I did some work on that some months ago: https://github.com/notro/fbdbi/tree/master/i80 So I wonder, can smi be used for anything else than as a 6800/8080 bus interface? |
There was a problem hiding this comment.
Is it possible to just store the scatterlist structure here, instead of using pointers and allocate later?
There was a problem hiding this comment.
For some reason I was under the impression they had to be page-aligned, not sure if this is the case. I'll check.
|
@notro has given lots of great feedback, much of which has been incorporated, and now we are down to more-or-less cosmetic/taste issues. I can live with the drivers as they are, and I'm keen to get them merged in so others can start to use them. @Wren6991 Do you plan to address any of the most recent comments? Either way, when you have finished, squash the commits down to one or two (smi + smi-nand) and then git push -f to update the PR. |
|
I've made the cosmetic changes for notro, and fixed a couple of minor issues with user space DMA. I'm limited in the testing I can do here, but SMI NAND driver works fine, and I haven't found any more issues with SMI in its current state. I'll squash into two commits, one for SMI + char dev and one for SMI NAND. |
Signed-off-by: Luke Wren <wren6991@gmail.com>
Signed-off-by: Luke Wren <wren6991@gmail.com>
|
@popcornmix @pelwell I've squashed my commits. How do you feel about the driver now? |
|
The defconfig changes in second commit are bcm2709_defconfig only. |
03a8bad to
d86a5c3
Compare
|
I've modified bcmrpi_defconfig appropriately and pushed the resulting commits to 4.1 and 4.2. |
See: raspberrypi/linux#1131 kernel: config: Add CIFS_DFS_UPCALL, CIFS_ACL, CIFS_SMB2, CIFS_FSCACHE See: raspberrypi/linux#1133 kernel: Add SMI driver See: raspberrypi/linux#1105 kernel: dwc_otg: Force host mode to fix incorrect compute module boards firmware: video codec: Cleanup of fix for regression from refactor userdata release mechanics in categoriser commit
See: raspberrypi/linux#1131 kernel: config: Add CIFS_DFS_UPCALL, CIFS_ACL, CIFS_SMB2, CIFS_FSCACHE See: raspberrypi/linux#1133 kernel: Add SMI driver See: raspberrypi/linux#1105 kernel: dwc_otg: Force host mode to fix incorrect compute module boards firmware: video codec: Cleanup of fix for regression from refactor userdata release mechanics in categoriser commit
See: raspberrypi/linux#1131 kernel: config: Add CIFS_DFS_UPCALL, CIFS_ACL, CIFS_SMB2, CIFS_FSCACHE See: raspberrypi/linux#1133 kernel: Add SMI driver See: raspberrypi/linux#1105 kernel: dwc_otg: Force host mode to fix incorrect compute module boards firmware: video codec: Cleanup of fix for regression from refactor userdata release mechanics in categoriser commit
Secondary memory interface is a peripheral on the BCM2835 for talking to devices like parallel-interface LCDs and NAND flash chips.
This commit adds a driver for controlling SMI which registers a simple chardev + ioctl interface, and an example NAND driver using the functionality exposed by the SMI driver on the kernel side. It's the intention that we'll eventually be able to boot off of NAND flash, but this needs work on the firmware side.
It's very much a work in progress - any suggestions are appreciated!