The United States and Brazil have reached a deal in their long-running battle over US cotton subsidies, with the US agreeing to pay $300m to settle the dispute.