OXNAS / oxnas-oxe810se-mbwe

Boot builder for OXE810SE Based WD My Book World Edition
0 stars 1 forks source link

Sata in dt on oxe810se #1

Open Ykidia opened 3 years ago

Ykidia commented 3 years ago

Hello!

Can you please tell me how to add SATA support for ox810se target in device tree? I am trying to get working linux kernel 5.4 on my MBWE, but with no success because of not working SATA driver (PLXTECH NAS782X SATA). As I understand, SATA driver simply not loading because of lack of SATA support in device tree. Please, can you finalize that support or tell me how can I do it considering SATA in ox810se is the same as one in ox820 or, at least, very similar? I am ready to do a lot for it. Simply tell what is required of me.

Thank you!

superna9999 commented 3 years ago

Hi,

I never finished writing the proper driver, here my last code: https://git.kernel.org/pub/scm/linux/kernel/git/narmstrong/linux-oxnas.git/refs/heads

The controller is different from ox820 and it doesn’t have an embedded dma so it must use a separate dma I managed to make it work to read some disk sectors.

You can continue the work if you wish

superna9999 commented 3 years ago

With DT https://github.com/OXNAS/linux/commits/topic/ox810se

Ykidia commented 3 years ago

Thank you for your answer! And another little question - do you have any programming manual on oxe810dse?

Ykidia commented 2 years ago

Hello! That's long time ago... but now I am glad to say that SATA driver is almost or fully working. I want to pull new code to you. How to do it better? If you want, I can demonstrate kernel log from my WD NAS MyBook World Edition II (with one, two identical or even different HDDs). The main differencies from your driver version (and/or SoC manufacturer's) are 1) coreint interrupts not working, only for ports and therefore 2) we must use qc_defer; 3) also some optimizations for resets are needed, because original drivers replete with negligence, both old for ox810 and newest for ox820.

superna9999 commented 2 years ago

@Ykidia this is a great news ! You can either push a changeset to a fit with a fork of Linux or simply add the patch to this issue so I can have a look

Ykidia commented 2 years ago

wd-mbwe.target.linux.oxnas.zip Tried to make it easy + some SATA driver cleanup, but there is still a lot of work to do ;-) Unpack and overwrite files in corresponding dir of the current OpenWrt root. Here my startup kernel log with installed old Debian:

Initialising disks
No FIS received from device 0
Detecting SATA busses:
Bus 0: Found first device OK
  Device 0: Model: ST5000LM000-2AN170 Firm: 0001 Ser#: WCJ28XXW
            Type: Hard Disk
            Capacity: 131071.9 MB = 127.9 GB (268435455 x 512)
  Device 1: Model: WDC WD5000LPCX-24C6HT0 Firm: 02.01A02 Ser#: WD-WX21E54V5883
            Type: Hard Disk
            Capacity: 131071.9 MB = 127.9 GB (268435455 x 512)
Environment successfully read from disk 0 primary image

U-Boot 1.1.2 (Dec 23 2009 - 15:24:27)

U-Boot code: 48D00000 -> 48D1B0E4  BSS: -> 48D1EEFC
RAM Configuration:
        Bank #0: 48000000 128 MB
SRAM Configuration:
        128KB at 0x58000000
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
WARNING: flash_make_cmd: unsuppported LittleEndian mode
## Unknown FLASH on Bank 0 - Size = 0x00000000 = 0 MB
Flash:  0 kB
In:    serial
Out:   serial
Err:   serial
WD 2NC Board

IDE read: device 0 block # 290, count 1 ... 1 blocks read: OK
Hit any key to stop autoboot:  0

IDE device 0: Model: ST5000LM000-2AN170 Firm: 0001 Ser#: WCJ28XXW
            Type: Hard Disk
            Capacity: 131071.9 MB = 127.9 GB (268435455 x 512)
... is now current device

