@@ -194,12 +194,19 @@ gve_process_device_options(struct gve_priv *priv,
194194
195195int gve_adminq_alloc (struct device * dev , struct gve_priv * priv )
196196{
197- priv -> adminq = dma_alloc_coherent ( dev , PAGE_SIZE ,
198- & priv -> adminq_bus_addr , GFP_KERNEL );
199- if (unlikely (!priv -> adminq ))
197+ priv -> adminq_pool = dma_pool_create ( "adminq_pool" , dev ,
198+ GVE_ADMINQ_BUFFER_SIZE , 0 , 0 );
199+ if (unlikely (!priv -> adminq_pool ))
200200 return - ENOMEM ;
201+ priv -> adminq = dma_pool_alloc (priv -> adminq_pool , GFP_KERNEL ,
202+ & priv -> adminq_bus_addr );
203+ if (unlikely (!priv -> adminq )) {
204+ dma_pool_destroy (priv -> adminq_pool );
205+ return - ENOMEM ;
206+ }
201207
202- priv -> adminq_mask = (PAGE_SIZE / sizeof (union gve_adminq_command )) - 1 ;
208+ priv -> adminq_mask =
209+ (GVE_ADMINQ_BUFFER_SIZE / sizeof (union gve_adminq_command )) - 1 ;
203210 priv -> adminq_prod_cnt = 0 ;
204211 priv -> adminq_cmd_fail = 0 ;
205212 priv -> adminq_timeouts = 0 ;
@@ -218,9 +225,20 @@ int gve_adminq_alloc(struct device *dev, struct gve_priv *priv)
218225 priv -> adminq_get_ptype_map_cnt = 0 ;
219226
220227 /* Setup Admin queue with the device */
221- iowrite32be (priv -> adminq_bus_addr / PAGE_SIZE ,
222- & priv -> reg_bar0 -> adminq_pfn );
223-
228+ if (priv -> pdev -> revision < 0x1 ) {
229+ iowrite32be (priv -> adminq_bus_addr / PAGE_SIZE ,
230+ & priv -> reg_bar0 -> adminq_pfn );
231+ } else {
232+ iowrite16be (GVE_ADMINQ_BUFFER_SIZE ,
233+ & priv -> reg_bar0 -> adminq_length );
234+ #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
235+ iowrite32be (priv -> adminq_bus_addr >> 32 ,
236+ & priv -> reg_bar0 -> adminq_base_address_hi );
237+ #endif
238+ iowrite32be (priv -> adminq_bus_addr ,
239+ & priv -> reg_bar0 -> adminq_base_address_lo );
240+ iowrite32be (GVE_DRIVER_STATUS_RUN_MASK , & priv -> reg_bar0 -> driver_status );
241+ }
224242 gve_set_admin_queue_ok (priv );
225243 return 0 ;
226244}
@@ -230,16 +248,27 @@ void gve_adminq_release(struct gve_priv *priv)
230248 int i = 0 ;
231249
232250 /* Tell the device the adminq is leaving */
233- iowrite32be (0x0 , & priv -> reg_bar0 -> adminq_pfn );
234- while (ioread32be (& priv -> reg_bar0 -> adminq_pfn )) {
235- /* If this is reached the device is unrecoverable and still
236- * holding memory. Continue looping to avoid memory corruption,
237- * but WARN so it is visible what is going on.
238- */
239- if (i == GVE_MAX_ADMINQ_RELEASE_CHECK )
240- WARN (1 , "Unrecoverable platform error!" );
241- i ++ ;
242- msleep (GVE_ADMINQ_SLEEP_LEN );
251+ if (priv -> pdev -> revision < 0x1 ) {
252+ iowrite32be (0x0 , & priv -> reg_bar0 -> adminq_pfn );
253+ while (ioread32be (& priv -> reg_bar0 -> adminq_pfn )) {
254+ /* If this is reached the device is unrecoverable and still
255+ * holding memory. Continue looping to avoid memory corruption,
256+ * but WARN so it is visible what is going on.
257+ */
258+ if (i == GVE_MAX_ADMINQ_RELEASE_CHECK )
259+ WARN (1 , "Unrecoverable platform error!" );
260+ i ++ ;
261+ msleep (GVE_ADMINQ_SLEEP_LEN );
262+ }
263+ } else {
264+ iowrite32be (GVE_DRIVER_STATUS_RESET_MASK , & priv -> reg_bar0 -> driver_status );
265+ while (!(ioread32be (& priv -> reg_bar0 -> device_status )
266+ & GVE_DEVICE_STATUS_DEVICE_IS_RESET )) {
267+ if (i == GVE_MAX_ADMINQ_RELEASE_CHECK )
268+ WARN (1 , "Unrecoverable platform error!" );
269+ i ++ ;
270+ msleep (GVE_ADMINQ_SLEEP_LEN );
271+ }
243272 }
244273 gve_clear_device_rings_ok (priv );
245274 gve_clear_device_resources_ok (priv );
@@ -251,7 +280,8 @@ void gve_adminq_free(struct device *dev, struct gve_priv *priv)
251280 if (!gve_get_admin_queue_ok (priv ))
252281 return ;
253282 gve_adminq_release (priv );
254- dma_free_coherent (dev , PAGE_SIZE , priv -> adminq , priv -> adminq_bus_addr );
283+ dma_pool_free (priv -> adminq_pool , priv -> adminq , priv -> adminq_bus_addr );
284+ dma_pool_destroy (priv -> adminq_pool );
255285 gve_clear_admin_queue_ok (priv );
256286}
257287
@@ -697,18 +727,7 @@ static int gve_set_desc_cnt(struct gve_priv *priv,
697727 struct gve_device_descriptor * descriptor )
698728{
699729 priv -> tx_desc_cnt = be16_to_cpu (descriptor -> tx_queue_entries );
700- if (priv -> tx_desc_cnt * sizeof (priv -> tx -> desc [0 ]) < PAGE_SIZE ) {
701- dev_err (& priv -> pdev -> dev , "Tx desc count %d too low\n" ,
702- priv -> tx_desc_cnt );
703- return - EINVAL ;
704- }
705730 priv -> rx_desc_cnt = be16_to_cpu (descriptor -> rx_queue_entries );
706- if (priv -> rx_desc_cnt * sizeof (priv -> rx -> desc .desc_ring [0 ])
707- < PAGE_SIZE ) {
708- dev_err (& priv -> pdev -> dev , "Rx desc count %d too low\n" ,
709- priv -> rx_desc_cnt );
710- return - EINVAL ;
711- }
712731 return 0 ;
713732}
714733
@@ -778,16 +797,17 @@ int gve_adminq_describe_device(struct gve_priv *priv)
778797 u16 mtu ;
779798
780799 memset (& cmd , 0 , sizeof (cmd ));
781- descriptor = dma_alloc_coherent ( & priv -> pdev -> dev , PAGE_SIZE ,
782- & descriptor_bus , GFP_KERNEL );
800+ descriptor = dma_pool_alloc ( priv -> adminq_pool , GFP_KERNEL ,
801+ & descriptor_bus );
783802 if (!descriptor )
784803 return - ENOMEM ;
785804 cmd .opcode = cpu_to_be32 (GVE_ADMINQ_DESCRIBE_DEVICE );
786805 cmd .describe_device .device_descriptor_addr =
787806 cpu_to_be64 (descriptor_bus );
788807 cmd .describe_device .device_descriptor_version =
789808 cpu_to_be32 (GVE_ADMINQ_DEVICE_DESCRIPTOR_VERSION );
790- cmd .describe_device .available_length = cpu_to_be32 (PAGE_SIZE );
809+ cmd .describe_device .available_length =
810+ cpu_to_be32 (GVE_ADMINQ_BUFFER_SIZE );
791811
792812 err = gve_adminq_execute_cmd (priv , & cmd );
793813 if (err )
@@ -868,8 +888,7 @@ int gve_adminq_describe_device(struct gve_priv *priv)
868888 dev_op_jumbo_frames , dev_op_dqo_qpl );
869889
870890free_device_descriptor :
871- dma_free_coherent (& priv -> pdev -> dev , PAGE_SIZE , descriptor ,
872- descriptor_bus );
891+ dma_pool_free (priv -> adminq_pool , descriptor , descriptor_bus );
873892 return err ;
874893}
875894
@@ -898,6 +917,7 @@ int gve_adminq_register_page_list(struct gve_priv *priv,
898917 .page_list_id = cpu_to_be32 (qpl -> id ),
899918 .num_pages = cpu_to_be32 (num_entries ),
900919 .page_address_list_addr = cpu_to_be64 (page_list_bus ),
920+ .page_size = cpu_to_be64 (PAGE_SIZE ),
901921 };
902922
903923 err = gve_adminq_execute_cmd (priv , & cmd );
0 commit comments