@@ -126,17 +126,22 @@ void RocPciDevice::initWithAddress(const PciAddress& address)
126126 PciDevice* pciDevice = typedPciDevice.pciDevice ;
127127 DeviceType type;
128128 if (addressFromDevice (pciDevice) == address) {
129+ Utilities::resetSmartPtr (mPdaBar0 , pciDevice, 0 );
130+ Utilities::resetSmartPtr (mPdaBar2 , pciDevice, 2 );
131+
132+ int serial;
133+ int endpoint;
129134 if (typedPciDevice.cardType == CardType::Crorc) {
130135 type = DeviceType (deviceTypes.at (0 ));
136+ serial = type.getSerial (mPdaBar0 );
131137 } else {
132138 type = DeviceType (deviceTypes.at (1 ));
139+ serial = type.getSerial (mPdaBar2 );
133140 }
134-
135- Utilities::resetSmartPtr (mPdaBar0 , pciDevice, 0 );
136- Utilities::resetSmartPtr (mPdaBar2 , pciDevice, 2 );
141+ endpoint = type.getEndpoint (mPdaBar0 );
137142
138143 mPciDevice = pciDevice;
139- mDescriptor = CardDescriptor{ type.cardType , SerialId{ type. getSerial ( mPdaBar2 ), type. getEndpoint ( mPdaBar0 ) }, type.pciId , address, PciDevice_getNumaNode (pciDevice) };
144+ mDescriptor = CardDescriptor{ type.cardType , SerialId{ serial, endpoint }, type.pciId , address, PciDevice_getNumaNode (pciDevice) };
140145 return ;
141146 }
142147 }
@@ -156,17 +161,22 @@ void RocPciDevice::initWithSequenceNumber(const PciSequenceNumber& sequenceNumbe
156161 PciDevice* pciDevice = typedPciDevice.pciDevice ;
157162 DeviceType type;
158163 if (sequenceNumber == sequenceCounter) {
164+ Utilities::resetSmartPtr (mPdaBar0 , pciDevice, 0 );
165+ Utilities::resetSmartPtr (mPdaBar2 , pciDevice, 2 );
166+
167+ int serial;
168+ int endpoint;
159169 if (typedPciDevice.cardType == CardType::Crorc) {
160170 type = DeviceType (deviceTypes.at (0 ));
171+ serial = type.getSerial (mPdaBar0 );
161172 } else {
162173 type = DeviceType (deviceTypes.at (1 ));
174+ serial = type.getSerial (mPdaBar2 );
163175 }
164-
165- Utilities::resetSmartPtr (mPdaBar0 , pciDevice, 0 );
166- Utilities::resetSmartPtr (mPdaBar2 , pciDevice, 2 );
176+ endpoint = type.getEndpoint (mPdaBar0 );
167177
168178 mPciDevice = pciDevice;
169- mDescriptor = CardDescriptor{ type.cardType , SerialId{ type. getSerial ( mPdaBar2 ), type. getEndpoint ( mPdaBar0 ) }, type.pciId , addressFromDevice (pciDevice), PciDevice_getNumaNode (pciDevice) };
179+ mDescriptor = CardDescriptor{ type.cardType , SerialId{ serial, endpoint }, type.pciId , addressFromDevice (pciDevice), PciDevice_getNumaNode (pciDevice) };
170180 return ;
171181 }
172182 sequenceCounter++;
@@ -185,19 +195,25 @@ std::vector<CardDescriptor> RocPciDevice::findSystemDevices()
185195 for (const auto & typedPciDevice : Pda::PdaDevice::getPciDevices ()) {
186196 PciDevice* pciDevice = typedPciDevice.pciDevice ;
187197 DeviceType type;
188- if (typedPciDevice.cardType == CardType::Crorc) {
189- type = DeviceType (deviceTypes.at (0 ));
190- } else {
191- type = DeviceType (deviceTypes.at (1 ));
192- }
193198
194199 std::shared_ptr<Pda::PdaBar> pdaBar0;
195200 Utilities::resetSmartPtr (pdaBar0, pciDevice, 0 );
196201 std::shared_ptr<Pda::PdaBar> pdaBar2;
197202 Utilities::resetSmartPtr (pdaBar2, pciDevice, 2 );
198203
204+ int serial;
205+ int endpoint;
206+ if (typedPciDevice.cardType == CardType::Crorc) {
207+ type = DeviceType (deviceTypes.at (0 ));
208+ serial = type.getSerial (pdaBar0);
209+ } else {
210+ type = DeviceType (deviceTypes.at (1 ));
211+ serial = type.getSerial (pdaBar2);
212+ }
213+ endpoint = type.getEndpoint (pdaBar0);
214+
199215 try {
200- cards.push_back (CardDescriptor{ type.cardType , SerialId{ type. getSerial (pdaBar2), type. getEndpoint (pdaBar0) }, type.pciId , addressFromDevice (pciDevice), PciDevice_getNumaNode (pciDevice) });
216+ cards.push_back (CardDescriptor{ type.cardType , SerialId{ serial, endpoint }, type.pciId , addressFromDevice (pciDevice), PciDevice_getNumaNode (pciDevice) });
201217 } catch (boost::exception& e) {
202218 std::cout << boost::diagnostic_information (e);
203219 }
0 commit comments