IDE read: device 0 block # 336, count 5700 ... 5700 blocks read: OK
## Booting image at 48500000 ...
   Image Name:   ARM OpenWrt Linux-5.10.83
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2905935 Bytes =  2.8 MB
   Load Address: 48008000
   Entry Point:  48008000
   Verifying Checksum ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.83 (user@3-rds) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 11.2.0 r18325-66f9ed1684) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 Mon Dec 1
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: Western Digital My Book World Edition
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000048000000-0x000000004fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000048000000-0x000000004fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000048000000-0x000000004fffffff]
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS1,115200n8 earlyprintk=serial root=/dev/md0 console=ttyS0,115200 elevator=cfq mac_adr=0x00,0x90,0xA9,0x71,0x14,0x00 mem=128s
[    0.000000] Kernel parameter elevator= does not have any effect anymore.
[    0.000000] Please use sysfs to set IO scheduler for individual devices.
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 111772K/131072K available (6144K kernel code, 6595K rwdata, 1452K rodata, 1024K init, 2124K bss, 19300K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] FPGA IRQ chip 0 "interrupt-controller" @ (ptrval), 32 irqs
[    0.000000] random: get_random_bytes called from start_kernel+0x26c/0x400 with crng_init=0
[    0.000045] sched_clock: 24 bits at 1562kHz, resolution 640ns, wraps every 5368708800ns
[    0.000149] clocksource: oxnas_rps_clocksource_timer: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 4778150833 ns
[    0.000181] timer_oxnas_rps: Registered clocksource rate 1562500Hz
[    0.000229] timer_oxnas_rps: Registered clock event rate 25000000Hz prescaler 0 period 250000
[    0.000412] Calibrating delay loop... 182.68 BogoMIPS (lpj=913408)
[    0.070318] pid_max: default: 32768 minimum: 301
[    0.070709] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.070760] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.072768] CPU: Testing write buffer coherency: ok
[    0.074434] Setting up static identity map for 0x48100000 - 0x4810003c
[    0.074844] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
[    0.082001] VFP support v0.3: not present
[    0.082321] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.082383] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.082589] pinctrl core: initialized pinctrl subsystem
[    0.083912] NET: Registered protocol family 16
[    0.085456] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.088720] cpuidle: using governor menu
[    0.089148] No ATAGs?
[    0.120868] SCSI subsystem initialized
[    0.122013] usbcore: registered new interface driver usbfs
[    0.122174] usbcore: registered new interface driver hub
[    0.122321] usbcore: registered new device driver usb
[    0.122588] pps_core: LinuxPPS API ver. 1 registered
[    0.122622] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.122693] PTP clock support registered
[    0.124897] clocksource: Switched to clocksource oxnas_rps_clocksource_timer
[    0.127022] NET: Registered protocol family 2
[    0.127374] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.128657] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.128778] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.128847] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.128903] TCP: Hash tables configured (established 1024 bind 1024)
[    0.129137] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.129208] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.129746] NET: Registered protocol family 1
[    0.129841] PCI: CLS 0 bytes, default 32
[    0.132036] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.149042] fuse: init (API version 7.32)
[    0.149600] SGI XFS with security attributes, no debug enabled
[    0.154194] io scheduler mq-deadline registered
[    0.154250] io scheduler kyber registered
[    0.157343] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.159507] printk: console [ttyS1] disabled
[    0.159861] 44300000.serial: ttyS1 at MMIO 0x44300000 (irq = 40, base_baud = 11458333) is a 16550A
[    0.606099] printk: console [ttyS1] enabled
[    0.612172] oxnas-sata: waiting for DMA to initialize
[    0.619100] Error: Driver 'oxnas-sata' is already registered, aborting...
[    0.627767] libphy: Fixed MDIO Bus: probed
[    0.633302] stmmaceth 40400000.ethernet: IRQ eth_wake_irq not found
[    0.639601] stmmaceth 40400000.ethernet: IRQ eth_lpi not found
[    0.645728] stmmaceth 40400000.ethernet: PTP uses main clock
[    0.651439] stmmaceth 40400000.ethernet: no reset control found
[    0.657780] stmmaceth 40400000.ethernet: Version ID not available
[    0.663914] stmmaceth 40400000.ethernet:     DWMAC1000
[    0.668808] stmmaceth 40400000.ethernet: No HW DMA feature register supported
[    0.675950] stmmaceth 40400000.ethernet: Wake-Up On Lan supported
[    0.682051] stmmaceth 40400000.ethernet: Normal descriptors
[    0.687630] stmmaceth 40400000.ethernet: Ring mode enabled
[    0.693146] stmmaceth 40400000.ethernet: device MAC address 26:5a:50:eb:f9:3f
[    0.747015] libphy: stmmac: probed
[    0.750476] mdio_bus stmmac-0:00: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[    0.759975] mdio_bus stmmac-0:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[    0.769468] mdio_bus stmmac-0:02: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:02, irq=POLL)
[    0.778960] mdio_bus stmmac-0:03: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:03, irq=POLL)
[    0.788452] mdio_bus stmmac-0:04: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:04, irq=POLL)
[    0.797944] mdio_bus stmmac-0:05: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:05, irq=POLL)
[    0.807436] mdio_bus stmmac-0:06: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:06, irq=POLL)
[    0.817077] mdio_bus stmmac-0:07: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:07, irq=POLL)
[    0.826581] mdio_bus stmmac-0:08: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:08, irq=POLL)
[    0.836080] mdio_bus stmmac-0:09: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:09, irq=POLL)
[    0.845571] mdio_bus stmmac-0:0a: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0a, irq=POLL)
[    0.855063] mdio_bus stmmac-0:0b: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0b, irq=POLL)
[    0.864555] mdio_bus stmmac-0:0c: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0c, irq=POLL)
[    0.874049] mdio_bus stmmac-0:0d: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0d, irq=POLL)
[    0.883539] mdio_bus stmmac-0:0e: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0e, irq=POLL)
[    0.893031] mdio_bus stmmac-0:0f: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:0f, irq=POLL)
[    0.902524] mdio_bus stmmac-0:10: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:10, irq=POLL)
[    0.912016] mdio_bus stmmac-0:11: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:11, irq=POLL)
[    0.921508] mdio_bus stmmac-0:12: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:12, irq=POLL)
[    0.931000] mdio_bus stmmac-0:13: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:13, irq=POLL)
[    0.940494] mdio_bus stmmac-0:14: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:14, irq=POLL)
[    0.949986] mdio_bus stmmac-0:15: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:15, irq=POLL)
[    0.959478] mdio_bus stmmac-0:16: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:16, irq=POLL)
[    0.968969] mdio_bus stmmac-0:17: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:17, irq=POLL)
[    0.978462] mdio_bus stmmac-0:18: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:18, irq=POLL)
[    0.987955] mdio_bus stmmac-0:19: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:19, irq=POLL)
[    0.997447] mdio_bus stmmac-0:1a: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1a, irq=POLL)
[    1.006939] mdio_bus stmmac-0:1b: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1b, irq=POLL)
[    1.016432] mdio_bus stmmac-0:1c: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1c, irq=POLL)
[    1.025923] mdio_bus stmmac-0:1d: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1d, irq=POLL)
[    1.035415] mdio_bus stmmac-0:1e: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1e, irq=POLL)
[    1.044908] mdio_bus stmmac-0:1f: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-0:1f, irq=POLL)
[    1.057068] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.064449] device-mapper: ioctl: 4.43.0-ioctl (2020-10-01) initialised: dm-devel@redhat.com
[    1.074664] ledtrig-cpu: registered to indicate activity on CPUs
[    1.082968] NET: Registered protocol family 10
[    1.091063] Segment Routing with IPv6
[    1.094980] NET: Registered protocol family 17
[    1.099704] 8021q: 802.1Q VLAN Support v1.8
[    2.155208] oxnas-dma 45600000.dma: OXNAS DMA Registered
[    2.163544] oxnas-sata: 934 two-ports SATA core v1.F2 (0x07F20008), iomap=[0xC9B00000-0xC9BFFFFF]
[    2.172669] ata1: port0 started
[    2.176961] ata2: port1 started
[    2.183310] scsi host0: oxnas-sata
[    2.188123] scsi host1: oxnas-sata
[    2.192049] ata1: SATA max UDMA/133 irq 34
[    2.196174] ata2: SATA max UDMA/133 irq 34
[    4.318387] ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[    4.336566] ata1.00: ATA-10: ST5000LM000-2AN170, 0001, max UDMA/133
[    4.342867] ata1.00: 9767541168 sectors, multi 0: LBA48 NCQ (depth 0/32)
[    4.623260] ata1.00: configured for UDMA/133
[    4.628485] scsi 0:0:0:0: Direct-Access     ATA      ST5000LM000-2AN1 0001 PQ: 0 ANSI: 5
[    4.641342] sd 0:0:0:0: [sda] 9767541168 512-byte logical blocks: (5.00 TB/4.55 TiB)
[    4.649127] sd 0:0:0:0: [sda] 4096-byte physical blocks
[    4.654663] sd 0:0:0:0: [sda] Write Protect is off
[    4.659948] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    4.736433]  sda: sda1 sda2
[    4.743409] sd 0:0:0:0: [sda] Attached SCSI disk
[    6.331654] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
[    6.338736] ata2.00: ATA-9: WDC WD5000LPCX-24C6HT0, 02.01A02, max UDMA/133
[    6.345648] ata2.00: 976773168 sectors, multi 0: LBA48 NCQ (depth 0/32)
[    6.353294] ata2.00: configured for UDMA/133
[    6.358524] scsi 1:0:0:0: Direct-Access     ATA      WDC WD5000LPCX-2 1A02 PQ: 0 ANSI: 5
[    6.369947] sd 1:0:0:0: [sdb] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[    6.377473] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[    6.382950] sd 1:0:0:0: [sdb] Write Protect is off
[    6.388233] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    6.729843]  sdb: sdb1 sdb2
[    6.736822] sd 1:0:0:0: [sdb] Attached SCSI disk
[    6.741629] md: Waiting for all devices to be available before autodetect
[    6.748432] md: If you don't use raid, use raid=noautodetect
[    6.754097] md: Autodetecting RAID arrays.
[    6.830743] md: invalid raid superblock magic on sda2
[    6.835834] md: sda2 does not have a valid v0.90 superblock, not importing!
[    6.856784] md: invalid raid superblock magic on sdb1
[    6.861872] md: sdb1 does not have a valid v0.90 superblock, not importing!
[    6.885378] md: invalid raid superblock magic on sdb2
[    6.890465] md: sdb2 does not have a valid v0.90 superblock, not importing!
[    6.897470] md: autorun ...
[    6.901686] md: running: <sda1>
[    6.906824] md/raid1:md0: active with 1 out of 2 mirrors
[    6.912355] md0: detected capacity change from 0 to 2744057856
[    6.918320] md: ... autorun DONE.
[    6.931798] EXT4-fs (md0): mounting ext3 file system using the ext4 subsystem
[    7.057480] EXT4-fs (md0): mounted filesystem with ordered data mode. Opts: (null)
[    7.065184] VFS: Mounted root (ext3 filesystem) readonly on device 9:0.
[    7.076798] Freeing unused kernel memory: 1024K
[    7.081462] Run /sbin/init as init process
[    7.526597] random: fast init done
Mount failed for selinuxfs on /sys/fs/selinux:  No such file or directory
INIT: version 2.88 booting
modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/5.10.83/modules.dep.bin'[info] Using makefile-style concurrent boot.
[....] Starting the hotplug events dispatcher: udevd[   11.802729] udevd (180): /proc/180/oom_adj is deprecated, please use /proc/180/oom_score_adj instead.
. ok
[....] Synthesizing the initial hotplug events...done.
[....] Waiting for /dev to be fully populated...udevd-event[401]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[401]: import_file_into_env: can't open 'nodmraid': No such file or directory

