From owner-freebsd-current@FreeBSD.ORG Thu Nov 17 16:35:26 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 110961065670; Thu, 17 Nov 2011 16:35:26 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 477DB8FC12; Thu, 17 Nov 2011 16:35:22 +0000 (UTC) Received: by ggnk5 with SMTP id k5so1363752ggn.13 for ; Thu, 17 Nov 2011 08:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=1HNt/biO0zSF+hFHG2Ktaq3529bkIlagJe3yV+8xPXs=; b=bwdwu/KdIK7wQZXM6e5FZQ9dKu1wnSOdQUYMK7KyaVmZhRlvYtpSQQyRz99BCDoHRh 5yP9crqhpBuSSGULo+WSw823yeNxTGp6iF8r2GTsYBY5qTJWE+/I7JgqYQfEMaqp0pCX n0D+DaMRXabY8M2kMU+ydrDZ/Gfa8X/k6zqG8= MIME-Version: 1.0 Received: by 10.236.161.4 with SMTP id v4mr10776228yhk.89.1321547721677; Thu, 17 Nov 2011 08:35:21 -0800 (PST) Sender: maksim.yevmenkin@gmail.com Received: by 10.100.122.19 with HTTP; Thu, 17 Nov 2011 08:35:21 -0800 (PST) In-Reply-To: <4EC531A4.4000803@FreeBSD.org> References: <4EC43ABA.7060407@FreeBSD.org> <4EC4404B.4070008@FreeBSD.org> <4EC531A4.4000803@FreeBSD.org> Date: Thu, 17 Nov 2011 08:35:21 -0800 X-Google-Sender-Auth: 3pgzlbvfu2fbONJOsWtOD97D83Q Message-ID: From: Maksim Yevmenkin To: Alexander Motin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: current@freebsd.org Subject: Re: [RFC] ahci(4) patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2011 16:35:26 -0000 On Thu, Nov 17, 2011 at 8:09 AM, Alexander Motin wrote: > On 11/17/11 01:08, Maksim Yevmenkin wrote: >> On Wed, Nov 16, 2011 at 2:59 PM, Alexander Motin wrote= : >>> On 17.11.2011 00:44, Maksim Yevmenkin wrote: >>>> >>>> On Wed, Nov 16, 2011 at 2:35 PM, Alexander Motin =A0w= rote: >>>>> >>>>> On 16.11.2011 23:59, Maksim Yevmenkin wrote: >>>>>> >>>>>> would anyone object to the following ahci(4) patch? >>>>>> >>>>>> =3D=3D >>>>>> >>>>>> --- ahci.c.orig 2011-11-16 21:35:26.000000000 +0000 >>>>>> +++ ahci.c =A0 =A0 =A02011-11-16 21:35:41.000000000 +0000 >>>>>> @@ -500,7 +500,7 @@ >>>>>> =A0 =A0 =A0 =A0for (unit =3D 0; unit< =A0 =A0ctlr->channels; unit++)= { >>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if ((ctlr->ichannels& =A0 =A0(1<< =A0= =A0unit)) =3D=3D 0) >>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue; >>>>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 child =3D device_add_child(dev, "ahcic= h", -1); >>>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 child =3D device_add_child(dev, "ahcic= h", unit); >>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (child =3D=3D NULL) >>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0device_printf(dev, "f= ailed to add channel >>>>>> device\n"); >>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else >>>>>> >>>>>> =3D=3D >>>>>> >>>>>> the idea is to have "static" numbering for ada(4) disks. >>>>> >>>>> I do. The only way I see this useful is if you have BIOS configured f= or >>>>> non-hot-swappable disks, in which case you have some AHCI channels >>>>> disabled, >>>>> but want to keep numbers of the rest. While I don't like this mode in >>>>> general, especially when it can't be disabled, that patch could be us= eful >>>>> in >>>>> these cases. But in other cases, when you have several AHCI controlle= rs, >>>>> it >>>>> just wont not work. You will receive error on attempt to create secon= d >>>>> ahcich0. >>>> >>>> shouldn't achcichX be destroyed when disk is detached/removed/etc.? >>> >>> List of implemented AHCI channels to expose as ahcichX set by BIOS in >>> vendor-specific way, but only during boot and not by many BIOSes. Destr= oying >>> them on disk detach theoretically possible, but IMHO not right, as bus >>> doesn't disappear on disk disconnect. >>> >>>> the particular problem i'm trying to address is disk re-numbering when >>>> one of the disks fails/removed/etc. i'm trying to use hints to wire >>>> disks to controllers/busses. it works perfectly fine with da(4) disks >>>> (even hot swappable ones) , but i can not make it to work with ada(4) >>>> disks. i'm perfectly fine to hid this under some sort of option >>>> (something similar to ATA_STATIC_ID, AHCI_STATIC_ID for example) >>> >>> Wiring works for adaX also, unless your BIOS is so "intelligent" to rep= ort >>> unconnected ports and not impliemented.. You should just wire CAM buses= to >>> ahcichX, not to ahciX. It could be done in other way changing just by o= ne >>> line around xpt_bus_register(), but now it is done so. >> >> ok. then i must be missing something, here is what i have in device.hint= s >> >> hint.scbus.0.at=3D"umass-sim0" >> hint.scbus.1.at=3D"ahcich0" >> hint.scbus.2.at=3D"ahcich1" >> hint.scbus.3.at=3D"ahcich2" >> hint.scbus.4.at=3D"ahcich3" >> hint.scbus.5.at=3D"ahcich4" >> hint.scbus.6.at=3D"ahcich5" >> >> hint.da.0.at=3D"scbus0" >> hint.ada.0.at=3D"scbus1" >> hint.ada.1.at=3D"scbus2" >> hint.ada.2.at=3D"scbus3" >> hint.ada.3.at=3D"scbus4" >> hint.ada.4.at=3D"scbus5" >> hint.ada.5.at=3D"scbus6" >> >> this is for 6-port ahci(4) compatible controller (intel) on the >> motherboard. no matter which achi(4) ports are connected, resulted >> adaX devices are always sequential starting from ada0. so, the >> question is: what am i doing wrong here? > > Just put your lines into my loader.conf and got this: > > %camcontrol devlist -v > scbus1 on ahcich0 bus 0: > =A0 =A0at scbus1 target 0 lun 0 (pass0,ad= a0) > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us1 target -1 lun -1 () > scbus2 on ahcich1 bus 0: > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us2 target -1 lun -1 () > scbus3 on ahcich2 bus 0: > =A0 =A0at scbus3 target 0 lun 0 (pass1,ad= a2) > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us3 target -1 lun -1 () > scbus4 on ahcich3 bus 0: > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us4 target -1 lun -1 () > scbus5 on ahcich4 bus 0: > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us5 target -1 lun -1 () > scbus6 on ahcich5 bus 0: > <> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 at scb= us6 target -1 lun -1 () > ... > > I see no problem. What am I doing wrong? > > Let me repeat question not asked directly: Does your BIOS reports unused > AHCI channels as implemented? Do you always have all 6 ahcich devices or > not? i not exactly sure. below is the relevant dmesg. as far as i can tell, channels are correct, however, ahcich numbering is sequential and that is why hints dont work. Nov 16 11:18:00 PREPROD-red1 kernel: ahci0: port 0xf070-0xf077,0xf060-0xf063,0xf050-0xf057,0xf040-0xf043,0xf000-0xf01f mem 0xfbb21000-0xfbb217ff irq 19 at device 31.2 on pci0 Nov 16 11:18:00 PREPROD-red1 kernel: ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported Nov 16 11:18:00 PREPROD-red1 kernel: ahcich0: at channel 0 on ahci0 Nov 16 11:18:00 PREPROD-red1 kernel: ada0 at ahcich0 bus 0 scbus1 target 0 = lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: port 0xf070-0xf077,0xf060-0xf063,0xf050-0xf057,0xf040-0xf043,0xf000-0xf01f mem 0xfbb21000-0xfbb217ff irq 19 at device 31.2 on pci0 Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: attempting to allocate 1 MSI vectors (1 supported) Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: using IRQ 270 for MSI Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: Caps: 64bit NCQ SNTF AL CLO 6Gbps PMD SSC PSC 32cmd EM 6ports Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: Caps2: APST Nov 17 09:22:51 PREPROD-red1 kernel: ahci0: EM Caps: ALHD XMT SMB LED Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: at channel 0 on ahci0 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: Caps: Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: at channel 2 on ahci0 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: Caps: Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: at channel 5 on ahci0 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: Caps: Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: AHCI reset... Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: SATA connect time=3D100us status=3D00000133 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: AHCI reset: device found Nov 17 09:22:51 PREPROD-red1 kernel: ahcich0: AHCI reset: device ready afte= r 0ms Nov 17 09:22:51 PREPROD-red1 kernel: (aprobe0:ahcich0:0:0:0): SIGNATURE: 00= 00 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: AHCI reset... Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: SATA connect time=3D100us status=3D00000123 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: AHCI reset: device found Nov 17 09:22:51 PREPROD-red1 kernel: ahcich1: AHCI reset: device ready afte= r 0ms Nov 17 09:22:51 PREPROD-red1 kernel: (aprobe0:ahcich1:0:0:0): SIGNATURE: 00= 00 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: AHCI reset... Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: SATA connect time=3D100us status=3D00000123 Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: AHCI reset: device found Nov 17 09:22:51 PREPROD-red1 kernel: ahcich2: AHCI reset: device ready afte= r 0ms Nov 17 09:22:51 PREPROD-red1 kernel: (aprobe0:ahcich2:0:0:0): SIGNATURE: 00= 00 Nov 17 09:22:51 PREPROD-red1 kernel: ada0 at ahcich0 bus 0 scbus1 target 0 = lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: ada1 at ahcich1 bus 0 scbus2 target 0 = lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: ada2 at ahcich2 bus 0 scbus3 target 0 = lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: pass0 at ahcich0 bus 0 scbus1 target 0 lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: pass1 at ahcich1 bus 0 scbus2 target 0 lun 0 Nov 17 09:22:51 PREPROD-red1 kernel: pass2 at ahcich2 bus 0 scbus3 target 0 lun 0 thanks, max