From owner-svn-src-stable-9@FreeBSD.ORG Mon Apr 2 16:30:14 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0AB961065672; Mon, 2 Apr 2012 16:30:14 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E90CC8FC15; Mon, 2 Apr 2012 16:30:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q32GUDVX005834; Mon, 2 Apr 2012 16:30:13 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q32GUDIY005830; Mon, 2 Apr 2012 16:30:13 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201204021630.q32GUDIY005830@svn.freebsd.org> From: Jim Harris Date: Mon, 2 Apr 2012 16:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233784 - stable/9/sys/dev/isci X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Apr 2012 16:30:14 -0000 Author: jimharris Date: Mon Apr 2 16:30:13 2012 New Revision: 233784 URL: http://svn.freebsd.org/changeset/base/233784 Log: MFC r233622: Ensure consistent target IDs for direct-attached devices. Sponsored by: Intel Reported by: sbruno, Ravi Pokala Tested by: Ravi Pokala Approved by: sbruno Modified: stable/9/sys/dev/isci/isci.h stable/9/sys/dev/isci/isci_controller.c stable/9/sys/dev/isci/isci_domain.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/isci/isci.h ============================================================================== --- stable/9/sys/dev/isci/isci.h Mon Apr 2 16:26:32 2012 (r233783) +++ stable/9/sys/dev/isci/isci.h Mon Apr 2 16:30:13 2012 (r233784) @@ -89,10 +89,10 @@ struct ISCI_REMOTE_DEVICE { }; struct ISCI_DOMAIN { - struct ISCI_CONTROLLER *controller; - SCI_DOMAIN_HANDLE_T sci_object; - uint8_t index; - + struct ISCI_CONTROLLER *controller; + SCI_DOMAIN_HANDLE_T sci_object; + uint8_t index; + struct ISCI_REMOTE_DEVICE *da_remote_device; }; struct ISCI_MEMORY Modified: stable/9/sys/dev/isci/isci_controller.c ============================================================================== --- stable/9/sys/dev/isci/isci_controller.c Mon Apr 2 16:26:32 2012 (r233783) +++ stable/9/sys/dev/isci/isci_controller.c Mon Apr 2 16:30:13 2012 (r233784) @@ -430,7 +430,18 @@ int isci_controller_allocate_memory(stru remote_device->frozen_lun_mask = 0; sci_fast_list_element_init(remote_device, &remote_device->pending_device_reset_element); - sci_pool_put(controller->remote_device_pool, remote_device); + + /* + * For the first SCI_MAX_DOMAINS device objects, do not put + * them in the pool, rather assign them to each domain. This + * ensures that any device attached directly to port "i" will + * always get CAM target id "i". + */ + if (i < SCI_MAX_DOMAINS) + controller->domain[i].da_remote_device = remote_device; + else + sci_pool_put(controller->remote_device_pool, + remote_device); remote_device_memory_ptr += remote_device_size; } Modified: stable/9/sys/dev/isci/isci_domain.c ============================================================================== --- stable/9/sys/dev/isci/isci_domain.c Mon Apr 2 16:26:32 2012 (r233783) +++ stable/9/sys/dev/isci/isci_domain.c Mon Apr 2 16:30:13 2012 (r233784) @@ -202,10 +202,14 @@ scif_cb_domain_da_device_added(SCI_CONTR struct ISCI_REMOTE_DEVICE *remote_device; struct ISCI_DOMAIN *isci_domain = (struct ISCI_DOMAIN *)sci_object_get_association(domain); - struct ISCI_CONTROLLER *isci_controller = - (struct ISCI_CONTROLLER *)sci_object_get_association(controller); - sci_pool_get(isci_controller->remote_device_pool, remote_device); + /* + * For direct-attached devices, do not pull the device object from + * the pool. Rather, use the one stored in the domain object which + * will ensure that we always get consistent target ids for direct + * attached devices. + */ + remote_device = isci_domain->da_remote_device; scif_remote_device_construct(domain, (uint8_t*)remote_device + sizeof(struct ISCI_REMOTE_DEVICE), @@ -287,6 +291,8 @@ scif_cb_domain_device_removed(SCI_CONTRO { struct ISCI_REMOTE_DEVICE *isci_remote_device = (struct ISCI_REMOTE_DEVICE *)sci_object_get_association(remote_device); + struct ISCI_DOMAIN *isci_domain = + (struct ISCI_DOMAIN *)sci_object_get_association(domain); struct ISCI_CONTROLLER *isci_controller = (struct ISCI_CONTROLLER *)sci_object_get_association(controller); uint32_t path = cam_sim_path(isci_controller->sim); @@ -301,7 +307,13 @@ scif_cb_domain_device_removed(SCI_CONTRO scif_remote_device_destruct(remote_device); - sci_pool_put(isci_controller->remote_device_pool, isci_remote_device); + /* + * Only put the remote device back into the pool if it was an + * expander-attached device. + */ + if (isci_remote_device != isci_domain->da_remote_device) + sci_pool_put(isci_controller->remote_device_pool, + isci_remote_device); } void