udevd-event[436]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[436]: import_file_into_env: can't open 'nodmraid': No such file or directory

udevd-event[450]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[450]: import_file_into_env: can't open 'nodmraid': No such file or directory

udevd-event[404]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[404]: import_file_into_env: can't open 'nodmraid': No such file or directory

udevd-event[475]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[475]: import_file_into_env: can't open 'nodmraid': No such file or directory

udevd-event[474]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[474]: import_file_into_env: can't open 'nodmraid': No such file or directory

[   20.510234] random: crng init done
udevd-event[488]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[488]: import_file_into_env: can't open 'nodmraid': No such file or directory

done.
[....] Generating udev events for MD arrays...udevd-event[544]: import_file_into_env: can't open 'noiswmd': No such file or directory

udevd-event[544]: import_file_into_env: can't open 'nodmraid': No such file or directory

done.
[....] Setting parameters of disc: (none). ok
[....] Activating swap...[   24.591052] Adding 525116k swap on /dev/sda2.  Priority:-2 extents:1 across:525116k
[   24.604097] Adding 525116k swap on /dev/sdb2.  Priority:-3 extents:1 across:525116k
done.

P.S. Don't understand where did it go "SATA link up 3.0 Gbps". Will investigate...

Ykidia commented 2 years ago

Don't understand where did it go "SATA link up 3.0 Gbps". Will investigate...

