Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Nov 2015 15:50:07 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Russell Haley <russ.haley@gmail.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: Hummingboard SATA
Message-ID:  <59E5D040-0DE5-469F-A913-5514C534C690@bsdimp.com>
In-Reply-To: <CABx9NuQMF5oa-JWOKnirnWySEz=Fpirtmr8Ty7mvp9d9%2ByX7Nw@mail.gmail.com>
References:  <CABx9NuQ=gf5s0bKNHRj10KmBVp%2Bpoz4xfbRXgAH3Bd8irJVNqQ@mail.gmail.com> <CANCZdfpQSHfPmNdY-sHMJ8jtE19OB%2BtwmsargLgDh=p3x9Qagg@mail.gmail.com> <CABx9NuQMF5oa-JWOKnirnWySEz=Fpirtmr8Ty7mvp9d9%2ByX7Nw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_8E1AD222-552C-488D-92B8-87FB637F0ED7
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8


> On Nov 14, 2015, at 11:16 PM, Russell Haley <russ.haley@gmail.com> =
wrote:
>=20
> Hi Warner,
>=20
> I am looking over the CAM code and it's relationship with ahci. There =
are also bits of information about CAM around: a chapter in the Kong =
book, a chapter in the developers handbook.
>=20
> The file ahci.c, line 660 - ahci_ch_attach() - this seems to be where =
the magic happens to attach the ahci driver to the CAM system.  =
Specifically line 754 "cam_sim_alloc()=E2=80=9D.

Yes. That creates the SIM. SIM used to mean SCSI Interface Module in the =
original CAM spec. Any more, it just means any device that can chat with =
devices attached via the appropriate transport.

The SIM has a number of busess connected to it. Each bus is a transport. =
A transport (xpt in the code) shuffles protocol messages from the periph =
devices using the SIM to send / receive them over the XPT.

When the SIM is instantiated, CAM automatically resets the bus and =
enumerates it, with the help of the SIM. For SCSI-like things, this is =
where ID scans are done, LUN scans, etc. For ATA, this is where ports =
are scanned, port expanders recognized, etc.

So as part of this scan, it is discovered that a SATA device exists on a =
given port, and an ada device is created.

> What I am not seeing is the relationship to the ata_da.c code.  I =
noticed that my drive wasn't listed in the ata_da.c,  ada_quirk_table. I =
don't know anything about quirks but imagine that this is an optional =
item?

Yes. The Quirk table is for those devices that lie to the system in some =
way and that lie needs to be sorted out through work arounds in the =
code.

> I think I am done reviewing the code for now and will move back to ddb =
and figure out how to examine the kernel checking for devices (read: no =
idea what I am doing). If anyone has any pointers on how to hook into =
the probe or attach methods using the debugger, or even any good =
scripts, I'd be grateful.

I usually just set breakpoints for the specific device I=E2=80=99m =
interested in, though device_probe_and_attach is also good.

Warner

> Thanks,
>=20
> Russ
>=20
>=20
>=20
> On Wed, Nov 11, 2015 at 9:39 PM, Warner Losh <imp@bsdimp.com> wrote:
>=20
>=20
> On Wed, Nov 11, 2015 at 10:22 PM, Russell Haley <russ.haley@gmail.com> =
wrote:
> Hello again,
>=20
> I have started looking at SATA support in FreeBSD by first reading the =
man
> pages and then examining the code. The Joseph Kong book is helping
> considerably to understand the structures.
>=20
> I see that there are three drivers in play: ahci, ada and ata. Man
> indicates that ahci takes precedence in driver selection. *Is that the
> driver for Arm and the Hummingboard?*
>=20
> ata is out of the picture now. It never really was used on arm.
>=20
> ahci is likely the driver you want, though I'm not sure what a =
Hummingboard
> is. A quick google search suggests it is a imx6 board. That's good =
news
> because FreeBSD has an attachment.
>=20
> ahci is what's call a CAM SIM. This means that it will create the ata =
xpt (handled
> in sys/cam/ata/ata_xpt.c). The XPT then enumerates the transport and =
finds the
> sata drives, which wind up getting assigned the ada PERIPH driver =
(handled by
> sys/cam/ata/ata_da.c).
>=20
> Chances are very good you have a problem with the ahci driver and/or
> how that driver is connected / sets up the iMX6 SoC sata hardware.
>=20
> What I can't seem to find is any direction on getting a debugger =
hooked up
> to driver code. Do I use gdb somehow, or do I use the kernel debugger? =
I'm
> going back over the Developers handbook again.
>=20
> I'd start with ddb.
>=20
> I also don't understand how to boot with the -d option. When is this
> entered? I have used the sysctl to enter the debugger and poked around
> but it doesn't mean much yet.
>=20
> sysctl debug.kdb.enter=3D1
>=20
> I don't think that the -d option is implemented on arm. Most of the =
ARM
> kernel config files have ALT_BREAK_TO_DEBUGGER defined, which means
> you'll need to send <CR> ~ ^B (that's hit return, hit the tilde key, =
hit control B).
> That will get you to the ddb prompt (db>). man 8 ddb for instructions =
on
> how to use it.
>=20
> Warner
>=20


--Apple-Mail=_8E1AD222-552C-488D-92B8-87FB637F0ED7
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJWTQCgAAoJEGwc0Sh9sBEAYRgQAKszJtJrwTQf0C4YlP/3zf3R
oHbOlnsn6vrNyjBVV1T0zIVaAfSZMinMbTPUGtnEcWpPXK7w3R/xinaYcZM55jqd
yJEsLr10WwHvpIhc1PNJNQsbK+85gEhRtg2IJ1CHBnAsD5DXwCpRNi6CyYT0R3ls
VQUYf7Gb47x40kBQ0VrXnj4WJq2R7qZJUkaaPkBO2ogIz7KGDTTVzlWuCfQrm4Oo
xWsMXhmBcfOhTPNZ8tY0SZ4ST/7MjouwMujcdzcKZWwQUSiMEulSQXuYjR2dX0mu
gAmsY2pBnDCXKEZjmt67oNwaD3DvbtoKQv1kxItlmQwhmy5AvMvYeWZFMmB3vHju
BPP49ix6iMHhN2gjiBGI+sgVWtHNNh65mFzktqiqvmXpO0Azpvjedh396mmbp+dE
JOxrTnc6u0ta5uUoFws1mDO+KsFIKlAWpTs7WWqCmNZY/Wg1b8gssa0jqHg09h8M
AAK9dYbxV+2B6VVFwcVBTsdZHA0xvlZdQ9r5VcSVZ4ysan7fV9HavoApEFqfV1mt
FG6oqhnqhH+3FE2sq1YcOO0bqDij3pVhMnDNfIen3hw5u9jhaGvgMNBqSe00rdis
KBJXIYJg+QsfWm7qmCwC9mrPKreeDa1GYShzpdd4x7DZMB+Jw1GWNA4vFrXGXY3K
tOfuCstIwO3o/TSN/5X+
=D8Vs
-----END PGP SIGNATURE-----

--Apple-Mail=_8E1AD222-552C-488D-92B8-87FB637F0ED7--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?59E5D040-0DE5-469F-A913-5514C534C690>