@@ -517,6 +517,48 @@ static int __xenbus_map_ring(struct xenbus_device *dev,
517
517
return err ;
518
518
}
519
519
520
+ /**
521
+ * xenbus_unmap_ring
522
+ * @dev: xenbus device
523
+ * @handles: grant handle array
524
+ * @nr_handles: number of handles in the array
525
+ * @vaddrs: addresses to unmap
526
+ *
527
+ * Unmap memory in this domain that was imported from another domain.
528
+ * Returns 0 on success and returns GNTST_* on error
529
+ * (see xen/include/interface/grant_table.h).
530
+ */
531
+ static int xenbus_unmap_ring (struct xenbus_device * dev , grant_handle_t * handles ,
532
+ unsigned int nr_handles , unsigned long * vaddrs )
533
+ {
534
+ struct gnttab_unmap_grant_ref unmap [XENBUS_MAX_RING_GRANTS ];
535
+ int i ;
536
+ int err ;
537
+
538
+ if (nr_handles > XENBUS_MAX_RING_GRANTS )
539
+ return - EINVAL ;
540
+
541
+ for (i = 0 ; i < nr_handles ; i ++ )
542
+ gnttab_set_unmap_op (& unmap [i ], vaddrs [i ],
543
+ GNTMAP_host_map , handles [i ]);
544
+
545
+ if (HYPERVISOR_grant_table_op (GNTTABOP_unmap_grant_ref , unmap , i ))
546
+ BUG ();
547
+
548
+ err = GNTST_okay ;
549
+ for (i = 0 ; i < nr_handles ; i ++ ) {
550
+ if (unmap [i ].status != GNTST_okay ) {
551
+ xenbus_dev_error (dev , unmap [i ].status ,
552
+ "unmapping page at handle %d error %d" ,
553
+ handles [i ], unmap [i ].status );
554
+ err = unmap [i ].status ;
555
+ break ;
556
+ }
557
+ }
558
+
559
+ return err ;
560
+ }
561
+
520
562
struct map_ring_valloc_hvm
521
563
{
522
564
unsigned int idx ;
@@ -608,45 +650,6 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
608
650
return err ;
609
651
}
610
652
611
-
612
- /**
613
- * xenbus_map_ring
614
- * @dev: xenbus device
615
- * @gnt_refs: grant reference array
616
- * @nr_grefs: number of grant reference
617
- * @handles: pointer to grant handle to be filled
618
- * @vaddrs: addresses to be mapped to
619
- * @leaked: fail to clean up a failed map, caller should not free vaddr
620
- *
621
- * Map pages of memory into this domain from another domain's grant table.
622
- * xenbus_map_ring does not allocate the virtual address space (you must do
623
- * this yourself!). It only maps in the pages to the specified address.
624
- * Returns 0 on success, and GNTST_* (see xen/include/interface/grant_table.h)
625
- * or -ENOMEM / -EINVAL on error. If an error is returned, device will switch to
626
- * XenbusStateClosing and the first error message will be saved in XenStore.
627
- * Further more if we fail to map the ring, caller should check @leaked.
628
- * If @leaked is not zero it means xenbus_map_ring fails to clean up, caller
629
- * should not free the address space of @vaddr.
630
- */
631
- int xenbus_map_ring (struct xenbus_device * dev , grant_ref_t * gnt_refs ,
632
- unsigned int nr_grefs , grant_handle_t * handles ,
633
- unsigned long * vaddrs , bool * leaked )
634
- {
635
- phys_addr_t phys_addrs [XENBUS_MAX_RING_GRANTS ];
636
- int i ;
637
-
638
- if (nr_grefs > XENBUS_MAX_RING_GRANTS )
639
- return - EINVAL ;
640
-
641
- for (i = 0 ; i < nr_grefs ; i ++ )
642
- phys_addrs [i ] = (unsigned long )vaddrs [i ];
643
-
644
- return __xenbus_map_ring (dev , gnt_refs , nr_grefs , handles ,
645
- phys_addrs , GNTMAP_host_map , leaked );
646
- }
647
- EXPORT_SYMBOL_GPL (xenbus_map_ring );
648
-
649
-
650
653
/**
651
654
* xenbus_unmap_ring_vfree
652
655
* @dev: xenbus device
@@ -858,51 +861,6 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr)
858
861
return rv ;
859
862
}
860
863
861
- /**
862
- * xenbus_unmap_ring
863
- * @dev: xenbus device
864
- * @handles: grant handle array
865
- * @nr_handles: number of handles in the array
866
- * @vaddrs: addresses to unmap
867
- *
868
- * Unmap memory in this domain that was imported from another domain.
869
- * Returns 0 on success and returns GNTST_* on error
870
- * (see xen/include/interface/grant_table.h).
871
- */
872
- int xenbus_unmap_ring (struct xenbus_device * dev ,
873
- grant_handle_t * handles , unsigned int nr_handles ,
874
- unsigned long * vaddrs )
875
- {
876
- struct gnttab_unmap_grant_ref unmap [XENBUS_MAX_RING_GRANTS ];
877
- int i ;
878
- int err ;
879
-
880
- if (nr_handles > XENBUS_MAX_RING_GRANTS )
881
- return - EINVAL ;
882
-
883
- for (i = 0 ; i < nr_handles ; i ++ )
884
- gnttab_set_unmap_op (& unmap [i ], vaddrs [i ],
885
- GNTMAP_host_map , handles [i ]);
886
-
887
- if (HYPERVISOR_grant_table_op (GNTTABOP_unmap_grant_ref , unmap , i ))
888
- BUG ();
889
-
890
- err = GNTST_okay ;
891
- for (i = 0 ; i < nr_handles ; i ++ ) {
892
- if (unmap [i ].status != GNTST_okay ) {
893
- xenbus_dev_error (dev , unmap [i ].status ,
894
- "unmapping page at handle %d error %d" ,
895
- handles [i ], unmap [i ].status );
896
- err = unmap [i ].status ;
897
- break ;
898
- }
899
- }
900
-
901
- return err ;
902
- }
903
- EXPORT_SYMBOL_GPL (xenbus_unmap_ring );
904
-
905
-
906
864
/**
907
865
* xenbus_read_driver_state
908
866
* @path: path for driver
0 commit comments