Found, corrected, the "SATA link up 3.0 Gbps" is back. Waiting for your notes and directions. wd-mbwe.target.linux.oxnas.tar.zip

P.S. What do you think about hardware RAID support? I tried to port raid1.c hacks from original 2.6.24.4 progressively, but somewhere in 3.x it turned out to be broken...

superna9999 commented 2 years ago

OK, now the step would be to clean the code and submit them as patches to the mailing lists.

I'll apply them to my linux tree to see the changes you did, anyway you did a great job here !

superna9999 commented 2 years ago

I pushed your changes on top of my commit https://git.kernel.org/pub/scm/linux/kernel/git/narmstrong/linux-oxnas.git/commit/?h=oxnas/v5.10/sata&id=acba9b2498a048f1a89fdac6f661ec263e369e76

Your code is very different, what base did you use ?

superna9999 commented 2 years ago

@Ykidia I did a global cleanup to match the kernel coding style and remove all warnings and pass all checkpatch strict checks https://git.kernel.org/pub/scm/linux/kernel/git/narmstrong/linux-oxnas.git/tree/drivers/ata/sata_ox810se.c?h=oxnas/v5.10/sata

superna9999 commented 2 years ago

There is still some work to do to make it upstreamable, the first would be to move ox810sata_hd out of global and get it from private_data

superna9999 commented 2 years ago

I got rid of the global data, but it may be simplfied a lot since we can get the host priv via ap->host->private_data so any function with ata_port could get rid of the priv parameter

Ykidia commented 2 years ago

@superna9999

Your code is very different, what base did you use ?

Primarily I used the code from original driver for 2.6.24.4 kernel. I've been doing incremental updates for whole kernel - 2.6.26, 2.6.27. 2.6.28 and so on (and starting from kernel 2.6.39 oxnas arch support was officially dropped). Prior to 3.7 kernel worked but installed Debian not (always stucks on "INIT: version 2.88 booting"). Then I refactored all oxnas includes and finally Debian started to work as expected. Unfortunately, somewhere in 2.6.3x I had to drop LEON support, and then in 3.x - hardware RAID1 (but I tried to keep it in SATA driver). I don't know how to patch RAID subsystem for oxnas now, but if there will be any ideas, I can try and test it. The main idea was (in old kernels) to process with 1 device (as RAID subsystem sees them) whereas SATA driver have to set to appropriate mode and operate with RAID registers instead of SATA ports registers for every device (both HDDs). As we can see from original sources, oxnas supports RAID0 also, but I could not find any documentation about it. Also, I think LEON support can be resurrected, but in 5.10 there are new driver(s) including Synopsis GMAC (now STMicroelectronics) natively without such a support. I have reached the version 4.4.x and wanted to go to the next step - 4.9. But in 4.9 oxnas arch appeared again, with device tree support, remappings, etc.. So I finally decided to rewrite driver with this new rules and at once for kernel 5.10, without intermediate kernel versions (I already spent 4 months on all this, and I wanted to get a working modern OpenWrt as soon as possible). So I get mine driver source for 4.4, your driver source for 5.10 and latest source for ox820 (BTW, in kernel 2.6.24.4 SATA driver for ox810 and ox820 is the same), and try to get uniform and easy debuggable driver (there were so many tests, debugs, data corruption, etc. :)), because I was afraid that the driver will not work with new (yours) DMA driver. But my fears were in vain, the driver immediately started working as expected with new DMA logic. One more thing - there are still two problems I could not get rid of: 1) First qc (as usual, internal) can stuck, then after timeout and followed reset all is OK. I tried all resets, tried some undocumented resets (as from bits titles), tried... but always not better (only worse) than this: after power on almost always first qcs going as expected, and after soft reset - not. BTW, original driver shows same symptoms, I think there is something in hardware. 2) Hot unplug works as expected, but hot plug not: in port 0, if there was no HDD at startup, SATA driver not getting hotplug events, we need to force detection from command line after HDD insertion, for example: https://unix.stackexchange.com/questions/404405/how-to-detect-new-hard-disk-attached-without-rebooting/404408 Also, some HDDs may cause system hang when hotplugged. I don't know why. I refactored driver many times but without full success. And one more problem - too few sectors for kernel in default WD MyBook World Edition bootloader's settings: only 5700. It got me thinking about "linux as bootloader" but that's a completely different story.

since we can get the host priv via ap->host->private_data

At first I did the same - without globals. But then I faced the "chicken or egg" problem in some functions while strictly using specialized I/O access functions (I found, that an universal ones, i.e. "io_read", with specifying raw base offset, is a breeding ground for mistakes), e.g. driver probe, I/O and RAID helpers.

Ykidia commented 1 year ago

Hello! Tried many times to run OpenWrt with kernel 5.15, but it always hangs after loading modules from rootfs. It doesn't matter which drivers or even what lies on rootfs - Debian or OpenWrt. Console lives and receiving symbols, but that's all. If I select failsafe mode when starting OpenWrt, then I can write some commands, but when I run mount_root - again hang. Now I started to think that driver (SATA or DMA) cannot initiate write process. BTW, on kernel 4.4 there are no problems with writing, Debian and Syncthing on it working like a charm, but this kernel uses old DMA driver... What are you thinking about this? Thank you.